This is the mail archive of the gdb@sources.redhat.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]
Other format: [Raw text]

Re: preprocessor support?


On Fri, May 28, 2004 at 03:35:52PM -0400, Paul Koning wrote:
> >>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
> 
>  Daniel> On Fri, May 28, 2004 at 03:24:19PM -0400, Paul Koning wrote:
>  >> These days GCC will output dwarf2 debug sections listing
>  >> preprocessor symbol definitions, but gdb 6.1 doesn't seem to look
>  >> at that (at least not for mips-netbsd).
>  >> 
>  >> Is that not implemented yet?  Is it in some targets but not this
>  >> one (and if so, any pointers to places I might look to teach this
>  >> target a new trick)?
> 
>  Daniel> It should work everywhere, so you'll have to dig at it
>  Daniel> harder.  I'm not sure that it's tested; there's at least one
>  Daniel> test in the testsuite but I don't see it going out of its way
>  Daniel> to pass -g3, so the binary won't have macro information.
> 
> To be more specific:
> 
> I looked at the .S file coming out of gcc, and saw the macro debug
> data.
> 
> I then linked the executable file, did an objdump on that, and again
> saw the macros in the debug data (.debug_macinfo section).
> 
> I then fed the executable to gdb, and asked it to print me the value
> of a couple of preprocessor symbols, like TEST which I defined and
> __GNUC__ which gcc put in.  Gdb said:
>   No symbol "__GNUC__" in current context.
> 
> Do I need to speak a magic word to have gdb look for the macro
> symbols?

No, you really shouldn't have to.  However, at a guess:

drow@nevyn:~% gcc -g3 -o m main-inc.c
drow@nevyn:~% gdb ./m
GNU gdb 6.1-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/tls/i686/cmov/libthread_db.so.1".

(gdb) p __GNUC__
No symbol "__GNUC__" in current context.
(gdb) i macro __GNUC__
GDB has no preprocessor macro information for that code.
(gdb) list
1       #include <stdio.h>
2
3       int
4       main()
5       {
6         printf ("Test\n");
7         return 0;
8       }
(gdb) i macro __GNUC__
Defined at /opt/mvista/tests/main-inc.c:1
#define __GNUC__ 3
(gdb) p __GNUC__
$1 = 3

So the macro code is not handling creation of a default source location
right; this is a recurring problem, I think...

-- 
Daniel Jacobowitz


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