본문 바로가기
디버그

[windbg] sx -

by WeZZ 2009. 9. 23.
sx, sxd, sxe, sxi, sxn, sxr, sx- (Set Exceptions)

이벤트 브레이크 포인트 설정 명령어다.

0:001> sx
  ct - Create thread - ignore
  et - Exit thread - ignore
 cpr - Create process - ignore
 epr - Exit process - break
  ld - Load module - output
  ud - Unload module - output
 ser - System error - ignore
 ibp - Initial breakpoint - break
 iml - Initial module load - ignore
 out - Debuggee output - output

  av - Access violation - break - not handled
asrt - Assertion failure - break - not handled
 aph - Application hang - break - not handled
 bpe - Break instruction exception - break
bpec - Break instruction exception continue - handled
  eh - C++ EH exception - second-chance break - not handled
 clr - CLR exception - second-chance break - not handled
clrn - CLR notification exception - second-chance break - handled
 cce - Control-Break exception - break
  cc - Control-Break exception continue - handled
 cce - Control-C exception - break
  cc - Control-C exception continue - handled
  dm - Data misaligned - break - not handled
dbce - Debugger command exception - ignore - handled
  gp - Guard page violation - break - not handled
  ii - Illegal instruction - second-chance break - not handled
  ip - In-page I/O error - break - not handled
  dz - Integer divide-by-zero - break - not handled
 iov - Integer overflow - break - not handled
  ch - Invalid handle - break
  hc - Invalid handle continue - not handled
 lsq - Invalid lock sequence - break - not handled
 isc - Invalid system call - break - not handled
  3c - Port disconnected - second-chance break - not handled
 svh - Service hang - break - not handled
 sse - Single step exception - break
ssec - Single step exception continue - handled
 sbo - Stack buffer overflow - break - not handled
 sov - Stack overflow - break - not handled
  vs - Verifier stop - break - not handled
vcpp - Visual C++ exception - ignore - handled
 wkd - Wake debugger - break - not handled
 wob - WOW64 breakpoint - break - handled
 wos - WOW64 single step exception - break - handled

해당 이벤트에 대해 예외 , 디버그 출력 , 브레이크등을 임의로 설정할 수 있다.

sx, sxd, sxe, sxi, sxn, sxr, sx- (Set Exceptions)

The sx* commands control the action that the debugger takes when an exception occurs in the application that is being debugged, or when certain events occur.

Syntax

sx 

sx{e|d|i|n} [-c "Cmd1"] [-c2 "Cmd2"] [-h] {Exception|Event|*

sx- [-c "Cmd1"] [-c2 "Cmd2"] {Exception|Event|*

sxr

Parameters

-c "Cmd1"
Specifies a command that is executed if the exception or event occurs. This command is executed when the first chance to handle this exception occurs, regardless of whether this exception breaks into the debugger. You must enclose the Cmd1 string in quotation marks. This string can include multiple commands, separated by semicolons. The space between the -c and the quoted command string is optional.
-c2 "Cmd2"
Specifies a command that is executed if the exception or event occurs and is not handled on the first chance. This command is executed when the second chance to handle this exception occurs, regardless of whether this exception breaks into the debugger. You must enclose the Cmd2 string in quotation marks. This string can include multiple commands, separated by semicolons. The space between the -c2 and the quoted command string is optional.
-h
Changes the specified event's handling status instead of its break status. If Event is cc, hc, bpec, or ssec, you do not have to use the -h option.
Exception
Specifies the exception number that the command acts on, in the current radix.
Event
Specifies the event that the command acts on. These events are identified by short abbreviations. For a list of the events, see Controlling Exceptions and Events.
*
Affects all exceptions that are not otherwise explicitly named for sx. For a list of explicitly named exceptions, see Controlling Exceptions and Events.

Environment

Modes User mode, kernel mode
Targets Live debugging only
Platforms All

Comments

The sx command displays the list of exceptions for the current process and the list of all nonexception events and displays the default behavior of the debugger for each exception and event.

The sxe, sxd, sxn, and sxi commands control the debugger settings for each exception and event.

The sxr command resets all of the exception and event filter states to the default settings. Commands are cleared, break and continue options are reset to their default settings, and so on.

The sx- command does not change the handling status or the break status of the specified exception or event. This command can be used if you wish to change the first-chance command or second-chance command associated with a specific event, but do not wish to change anything else.

If you include the -h option (or if the cc, hc, bpec, or ssec events are specified), the sxe, sxd, sxn, and sxi commands control the handling status of the exception or event. In all other cases, these commands control the break status of the exception or event.

When you are setting the break status, these commands have the following effects.

Command Status name Description
sxe Break

(Enabled)

When this exception occurs, the target immediately breaks into the debugger before any other error handlers are activated. This kind of handling is called first chance handling.
sxd Second chance break

(Disabled)

The debugger does not break for a first-chance exception of this type (although a message is displayed). If other error handlers do not address this exception, execution stops and the target breaks into the debugger. This kind of handling is called second chance handling.
sxn Output

(Notify)

When this exception occurs, the target application does not break into the debugger at all. However, a message is displayed that notifies the user of this exception.
sxi Ignore When this exception occurs, the target application does not break into the debugger at all, and no message is displayed.

When you are setting the handling status, these commands have the following effects:

Command Status name Description
sxe Handled The event is considered handled when execution resumes.
sxd,
sxn,
sxi
Not Handled The event is considered not handled when execution resumes.

You can use the -h option together with exceptions, not events. Using this option with ch, bpe, or sse sets the handling status for hc, bpec, or ssec, respectively. If you use the -h option with any other event, it has no effect.

Using the -c or -c2 options with hc, bpec, or ssec associates the specified commands with ch, bpe, or sse, respectively.

In the following example, the sxe command is used to set the break status of access violation events to break on the first chance, and to set the first-chance command that will be executed at that point to r eax. Then the sx- command is used to alter the first-chance command to r ebx, without changing the handling status. Finally, a portion of the sx output is shown, indicating the current settings for access violation events:

0:000> sxe -c "r eax" av 

0:000> sx- -c "r ebx" av 

0:000> sx 
  av - Access violation - break - not handled
       Command: "r ebx"
  . . .  

Additional Information

For more information about break status and handling status, descriptions of all event codes, a list of the default status for all events, and other methods of controlling this status, see Controlling Exceptions and Events.