public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* -ggdb3 -gdwarf-4 but "info macro BLAH" still doesn't work?
@ 2012-05-01 20:37 Martin Olsson
  2012-05-01 21:56 ` Matt Rice
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Olsson @ 2012-05-01 20:37 UTC (permalink / raw)
  To: gdb

Hello,

In a small test app built with -g3 I can print values of macros inside 
gdb by doing "info macro MYMACRONAME", however in a larger application 
I cannot get it to work despite passing the same -g3 and using the 
same gdb command. Just to be sure, I tried turning off stuff like 
pre-compiled headers etc in the large app but I still can't get the 
macro values to print correctly. In the large app, what I see is:

(gdb) info macro MYMACRONAME
The symbol `MYMACRONAME' has no definition as a C/C++ preprocessor macro
at ../../platforms/linux/src/main.cpp:263

In both cases gdb "info source" reports "Includes preprocessor macro 
info."
and also "Compiled with DWARF 2 debugging format."

For the large app readelf also reports the macro I'm testing as 
present (so I'm assuming the gcc end is doing the right thing):

$ readelf -wm binary | grep MYMACRONAME
  DW_MACINFO_define - lineno : 12 macro : MYMACRONAME 4096

FWIW; I'm using ubuntu 12.04 LTS which means I got gcc 
4:4.6.3-1ubuntu5 and gdb 7.4-2012.02-0ubuntu2. I've also tried 
building with "-ggdb3 -gdwarf-4" but I still can't get values of 
macros and oddly gdb then still reports "Compiled with DWARF 2 
debugging format", which was a bit weird?

Also if I do "info macros" then I get nothing printed at all.

---

What else can I try to make progress on this issue?

If there is no easier way, maybe someone can recommend a breakpoint 
location in GDB where I can step through the code that executes the 
"info macro BLAH" command ?

		Martin

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: -ggdb3 -gdwarf-4 but "info macro BLAH" still doesn't work?
@ 2012-05-08 10:04 Luke
  2012-05-08 10:52 ` Jan Kratochvil
  0 siblings, 1 reply; 5+ messages in thread
From: Luke @ 2012-05-08 10:04 UTC (permalink / raw)
  To: gdb

I'm having the same problem.

Here is a very simple test C program:

#include <stdio.h>
#define M 42
#define ADD(x) (M + x)
int main ()
{
  printf("%d\n", M);
  printf("%d\n", ADD(2));
  return 0;
}

I compile with:

$ gcc -gdwarf-4 -gdb3 -Wall -O0 sample.c -o sample

then debug:

$ gdb -q ./sample
Reading symbols from /tmp/sample...done.
(gdb) b main
Breakpoint 1 at 0x400560: file sample.c, line 6.
(gdb) run
Starting program: /tmp/sample
Breakpoint 1, main () at sample.c:6
6	      printf("%d\n", M);
(gdb) macro list
(gdb) info source
Current source file is sample.c
Compilation directory is /tmp
Located in /tmp/sample.c
Contains 27 lines.
Source language is c.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
(gdb) macro expand ADD(1)
expands to: ADD(1)
(gdb) print M
No symbol "M" in current context.

I have tried -g3, -gstabs, -gstabs+ and all have the same problem.

This happens with Linaro gcc 4.7-2012.04, as well as a very recent
pull from gcc master (4.8.0 20120502).

It doesn't happen with gcc 4.6.2.

Hopefully somebody is aware of this and knows what to do.

Any suggestions?  I'm guessing this is a gcc bug.  I'll search there
and if it isn't already reported, I will reported it.

~Luke

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-08 10:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-01 20:37 -ggdb3 -gdwarf-4 but "info macro BLAH" still doesn't work? Martin Olsson
2012-05-01 21:56 ` Matt Rice
2012-05-08 10:04 Luke
2012-05-08 10:52 ` Jan Kratochvil
2012-05-08 10:55   ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).