microsoft / vscode-embedded-tools

Official issue tracking repository for Microsoft's Embedded Tools VS Code extension.
MIT License
43 stars 3 forks source link

Placing a breakpoint while program is running throws an exception #49

Open alexandru-vrn opened 1 year ago

alexandru-vrn commented 1 year ago

Placing a breakpoint somewhere in the code seems to halt the microcontroller, GDB reporting the following in the debug console tab:

ST-LINK_gdbserver: Received Ctrl-C from the client ST-LINK_gdbserver: Device not halted(0), performing Ctrl-C ST-LINK_gdbserver: GDB session, device event: 4 ST-LINK_gdbserver: Device halted ST-LINK_gdbserver: ST-LINK device status: HALT_MODE ST-LINK_gdbserver: GDB session, device event: 0

VSCode displays the error like this: image

Resuming the program works, and the breakpoint is actually applied and reached by the program execution as expected, regardless of all of the warnings and errors displayed when it is set up.

benmcmorran commented 1 year ago

Can you try adding this line to your launch.json? I made a change to MIEngine (the underlying debug engine used by the C/C++ VS Code extenion) a while ago that should let you configure how unexpected breakpoints are handled.

"unknownBreakpointHandling": "stop"

This won't prevent the debugger from stopping entirely (because it sounds like for some reason GDB is still stopping the program), but it should prevent it from appearing as an exception.

alexandru-vrn commented 1 year ago

I have added the line to launch.json and the exception is not thrown in the way I described, but this only works once. If I add a new breakpoint then VSCode behaves like before adding the option you mentioned. If I run the program again, the exception is thrown from the first attempt of adding a new breakpoint. I have to restart VSCode and then it behaves as you describe, but only once.