public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* 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

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

On Tue, 08 May 2012 12:03:50 +0200, Luke wrote:
> $ gcc -gdwarf-4 -gdb3 -Wall -O0 sample.c -o sample

-ggdb3, otherwise:
cc1: error: unrecognised debug output level "db3"


> 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.

It is probably due to the smaller .debug_macro section by Jakub Jelinek.
See 'readelf -WS sample', .debug_macinfo is the gdb-7.4.x compatible format,
.debug_macro is the new format available only in post-7.4 GDB snapshots since:
	commit 101e95e8a31879712dff26d233cdb266c1aba673
	Author: Tom Tromey <tromey@redhat.com>
	Date:   Tue Jul 26 17:04:21 2011 +0000

You can request with new GCC the old .debug_macinfo format by -gstrict-dwarf
but it also generates more poor debug info in other regards.


> Any suggestions?  I'm guessing this is a gcc bug.

Use GDB snapshot:
	http://sources.redhat.com/gdb/current/


Regards,
Jan

^ 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:52 ` Jan Kratochvil
@ 2012-05-08 10:55   ` Jan Kratochvil
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kratochvil @ 2012-05-08 10:55 UTC (permalink / raw)
  To: Luke; +Cc: gdb

On Tue, 08 May 2012 12:51:50 +0200, Jan Kratochvil wrote:
> See 'readelf -WS sample', .debug_macinfo is the gdb-7.4.x compatible format,
> .debug_macro is the new format available only in post-7.4 GDB snapshots since:
> 	commit 101e95e8a31879712dff26d233cdb266c1aba673
> 	Author: Tom Tromey <tromey@redhat.com>
> 	Date:   Tue Jul 26 17:04:21 2011 +0000

Sorry, gdb-7.4 already contains this patch.  You did not write your GDB
version, try to upgrade to 7.4 (7.4.1).


Jan

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

* Re: -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, 0 replies; 5+ messages in thread
From: Matt Rice @ 2012-05-01 21:56 UTC (permalink / raw)
  To: Martin Olsson; +Cc: gdb

On Tue, May 1, 2012 at 1:36 PM, Martin Olsson <mnemo@minimum.se> wrote:
> 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

the important part here I think is the:
at ../../platforms/linux/src/main.cpp:263

are you sure that MYMACRONAME is included and defined
at that point in the main.o file? info macro only does macros for the
place the program is currently executing at.

i see you are not getting the error message from the function
macro_inform_no_debuginfo so it seems there is a 'macro scope'.

> 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.

that is rather odd, even in empty sources i've always noticed some gcc
defined stuff from "info macros".

> 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 ?

macrocmd.c the function info_macro_command would probably be the place to start.

you can also try running make check and checking the results for the
macro tests,
macscp.exp
info-macros.exp

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

* -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

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-08 10:04 -ggdb3 -gdwarf-4 but "info macro BLAH" still doesn't work? Luke
2012-05-08 10:52 ` Jan Kratochvil
2012-05-08 10:55   ` Jan Kratochvil
  -- strict thread matches above, loose matches on Subject: below --
2012-05-01 20:37 Martin Olsson
2012-05-01 21:56 ` Matt Rice

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).