2023-05-16 12:18 AM
I am compiling for the STM32C031C6 (development board)
I have optimization set to -Os because otherwise we are not going to fit a simple stack.
In normal compilation mode everything is working as expected. (except for a bug I am chasing now)
So I have 2 pieces of code in the same statemachine:
...
test_fsm = TEST_TX_1B;
return;
...
test_fsm = TEST_TX_1B;
break;
...
Both will result in leaving the calling function so I understand that the compiler has optimized those to the same assembly code.
Now comes the problem:
When I set a breakpoint to one of the two, the code breaks on the other (which is a very common occurrence).
This should not happen and in this case the compiler should have duplicated the code because of the breakpoint.
Please fix this since it costs a lot of time to chase these kind of ghost problems.
thank you
2023-05-18 08:14 PM
Make sure your project is with compiler optimization zero or minimal. If this fixes it, compare assembly with both cases to confirm the compiler has optimised the code so much that no all C code can have a breakpoint. This applies to any compiler from any vendor, mcu, mpu, cpu.
2023-05-18 11:16 PM
This is NOT a compiler error. The compiler doesn't know anything about your breakpoins. To get simple and precise debugging, turn off the optimization.