PRB: Debugger/CodeView Appear Not to Break on Correct Line

ID: Q111501

4.00 4.01 4.10 | 1.00 1.50 1.51 1.52 4.00 4.01 4.10

MS-DOS         | WINDOWS
kbtool kbprb

The information in this article applies to:

SYMPTOMS

When setting a breakpoint (using the "Break When Expression Has Changed" option) where a variable in the expression is modified by the increment (++) or decrement (--) operator, CodeView and the Visual Workbench debugger may not appear to stop on the correct source line.

CAUSE

The debugger will stop after the assembly language instruction that first modifies the variable. In a situation where multiple assembly language instructions are necessary to implement the C language source line, the debugger will stop on that source line, because the line has not executed to completion.

MORE INFORMATION

This is the expected behavior for the 16-bit debuggers. Using Mixed Source/Assembly mode will reveal the fact that the C language statements x++ and x-- each require two assembly language statements. CodeView and the Visual Workbench debugger both step, and therefore break at the assembly language level and stop after the first assembly statement involved in the increment of the variable x.

NOTE: This does not occur with the 32-bit debugger.

The sample program below demonstrates the situation. When "Break When Expression Has Changed" is set on the variable x, the debugger will stop on the statement x++ instead of the following line. This is because the variable x is a long, and the C language statement x++ needs two assembly statements to be implemented.

To reproduce this problem using CodeView for Windows or the Visual Workbench debugger, this sample should be compiled and linked as a QuickWin application.

Sample Code

/* Compile options needed: /Od /Zi
** ** The CodeView command window command to set a ** breakpoint when the variable x has changed is: ** ** bp=x
*/ 

long x;

void main()
{
   x++;
}

Additional reference words: 1.00 1.50 4.00 4.10 KBCategory: kbtool kbprb KBSubcategory: WBDebug CvwIss Keywords : kb16bitonly

Last Reviewed: July 23, 1997