public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/53927] New: wrong value for DW_AT_static_link
@ 2012-07-11 13:20 tromey at gcc dot gnu.org
  2013-01-24 20:25 ` [Bug debug/53927] " tromey at gcc dot gnu.org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: tromey at gcc dot gnu.org @ 2012-07-11 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53927
           Summary: wrong value for DW_AT_static_link
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tromey@gcc.gnu.org


Compile this program with -g:

typedef int compute_function (int);

int nestee (compute_function *computer, int arg, int self_call)
{
  int nested (int nested_arg)
  {
    return nested_arg + 23 + self_call;    /* Break here */
  }

  if (self_call)
    arg = nestee (nested, arg + 5, 0);

  return computer (arg);
}

int misc (int arg)
{
  return 0;
}

int main(int argc, char **argv)
{
  nestee (misc, 5, 1);
  return 0;
}


.debug_info says:

 <2><8b>: Abbrev Number: 9 (DW_TAG_subprogram)
    <8c>   DW_AT_name        : (indirect string, offset: 0xe6): nested    
    <90>   DW_AT_decl_file   : 1    
    <91>   DW_AT_decl_line   : 5    
    <92>   DW_AT_prototyped  : 1    
    <92>   DW_AT_type        : <0x47>    
    <96>   DW_AT_low_pc      : 0x4004b4    
    <9e>   DW_AT_high_pc     : 0x4004ca    
    <a6>   DW_AT_frame_base  : 1 byte block: 9c     (DW_OP_call_frame_cfa)
    <a8>   DW_AT_static_link : 1 byte block: 50     (DW_OP_reg0 (rax))
    <aa>   DW_AT_GNU_all_call_sites: 1    
    <aa>   DW_AT_sibling     : <0xcb>    


That is, the static link is $rax.

In gdb I set a breakpoint at line 7 and ran the program.  Then:

(gdb) p/x $rax
$8 = 0x7fffffffe400

Now I go up a couple of frames to the relevant (outermost) invocation
of nestee:

(gdb) p /x $pc
$9 = 0x40052c

And then from the frame info:

00000080 0000001c 00000084 FDE cie=00000000 pc=0040053c..0040054a
   LOC           CFA      rbp   ra      
000000000040053c rsp+8    u     c-8   
000000000040053d rsp+16   c-16  c-8   
0000000000400540 rbp+16   c-16  c-8   
0000000000400549 rsp+8    c-16  c-8   

So I think the CFA in this frame is $rsp+8.
But in gdb:

(gdb) p /x $rsp+8
$10 = 0x7fffffffe3f8

... which is different from the DW_AT_static_link.

nestee does specify that its frame base is the CFA:

 <1><4e>: Abbrev Number: 6 (DW_TAG_subprogram)
    <4f>   DW_AT_external    : 1    
    <4f>   DW_AT_name        : (indirect string, offset: 0xed): nestee    
    <53>   DW_AT_decl_file   : 1    
    <54>   DW_AT_decl_line   : 3    
    <55>   DW_AT_prototyped  : 1    
    <55>   DW_AT_type        : <0x47>    
    <59>   DW_AT_low_pc      : 0x4004ca    
    <61>   DW_AT_high_pc     : 0x40053c    
    <69>   DW_AT_frame_base  : 1 byte block: 9c     (DW_OP_call_frame_cfa)


So, I think this is a GCC bug.


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

end of thread, other threads:[~2015-03-10  9:41 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11 13:20 [Bug debug/53927] New: wrong value for DW_AT_static_link tromey at gcc dot gnu.org
2013-01-24 20:25 ` [Bug debug/53927] " tromey at gcc dot gnu.org
2013-01-31 15:01 ` ebotcazou at gcc dot gnu.org
2013-01-31 19:23 ` jason at gcc dot gnu.org
2013-01-31 19:40 ` tromey at gcc dot gnu.org
2013-01-31 20:12 ` jason at gcc dot gnu.org
2013-01-31 22:34 ` ebotcazou at gcc dot gnu.org
2013-01-31 23:23 ` jason at gcc dot gnu.org
2013-02-01 18:22 ` tromey at gcc dot gnu.org
2013-02-01 22:17 ` ebotcazou at gcc dot gnu.org
2013-02-01 22:21 ` ebotcazou at gcc dot gnu.org
2014-05-09 16:14 ` ebotcazou at gcc dot gnu.org
2014-06-06  8:14 ` ebotcazou at gcc dot gnu.org
2015-02-25 15:02 ` derodat at adacore dot com
2015-02-25 15:03 ` derodat at adacore dot com
2015-03-02 14:42 ` derodat at adacore dot com
2015-03-02 14:59 ` tromey at gcc dot gnu.org
2015-03-03 10:02 ` derodat at adacore dot com
2015-03-03 11:03 ` ebotcazou at gcc dot gnu.org
2015-03-03 15:13 ` tromey at gcc dot gnu.org
2015-03-09 15:56 ` derodat at adacore dot com
2015-03-10  9:41 ` ebotcazou at gcc dot gnu.org

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