Setting Dynamic Breakpoints in WinDbg |
Q100642
The WinDbg breakpoint command contains a metacircular interpreter; that is,
you can execute commands dynamically once a breakpoint is hit. This allows
you to perform complex operations, including breaking when an automatic
variable has changed, as described below.
The command interpreter of WinDbg allows any valid C expression to serve as
a break condition. For example, to break whenever a static variable has
changed, use the following expression in the Expression field of the
breakpoint dialog box:
&<variablename>In addition, the length should be specified as 4 (the size of a DWORD) in the length field.
Suppose that the name of the function is "subroutine" and the local
variable name is "i". The following steps will be used:
g subroutine
p
bp500 ={subroutine}&i /r4 /C"?i"
The breakpoint number is chosen to be large so that the breakpoint
will be well out of range of other breakpoints. Note that /r4
indicates a length of 4 because i is an integer. Make this number
larger for other data types. The command "?i" prints out the value
of i.
bd500
because the address of i may change. The breakpoint will be enabled
when in the scope of function subroutine.
bp .<FirstLine> /C"be 500;g"
This is where thebreakpoint is enabled. Note that <FirstLine> is
the line number of the first statement in the function subroutine.
bp .<LastLine> /C"bd 500;g"
and will disable the breakpoint again. Note that <LastLine> is the
line number of the last statement in the function subroutine.
Additional query words: 3.10 3.50 4.00 95
Keywords :
Issue type :
Technology :
|
Last Reviewed: January 18, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |