首页 > 解决方案 > 使用windbg时如何设置当前线程

问题描述

使用 windbag 分析崩溃转储。需要将代码设置为转到当前线程。我尝试做 ~thread 5a0.b44 但这没有用。它给了我一个错误“'~thread 5a0.b44'中没有可运行的调试错误n。我需要设置转储来调试特定线程。我该怎么做?

标签: multithreadingwindbgdump

解决方案


您可以仅列出所有线程~。它将显示逻辑线程 ID 和操作系统线程 ID。

您可以使用 (s for select) 按逻辑编号选择线程,~<number>s使用 . 按操作系统线程 ID 选择线程~~[<number>]s

0:000> ~
.  0  Id: 1ee0.2270 Suspend: 1 Teb: 0000008c`1373b000 Unfrozen
   1  Id: 1ee0.2b18 Suspend: 1 Teb: 0000008c`1373d000 Unfrozen
   2  Id: 1ee0.1d44 Suspend: 1 Teb: 0000008c`1373f000 Unfrozen
   3  Id: 1ee0.1a1c Suspend: 1 Teb: 0000008c`13741000 Unfrozen
0:000> ~1s
ntdll!NtWaitForWorkViaWorkerFactory+0x14:
00007fff`32522fe4 c3              ret
0:001> ~~[1d44]s
ntdll!NtWaitForWorkViaWorkerFactory+0x14:
00007fff`32522fe4 c3              ret
0:002> *** on thread 2 now

您不能将进程 ID 与线程 ID 一起使用:

0:002> ~~[1ee0.1a1c]s
Syntax error at '1ee0.1a1c]s'
0:002> ~~[1ee01a1c]s
                  ^ Illegal thread error in '~~[1ee01a1c]s

如果您需要切换进程,请使用|<number>sor |~[<number>]s

0:003> |
.  0    id: 1ee0    examine name: C:\Windows\System32\ApproveChildRequest.exe
#  1    id: 1e9c    attach  name: C:\Program Files\paint.net\PaintDotNet.exe
0:003> |~[1e9c]s
ntdll!DbgBreakPoint:
00007fff`32523060 cc              int     3
1:026> *** on process 1 now

推荐阅读