3 weeks, 5 days ago.

Is it a bug of Mbed Studio when debuging?

/media/uploads/wanggaoteng/mbedstudio_debug.gif Hi, there is a strange thing when debuging using mbed studio (0.6.1). As the .gif illustrated, the code "printf("debug test.\n");" is executed before the code "++count;" when debuging. Why does this happen?

Comment on this question

1 Answer

3 weeks, 4 days ago.

Hello Wang,

This strange "phenomenon" (statements are not executed in the same sequence as specified in the C++/C source code) is usually caused by optimization performed by the compiler when building the binary code. It isn't specific only for the Mbed Studio. One can observe it also when building/debugging with the GCC Arm compiler. To avoid it turn off any optimization when building a project for debugging.

Hi, Zoltan, Thank you very much for telling me the reasons and the skills. Best regards.

posted by wang gaoteng 23 Sep 2019

Thanks for answering this Zoltan!

posted by Joe Alderson 23 Sep 2019

Hi, Joe, As the picture shows, there is another problem. When clicking the "Step Over"button, then the "CALL STACK" area and the "VARIABLES" area disappeared. I think this is an abnormal phenomenon. @Joe Alderson

posted by wang gaoteng 24 Sep 2019