Debugger hot plug

I’m currently working on device that cannot be tested with debugger plugged in. Once every some time software stops doing it’s job, wheter due to some kind of HardFault or deadlock. I would like to attach debugger after application crashes.
Flashing device with software compiled in debug mode is not an issue.

I was wondering if it would be possible connect to device in hot plug mode without disturbing its state?
I am positive that STM32CubeProgrammer tool can connect to device in this way and read device data, how would i go about replicating that with platformio?

As discussed in Attach debugger to running program without reset - #3 by deltaphi.