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:

  1. Click on the [Debugger] tab to reach the SWV settings and enable SWV (SWV is not enabled by default).

  2. 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:

../../../_images/image029.gif

Resume full speed execution of the application on the target (greyed out when running).

../../../_images/image030.gif

Halt execution (greyed out when halted).

../../../_images/image031.gif

Step into a function, over a function, or out of a function.

../../../_images/image032.webp

Toggle between C and instruction stepping.

../../../_images/image033.webp

Reset the chip and restart execution.

../../../_images/image034.gif

Terminate the debug session.

../../../_images/image035.webp

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.