From ba57369fcaaff18ec87a939476bf98a8aee72c33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Feb 2026 22:20:57 +0000 Subject: [PATCH 1/3] Initial plan From 1fcc689640d22aa9bec0acda97a5975d46e599a6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Feb 2026 22:24:04 +0000 Subject: [PATCH 2/3] Fix ThreadState example formatting by moving it out of table Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com> --- .../tools/sos-dll-sos-debugging-extension.md | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/framework/tools/sos-dll-sos-debugging-extension.md b/docs/framework/tools/sos-dll-sos-debugging-extension.md index 71fc3b9ba7de3..a0d071254a09d 100644 --- a/docs/framework/tools/sos-dll-sos-debugging-extension.md +++ b/docs/framework/tools/sos-dll-sos-debugging-extension.md @@ -83,7 +83,7 @@ The SOS debugging extension (SOS.dll) helps you debug managed programs in Visual |**ThreadPool**|Displays information about the managed thread pool, including the number of work requests in the queue, the number of completion port threads, and the number of timers.| |**Token2EE** \<*module name*> \<*token*>|Turns the specified metadata token in the specified module into a `MethodTable` structure or `MethodDesc` structure.

You can pass `*` for the module name parameter to find what that token maps to in every loaded managed module. You can also pass the debugger's name for a module, such as `mscorlib` or `image00400000`.| |**Threads** [**-live**] [**-special**]|Displays all managed threads in the process.

The **Threads** command displays the debugger shorthand ID, the CLR thread ID, and the operating system thread ID. Additionally, the **Threads** command displays a Domain column that indicates the application domain in which a thread is executing, an APT column that displays the COM apartment mode, and an Exception column that displays the last exception thrown in the thread.

The **-live** option displays threads associated with a live thread.

The **-special** option displays all special threads created by the CLR. Special threads include garbage collection threads (in concurrent and server garbage collection), debugger helper threads, finalizer threads, unload threads, and thread pool timer threads.| -|**ThreadState \<** *State value field* **>**|Displays the state of the thread. The `value` parameter is the value of the `State` field in the **Threads** report output.

Example:

`0:003> !Threads ThreadCount: 2 UnstartedThread: 0 BackgroundThread: 1 PendingThread: 0 DeadThread: 0 Hosted Runtime: no PreEmptive GC Alloc Lock ID OSID ThreadOBJ State GC Context Domain Count APT Exception 0 1 250 0019b068 a020 Disabled 02349668:02349fe8 0015def0 0 MTA 2 2 944 001a6020 b220 Enabled 00000000:00000000 0015def0 0 MTA (Finalizer) 0:003> !ThreadState b220 Legal to Join Background CLR Owns CoInitialized In Multi Threaded Apartment`| +|**ThreadState \<** *State value field* **>**|Displays the state of the thread. The `value` parameter is the value of the `State` field in the **Threads** report output. See the [ThreadState example](#threadstate-example) for usage.| |**TraverseHeap** [**-xml**] \<*filename*>|Writes heap information to the specified file in a format understood by the CLR profiler. The **-xml** option causes the **TraverseHeap** command to format the file as XML.| |**U** [**-gcinfo**] [**-ehinfo**] [**-n**] \<*MethodDesc address*> | \<*Code address*>|Displays an annotated disassembly of a managed method specified either by a `MethodDesc` structure pointer for the method or by a code address within the method body. The **U** command displays the entire method from start to finish, with annotations that convert metadata tokens to names.

The **-gcinfo** option causes the **U** command to display the `GCInfo` structure for the method.

The **-ehinfo** option displays exception information for the method. You can also obtain this information with the **EHInfo** command.

The **-n** option disables the display of source file names and line numbers. If the debugger has the option SYMOPT_LOAD_LINES specified, SOS looks up the symbols for every managed frame and, if successful, displays the corresponding source file name and line number. You can specify the **-n** option to disable this behavior.| |**VerifyHeap**|Checks the garbage collector heap for signs of corruption and displays any errors found.

Heap corruptions can be caused by platform invoke calls that are constructed incorrectly.| @@ -201,6 +201,37 @@ The following command displays information about the metadata token at the addre !token2ee unittest.exe 02000003 ``` +### ThreadState example + +The following example demonstrates using the **ThreadState** command to decode thread state values from the **Threads** command output. + +First, display all threads to get state values: + +```console +0:003> !Threads +ThreadCount: 2 +UnstartedThread: 0 +BackgroundThread: 1 +PendingThread: 0 +DeadThread: 0 +Hosted Runtime: no + PreEmptive GC Alloc Lock + ID OSID ThreadOBJ State GC Context Domain Count APT Exception + 0 1 250 0019b068 a020 Disabled 02349668:02349fe8 0015def0 0 MTA + 2 2 944 001a6020 b220 Enabled 00000000:00000000 0015def0 0 MTA (Finalizer) +``` + +Then decode a specific state value (for example, `b220`): + +```console +0:003> !ThreadState b220 + Legal to Join + Background + CLR Owns + CoInitialized + In Multi Threaded Apartment +``` + ## See also - [Tools](index.md) From f11f4b05ee0d91c6017feefdfb679b4ca4a68d33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Feb 2026 22:37:55 +0000 Subject: [PATCH 3/3] Keep ThreadState example in table with improved HTML formatting Co-authored-by: meaghanlewis <10103121+meaghanlewis@users.noreply.github.com> --- .../tools/sos-dll-sos-debugging-extension.md | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/docs/framework/tools/sos-dll-sos-debugging-extension.md b/docs/framework/tools/sos-dll-sos-debugging-extension.md index a0d071254a09d..0fea35249e8ee 100644 --- a/docs/framework/tools/sos-dll-sos-debugging-extension.md +++ b/docs/framework/tools/sos-dll-sos-debugging-extension.md @@ -83,7 +83,7 @@ The SOS debugging extension (SOS.dll) helps you debug managed programs in Visual |**ThreadPool**|Displays information about the managed thread pool, including the number of work requests in the queue, the number of completion port threads, and the number of timers.| |**Token2EE** \<*module name*> \<*token*>|Turns the specified metadata token in the specified module into a `MethodTable` structure or `MethodDesc` structure.

You can pass `*` for the module name parameter to find what that token maps to in every loaded managed module. You can also pass the debugger's name for a module, such as `mscorlib` or `image00400000`.| |**Threads** [**-live**] [**-special**]|Displays all managed threads in the process.

The **Threads** command displays the debugger shorthand ID, the CLR thread ID, and the operating system thread ID. Additionally, the **Threads** command displays a Domain column that indicates the application domain in which a thread is executing, an APT column that displays the COM apartment mode, and an Exception column that displays the last exception thrown in the thread.

The **-live** option displays threads associated with a live thread.

The **-special** option displays all special threads created by the CLR. Special threads include garbage collection threads (in concurrent and server garbage collection), debugger helper threads, finalizer threads, unload threads, and thread pool timer threads.| -|**ThreadState \<** *State value field* **>**|Displays the state of the thread. The `value` parameter is the value of the `State` field in the **Threads** report output. See the [ThreadState example](#threadstate-example) for usage.| +|**ThreadState \<** *State value field* **>**|Displays the state of the thread. The `value` parameter is the value of the `State` field in the **Threads** report output.

Example:

0:003> !Threads
ThreadCount: 2
UnstartedThread: 0
BackgroundThread: 1
PendingThread: 0
DeadThread: 0
Hosted Runtime: no
PreEmptive GC Alloc Lock
ID OSID ThreadOBJ State GC Context Domain Count APT Exception
0 1 250 0019b068 a020 Disabled 02349668:02349fe8 0015def0 0 MTA
2 2 944 001a6020 b220 Enabled 00000000:00000000 0015def0 0 MTA (Finalizer)

0:003> !ThreadState b220
Legal to Join
Background
CLR Owns
CoInitialized
In Multi Threaded Apartment
| |**TraverseHeap** [**-xml**] \<*filename*>|Writes heap information to the specified file in a format understood by the CLR profiler. The **-xml** option causes the **TraverseHeap** command to format the file as XML.| |**U** [**-gcinfo**] [**-ehinfo**] [**-n**] \<*MethodDesc address*> | \<*Code address*>|Displays an annotated disassembly of a managed method specified either by a `MethodDesc` structure pointer for the method or by a code address within the method body. The **U** command displays the entire method from start to finish, with annotations that convert metadata tokens to names.

The **-gcinfo** option causes the **U** command to display the `GCInfo` structure for the method.

The **-ehinfo** option displays exception information for the method. You can also obtain this information with the **EHInfo** command.

The **-n** option disables the display of source file names and line numbers. If the debugger has the option SYMOPT_LOAD_LINES specified, SOS looks up the symbols for every managed frame and, if successful, displays the corresponding source file name and line number. You can specify the **-n** option to disable this behavior.| |**VerifyHeap**|Checks the garbage collector heap for signs of corruption and displays any errors found.

Heap corruptions can be caused by platform invoke calls that are constructed incorrectly.| @@ -201,37 +201,6 @@ The following command displays information about the metadata token at the addre !token2ee unittest.exe 02000003 ``` -### ThreadState example - -The following example demonstrates using the **ThreadState** command to decode thread state values from the **Threads** command output. - -First, display all threads to get state values: - -```console -0:003> !Threads -ThreadCount: 2 -UnstartedThread: 0 -BackgroundThread: 1 -PendingThread: 0 -DeadThread: 0 -Hosted Runtime: no - PreEmptive GC Alloc Lock - ID OSID ThreadOBJ State GC Context Domain Count APT Exception - 0 1 250 0019b068 a020 Disabled 02349668:02349fe8 0015def0 0 MTA - 2 2 944 001a6020 b220 Enabled 00000000:00000000 0015def0 0 MTA (Finalizer) -``` - -Then decode a specific state value (for example, `b220`): - -```console -0:003> !ThreadState b220 - Legal to Join - Background - CLR Owns - CoInitialized - In Multi Threaded Apartment -``` - ## See also - [Tools](index.md)