Debugging ¶
Once the project is built without errors, use the debeug icon to launch the program code into the part together with the debugger. The first time a debug session is launched, STM32CubeIDE builds the project and then shows the debug launch configuration menu. This gives the user the opportunity to verify settings and make changes if desired.
Important: If the Serial Wire Viewer (SWV) is to be used during debugging, this must be explicitly enabled in the dialogue box:
Click on the [Debugger] tab to reach the SWV settings and enable SWV (SWV is not enabled by default).
If changes are made to the default settings in the launch configuration properties dialog box, they must be saved by clicking on the [Apply] button.
When ready to launch the debug session, click on [OK]. Several things happen “under the hood” including the launch of the debugger driver and GDB server, as well as the programming of the application into the part, and any other actions called for in the startup script. At this point, the application is normally halted at the first line of main().
The main control icons of the debugger are as follows:
Resume full speed execution of the application on the target (greyed out when running).
Halt execution (greyed out when halted).
Step into a function, over a function, or out of a function.
Toggle between C and instruction stepping.
Reset the chip and restart execution.
Terminate the debug session.
Terminate and relaunch the debug session.
Basic debugging techniques
To set a breakpoint, click on the blue horizontal bar next to the statement line number.
To view memory locations, use the Variables (variables in focus or global variables), Memory, or Expressions window.
Configuring and using debugging tools, especially with SWV, is frequently more complicated than using the IDE for C/C++ code development. More details on this topic are provided by associated documents available on the STM32CubeIDE web page, which must be consulted for anything beyond the most basic operations.