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/12319] New: Wrong DW_AT_low_pc and DW_AT_high_pc for DW_TAG_inlined_subroutine


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Wrong DW_AT_low_pc and DW_AT_high_pc for
                    DW_TAG_inlined_subroutine
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carlo at alinoe dot com
                CC: gcc-bugs at gcc dot gnu dot org

Consider the following code snippet:

# cat troep.c
extern int a;

inline void g()
{
  a = a + 1;     // line 5
}

void f()
{
  g();
}                // line 11

Compiled as

# gcc-cvs-3.4 -g -O3 -c troep.c

Then the DWARF2 .debug_info section contains
wrong information:

# readelf --debug-dump troep.o
[...]
 <2><5b>: Abbrev Number: 7 (DW_TAG_inlined_subroutine)
     DW_AT_abstract_origin: <25>
     DW_AT_low_pc      : 0x10 16
     DW_AT_high_pc     : 0x1b 27

Where <25> refers to:

 <1><25>: Abbrev Number: 2 (DW_TAG_subprogram)
     DW_AT_external    : 1
     DW_AT_name        : g

Note that function f() has:

 <1><3b>: Abbrev Number: 4 (DW_TAG_subprogram)
     DW_AT_sibling     : <48>
     DW_AT_external    : 1
     DW_AT_name        : f

Ie, it is <3b>, and

 <1><48>: Abbrev Number: 6 (DW_TAG_subprogram)
     DW_AT_sibling     : <69>
     DW_AT_abstract_origin: <3b>
     DW_AT_low_pc      : 0x10 16
     DW_AT_high_pc     : 0x1b 27

In other words, f() starts at offset 0x10 and
ends at 0x1b: its total size is 11 bytes.
That is correct.

What is wrong is that the inlined g() is said
to ALSO start at 0x10 and end at 0x1b.  This
is 100% nonsense.

troep.s:

.globl _Z1fv
        .type   _Z1fv,@function
_Z1fv:
.LFB3:
        .file 1 "troep.cc"
        .loc 1 9 0
.LBB2:
.LBB3:
.LBB4:
        pushl   %ebp            <-- Start of f() (offset 0x10)
.LCFI0:
        movl    %esp, %ebp
.LCFI1:
        .loc 1 5 0              <-- debug file/line number change (line 5)
        incl    a               <-- Start of inlined g() (offset 0x13!)
        .loc 1 11 0             <-- debug file/line number change (line 11)
        leave                   <-- End of inlined g() (offset 0x19!)
        ret
                                <-- End of f() (offset 0x1b)

See also disassembly:

# objdump -d troep.o
[...]
00000010 <f>:
  10:   55                      push   %ebp
  11:   89 e5                   mov    %esp,%ebp
  13:   ff 05 00 00 00 00       incl   0x0
  19:   5d                      pop    %ebp
  1a:   c3                      ret


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