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)
May 22 2024, 6:36 PM
Unknown Object (File)
Feb 28 2024, 10:50 AM
Unknown Object (File)
Feb 28 2024, 9:03 AM
Unknown Object (File)
Dec 20 2023, 12:58 AM
Unknown Object (File)
Sep 23 2023, 4:36 PM
Unknown Object (File)
Aug 5 2023, 8:55 PM
Unknown Object (File)
Jun 6 2023, 7:27 AM
Unknown Object (File)
Apr 14 2017, 3:50 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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
150 ↗(On Diff #6370)

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 ↗(On Diff #7121)

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.