The information in this article applies to:
- The Visual Workbench Integrated Debugger, included with:
- Microsoft Visual C++ for Windows, version 1.0, 1.5, 1.51, 1.52
- Microsoft Visual C++ 32-bit Edition, version 1.0, 2.0, 2.1, 4.0, 5.0
SYMPTOMS
In the Visual Workbench debugger, an attempt to set conditional breakpoints
may fail. A message box may appear containing a message such as
The breakpoint <breakpoint_name> cannot be set.
Or, as with the Developer Studio debugger included with Visual C++ 4.0 and
later, the conditional breakpoint may appear to be set, but when the debug
session is initiated, a message box may appear containing the following
text:
One or more of the breakpoints cannot be set and have been
disabled. Execution will stop at the beginning of the program.
CAUSE
This problem occurs only when you attempt to set the breakpoint while the
specified variable is out of scope.
RESOLUTION
There are two methods to address this situation:
- Trace into the program until the variable is in scope, then set
the breakpoint.
- Specify the context of the variable when you set the breakpoint.
For example, specify a breakpoint on "{main}a" instead of on "a"
(in both cases without quotation marks).
MORE INFORMATION
Perform the following six steps to demonstrate this error with Visual C++
versions 2.x and earlier:
- Create a new application to contain the code example below.
- From the Project menu, choose Options. In the Program Type list
box, choose QuickWin EXE and choose OK.
- Choose Build from the Project menu to build the sample program.
- Choose Breakpoints from the Debug menu; a dialog box appears.
- Set the Break field to "If Expr is True" and type "a" (without
quotation marks) in the Expression edit control. Because the
default length is 1 as is the size of "a," choose the Add button,
then choose OK.
- Press F5 to run the program.
Perform the following six steps to demonstrate this error with the
Developer Studio:
- Create a new console application project.
- Save the code example below as t.c and add it to the project.
- Choose Build t.exe from the Build menu.
- Choose Breakpoints... from the Edit menu. The Breakpoints dialog box
appears.
- In the Location Tab, type "main" (without the quotation marks) in the
Break at field. Press the Condition button to display the Breakpoint
Condition dialog box. Type "a" (without the quotation marks) in the
Break when expression changes field. Press OK to close the Breakpoint
Condition dialog box. Press OK to close the Breakpoints dialog box.
- Press F5 to run the program.
At this point, a message box appears with the error message listed in the
SYMPTOMS section above and the breakpoint is not set. When you choose OK in
the error message box, programs debugged with Visual C++ versions 2.x and
earlier run to completion because no breakpoints are set; programs debugged
with Developer Studio halt at the beginning of the program (as if a
breakpoint were set) and may be stepped through if desired.
If you are setting a breakpoint from within a C++ member function, you need
to specify '{ClassName::Member}' in order to set the breakpoint properly.
Sample Code
/*
* Compile options needed: none
*/
void main(void)
{
char a;
a = 'a';
}
NOTE: The breakpoint evaluator doesn't take into account the preprocessor's
#define statements.
Keywords : WBDebug
Version : 1.0 1.5 1.51 1.52 2.0 2.1 4.0 5.0
Platform : NT WINDOWS
Issue type : kbprb
|