Windows 内核调试 Devstudio 的 spindump
spindump for Windows Kernel Debugging Devstudio
因此,当 运行 陷入死锁、互斥、锁反转等情况时,OSX 上的 spindump
工具非常有用。它只是转储 所有 系统上的线程堆栈(用户空间和内核),并且可以清楚地看到哪些线程被阻塞了。
现在使用 Devstudio 在 2nd VM 上进行内核调试,我遇到了死锁。我看到我可以使用“!process 0 0”来转储所有进程。而且我相信我可以切换到一个进程,并转储线程(?),然后选择一个带有“!线程”和 "k" 的线程来查看堆栈。但是确实有数千个线程,肯定有一种方法可以在不手动执行的情况下将它们全部转储吗?
"!process 0 7" 运行了大约 40 分钟,none 的堆栈中有我的函数。
spindump 输出看起来像
Thread 0x8ab 1000 samples (1-1000) priority 81 (base 81)
*1000 call_continuation + 23 (kernel.development + 1927415)
*1000 arc_reclaim_thread + 2391 (arc.c:5095,11 in zfs + 131367)
*1000 cv_timedwait_hires + 206 (spl-condvar.c:172,14 in spl + 8125)
*1000 msleep + 98 (kernel.development + 7434066)
*1000 _sleep + 219 (kernel.development + 7432603)
*1000 lck_mtx_sleep_deadline + 147 (kernel.development + 2362339)
*1000 thread_block_reason + 286 (kernel.development + 2407438)
所以没什么神奇的,只是它遍历所有线程。
对 0,1,2 使用 !stacks
引用自 windbg chm 文件
The !stacks extension gives a brief summary of the state of every thread. You
can use this extension instead of the !process extension to get a quick overview
of the system, especially when debugging multithread issues such as resource
conflicts or deadlocks.
The !findstack user-mode extension also displays information about particular stacks.
Here is an example of the simplest !stacks display:
kd> !stacks 0
Proc.Thread .Thread ThreadState Blocker
[System]
4.000050 827eea10 Blocked +0xfe0343a5
[smss.exe]
[csrss.exe]
b0.0000a8 82723b70 Blocked ntoskrnl!_KiSystemService+0xc4
b0.0000c8 82719620 Blocked ntoskrnl!_KiSystemService+0xc4
b0.0000d0 827d5d50 Blocked ntoskrnl!_KiSystemService+0xc4
.....
编辑
!stacks 是一个耗时的操作
速度与正在使用的传输有关
虚拟机到虚拟机有自己的开销
通过网络调试或与物理机的物理连接
pre win 10 上的 1394 比 115200 波特率的 com 端口或管道更快
我不确定你的虚拟机是什么,但如果你在 vbox 上,那么你可以试试 vmkd
以任何方式回答您的评论
你可以运行这个来记录和grep输出
.logopen z:\foo.txt ; !堆叠 0; .logclose
这将在您想要的路径中打开一个日志文件,并将所有输出重定向到日志文件,并在命令完成后关闭日志文件
还要记住 !stacks 接受通配符过滤字符串,这样只有带有您知道的符号的堆栈才能被过滤
喜欢
kd> .logopen c:\stacks.txt ; !stacks 0 Etw; .logclose
Opened log file 'c:\stacks.txt'
Proc.Thread .Thread Ticks ThreadState Blocker
Max cache size is : 1048576 bytes (0x400 KB)
Total memory in cache : 0 bytes (0 KB)
Number of regions cached: 0
0 full reads broken into 0 partial reads
counts: 0 cached/0 uncached, 0.00% cached
bytes : 0 cached/0 uncached, 0.00% cached
** Prototype PTEs are implicitly decoded
[82965600 Idle]
[840dcc40 System]
4.000078 8410ed48 0000081 Blocked nt!EtwpLogger+0xd0
4.000080 8410e4d8 0000081 Blocked nt!EtwpLogger+0xd0
4.000084 84142020 0000081 Blocked nt!EtwpLogger+0xd0
4.000088 84142d48 0000081 Blocked nt!EtwpLogger+0xd0
4.000090 8416c630 000001d Blocked nt!EtwpLogger+0xd0
4.000094 8496ea88 0000bf3 Blocked nt!EtwpLogger+0xd0
4.0000a0 84079a88 000004a Blocked nt!EtwpLogger+0xd0
4.000194 85144d48 000445c Blocked nt!EtwpLogger+0xd0
4.000308 851b9d48 0004035 Blocked nt!EtwpLogger+0xd0
4.00032c 851d3d48 0002d48 Blocked nt!EtwpLogger+0xd0
4.00034c 852e8d48 0003e4a Blocked nt!EtwpLogger+0xd0
4.000350 84973d48 0003df4 Blocked nt!EtwpLogger+0xd0
4.000354 84f0dd48 0003de4 Blocked nt!EtwpLogger+0xd0
4.000444 854c7970 0002158 Blocked nt!EtwpLogger+0xd0
[84f0b930 smss.exe]
[8409eb38 csrss.exe]
[84f34d40 wininit.exe]
[84f4d030 csrss.exe]
[850f8d40 winlogon.exe]
[8515bb38 services.exe]
[85161d40 lsass.exe]
[85163d40 lsm.exe]
因此,当 运行 陷入死锁、互斥、锁反转等情况时,OSX 上的 spindump
工具非常有用。它只是转储 所有 系统上的线程堆栈(用户空间和内核),并且可以清楚地看到哪些线程被阻塞了。
现在使用 Devstudio 在 2nd VM 上进行内核调试,我遇到了死锁。我看到我可以使用“!process 0 0”来转储所有进程。而且我相信我可以切换到一个进程,并转储线程(?),然后选择一个带有“!线程”和 "k" 的线程来查看堆栈。但是确实有数千个线程,肯定有一种方法可以在不手动执行的情况下将它们全部转储吗?
"!process 0 7" 运行了大约 40 分钟,none 的堆栈中有我的函数。
spindump 输出看起来像
Thread 0x8ab 1000 samples (1-1000) priority 81 (base 81)
*1000 call_continuation + 23 (kernel.development + 1927415)
*1000 arc_reclaim_thread + 2391 (arc.c:5095,11 in zfs + 131367)
*1000 cv_timedwait_hires + 206 (spl-condvar.c:172,14 in spl + 8125)
*1000 msleep + 98 (kernel.development + 7434066)
*1000 _sleep + 219 (kernel.development + 7432603)
*1000 lck_mtx_sleep_deadline + 147 (kernel.development + 2362339)
*1000 thread_block_reason + 286 (kernel.development + 2407438)
所以没什么神奇的,只是它遍历所有线程。
对 0,1,2 使用 !stacks
引用自 windbg chm 文件
The !stacks extension gives a brief summary of the state of every thread. You
can use this extension instead of the !process extension to get a quick overview
of the system, especially when debugging multithread issues such as resource
conflicts or deadlocks.
The !findstack user-mode extension also displays information about particular stacks.
Here is an example of the simplest !stacks display:
kd> !stacks 0
Proc.Thread .Thread ThreadState Blocker
[System]
4.000050 827eea10 Blocked +0xfe0343a5
[smss.exe]
[csrss.exe]
b0.0000a8 82723b70 Blocked ntoskrnl!_KiSystemService+0xc4
b0.0000c8 82719620 Blocked ntoskrnl!_KiSystemService+0xc4
b0.0000d0 827d5d50 Blocked ntoskrnl!_KiSystemService+0xc4
.....
编辑
!stacks 是一个耗时的操作
速度与正在使用的传输有关
虚拟机到虚拟机有自己的开销
通过网络调试或与物理机的物理连接
pre win 10 上的 1394 比 115200 波特率的 com 端口或管道更快
我不确定你的虚拟机是什么,但如果你在 vbox 上,那么你可以试试 vmkd
以任何方式回答您的评论
你可以运行这个来记录和grep输出
.logopen z:\foo.txt ; !堆叠 0; .logclose
这将在您想要的路径中打开一个日志文件,并将所有输出重定向到日志文件,并在命令完成后关闭日志文件
还要记住 !stacks 接受通配符过滤字符串,这样只有带有您知道的符号的堆栈才能被过滤
喜欢
kd> .logopen c:\stacks.txt ; !stacks 0 Etw; .logclose
Opened log file 'c:\stacks.txt'
Proc.Thread .Thread Ticks ThreadState Blocker
Max cache size is : 1048576 bytes (0x400 KB)
Total memory in cache : 0 bytes (0 KB)
Number of regions cached: 0
0 full reads broken into 0 partial reads
counts: 0 cached/0 uncached, 0.00% cached
bytes : 0 cached/0 uncached, 0.00% cached
** Prototype PTEs are implicitly decoded
[82965600 Idle]
[840dcc40 System]
4.000078 8410ed48 0000081 Blocked nt!EtwpLogger+0xd0
4.000080 8410e4d8 0000081 Blocked nt!EtwpLogger+0xd0
4.000084 84142020 0000081 Blocked nt!EtwpLogger+0xd0
4.000088 84142d48 0000081 Blocked nt!EtwpLogger+0xd0
4.000090 8416c630 000001d Blocked nt!EtwpLogger+0xd0
4.000094 8496ea88 0000bf3 Blocked nt!EtwpLogger+0xd0
4.0000a0 84079a88 000004a Blocked nt!EtwpLogger+0xd0
4.000194 85144d48 000445c Blocked nt!EtwpLogger+0xd0
4.000308 851b9d48 0004035 Blocked nt!EtwpLogger+0xd0
4.00032c 851d3d48 0002d48 Blocked nt!EtwpLogger+0xd0
4.00034c 852e8d48 0003e4a Blocked nt!EtwpLogger+0xd0
4.000350 84973d48 0003df4 Blocked nt!EtwpLogger+0xd0
4.000354 84f0dd48 0003de4 Blocked nt!EtwpLogger+0xd0
4.000444 854c7970 0002158 Blocked nt!EtwpLogger+0xd0
[84f0b930 smss.exe]
[8409eb38 csrss.exe]
[84f34d40 wininit.exe]
[84f4d030 csrss.exe]
[850f8d40 winlogon.exe]
[8515bb38 services.exe]
[85161d40 lsass.exe]
[85163d40 lsm.exe]