Pico debug issue with PICO_CXX_ENABLE_EXCEPTIONS enabled #2685
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#2685
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally posted by @GuySMowbray in #1952
@GuySMowbray That issue you've linked to is from over a year ago, and various parts of the software-stack (pico-sdk, openocd, debugprobe, VS Code extension, etc,) have all been updated since then.
Please provide details of exactly what hardware you're using, what OS you're running, what software versions you have installed, what it is you're trying to do, and where exactly it goes wrong. The more detail that you'e able to provide, the easier it'll be for us to try and reproduce your problem. Thanks.
Pico W with UFT bootloader V3.0
Pi Debug probe
SDK 2.2.0 on VS code
Version: 1.104.2 (user setup)
Commit: e3a5acfb517a443235981655413d566533107e92
Date: 2025-09-24T11:21:37.073Z
Electron: 37.3.1
ElectronBuildId: 12404162
Chromium: 138.0.7204.235
Node.js: 22.18.0
V8: 13.8.258.31-electron.0
OS: Windows_NT x64 10.0.26100
running debug as
Clean build on Cmake debugs ok, with two error
reset init failed args[i] option value ('CX') in not valid
cannot convert main from CP1252 to utf_32
I believe these are both reported fairly frequently and are not critical.
While debugging, if I stop the debugger, sometimes it does not stop, sometimes it reports stopped but the control panel stays and wont do anything . On occasion it will stick on the spinlock or another timer. Sometimes the code the debugger is running is different to the code I am seeing (sync loss). On most of these occasions, I cannot get the debug to reset and allow a restart without cleaning Cmaker again.
Have you got
PICO_CXX_ENABLE_EXCEPTIONSenabled like in that issue? We have been unable to get to the bottom of why that flag makes debugging so flaky, as you can see from that issue. If not then could you provide your full code so we can reproduce the issue.You mention that from a clean build debugging works fine, which is the current workaround for this - what do you think needs to be more clearly explained about that workaround?
Hello - chiming in here, I have read through the previous issue where this was discussed. I am encountering this same bug - I am using a debug probe with a vanilla Pico and have the the
set(PICO_CXX_ENABLE_EXCEPTIONS 1)in mycmakelists.txtfile. I am using SDK 2.2.0, but it also occurred in SDK 2.1.1. When I try to debug through the VScode extension (VScode is up to date as are extensions, and I'm on Windows), the result is slightly different (my app runs to completion, ignoring all breakpoints) but the enable/disable of exceptions flips behavior. I also found the fix of deleting the build folder and rebuilding everything to fix the issue, but as soon as you need to re-compile, the new upload fails and the issue persists.launch.json:my app is simply this:
and my cmakelists.txt is this:
if helpful, my stacktrace when the debugger does halt looks like this. the event logged
my server logs look typical, with two breakpoints I see this:
but in
debug consolethe output shows us not stopping at breakpoints, only the end:Hope that is helpful! I'll follow this thread and can test things as needed.
@GuySMowbray Here's the clear explanation of the workaround:
PICO_CXX_ENABLE_EXCEPTIONSdebugging doesn't stop at breakpoints correctlyI have the same issue where I have to delete the build folder, but I do not think it has anything to do with PICO_CXX_ENABLE_EXCEPTIONS.
I think it may be something to do with file caching. The reason I say this is that on the PC where I do not have issue, the debug console shows that after the symbols are read, a line outs that shows the file and location of main
man() at ...\main.cpp::33as an exampleon a PC where I have to delete the build folder, if I don't delete it and make a change and debug, then after the elf file is loaded you get a line saying
.....elf' has changed; re-reading symbols.and then after this it displays a random .cpp file and some of its contents
0x1000758c in stdio_usb_init () at C:\WorkTemp\RP2040\pico-sdk\src\rp2_common\pico_stdio_usb\stdio_usb.c:228 228 if (rc) {Its almost like something detects that the elf file is different and then re-reads a different file where all the location data in wrong so it displays incorrect information
And then it can no longer find main , flash never gets loaded, an so on
sound slightly different to my issue, which although ive been too busy to
dig into it in detail is probably around the debug not correctly
identifying changed files.
adding "overrideLaunchCommands": [
"monitor reset init",
"load "${command:raspberry-pi-pico.launchTargetPath}""
], to launch.json
reduced the issues frequency but doesnt always work, even when i do a clean
rebuild from cmake. I'm begining to suspect the openOCD interface.
My workaround :
I just check to see if the flash upload appears in the log if it does i'll
get a clean debug break at main, if not it just restarts with stale code so
i do the crude work around of deleting the whole build to force the issue.
Ive seen this is causing a lot of pain for some people, i bet there are
many more who just putup with it.
On Mon, 17 Nov 2025, 21:26 Shawn Lammers, @.***> wrote:
I'm seeing this problem on my project too.
I'm on a windows 11 laptop using the pi debug probe (connected to a Pico 2040 on a W board).
sdk 2.2.0
Probe CMSIS-DAP: FW Version = 2.0.0 (issue was still happening for me with older probe fw)
Raspberry Pi Pico Visual Studio Code extension Version 0.19.0
The problem still occurs for me with:
set(PICO_CXX_ENABLE_EXCEPTIONS 0)
set(PICO_CXX_ENABLE_RTTI 1)
The only combination that works for me is to have both options turned off.
The one difference in the debug console output is this line appears when it goes wrong:
`c:\Users\me\my-pico-project\build\my-pico-project.elf' has changed; re-reading symbols.
When I pause the debugger after it fails to honor my breakpoints I get the following (bad?) values for rp2040.core0 callstack:
sp=0x20041f00
pc=0x127372c0
The work around (deleting the build folder) works but I'm disabling both of the faulty options until a fix is found.
If I try debugging a stock example project (hello_usb) with both options turned on there's no problems.
My launch script:
is this a VS code only issue; if so probably worth labeling it as such @will-v-pi
I have some success up till now using this, even with exceptions enabled
lauch.json
I believe I have a fix for this issue - could you try changing your toolchain to 14.3.Rel1 and see if you still see your issue? To do that, click "Pico SDK: 2.2.0" in the bottom right, select "v2.2.0" then "Yes" to configure advanced options, and select the "14.3.Rel1" toolchain (select "Default" for everything else)
Early days, but it does appear to be behaving for me:)
On Wed, 1 Apr 2026 at 10:46, will-v-pi @.***> wrote:
Great - this should now be fixed for new installs of Pico VSCode, and will be completely fixed with the next SDK version