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

            Bug ID: 98780
           Summary: Missing line table entry for inlined stmt at -g -O0
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50018
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50018&action=edit
source file

[ Spinoff of gdb PR25884 - "Stepping over inlined function without line number
statement fails" (https://sourceware.org/bugzilla/show_bug.cgi?id=25884). ]

Consider test source gdb/testsuite/gdb.opt/inline-cmds.c (attached).

When compiled with -O0 -g, this bit:
...
    71    result = 0; /* set breakpoint 3 here */
    72
    73    func1 (); /* first call */
    74    func1 (); /* second call */
    75    marker ();
...
where func1 is:
...
    33  inline __attribute__((always_inline)) int func1(void)
    34  {
    35    bar ();
    36    return x * y;
    37  }
...
is represented in the line info as:
...
Line number    Starting address    View    Stmt
71                0x64               x
35                0x6e               x
75                0x78               x
...
where the insn are:
...
  64:   c7 05 00 00 00 00 00    movl   $0x0,0x0(%rip)        # 6e <main+0x6e>
  6b:   00 00 00 
  6e:   e8 00 00 00 00          callq  73 <bar>
  73:   e8 00 00 00 00          callq  78 <bar>
  78:   e8 00 00 00 00          callq  7d <marker>
...

The calls to bar at 6e and 73 represent different instantiations of the same
statement, but they get a single entry in the line table.

It would be more accurate to have two entries.

Note that each call to bar has its own DW_TAG_inlined_subroutine descriptor:
...
 <2><11e>: Abbrev Number: 10 (DW_TAG_inlined_subroutine)
    <11f>   DW_AT_abstract_origin: <0x208>
    <123>   DW_AT_low_pc      : 0x6e
    <12b>   DW_AT_high_pc     : 0x5
    <133>   DW_AT_call_file   : 1
    <134>   DW_AT_call_line   : 73
    <135>   DW_AT_call_column : 3
 <2><136>: Abbrev Number: 10 (DW_TAG_inlined_subroutine)
    <137>   DW_AT_abstract_origin: <0x208>
    <13b>   DW_AT_low_pc      : 0x73
    <143>   DW_AT_high_pc     : 0x5
    <14b>   DW_AT_call_file   : 1
    <14c>   DW_AT_call_line   : 74
    <14d>   DW_AT_call_column : 3
...
so at some level gcc knows that these are different statements.

[ The problem with gdb is that it ignores the DW_TAG_inlined_subroutine on the
second call because there's no corresponding line table entry. ]

Reply via email to