This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Standard scheme for maintainer-only debugging code?
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Nathanael Nerode <neroden at twcny dot rr dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 10 Jun 2003 23:13:18 +0100 (BST)
- Subject: Re: Standard scheme for maintainer-only debugging code?
- References: <20030610195038.GA19115@doctormoo>
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