@@ -45,42 +45,64 @@ class UserStacks(sdb.Locator, sdb.PrettyPrinter):
4545 The command returns all thread IDs that matched the
4646 filter.
4747
48+ The command will not produce output on running userland processes,
49+ because the process is not stopped while being analyzed.
50+
4851 EXAMPLES
4952 Print the call stacks for all threads
5053
5154 sdb> stacks
52- TASK_STRUCT STATE COUNT
53- ==========================================
54- 0xffff9521bb3c3b80 IDLE 394
55- __schedule+0x24e
56- schedule+0x2c
57- worker_thread+0xba
58- kthread+0x121
59- ret_from_fork+0x35
60-
61- 0xffff9521bb3cbb80 INTERRUPTIBLE 384
62- __schedule+0x24e
63- schedule+0x2c
64- smpboot_thread_fn+0x166
65- kthread+0x121
66- ret_from_fork+0x35
55+ TID COUNT
56+ ==========================================================
57+ ...
58+ 125023 1
59+ 0x7f2fd24c1170+0x0
60+ spa_open_common+0x1ac
61+ dsl_sync_task_common+0x65
62+ dsl_sync_task_sig+0x13
63+ zcp_eval+0x70f
64+ dsl_destroy_snapshots_nvl+0x12b
65+ dsl_destroy_snapshot+0x3f
66+ ztest_objset_destroy_cb+0xb7
67+ dmu_objset_find_impl+0x481
68+ dmu_objset_find+0x56
69+ ztest_dmu_objset_create_destroy+0xad
70+ ztest_execute+0x6c
71+ ztest_thread+0xd9
72+ zk_thread_wrapper+0x1c
73+ 0x7f2fd24b6609+0x0
74+ ...
75+ 125037 1
76+ 0x7f2fd22ff00b+0x0
77+ 0x557766d8aeed+0x0
78+ ztest_dsl_dataset_promote_busy+0x9e
79+ ztest_execute+0x6c
80+ ztest_thread+0xd9
81+ zk_thread_wrapper+0x1c
82+ 0x7f2fd24b6609+0x0
6783 ...
6884
6985 Print stacks containing the l2arc_feed_thread function
7086
71- sdb> stacks -c l2arc_feed_thread
72- TASK_STRUCT STATE COUNT
73- ==========================================
74- 0xffff9521b3f43b80 INTERRUPTIBLE 1
75- __schedule+0x24e
76- schedule+0x2c
77- schedule_timeout+0x15d
78- __cv_timedwait_common+0xdf
79- __cv_timedwait_sig+0x16
80- l2arc_feed_thread+0x66
81- thread_generic_wrapper+0x74
82- kthread+0x121
83- ret_from_fork+0x35
87+ sdb> stacks -c zcp_eval
88+ TID COUNT
89+ ==========================================================
90+ 125023 1
91+ 0x7f2fd24c1170+0x0
92+ spa_open_common+0x1ac
93+ dsl_sync_task_common+0x65
94+ dsl_sync_task_sig+0x13
95+ zcp_eval+0x70f
96+ dsl_destroy_snapshots_nvl+0x12b
97+ dsl_destroy_snapshot+0x3f
98+ ztest_objset_destroy_cb+0xb7
99+ dmu_objset_find_impl+0x481
100+ dmu_objset_find+0x56
101+ ztest_dmu_objset_create_destroy+0xad
102+ ztest_execute+0x6c
103+ ztest_thread+0xd9
104+ zk_thread_wrapper+0x1c
105+ 0x7f2fd24b6609+0x0
84106
85107
86108 """
@@ -128,12 +150,9 @@ def get_frame_pcs(thread: Thread) -> List[int]:
128150 # masking other "ValueError" exceptions that are not due
129151 # to unwinding the stack of a running task.
130152 #
131- # We can't check the state of the task here, and verify
132- # it's in the "R" state, since that state can change in
133- # between the point where the "ValueError" exception was
134- # originally raised, and here where we'd verify the
135- # state of the task; i.e. it could have concurrently
136- # transitioned from running to some other state.
153+ # This also means that debugging a running userland process will
154+ # be largely ineffective, since we don't use ptrace to stop the
155+ # process the way other debuggers like gdb do.
137156 #
138157 pass
139158 return frame_pcs
@@ -228,25 +247,16 @@ class UserCrashedThread(sdb.Locator, sdb.PrettyPrinter):
228247
229248 EXAMPLES
230249 sdb> crashed_thread
231- TASK_STRUCT STATE COUNT
232- ==========================================
233- 0xffff8f15d7333d00 RUNNING 1
234- __crash_kexec+0x9d
235- __crash_kexec+0x9d
236- panic+0x11d
237- 0xffffffff9020b375+0x0
238- __handle_sysrq.cold+0x48
239- write_sysrq_trigger+0x28
240- proc_reg_write+0x43
241- __vfs_write+0x1b
242- vfs_write+0xb9
243- vfs_write+0xb9
244- ksys_write+0x67
245- __x64_sys_write+0x1a
246- __x64_sys_write+0x1a
247- __x64_sys_write+0x1a
248- do_syscall_64+0x57
249- entry_SYSCALL_64+0x94
250+ TID COUNT
251+ ==========================================================
252+ 125037 1
253+ 0x7f2fd22ff00b+0x0
254+ 0x557766d8aeed+0x0
255+ ztest_dsl_dataset_promote_busy+0x9e
256+ ztest_execute+0x6c
257+ ztest_thread+0xd9
258+ zk_thread_wrapper+0x1c
259+ 0x7f2fd24b6609+0x0
250260 """
251261
252262 names = ["crashed_thread" , "panic_stack" , "panic_thread" ]
0 commit comments