This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Standard scheme for maintainer-only debugging code?


On Tue, 10 Jun 2003, Nathanael Nerode wrote:

> How about simply a convention: debugging code should be guarded by
> 
> if (debug_XYZ)
> 
> and debug_XYZ should be defined, for all XYZ, in some way which makes
> it a constant 0, optimizable out, unless it's altered by a maintainer.

Why does this code need to be compiled out?  I suggest including the code
unconditionally, controlled by some command-line option, as with the
existing debugging RTL dumps.  (But with *names* for the debugging options
that are turned on - the single letter -d options are hardly a scalable
way to go for too many debugging options.)  If it's in an inner loop, you
can use __builtin_expect to minimise the cost if really necessary (but I
don't expect debugging dumps from inner loops).

Whereas #if 0 code that isn't debugging should either be removed or
replaced with a comment "we don't do things this way because of ...",
depending on whether it has current documentary value.

-- 
Joseph S. Myers
jsm28@cam.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]