Developer2015
Developer2015

Reputation: 61

How do you set the current thread when using windbg

Analyzing a crash dump using windbag. Need to set the code to go to a current thread. I tried doing ~thread 5a0.b44 but that did not work. It gives me an error "No runnable debuggees error n in '~thread 5a0.b44'. I need to setup the dump to debug a particular thread. how do i do this?

Upvotes: 3

Views: 7813

Answers (1)

Thomas Weller
Thomas Weller

Reputation: 59304

You can list all threads by just ~. It will show logical thread IDs and OS thread IDs.

You can select a thread by its logical number using ~<number>s (s for select) and by its OS thread ID using ~~[<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

You can't use the process ID together with the thread ID:

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

If you need to switch the process, use |<number>s or |~[<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

Upvotes: 10

Related Questions