public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/18413] New: gdb can't step out of plt stub
@ 2015-05-13 20:02 dje at google dot com
  0 siblings, 0 replies; only message in thread
From: dje at google dot com @ 2015-05-13 20:02 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 18413
           Summary: gdb can't step out of plt stub
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com
  Target Milestone: ---

IWBN if "next" in a plt stub could step out of the function, instead of leaving
the user stranded in a place where next/step no longer work.

gcc -fpic -shared stripped-shared.c -o stripped-shared.so
gcc -g stripped-shared-user.c stripped-shared.so -Wl,-rpath,$(pwd)

bash$ gdb a.out
(gdb) b foo@plt
Breakpoint 1 at 0x400600
(gdb) r
Starting program: /usr/local/google/home/dje/ruffies-copy/src/play/a.out


Breakpoint 1, 0x0000000000400600 in foo@plt ()
(gdb) x/4i $pc
=> 0x400600 <foo@plt>:  jmpq   *0x200a22(%rip)        # 0x601028 <foo@got.plt>
   0x400606 <foo@plt+6>:        pushq  $0x2
   0x40060b <foo@plt+11>:       jmpq   0x4005d0
   0x400610 <sleep@plt>:
    jmpq   *0x200a1a(%rip)        # 0x601030 <sleep@got.plt>
(gdb) n
Single stepping until exit from function foo@plt,
which has no line number information.
0x00000000004005d0 in ?? ()
(gdb) n
Cannot find bounds of current function
(gdb) x/4i $pc
=> 0x4005d0:    pushq  0x200a32(%rip)        # 0x601008
   0x4005d6:    jmpq   *0x200a34(%rip)        # 0x601010
   0x4005dc:    nopl   0x0(%rax)
   0x4005e0 <__libc_start_main@plt>:
    jmpq   *0x200a32(%rip)        # 0x601018 <__libc_start_main@got.plt>
(gdb) disp/i $pc
1: x/i $pc
=> 0x4005d0:    pushq  0x200a32(%rip)        # 0x601008
(gdb) si
0x00000000004005d6 in ?? ()
1: x/i $pc
=> 0x4005d6:    jmpq   *0x200a34(%rip)        # 0x601010
(gdb) si
_dl_runtime_resolve () at ../sysdeps/x86_64/dl-trampoline.S:34
34      ../sysdeps/x86_64/dl-trampoline.S: No such file or directory.
1: x/i $pc
=> 0x7ffff7df04e0 <_dl_runtime_resolve>:        sub    $0x38,%rsp
(gdb) 

The two piece nature of the stub gets in the way of what I think gdb intends to
accomplish here.
Part 1 is at 0x400600 and part 2 is at 0x4005d0.
The "n" command skips passed part 1 and leaves the user in part 2
where it can be confusing trying to figure out what to do next.

It may be sufficient (for now) to include in the message to the user
instructions for what will and will not work at that point (and why).

See also PR 15314.

---snip--- stripped-shared.c
int foo () { return 42; }
---snip---

---snip--- stripped-shared-user.c

#include <stdlib.h>

extern int foo ();

int x;

int
main ()
{
  while (1)
    {
      x += foo ();
      sleep (1);
    }

  return 0;
}
---snip---

-- 
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:[~2015-05-13 20:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-13 20:02 [Bug breakpoints/18413] New: gdb can't step out of plt stub dje at google dot com

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