Page MenuHomeFreeBSD

ddb: remove some dead code from the amd64 stack unwinder
ClosedPublic

Authored by markj on Jun 18 2015, 5:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 2:52 AM
Unknown Object (File)
Feb 28 2024, 10:50 AM
Unknown Object (File)
Feb 28 2024, 9:02 AM
Unknown Object (File)
Feb 8 2024, 9:47 AM
Unknown Object (File)
Dec 2 2023, 12:59 PM
Unknown Object (File)
Dec 1 2023, 3:44 PM
Unknown Object (File)
Nov 22 2023, 4:44 PM
Unknown Object (File)
Nov 7 2023, 7:46 PM
Subscribers

Details

Summary

None of the callers of db_backtrace() pass a trap frame, so don't bother
attempting to decode the current instruction. This change is a precursor
to a couple of bug fixes for the unwinder and introduces no functional
changes.

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: remove some dead code from the amd64 stack unwinder.
markj edited the test plan for this revision. (Show Details)
markj updated this object.

Removing the numargs stuff is definitely fine.

I think the trapframe bit is probably a bug in db_trace_thread(). It should be passing kdb_frame when kdb_thread is used. kdb_thr_ctx() does some of this already as it creates a fake pcb that is used to pass
the PC and sp values derived from kdb_frame. I bet some of the KDB changes several years ago broke this. However, I'm not sure how you would reproduce it. Perhaps a kernel module with an int3 instruction at specific points in a function prologue would be able to test it, but that would be tedious.

I also wonder if db_nextframe() should use similar logic to construct the frame it builds "below" the trapframe. In that case it would need to be done in a shared function, and you could probably do it explicitly in db_trace_thread() for the kdb_thread case and not keep it in db_backtrace().

If you do remove the special trapframe handling, you should do so on both amd64 and i386.

In D2857#55658, @jhb wrote:

Removing the numargs stuff is definitely fine.

I think the trapframe bit is probably a bug in db_trace_thread(). It should be passing kdb_frame when kdb_thread is used. kdb_thr_ctx() does some of this already as it creates a fake pcb that is used to pass
the PC and sp values derived from kdb_frame. I bet some of the KDB changes several years ago broke this. However, I'm not sure how you would reproduce it. Perhaps a kernel module with an int3 instruction at specific points in a function prologue would be able to test it, but that would be tedious.

I see. Looks like this was broken by r131952. It should be possible to use DDB to put a breakpoint on a function prologue, so I'll give that a try and see if I can fix this.

I also wonder if db_nextframe() should use similar logic to construct the frame it builds "below" the trapframe. In that case it would need to be done in a shared function, and you could probably do it explicitly in db_trace_thread() for the kdb_thread case and not keep it in db_backtrace().

If you do remove the special trapframe handling, you should do so on both amd64 and i386.

markj edited edge metadata.
  • Restore trap frame handling: it'll be fixed properly in a new change.
  • Remove more remnants of argument printing support.
jhb edited edge metadata.
This revision is now accepted and ready to land.Jul 21 2015, 4:53 AM
This revision was automatically updated to reflect the committed changes.