Page MenuHomeFreeBSD

Fix DDB to unwind across exception frames.
ClosedPublic

Authored by jhb on Feb 4 2020, 11:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 1:39 AM
Unknown Object (File)
Nov 11 2023, 2:13 PM
Unknown Object (File)
Nov 9 2023, 2:17 PM
Unknown Object (File)
Nov 1 2023, 9:38 AM
Unknown Object (File)
Sep 30 2023, 9:39 AM
Unknown Object (File)
Aug 25 2023, 12:04 AM
Unknown Object (File)
Aug 3 2023, 10:03 PM
Unknown Object (File)
Jun 26 2023, 7:33 PM
Subscribers

Details

Summary

While here, add an extra line of information for exceptions and
interrupts and compress the per-frame line down to one line to
match other architectures.

Test Plan
  • stack traces while debugging some kernel issues, but you can also compare debug.kdb.trap=1 stack traces before and after

Diff Detail

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

Event Timeline

Existing format for debug.kdb.trap=1:

panic: Fatal page fault at 0xffffffc00028d4c6: 0x00000000000010
cpuid = 0
time = 1578356275
KDB: stack backtrace:
db_trace_self() at db_read_token_flags+0x694
         pc = 0xffffffc0004f337a ra = 0xffffffc0000d2896
         sp = 0xffffffc0354133c8 fp = 0xffffffc0354135e8

db_read_token_flags() at kdb_backtrace+0x2e
         pc = 0xffffffc0000d2896 ra = 0xffffffc00028d654
         sp = 0xffffffc0354135e8 fp = 0xffffffc035413698

kdb_backtrace() at vpanic+0x154
         pc = 0xffffffc00028d654 ra = 0xffffffc00024fef4
         sp = 0xffffffc035413698 fp = 0xffffffc0354136d8

vpanic() at panic+0x22
         pc = 0xffffffc00024fef4 ra = 0xffffffc00024ff2c
         sp = 0xffffffc0354136d8 fp = 0xffffffc0354136f8

panic() at sysarch+0x264
         pc = 0xffffffc00024ff2c ra = 0xffffffc000500b08
         sp = 0xffffffc0354136f8 fp = 0xffffffc035413808

sysarch() at do_trap_supervisor+0x6a
         pc = 0xffffffc000500b08 ra = 0xffffffc000500c1e
         sp = 0xffffffc035413808 fp = 0xffffffc035413828

do_trap_supervisor() at cpu_exception_handler_supervisor+0x66
         pc = 0xffffffc000500c1e ra = 0xffffffc0004f3a26
         sp = 0xffffffc035413828 fp = 0xffffffc035413970

cpu_exception_handler_supervisor() at sysctl_handle_opaque+0x5f0
         pc = 0xffffffc0004f3a26 ra = 0xffffffc00025b1aa
         sp = 0xffffffc035413970 fp = 0xffffffc0354139c0

sysctl_handle_opaque() at sysctl_find_oid+0x464
         pc = 0xffffffc00025b1aa ra = 0xffffffc00025d172
         sp = 0xffffffc0354139c0 fp = 0xffffffc035413a40

sysctl_find_oid() at userland_sysctl+0x104
         pc = 0xffffffc00025d172 ra = 0xffffffc00025d9f2
         sp = 0xffffffc035413a40 fp = 0xffffffc035413af0

userland_sysctl() at sys___sysctl+0x66
         pc = 0xffffffc00025d9f2 ra = 0xffffffc00025dbaa
         sp = 0xffffffc035413af0 fp = 0xffffffc035413ba0

sys___sysctl() at do_trap_user+0x35a
         pc = 0xffffffc00025dbaa ra = 0xffffffc000500fde
         sp = 0xffffffc035413ba0 fp = 0xffffffc035413c50

do_trap_user() at cpu_exception_handler_user+0x70
         pc = 0xffffffc000500fde ra = 0xffffffc0004f3af0
         sp = 0xffffffc035413c50 fp = 0x0000003fffffe0f0

vs with change:

panic: Fatal page fault at 0xffffffc0002bf63a: 0x00000000000010
cpuid = 0
time = 1578356209
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_fetch_ksymtab() at db_fetch_ksymtab+0x12a
kdb_backtrace() at kdb_backtrace+0x2c
vpanic() at vpanic+0x144
panic() at panic+0x26
do_trap_supervisor() at do_trap_supervisor+0x278
do_trap_supervisor() at do_trap_supervisor+0x68
cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x6a
--- exception 13, tval = 0x10
kdb_trap() at kdb_trap+0x4ce
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

One thing that is less obvious from this example that I found to be true in some real-world cases is that the stack trace would skip over several frames when it hit an exception frame.

sys/riscv/riscv/db_trace.c
104 ↗(On Diff #67801)

Should this be %ld?

LGTM, besides the nit.

This revision is now accepted and ready to land.Feb 5 2020, 8:53 PM
br added inline comments.
sys/riscv/riscv/db_trace.c
4 ↗(On Diff #67801)

Copyright (c) 2020 John Baldwin <jhb@FreeBSD.org>

This revision was automatically updated to reflect the committed changes.
jhb marked an inline comment as done.
jhb marked an inline comment as done.Feb 6 2020, 6:03 PM