WinDbg中StopOnException命令的伪寄存器编号参数作用是什么?
!soe Command Great question about that often-overlooked parameter in the !soe (StopOnException) command! Let me break down exactly what it does:
- Core Purpose: The
<pseudo-register number for result>tells WinDbg to store the memory address of the caught exception object into a specific pseudo-register when the debugger pauses on the specified exception. This lets you quickly reference the exception for further debugging without having to hunt down its address manually.
WinDbg uses pseudo-registers named $r0 through $r15 (the number you pass maps directly to the suffix here). For example, in the sample command:
!soe -create System.OutOfMemoryException 1
When a System.OutOfMemoryException is thrown and the debugger stops, the address of that exception object will be saved to $r1.
Practical Use Case
Right after the debugger pauses, you can use the pseudo-register to inspect the exception details immediately. For example:
!dumpobj $r1
This command will dump all the properties, inner exceptions, and other metadata of the OutOfMemoryException object stored in $r1—saving you the step of locating the exception address via stack frames or other commands.
If you omit this parameter, the debugger will still pause on the exception, but you'll have to manually retrieve the exception address through other means (like examining the current stack frame's exception pointer), which is less efficient.
内容的提问来源于stack exchange,提问作者StayOnTarget

