Page MenuHomeFreeBSD

Use the context created in makectx() for stack traces.
ClosedPublic

Authored by jhb on Feb 5 2020, 12:41 AM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 19 2024, 12:28 PM
Unknown Object (File)
Sep 28 2024, 6:31 AM
Unknown Object (File)
Sep 17 2024, 2:01 PM
Unknown Object (File)
Sep 5 2024, 11:14 PM
Unknown Object (File)
Aug 24 2024, 5:23 PM
Unknown Object (File)
Aug 20 2024, 1:34 AM
Unknown Object (File)
Aug 19 2024, 4:48 PM
Unknown Object (File)
Aug 18 2024, 12:21 AM
Subscribers

Details

Summary

Always use the kdb_thr_ctx() for db_trace_thread() as on other
architectures. Initialize pcb_ra to be the sepc from the saved
trapframe rather than the saved ra to avoid skipping a frame.

Test Plan
  • compared traces from ddb

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 29177
Build 27109: arc lint + arc unit

Event Timeline

Before:

KDB: enter: sysctl debug.kdb.enter
[ thread pid 690 tid 100049 ]
Stopped at      kdb_trap+0x42a: sd      zero,0(a0)
db> tr
Tracing pid 690 tid 100049 td 0xffffffd001a26560
db_trace_self() at db_trace_self
db_hex2dec() at db_hex2dec+0x1d2
db_command_loop() at db_command_loop+0x2c6
db_command_loop() at db_command_loop+0x6a
db_fetch_ksymtab() at db_fetch_ksymtab+0x2c8
kdb_trap() at kdb_trap+0x156
do_trap_supervisor() at do_trap_supervisor+0xaa
cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x6a
--- exception 3, tval = 0
kdb_trap() at kdb_trap+0x42a
sbuf_new_for_sysctl() at sbuf_new_for_sysctl+0x11a
kernel_sysctl() at kernel_sysctl+0x376
userland_sysctl() at userland_sysctl+0x150
sys___sysctl() at sys___sysctl+0x54
do_trap_user() at do_trap_user+0x3d6
cpu_exception_handler_user() at cpu_exception_handler_user+0x74
--- exception 8, tval = 0
db> c

vs after:

KDB: enter: sysctl debug.kdb.enter
[ thread pid 700 tid 100063 ]
Stopped at      kdb_trap+0x42a: sd      zero,0(a0)
db> tr
Tracing pid 700 tid 100063 td 0xffffffd03e80c560
kdb_trap() at kdb_trap+0x428
sbuf_new_for_sysctl() at sbuf_new_for_sysctl+0x11a
kernel_sysctl() at kernel_sysctl+0x376
userland_sysctl() at userland_sysctl+0x150
sys___sysctl() at sys___sysctl+0x54
do_trap_user() at do_trap_user+0x3d6
cpu_exception_handler_user() at cpu_exception_handler_user+0x74
--- exception 8, tval = 0
db> c

Mostly it means stack traces don't show the internals of being in ddb itself but start at the time of entering the debugger.

LGTM. The change to db_trace_thread also needs doing for arm and arm64.

This revision is now accepted and ready to land.Feb 5 2020, 8:24 PM

Yes, it was probably copied from arm64 originally. Fixing it on those platforms requires auditing makectx() to make sure it DTRT however.

In D23513#516255, @jhb wrote:

Yes, it was probably copied from arm64 originally. Fixing it on those platforms requires auditing makectx() to make sure it DTRT however.

Ack, thanks.

This revision was automatically updated to reflect the committed changes.