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)
Tue, Nov 26, 12:59 PM
Unknown Object (File)
Nov 20 2024, 11:18 PM
Unknown Object (File)
Nov 7 2024, 11:09 PM
Unknown Object (File)
Nov 4 2024, 10:46 AM
Unknown Object (File)
Oct 18 2024, 6:07 AM
Unknown Object (File)
Oct 18 2024, 6:07 AM
Unknown Object (File)
Oct 18 2024, 5:45 AM
Unknown Object (File)
Oct 2 2024, 5:40 AM
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.