BP [[address]] [[[[=expression[[/Rrange]]]] | [[?expression]]]] [[/Ppasscount]] [[/C"commands"]] [[/Mmsgname|msgclass[[/D]]]]
address
An expression giving the address at which to set the breakpoint. If omitted, sets a breakpoint on the current line, unless =expression is also specified.
=expression
Breaks program execution when the value of expression changes. If address is given, the expression is checked for changes only at that address. The expression is usually the name of a variable.
/Rrange
Watches all addresses in the given range for changes. The range is determined by multiplying range with the size of expression.
?expression
Breaks program execution when expression becomes true (nonzero). If address is given, the breakpoint expression is evaluated only at that address. You cannot specify both =expression and ?expression in the same breakpoint. Also, you cannot have more than one local context in expression. If the expression contains spaces, it must be enclosed in double quotation marks ("expression").
/Ppasscount
Specifies the first time the breakpoint is to be taken. For example, if passcount is 5, the breakpoint will be ignored the first four times it is encountered and taken the fifth time. From that point on, the breakpoint is always taken until the program is restarted.
/C"commands"
A list of command-window commands to be executed when the breakpoint is encountered. The commands must be enclosed in double quotation marks ("") and separated by semicolons (;).
/Mmsgname
(CVW only) Breaks program execution whenever the specified message is received. When /D is also specified, the message received is displayed, but the breakpoint is not taken.
/Mmsgclass
(CVW only) Breaks program execution whenever a message belonging to one of the specified classes is received. When /D is also specified, the message received is displayed but the breakpoint is not taken. Can be one or more of the following:
Message Class | Type of Windows Message |
m | Mouse |
w | Window management |
n | Input |
s | System |
i | Initialization |
c | Clipboard |
d | DDE |
z | Nonclient |
The Breakpoint Set (BP) command creates a breakpoint at a specified address. Whenever a breakpoint is encountered during program execution, the program halts and waits for a new command.
You can set breakpoints at source lines, functions, explicit addresses, or labels in any module of a program. If no arguments are given, BP sets a breakpoint at the current line.
Windows Breakpoints
In CodeView for Windows (CVW) use of the /M options requires that address be the name or address of a window function (“winproc”).
When the /D option is specified, CVW displays each message in the Command window as it is sent to the application's window function. The message is displayed in the following format:
HWND:wh wParm:wp lParm:lp msg:msgnum msgname
where wh is the window handle, wp is the message's word-sized parameter, lp is the message's long-sized parameter, msgnum is is the message number, and msgname is the name of the message. The following is a typical display:
HWND:lc00 wParm:0000 lParm:000000 msg:000F WM_PAINT
Windows breakpoints appear in the list of breakpoints and may be enabled, disabled, and cleared with the usual CodeView breakpoint commands.
Breakpoint Options
For any breakpoint, you can also specify:
A pass count to tell CodeView how many times to pass over the breakpoint.
Commands to be executed after the program reaches the breakpoint.
Breakpoints are numbered, beginning with the number 0. Each new breakpoint is assigned the next available number. Breakpoints remain in memory until you explicitly delete them. Breakpoints are saved in the CURRENT.STS file when you exit CodeView and are restored the next time you debug the program.
Types of Breakpoints
You can set breakpoints to break execution when any of the following conditions are true:
The program reaches a given source line, function, label, or address.
An expression becomes true (nonzero). The CodeView expression evaluator evaluates this type of expression based on the the currently visible function.
The value of an expression or memory range changes. CodeView references this type of expression by memory location. As a result, the original value of the expression is checked no matter which function is currently visible.
In addition to typing the BP command, you can also set a breakpoint with the following shortcuts:
From the Data menu, choose Set Breakpoint.
Double-click a source line.
Move the cursor to a source line, and press F9.
Command | Action |
BP @47 | Set a breakpoint at line 47 of the currently executing module. |
BP 0x23f0:3c84 | Set a breakpoint at address 23F0:3C84. |
BP =curr_sum | Halt execution whenever the value in curr_sum changes. |
BP =myint /R8 | Halt execution whenever a change occurs in the range of eight integers that begins at myint. If myint is a 2-byte value, the range is 16 bytes in size. |
BP @47 =int_array[0] /R20 | Set a breakpoint at line 47 of the currently executing module. The breakpoint will be taken at that line if any 20 elements of the array int_array changes. Since int_array is a 2-byte value, the range is 40 bytes in size. |
BP {,mymod}@47 ?myptr==0 | Set a breakpoint at line 47 of the module mymod. The breakpoint is taken only if myptr is zero. |
BP stats /P10 /C"?counter+=1" | Set a breakpoint at the address of the function stats but ignore the breakpoint the first nine times the function is executed. On the tenth and later call to stats, stop execution, and use the Display Expression (?) command to increment the value of counter. If counter is set to 0 when the breakpoint is set, counter can be used to count the number of times the breakpoint is taken. |