Skip to content
Prev Previous commit
Update breakpoints section of IDE 2.x debugger tutorial to reflect ne…
…w behavior The version of the "Cortex-Debug" VS Code extension that provides the integrated sketch debugger for Arduino IDE 2.x was updated for the Arduino IDE 2.0.3 release. This update resulted in some changes in the behavior of the debugger. One of these changes is in how the debugger behaves when it is started: When started, the version of the debugger (0.3.10) used by Arduino IDE 2.0.2 and older would pause at some point at the start of the program (e.g., the `Reset_Handler` function in the cortex_handlers.c file of the "Arduino SAMD Boards (32-bits ARM Cortex-M0+)" platform). When started, the version of the debugger (1.5.1) used by Arduino IDE 2.0.3 and newer simply runs the sketch program, only automatically pausing if it reaches a breakpoint set by the user. The Arduino IDE 2.x debugger tutorial was written based on the previous behavior, and that information is not applicable to Arduino IDE 2.0.3 and newer. So the outdated information is hereby updated to be correct for the current IDE versions. This task was a bit challenging due to the tutorial being vague and inconsistent about the clicking of the "Start Debugging" button. It is not clear exactly when (or if!!!) the user will click this button: If they click it before adding the breakpoints, execution will pause at whichever breakpoint the execution reaches first. That will most likely be line 33, since there is only a 1 s time window when line 35 would be the next breakpoint, but it is not guaranteed. If they click it after adding the breakpoints, execution will pause at the first breakpoint at line 33.
  • Loading branch information
per1234 committed Dec 5, 2022
commit c9ede0e06ba2f298434c2376cb4b32f3f80a81e2
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ In this example, we are going to set a breakpoint for **line 33** and **line 35*
![Navigating the Debugger.](assets/debugger-img03.png)

We can now go through our code, step by step.
The first (automatic) stop will be triggered by the **Debugger** itself, and it will be a standard entry-point, ignore that for now.
The debugger will automatically stop at the first breakpoint it reached.

Let's continue, by clicking on the **Play/pause** button (**Continue**). The program will now run to the first breakpoint, line 33. If we click it again, it will jump to line 35 (line 34 will still be executed but we won't see that). Clicking the **Play/pause** button again will continue running the program which will pause at its next breakpoint, line 33. We're in the main loop, after all.
Let's continue, by clicking on the **Play/pause** button (**Continue**). The program will now run to the next breakpoint (e.g., line 35). If we click it again, it will jump to line 33 (the other lines in the program sequence will still be executed but we won't see that). Clicking the **Play/pause** button again will continue running the program which will pause at its next breakpoint, line 35. We're in the main loop, after all.

![Going between breakpoints.](assets/playpause.gif)

Expand Down