How to terminate gdbserver?

31,702

Solution 1

Give command

monitor exit

from your host gdb before terminating the client. If you have already terminated it, just attach with another one.

Solution 2

monitor exit step-by-step

https://stackoverflow.com/a/23647002/895245 mentions it, but this is the full setup you need.

Remote:

# pwd contains cross-compiled ./myexec
gdbserver --multi :1234

Local:

# pwd also contains the same cross-compiled ./myexec
gdb -ex 'target extended-remote 192.168.0.1:1234' \
    -ex 'set remote exec-file ./myexec' \
    --args ./myexec arg1
(gdb) r
[Inferior 1 (process 1234) exited normally]
(gdb) monitor exit

Tested in Ubuntu 14.04.

Solution 3

on linux write:

ps -ef |grep gdbserver

Now find the pid of the gdbserver process and then

kill -9 <pid>

Solution 4

gdbserver runs on the target, not the host.

Terminating it is target dependent. For example, if your target is UNIX-ish, you could remote login and use ps and kill from a target shell.

For any type of target, rebooting should kill gdbserver.

(If this isn't enough to answer your question, include more information about the target in the question.)

Solution 5

quit [expression]


q To exit GDB, use the quit command (abbreviated q), or type an end-of-file character (usually C-d). If you do not supply expression, GDB will terminate normally; otherwise it will terminate using the result of expression as the error code.

Share:
31,702

Related videos on Youtube

yehudahs
Author by

yehudahs

Updated on July 09, 2022

Comments

  • yehudahs
    yehudahs almost 2 years

    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 ?

  • yehudahs
    yehudahs over 10 years
    yes - I tried all the above on the target... and yes - tried to find the gdbserver process on the target with ps and top and no luck...my machine is "Linux version 2.6.32-71.el6.x86_64 ([email protected]) (gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) ) #1 SMP Wed Sep 1 01:33:01 EDT 2010"
  • yehudahs
    yehudahs over 10 years
    yes - I know how to kill the process. But I want to exit from within the gdbserver in the normal way. like exiting gdb with q...
  • Sandeep Datta
    Sandeep Datta almost 10 years
    Worked when connected using extended-remote
  • Ciro Santilli OurBigBook.com
    Ciro Santilli OurBigBook.com almost 7 years
    @SandeepDatta you are right, this is the detailed procedure: stackoverflow.com/a/44162888/895245
  • wisbucky
    wisbucky over 6 years
    Looks like this is the only way to terminate it from the remote target. And ctrl+z doesn't work either, so you have to login from another session to do this.