Page MenuHomeFreeBSD

ddb: get the unwinder to handle function prologue/epilogue exceptions
ClosedPublic

Authored by markj on Jun 21 2015, 11:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 11 2024, 12:45 AM
Unknown Object (File)
Sep 25 2024, 1:57 AM
Unknown Object (File)
Sep 24 2024, 8:52 AM
Unknown Object (File)
Sep 23 2024, 11:38 PM
Unknown Object (File)
Sep 23 2024, 6:10 PM
Unknown Object (File)
Sep 23 2024, 12:23 AM
Unknown Object (File)
Sep 18 2024, 7:59 PM
Unknown Object (File)
Sep 14 2024, 8:30 PM
Subscribers

Details

Summary

The trapframe argument to db_backtrace() was previously always NULL, so
this code was never executing. Modify db_trace_thread() to pass
kdb_frame if we're being asked to trace kdb_thread's stack.

Get rid of get_rsp(). It looks like this came over from i386, which
needs to take into account whether the exception triggered a CPL switch,
since SS:ESP is only pushed onto the stack if so. On amd64, SS:RSP is
pushed regardless of whether the CPL changed, so get_rsp() was doing the
wrong thing for exceptions in ring 0.

Test Plan

Tested on amd64 and i386 by placing breakpoints on a sysctl handler and making sure that we get the right backtrace when:

  • the bp is on the first instruction (push rbp)
  • the bp is on the second instruction (mov rsp, rbp)
  • the bp is on a ret instruction, after a "pop rbp"

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage

Event Timeline

markj retitled this revision from to ddb: get the unwinder to handle function prologue/epilogue exceptions.
markj edited the test plan for this revision. (Show Details)
markj updated this object.
markj added a reviewer: jhb.
sys/amd64/amd64/db_trace.c
146–147

Good catch on removing get_rsp(). However, I think you can remove db_rsp entirely and just use db_frame.

Is the same true of db_ss() btw? Ah, it is. You can remove db_ss() and just use db_frame() to read/write tf_ss as well.

  • Remove more unneeded special handling of SS and RSP.
sys/amd64/amd64/db_trace.c
146–147

Gah. Thanks!

jhb edited edge metadata.
This revision is now accepted and ready to land.Jul 21 2015, 6:57 PM
This revision was automatically updated to reflect the committed changes.