Project

General

Profile

Actions

Bug #15288

closed

mdb amd64 ::step out seems like it's busted

Added by Rich Lowe 5 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
mdb - modular debugger
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

pt_step_out on amd64 passes registers as if they're x86 and quite possibly behaves randomly.

int
pt_step_out(mdb_tgt_t *t, uintptr_t *p)
{
    const lwpstatus_t *psp = &Pstatus(t->t_pshandle)->pr_lwp;

    if (Pstate(t->t_pshandle) != PS_STOP)
        return (set_errno(EMDB_TGTBUSY));

    return (mdb_amd64_step_out(t, p, psp->pr_reg[EIP], psp->pr_reg[EBP],
        psp->pr_reg[UESP], psp->pr_instr));
}
Actions #1

Updated by Rich Lowe 5 months ago

  • Subject changed from mdb amd5 to mdb amd64 ::step out seems like it's busted
  • Description updated (diff)
  • Category set to mdb - modular debugger
Actions #2

Updated by Rich Lowe 5 months ago

  • Status changed from New to In Progress
  • Assignee set to Rich Lowe
Actions #3

Updated by Electric Monk 5 months ago

  • Gerrit CR set to 2576
Actions #4

Updated by Rich Lowe 5 months ago

I've tested this by doing mdb of the 64bit ls with a breakpoint in printf, and stepping out of it:

before:

mdb +o pager /bin/amd64/ls
> ::bp printf
> ::run
mdb: stop at printf
mdb: target stopped at:
libc.so.1`printf:       pushq  %rbp
> ::step
mdb: target stopped at:
libc.so.1`printf+1:     movq   %rsp,%rbp
> ::step
mdb: target stopped at:
libc.so.1`printf+4:     pushq  %rdi
> ::step
mdb: target stopped at:
libc.so.1`printf+5:     subq   $0x8,%rsp
> ::step out
mdb: failed to step (out) target: no mapping for address

after:

intel/amd64/mdb/mdb +o pager /bin/amd64/ls
> ::bp printf
> ::run
mdb: stop at printf
mdb: target stopped at:
libc.so.1`printf:       pushq  %rbp
> ::step
mdb: target stopped at:
libc.so.1`printf+1:     movq   %rsp,%rbp
> ::step
mdb: target stopped at:
libc.so.1`printf+4:     pushq  %rdi
> ::step
mdb: target stopped at:
libc.so.1`printf+5:     subq   $0x8,%rsp
> $C
00007fffbfff38f0 libc.so.1`printf+5(409d2b)
00007fffbfff3930 pentry+0x347()
00007fffbfff3980 pem+0x12a()
00007fffbfff39d0 pdirectory+0x2a7()
00007fffbfff3cf0 main+0xa36()
00007fffbfff3d20 _start_crt+0x87()
00007fffbfff3d30 _start+0x18()
> ::step
mdb: target stopped at:
libc.so.1`printf+9:     pushq  %r13
> ::step out
mdb: target stopped at:
pentry+0x347:   movq   %r14,%rdi
> $C
00007fffbfff3930 pentry+0x347()
00007fffbfff3980 pem+0x12a()
00007fffbfff39d0 pdirectory+0x2a7()
00007fffbfff3cf0 main+0xa36()
00007fffbfff3d20 _start_crt+0x87()
00007fffbfff3d30 _start+0x18()

Actions #5

Updated by Electric Monk 5 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 405e3c92bc49aa93cbbccd57dc60e04369d03f9d

commit  405e3c92bc49aa93cbbccd57dc60e04369d03f9d
Author: Richard Lowe <richlowe@richlowe.net>
Date:   2023-01-04T19:36:28.000Z

    15288 mdb amd64 ::step out seems like it's busted
    Reviewed by: Jason King <jason.brian.king+illumos@gmail.com>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
    Approved by: Robert Mustacchi <rm@fingolfin.org>

Actions

Also available in: Atom PDF