Attach debugger to running program without reset

Hi @maxgerhardt,

your debug_init_cmds were spot-on. Instead of emptying out debug_load_cmds, I set debug_load_mode = manual to prevent firmware upload.

My overall process:

  • Start a debug sesseion with no modifications to platformio.ini. This ensures that a debug image is uploaded and running on the target.

  • Stop the debugging session but leave the target powered.

  • Extend platformio.ini as follows:

    debug_load_mode = manual
    ; do not reset board upon connecting
    debug_init_cmds =
      target extended-remote $DEBUG_PORT
      $INIT_BREAK
      monitor halt
      monitor init
      monitor resume
    ; this is a guess based on the openocd commands 
    ; in http://openocd.org/doc/html/General-Commands.html
    ; maybe also needs monitor reset run
    ; or monitor reset init
    
  • Start another debug session.

  • I can now stop the target, set breakpoints, etc. - the full debugging experience.

I can observe from the serial port that the target did not reset.

I will file a feature request for the PlatformIO IDE to offer this as a regular feature, so that you can select whether you want the regular build to build/upload a release or debug image and whether you want the debugger to reset/attach.

EDIT: Feature Request

Thank you!
Damian