sdb
sdb copied to clipboard
DLPX-84435 Support printing local variables
Problem
Need to be able to find local variables and their values
Solution
This PR provodes 4 new commands: trace, frame, locals, and registers
sdb> help trace
SUMMARY
trace [-h] [<task address>]
Given a task_struct, trace the thread's execution state.
positional arguments:
<task address> trace this task if no input
optional arguments:
-h, --help show this help message and exit
ALIASES
trace, bt
FIELDS
frame# - frame number in backtrace (most recent first)
addr - address of the frame
function - function name in the frame (or symbol if no function)
file - file name (if available) containing the function
line - line number in the file
EXAMPLE
sdb> trace 0xffff94614e796000
TASK: 0xffff94614e796000 INTERRUPTIBLE PID: 268
#0 0xffffffffa0c549e8 in context_switch() at core.c:5038:2 (inlined)
#1 0xffffffffa0c549e8 in __schedule() at core.c:6384:8
#2 0xffffffffa0c54fe9 in schedule() at core.c:6467:3
#3 0xffffffffa0c595c2 in schedule_timeout() at timer.c:2116:2
#4 0xffffffffc04836ae in __cv_timedwait_common() at spl-condvar.c:250:15
#5 0xffffffffc0483829 in __cv_timedwait_idle() at spl-condvar.c:307:7
#6 0xffffffffc0571554 in l2arc_feed_thread() at arc.c:9460:10
#7 0xffffffffc048c8d1 in thread_generic_wrapper() at spl-thread.c:61:3
#8 0xffffffffa00efb17 in kthread() at kthread.c:334:9
#9 0xffffffffa0004c3f (ret_from_fork+0x1f/0x2d) at entry_64.S:287
sdb> help frame
SUMMARY
frame [-h] [-v] [<frame>]
Given a task_struct and frame, return requested stack frame
positional arguments:
<frame> set local context to this frame number
optional arguments:
-h, --help show this help message and exit
-v, --verbose print full file path for frame
ALIASES
stackframe, frame, f
EXAMPLE
sdb> frame 7
#7 0xffffffffc048c8d1 in thread_generic_wrapper (arg=0xffff94614f3cc400) at spl-thread.c:61:3
sdb> help locals
SUMMARY
locals [-h] [-v] [<variable> [<variable> ...]]
Given a stack frame, return the local variables
positional arguments:
<variable> variable to retrieve
optional arguments:
-h, --help show this help message and exit
-v, --verbose dereference pointers
ALIASES
locals, local
EXAMPLE
sdb> frame 7 | locals
arg = (void *)0xffff94614f3cc400
tp = (thread_priv_t *)0xffff94614f3cc400
func = (void (*)(void *))l2arc_feed_thread+0x0 = 0xffffffffc05714f0
args = (void *)0x0
sdb> help registers
SUMMARY
registers [-h] [-x] [<register> [<register> ...]]
Given a stack frame, return the registers
positional arguments:
<register> register to retrieve
optional arguments:
-h, --help show this help message and exit
-x, --hex print registers in hexadecimal
ALIASES
registers, register
EXAMPLE
sdb> frame 7 | registers
rbx = 18446744072641516784
rbp = 18446653449961438984
rsp = 18446653449961438960
r12 = 18446625744394961920
r13 = 0
r14 = 18446653449906223704
r15 = 18446625744394961920
rip = 18446744072640579793
Testing Done
Verified commands on engine kernel