How to terminate gdbserver?

Viewed 33445

I am trying to debug with gdbserver. after I terminat the gdb client on the host I see that the gdbserver is still listening :

Remote side has terminated connection.  GDBserver will reopen the connection.
Listening on port 5004

I tried to exit gdbserver with everything I have found anywhere no luck: quit,exit,q, monitor exit,Esc,Cnt+c... nothing kills it. Moreover, when I opened another terminal and looked for the process running gdbserver (with the commands ps,top) I couldn't find it there... my question is - How to terminate gdbserver ?

7 Answers

Here is a script which I'm using to start gdb server via ssh and kill it when necessary with ctrl+c

#!/usr/bin/env bash

trap stop_gdb_server INT

function stop_gdb_server {
    ssh remote-srv-name "pkill gdbserver"
    echo "GDB server killed"
}

ssh remote-srv-name "cd /path/to/project/dir/ && gdbserver localhost:6789 my-executable"
Related