Issue
I am using the Eclipse IDE to develop C++ code for an ARM (STM32) processor. One of the options the debugger/Eclipse has is to set not only a breakpoint, but a condition at which to break. For example, "break at line 5 only if foo is 10."
However, when debugging in this way, I came across a problem where memory was changing unexpectedly. Why is this happening?
Solution
The "condition" field for a breakpoint allows you to write a C/C++ statement which will be evaluated to determine if the processor should be paused.
The fact that this can be ANY valid C/C++ statement can have some interesting (i.e., problematic) side-effects if you are not careful.
For example, consider the following code:
1: void foo(int a) {
2: int b = a + 2;
3: }
If you want to break at line (2) only if a
is equal to 10, make sure the condition is
a == 10
If you write
a = 10
for the condition, the debugger will break at line (2) and set the value of a to 10
Answered By - Patrick Wright
Answer Checked By - Terry (JavaFixing Volunteer)