Page MenuHomeFreeBSD

Various fixes for the MIPS DDB stack unwinder.
ClosedPublic

Authored by jhb on Nov 24 2020, 9:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 18 2023, 3:44 PM
Unknown Object (File)
Sep 3 2023, 3:52 AM
Unknown Object (File)
Sep 3 2023, 3:51 AM
Unknown Object (File)
Aug 28 2023, 7:38 AM
Unknown Object (File)
Aug 28 2023, 7:26 AM
Unknown Object (File)
Jul 24 2023, 9:00 PM
Unknown Object (File)
Jun 30 2023, 4:45 AM
Unknown Object (File)
Jun 27 2023, 12:03 PM
Subscribers

Details

Summary
  • Fix kernel stack unwinding end-of-function false-positive

    The kernel stack unwinder assumes that any jr $ra indicates the end of the current function. However, modern compilers generate code that contains jr $ra at various places inside the function.
  • Handle LLD inter-function padding when looking for the start of a function.
  • Use call site for symbol name/offset when unwinding

    Currently we use the return address, which will normally just give an output that's off by 8 from the actual call site. However, for tail calls, this is particularly bad, as we end up printing the symbol name for the function that comes after the one that made the call. Instead we should go back two instructions from the return address for the unwound program counter.

Submitted by: arichardson (1, 2), jrtc27 (3)
Obtained from: CheriBSD

Diff Detail

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

Event Timeline

jhb requested review of this revision.Nov 24 2020, 9:49 PM
jhb created this revision.
arichardson added inline comments.
sys/mips/mips/db_trace.c
386 ↗(On Diff #79959)

Not sure if the definition of this union is currently visible, but using sizeof(InstFmt) could make it more explicit. Or just 2 * 4?

This revision is now accepted and ready to land.Nov 26 2020, 10:25 AM
sys/mips/mips/db_trace.c
386 ↗(On Diff #79959)

We actually use sizeof(int) in other places in this function (e.g. the loop that tries to find the function start, the loop that walks over the function prologue), so I think this spelling is the most consistent within the function. If we wanted to change it we could perhaps use sizeof(instr).

This revision was automatically updated to reflect the committed changes.