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?


> Date: Tue, 10 Jun 2003 15:50:38 -0400
> Cc: gcc@gcc.gnu.org
> From: Nathanael Nerode <neroden@twcny.rr.com>

> >I don't think making this a single header is a good idea; it would
> >mean that whenever you changed one debugging flag, the dependencies
> >would cause the whole compiler to be rebuilt, which would be annoying.
> 
> Excellent point.  My macro scheme has essentially the same flaw anyway.
> 
> 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.
> 
> (How should this be done?  In C, declaring constants which can easily be 
> made into variables is an odd process, and I'm not quite sure what the 
> right magic incantation is.  "const static bool debug_XYZ = 0;" ?)

'enum { debug_XYZ = 0 };'

is the best way to do a manifest constant like this.  GCC will
reliably constant-fold it, and the debugger can see it.

> A standard prefix and declaration makes it possible to do a routine 
> check of the CVS tree to make sure none of them are left turned on by 
> accident.  
> 
> I do worry that there are too many different types of things 
> with the  debug_ prefix.  I want a unique prefix.  Perhaps mdbg_ for 
> maintainer debug?  Or perhaps use the debug_ prefix for this, and stop 
> using it for some of the other things it's used for?  ???

Yes, pick some unique prefix.

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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