Compilation directive LOCAL_DEBUG and DBG()

Maria Matejka maria.matejka at nic.cz
Sun Jul 18 08:19:54 CEST 2021


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



More information about the Bird-users mailing list