public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug tdep/29043] New: [gdb, i386, pie] Prologue skipper does not skip get_pc_thunk
@ 2022-04-11  5:38 vries at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: vries at gcc dot gnu.org @ 2022-04-11  5:38 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 29043
           Summary: [gdb, i386, pie] Prologue skipper does not skip
                    get_pc_thunk
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: tdep
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider function bar in test-case gdb/testsuite/gdb.dwarf2/dw2-lines.c:
...
void
bar (void)
{
  asm ("bar_label: .globl bar_label");
  foo (1);
  asm ("bar_label_2: .globl bar_label_2");
  foo (2);
  asm ("bar_label_3: .globl bar_label_3");
  foo (3);
  asm ("bar_label_4: .globl bar_label_4");
  foo (4);
  asm ("bar_label_5: .globl bar_label_5");
}
...

When compiled for m32/pie:
...
$ gcc src/gdb/testsuite/gdb.dwarf2/dw2-lines.c -g -m32 -fPIE -pie
...
and setting a breakpoint at bar:
...
│    0x5655552d <bar>        push   %ebp                                       
             │
│    0x5655552e <bar+1>      mov    %esp,%ebp                                  
             │
│    0x56555530 <bar+3>      call   0x5655557e <__x86.get_pc_thunk.ax>         
             │
│    0x56555535 <bar+8>      add    $0x1acb,%eax                               
             │
│B+> 0x5655553a <bar+13>     push   $0x1                                       
             │
│    0x5655553c <bar+15>     call   0x5655551d <foo>                           
             ...
we see that it ends up after the get_pc_thunk, so apparently, with regular
debug info available, this is considered part of the prologue.

But when running the test-case, so with synthetic debug info, we run into a
FAIL:
...
Breakpoint 2, 0x56555540 in bar ()^M
(gdb) PASS: gdb.dwarf2/dw2-lines.exp: cv=2: cdw=32: lv=2: ldw=32: continue to
breakpoint: foo \(1\)
next^M
Single stepping until exit from function bar,^M
which has no line number information.^M
0x56555587 in main ()^M
(gdb) FAIL: gdb.dwarf2/dw2-lines.exp: cv=2: cdw=32: lv=2: ldw=32: next to foo
(2)
...
because the breakpoint ends up before the call to get_pc_thunk:
...
│    0x5655553d <bar>        push   %ebp                                       
             │
│    0x5655553e <bar+1>      mov    %esp,%ebp                                  
             │
│B+> 0x56555540 <bar+3>      call   0x5655558e <__x86.get_pc_thunk.ax>         
             │
│    0x56555545 <bar+8>      add    $0x1abb,%eax                               
             │
│    0x5655554a <bar+13>     push   $0x1                                       
             │
│    0x5655554c <bar+15>     call   0x5655552d <foo>                           
             ...
which is in a part that the synthetic debug info doesn't provide line number
information for, hence the FAIL.

AFAIU, the synthetic debug info is incomplete and therefore gdb needs to rely
on the port's prologue skipper, which apparently doesn't handle get_pc_thunk.

The test-case itself is not meant to test this behaviour, and can be fixed by
setting a breakpoint on bar_label instead of bar.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-11  5:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11  5:38 [Bug tdep/29043] New: [gdb, i386, pie] Prologue skipper does not skip get_pc_thunk vries 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).