Compilation directive LOCAL_DEBUG and DBG()

Senthil Kumar Nagappan sknagappan at yahoo.com
Sun Jul 18 09:24:53 CEST 2021


 Thanks Maria for the response.
I defined in Makefile and i was just using only ospf, so no other undefs were interfering and it worked, except for 1 or 2 compilation errors.As you suggested, there is no #undef to change to  #define in ospf specific files and its in common shared files.
So this LOCAL_DEBUG/GLOBAL_DEBUG and DBG() support does not have a clean user interface requires changing the makefile/code.
In ospf this DBG() is used to trace important information like neighbor state machine, lsa flooding, req/update...So can we add another proto debug flags (struct proto p->debug;/* Debugging flags */) like D_DBG and move the exiting use of DBG() to this? 

    On Sunday, July 18, 2021, 11:54:46 AM GMT+5:30, Maria Matejka <maria.matejka at nic.cz> wrote:  
 
 Hello!

On 7/18/21 7:48 AM, Senthil Kumar Nagappan wrote:
> Hi,
> 
> To enable debug outputs using DBG macro, it requires LOCAL_DEBUG or 
> GLOBAL_DEBUG to be defined during compilation.

Yes, you are right. And GLOBAL_DEBUG is generally not recommended to 
enable as it spits out loads of text.

> 1. Defined it in the Makefile as below. Is there an option without 
> changing the auto generated Makefile?
> 
> CFLAGS=$(CPPFLAGS) -g -O2 -pthread -fno-strict-aliasing 
> -fno-strict-overflow -flto -Wall -Wextra -Wstrict-prototypes 
> -Wno-parentheses -Wno-pointer-sign 
> -Wno-missing-field-initializers*-DLOCAL_DEBUG

This is not recommended and it is also negated by the #undef's everywhere.

> 2. If we try to define  LOCAL_DEBUG in the code, there are undef 
> directive in the different places of the code, so may not work consistently.

The right place to enable this is to _change_ the #undef to #define.

> 3.  If we define this  LOCAL_DEBUG or GLOBAL_DEBUG, there are 
> compilation errors that needs to be addressed.

Yes, you are right. The DBG() calls are typically just left there from 
the last debugging, not touched anymore, to see where it may make sense 
to write out some debug message. These calls may be also totally unsafe. 
Therefore you are supposed to check them thoroughly when enabling 
LOCAL_DEBUG. You may induce other bugs simply by enabling LOCAL_DEBUG.

Maria

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20210718/3ad920ae/attachment.htm>


More information about the Bird-users mailing list