This is the mail archive of the gdb-prs@sourceware.org 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]

[Bug symtab/13590] always display addresses in "info var" output


http://sourceware.org/bugzilla/show_bug.cgi?id=13590

--- Comment #2 from Paul Pluzhnikov <ppluzhnikov at google dot com> 2012-01-13 22:38:50 UTC ---
It gets even worse if some of the sources have debug info, while others don't.
In that case, the variable without debug info is completely hidden:

// foo.h
typedef struct foo { int x; } foo_t;

// foo.c
#include "foo.h"

static foo_t foo;

int foo_fn() { return foo.x++; }

// bar.c
#include "foo.h"

static foo_t foo;

int bar_fn() { return foo.x++; }

// main.c
int main()
{
  return foo_fn() + bar_fn();
}


1. Without debug info we get the *best* info:

gcc main.c foo.c bar.c
gdb -q a.out
Reading symbols from /tmp/gdb-bug/a.out...(no debugging symbols found)...done.
(gdb) info var foo
All variables matching regular expression "foo":

Non-debugging symbols:
0x0000000000601028  foo
0x000000000060102c  foo

2. With full debug info we get source location, but no address:

gcc main.c foo.c bar.c -g
gdb -q a.out
Reading symbols from /tmp/gdb-bug/a.out...done.
(gdb) info var foo
All variables matching regular expression "foo":

File foo.c:
static foo_t foo;

File bar.c:
static foo_t foo;


3. With partial debug info, one of the variables is completely *hidden*. This
is  very misleading. In my case, the variable in a.out didn't have debug info,
but a variable in shared library did. GDB printed the variable in shared
library, even though the variable in main executable was the one that was being
actually used.

gcc -c bar.c
gcc -g main.c foo.c bar.o
gdb -q a.out
Reading symbols from /tmp/gdb-bug/a.out...done.
(gdb) info var foo
All variables matching regular expression "foo":

File foo.c:
static foo_t foo;

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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