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 gdb/17161] New: gdb confused about variable address in a nested function


https://sourceware.org/bugzilla/show_bug.cgi?id=17161

            Bug ID: 17161
           Summary: gdb confused about variable address in a nested
                    function
           Product: gdb
           Version: 7.7
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: gdb at dima dot secretsauce.net

I have this C program:

int main(void)
{
    int v = 0;

    int b(void)
    {
        return v;
    }

    int a(void)
    {
        return b();
    }

    return a();
}

I build like this:

$ gcc-4.9 -g -std=gnu11 -o tst tst.c

The program runs without surprises. What IS surprising is what gdb thinks is
the value of v and &v at various points. At "return a()" and inside b() gdb is
correct:


(gdb) p v
$32 = 0

(gdb) p &v
$33 = (int *) 0x7fffffffe450

However inside a(), gdb is confused about the address and the value of v:

(gdb) s
a () at tst.c:12

(gdb) p v
$34 = 5658608

(gdb) p &v
$35 = (int *) 0x7fffffffe430


This causes unnecessary confusion, I think. I'm using Debian/sid on an amd64
box. The gdb Debian package is version 7.7.1-2, although I was seeing this with
7.6 as well.

Thanks
dima

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