Debugging Tools for Windows |
!cs 扩展显示一个或多个临界区(critical section)或者整个临界区树。
!cs [-s] [-o] [Address]
!cs [-s] [-l] [-o] StartAddress EndAddress
!cs [-s] [-o] -d InfoAddress
!cs [-s] -t [TreeAddress]
!cs -?
Windows 2000 | 不可用 |
Windows XP 和之后 | Exts.dll |
!cs 扩展要求被调试进程和Ntdll.dll的完整符号(包含类型信息)。如果没有Ntdll.dll的符号,查看安装Windows符号文件。
下面是如何使用!cs的示例。这条命令显示0x7803B0F8地址处的临界区的信息和初始调用堆栈。
Critical section = 0x7803B0F8 (MSVCRT!__app_type+0x4)
DebugInfo = 0x6A262080
NOT LOCKED
LockSemaphore = 0x0
SpinCount = 0x0
Stack trace for DebugInfo = 0x6A262080:
0x6A2137BD: ntdll!RtlInitializeCriticalSectionAndSpinCount+0x9B
0x6A207A4C: ntdll!LdrpCallInitRoutine+0x14
0x6A205569: ntdll!LdrpRunInitializeRoutines+0x1D9
0x6A20DCE1: ntdll!LdrpInitializeProcess+0xAE5
下面的命令显示DebugInfo在0x7803B0F8处的临界区信息。
DebugInfo = 0x6A262080
Critical section = 0x7803B0F8 (MSVCRT!__app_type+0x4)
NOT LOCKED
LockSemaphore = 0x0
SpinCount = 0x0
下面的信息显示当前进程中的所有活动临界区的信息。
-----------------------------------------
DebugInfo = 0x6A261D60
Critical section = 0x6A262820 (ntdll!RtlCriticalSectionLock+0x0)
LOCKED
LockCount = 0x0
OwningThread = 0x460
RecursionCount = 0x1
LockSemaphore = 0x0
SpinCount = 0x0
-----------------------------------------
DebugInfo = 0x6A261D80
Critical section = 0x6A262580 (ntdll!DeferedCriticalSection+0x0)
NOT LOCKED
LockSemaphore = 0x7FC
SpinCount = 0x0
-----------------------------------------
DebugInfo = 0x6A262600
Critical section = 0x6A26074C (ntdll!LoaderLock+0x0)
NOT LOCKED
LockSemaphore = 0x0
SpinCount = 0x0
-----------------------------------------
DebugInfo = 0x77fbde20
Critical section = 0x77c8ba60 (GDI32!semColorSpaceCache+0x0)
LOCKED
LockCount = 0x0
OwningThread = 0x00000dd8
RecursionCount = 0x1
LockSemaphore = 0x0
SpinCount = 0x00000000
-----------------------------------------
...
下面的命令显示临界区树。
Tree root 00bb08c0
Level Node CS Debug InitThr EnterThr WaitThr TryEnThr LeaveThr EnterCnt WaitCnt
-----------------------------------------------------------------------------------------------
0 00bb08c0 77c7e020 77fbcae0 4c8 4c8 0 0 4c8 c 0
1 00dd6fd0 0148cfe8 01683fe0 4c8 4c8 0 0 4c8 2 0
2 00bb0aa0 008e8b84 77fbcc20 4c8 0 0 0 0 0 0
3 00bb09e0 008e8704 77fbcba0 4c8 0 0 0 0 0 0
4 00bb0a40 008e8944 77fbcbe0 4c8 0 0 0 0 0 0
5 00bb0a10 008e8824 77fbcbc0 4c8 0 0 0 0 0 0
5 00bb0a70 008e8a64 77fbcc00 4c8 0 0 0 0 0 0
3 00bb0b00 008e8dc4 77fbcc60 4c8 0 0 0 0 0 0
4 00bb0ad0 008e8ca4 77fbcc40 4c8 0 0 0 0 0 0
4 00bb0b30 008e8ee4 77fbcc80 4c8 0 0 0 0 0 0
5 00dd4fd0 0148afe4 0167ffe0 4c8 0 0 0 0 0 0
2 00bb0e90 77c2da98 00908fe0 4c8 4c8 0 0 4c8 3a 0
3 00bb0d70 77c2da08 008fcfe0 4c8 0 0 0 0 0 0
!cs -t 的显示中有如下内容:
关于其他可以显示临界区信息的命令和扩展,查看显示临界区。关于临界区的更多信息,查看Microsoft Windows SDK文档、Windows Driver Kit (WDK)文档、以及Mark Russinovich 和David Solomon 编写的Microsoft Windows Internals。