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)
Thu, Nov 21, 2:10 AM
Unknown Object (File)
Oct 1 2024, 2:46 PM
Unknown Object (File)
Sep 19 2024, 11:43 AM
Unknown Object (File)
Sep 8 2024, 10:36 PM
Unknown Object (File)
Sep 5 2024, 11:17 PM
Unknown Object (File)
Sep 2 2024, 8:58 PM
Unknown Object (File)
Aug 31 2024, 10:48 PM
Unknown Object (File)
Aug 31 2024, 12:15 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

Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 29172
Build 27104: arc lint + arc unit

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

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

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