This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


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

RE: GCC: -D definitions in executable ???


Were it so simple as grepping for #if(def)? and such. To do this right you
need to actually evaluate the (possibly complex) expressions contained in
the conditional. For example,

#if FOO && !BAR
#elif defined(BAZ) || BAR
#endif

You need to make the values of each of these macros available to the
editor/debugger so it can properly evaluate the expressions and determine
whether the contained code is live or not.

Perhaps for gdb dealing with these wouldn't be a big deal: determine where
the conditionals appear in the source file and match this against the
debugging information, "graying out" conditionals that are dead. But in a
syntax-aware editor doing this right is difficult.

	-tre

-----Original Message-----
From: Stan Shebs [mailto:shebs@cygnus.com]
Sent: Thursday, July 08, 1999 3:11 PM
To: mrs@wrs.com
Cc: brendan@dgs.monash.edu.au; egcs@egcs.cygnus.com;
gdb@sourceware.cygnus.com
Subject: Re: GCC: -D definitions in executable ???



   Date: Thu, 8 Jul 1999 11:24:29 -0700
   From: mrs@wrs.com (Mike Stump)

   > Date: Thu, 08 Jul 1999 12:22:17 +1000
   > From: Brendan Simon <brendan@dgs.monash.edu.au>

   > With this type of feature, it would be possible for smart debuggers,
   > such as gdb, to highlight code that was not conditionally compiled,
   > in another color or even not be displayed.  I'm thinking of debugger
   > GUIs.

   I think this is mostly possible now.  All that one needs is a GUI and
   to read a little source code and read the debugging information
   already present.

In fact both Insight and the old gdbtk sources include the algorithm
to pick out and identify the breakable lines.  Identifying the
conditionals is a little more trouble, since GDB normally doesn't try
to interpret the contents of source lines, just passes them through
when doing listings and such.  However, you wouldn't need a full
preprocessor, just need to identify the #if/#ifdef/#else/#endif lines.
I don't think any compiler work would be necessary.

If someone were to write this, I would certainly be pleased to add it
into GDB.

								Stan

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