Linux 如何终止gdbserver?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20870338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to terminate gdbserver?
提问by yehudahs
I am trying to debug with gdbserver. after I terminat the gdb client on the host I see that the gdbserver is still listening :
我正在尝试使用 gdbserver 进行调试。在主机上终止 gdb 客户端后,我看到 gdbserver 仍在侦听:
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 ?
我试图用我在任何地方都找不到的所有东西退出 gdbserver:退出、退出、q、监控退出、Esc、Cnt+c ......没有什么能杀死它。此外,当我打开另一个终端并查找运行 gdbserver 的进程(使用命令 ps,top)时,我在那里找不到它......我的问题是 - 如何终止 gdbserver ?
回答by Paul Beusterien
gdbserver
runs on the target, not the host.
gdbserver
在目标上运行,而不是主机上。
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.
终止它取决于目标。例如,如果您的目标是 UNIX-ish,您可以远程登录并使用 ps 并从目标 shell 中杀死。
For any type of target, rebooting should kill gdbserver
.
对于任何类型的目标,重新启动应该会杀死gdbserver
.
(If this isn't enough to answer your question, include more information about the target in the question.)
(如果这还不足以回答您的问题,请在问题中包含有关目标的更多信息。)
回答by Innovation
on linux write:
在 linux 上写:
ps -ef |grep gdbserver
Now find the pid of the gdbserver process and then
现在找到 gdbserver 进程的 pid 然后
kill -9 <pid>
回答by cup
gdbserver should exit when your target exits. The question is how your target is exiting: does it
当你的目标退出时 gdbserver 应该退出。问题是你的目标是如何退出的:是吗
- do nothing: just fall through
- return 0 in main
- exit(0) in main
- 什么都不做:只是失败
- 在 main 中返回 0
- 退出(0)在主
From the debug sessions I've been running, in the first case, gdbserver will not exit. It will just hang around forever and you have to kill it. In the latter two cases, gdbserver will exit.
从我一直在运行的调试会话中,在第一种情况下,gdbserver 不会退出。它会永远存在,你必须杀死它。在后两种情况下,gdbserver 将退出。
回答by Konstantin Shemyak
Give command
发出命令
monitor exit
from your host gdbbefore terminating the client. If you have already terminated it, just attach with another one.
在终止客户端之前从您的主机 gdb。如果您已经终止它,只需附加另一个。
回答by wsha
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.
q 要退出 GDB,请使用退出命令(缩写为 q),或键入文件结束符(通常为 Cd)。如果不提供表达式,GDB 将正常终止;否则它将使用表达式的结果作为错误代码终止。
回答by Ivan Talalaev
Here is a script which I'm using to start gdb server
via ssh and kill it when necessary with ctrl+c
这是我用来gdb server
通过 ssh启动并在必要时使用 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"