Support Attaching Debugger to a Running Target
This is a feature request. In this post on the community forums, I asked whether it is possible to attach a debugger to a running target without resetting the target. My usecase is tracking down a pesky bug that only occurs sporadically, typically while I am running without a debugger attached.
The commands provided by maxgerhard worked perfectly, as I explained in the forum post. However, using this does require quite a bit of back-and-forth commenting and uncommenting variables in the platformio.ini to switch between "upload a debug image" and "attach to a debug image without resetting". Also, this makes the edit-compile-upload-test loop rather slow as you have to wait for the slow debugger start after every upload,.
I attribute this to the fact that PlatformIO only knows about the usecases "Upload (without debugger)" and "Start Debugging".
I would like to request the following features:
- For the regular upload (equivalent of
platformio runandplatformio upload): Make it configurable whether the release configuration or the debug configuration is used. This enables to consistently upload debug images that can later be attached. Default should be to upload a release image, thus replicating the past behavior. - Offer a new command to attach the debugger to a running target (perhaps equivalent to a new parameter to
platformio debug). This command will skip uploading the software, regardless of what has been set indebug_load_mode. It will also use an alternate set ofdebug_init_cmds(perhaps calleddebug_attach_init_cmds?) that do not reset the target.
Quoting from the forum post, the following commands worked on a STM32 BluePill board using an ST-Link V2 clone:
debug_init_cmds =
target extended-remote $DEBUG_PORT
$INIT_BREAK
monitor halt
monitor init
monitor resume
Thanks! Damian