Standard scheme for maintainer-only debugging code?
Joseph S. Myers
jsm28@cam.ac.uk
Tue Jun 10 22:21:00 GMT 2003
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
More information about the Gcc
mailing list