delphix / sdb

The Slick Debugger
Apache License 2.0
57 stars 20 forks source link

DLPX-84437 Print panicked thread of crash dump on SDB #309

Closed sdimitro closed 1 year ago

sdimitro commented 1 year ago

= Motivation

The stacks command can be overwhelming for newcomers that need to figure out which thread caused the debugging target to panic. An alternative would be dmesg, but that command also has a lot of extraneous output.

= This Patch

Creates a new SDB command that yields the panicked thread to subsequent commands or just pretty-prints it in the style of the stacks command.

= Example Output

sdb> crashed_thread
TASK_STRUCT        STATE             COUNT
==========================================
0xffff8f15d7333d00 RUNNING               1
          __crash_kexec+0x9d
          __crash_kexec+0x9d
          panic+0x11d
          0xffffffff9020b375+0x0
          __handle_sysrq.cold+0x48
          write_sysrq_trigger+0x28
          proc_reg_write+0x43
          __vfs_write+0x1b
          vfs_write+0xb9
          vfs_write+0xb9
          ksys_write+0x67
          __x64_sys_write+0x1a
          __x64_sys_write+0x1a
          __x64_sys_write+0x1a
          do_syscall_64+0x57
          entry_SYSCALL_64+0x94

Error case A: Live-Target:

$ sudo sdb
sdb> crashed_thread
sdb: crashed_thread: command only works for core/crash dumps

Error case B: Pretty-print bogus thread/value:

sdb> stacks | head 1 | crashed_thread
sdb: crashed_thread: can only pretty print the crashed thread
sdb> echo 0x0 | crashed_thread
sdb: crashed_thread: can only pretty print the crashed thread
codecov-commenter commented 1 year ago

Codecov Report

Merging #309 (af4bea3) into 6.0/stage (8c98877) will increase coverage by 0.01%. The diff coverage is 88.88%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@              Coverage Diff              @@
##           6.0/stage     #309      +/-   ##
=============================================
+ Coverage      86.97%   86.98%   +0.01%     
=============================================
  Files             64       64              
  Lines           2595     2613      +18     
=============================================
+ Hits            2257     2273      +16     
- Misses           338      340       +2     
Impacted Files Coverage Δ
sdb/commands/stacks.py 94.80% <88.88%> (-0.79%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

sdimitro commented 1 year ago

@mmaybee both sound good, I can add them as command aliases