CLion remote debugging will not kill remote process

Viewed 147

I have the newest (2020.3 EAP ATM) version of CLion and I currently use it to remote debug a program on an embedded target (linux-mipsel).

Everything works as expected, after a bit of configuration, using self-built cross-toolchain and gdbserver.

My only problem is hitting the "red square" to stop execution will neither kill the running program nor gdbserver itself. This means next iteration of edit-compile-debug cycle I will have two copies of both (I can get more, if I insist) which will not work as each tries to open the same resources (e.g.: a serial port) concurrently.

I have to manually log into target and kill the offending processes.

Am I missing something, is it a known bug or what?

Small update:

gdbserver is actually killed (does not show in ps ax) but underlying program (debugee) is still there. I am unsure why I was convinced otherwise, my bad.

1 Answers

This is a known issue and will hopefully be fixed soon.
Here is the link to the youtrack issue: https://youtrack.jetbrains.com/issue/CPP-20346
You could try the suggested workarounds:

  1. Add pre-deploy configuration which kills running instances of the program
  2. Follow the instructions for the gdb configuration in the comments:
    GDB Server: /bin/bash
    GDB Server args: -c "gdbserver :1234 /home/pi/myapp; pkill -e myapp"

    The second config did not work for me, so I added the execution of an external tool where I run in /bin/bash the command -c "pkill -e myapp || true". The true is mandatory to avoid errors if the program is not running.
Related