This is the mail archive of the gcc-patches@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: RFC: debugging-GCC commented-out-code architecture


Nathanael Nerode wrote:
> The following is my first draft of the standard scheme for miscellaneous
> debugging code which is discussed in the thread beginning at
> http://gcc.gnu.org/ml/gcc/2003-06/msg00900.html (and some other places).

You might be interested in how we solved this problem in LLVM.  Basically,
we have a DEBUG macro that people can wrap their debugging code with, like
this:

   ...
   DEBUG(printf("foo happened!\n"));
   ...

These macros expand to nothing in an optimized build, but in a development
build they are enablable on the command line (and thus, the code is always
compiled in development mode).  If, on the command line, the user adds the
'-debug' flag, all of the DEBUG statements in the entire compiler are
enabled.  This can obviously be overwhelming and underuseful, so there is
also a '-debug-only=foo,bar' option, which enables all DEBUG statements
which are of type 'foo' and 'bar'.  The type of debug statements is
usually set once per translation until at the top of the file.

Having this stuff controlled on the command line is useful, because it
means that all of the debug code is always compiled (in dev mode) so it
can't get out of date, and it also means you don't have to recompile stuff
to enable debugging information.

If you're interested, this is described here in the LLVM programmer's
manual:
http://llvm.cs.uiuc.edu/docs/ProgrammersManual.html#DEBUG

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/


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