MindStudio IDE Cannot Properly Use the C&C++ Project Debugging Function

Symptom

After you open a C&C++ project in MindStudio IDE for debugging, the program breakpoints do not work properly, and the code is not executed according to the code logic.

Fault Analysis

The compilation optimization option -O2 has been set for the C&C++ project. This option optimizes the program code during compilation. If the compiled program does not match the actual source code, it will cause issues with breakpoint generation during debugging, resulting in the code not executing according to its intended logic.

Solution

During debugging, change the compilation optimization option -O2 in the cmakelist file to -O0 or directly delete it.