This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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 debug/53927] wrong value for DW_AT_static_link


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53927

--- Comment #17 from Pierre-Marie de Rodat <derodat at adacore dot com> ---
(In reply to Tom Tromey from comment #16)
> I'm curious if you tried it on the test case in this PR.

I did not, but it looks like it now works as expected. Here are the frame base
info for "nestee" and the static link info for "nested":

    [nestee]
    <69>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
    [nested]
    <aa>   DW_AT_static_link : 6 byte block: 91 60 6 23 20 6    (DW_OP_fbreg:
-32; DW_OP_deref; DW_OP_plus_uconst: 32; DW_OP_deref)

... and the CFA for the two locations we will be interrested in later:

       LOC           CFA
    0000000000400496 rsp+8
    0000000000400497 rsp+16
    000000000040049a rbp+16   # A
    00000000004004af rsp+8

       LOC           CFA
    000000000040053b rsp+8
    000000000040053c rsp+16
    000000000040053f rbp+16   # B
    0000000000400564 rsp+8

Now in GDB:

    $ gdb -n -q -ex 'b pr53927.c:7' -ex r --args ./pr53927
    [...]
    Breakpoint 1, nested (nested_arg=10) at pr53927.c:7
    7           return nested_arg + 23 + self_call; /* Break here */
    (gdb) bt
    #0  nested (nested_arg=10) at pr53927.c:7
    #1  0x000000000040052b in nestee (computer=0x7fffffffdf24, arg=10) at
pr53927.c:13
    #2  0x000000000040051d in nestee (computer=0x40052d <misc>, arg=5) at
pr53927.c:11
    #3  0x000000000040055e in main (argc=1, argv=0x7fffffffe058) at
pr53927.c:23

    (gdb) p $pc
    $1 = (void (*)()) 0x4004a4 <nested+14>
    # This PC corresponds to the "B" line above: CFA = $rbp + 16
    (gdb) x/1gx $rbp + 16 - 32
    0x7fffffffdea0: 0x00007fffffffdf20
    (gdb) x/1gx 0x00007fffffffdf20 + 32
    0x7fffffffdf40: 0x00007fffffffdf60

... so the static link expression gives us the following frame base address:
0x00007fffffffdf60

    (gdb) f 2
    #2  0x000000000040051d in nestee (computer=0x40052d <misc>, arg=5) at
pr53927.c:11
    11          arg = nestee (nested, arg + 5, 0);
    # This PC corresponds to the "A" line above: CFA = $rbp + 16
    (gdb) p/x $rbp + 16
    $2 = 0x7fffffffdf60

So the static link expression correctly yields the frame 2'sÂCFA.

> Yeah, growing these is to be avoided.
> My patch for this added a method to symbol_computed_ops instead.
> 
> Unfortunately gitorious is acting weird so you can't see the patch
> online :-(.  But you can fetch from
> https://gitorious.org/binutils-gdb/gdb.git
> and look at the branch static-link-fix if you like.

Interesting! Having a look at this: thank you! IÂguess you waited for the GCC
issue to be solved before submitting them to GDB?

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