Tutorial :How do I determine which are the foreground .NET threads from WinDBG?



Question:

How do I determine which are the foreground .NET threads from WinDBG ? Using the !threads command the SOS extenstion tells us the count of the foreground threads but not which ones.


Solution:1

The state flag in the !threads output holds a lot of information. If the 0x00000200 flag is set the thread is a background thread.

In SOS for .NET 4 and PSSCOR2, there's a !threadstate command, that will list the texts for a given flag value. If you don't have that, there's an overview of the flags in the rotor source code and in Debugging .NET 2.0 applications by John Robbins.


Solution:2

You can use the thread state values given in this link and find out if a thread is a background thread or not.

TS_Background 0x00000200 Thread is a background thread


Solution:3

Netext's command !wthreads shows type and status information:

0:011> !wthreads     Id OSId Address  Domain   Alloc Start:End   COM  GC Type  Locks Type / Status             Last Exception      1 1854 0074f580 00748cd0 02c19308:02c1b2e8 STA  Preemptive   0                                2 1890 0075ab18 00748cd0 00000000:00000000 MTA  Preemptive   0 Background|Finalizer           3 1bac 080ecb98 00748cd0 00000000:00000000 MTA  Preemptive   0 Background|Worker              4 ---- 08106068 00748cd0 00000000:00000000 MTA  Preemptive   0 Worker|Terminated              5 ---- 0810e988 00748cd0 00000000:00000000 MTA  Preemptive   0 Worker|Terminated              6 ---- 080eb1d0 00748cd0 00000000:00000000 MTA  Preemptive   0 Worker|Terminated              7 081c 080fcb48 00748cd0 00000000:00000000 MTA  Preemptive   0 Background|IOCPort  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »