我可以使用GDB来调试正在运行的进程吗? [英] Can I use GDB to debug a running process?
问题描述
在linux下,我可以使用GDB调试当前运行的进程吗?
Under linux, can I use GDB to debug a process that is currently running?
推荐答案
是的。使用 attach
命令。有关详细信息,请查看此链接。在GDB控制台上输入 help附加
可以得到以下内容:
Yes. Use the attach
command. Check out this link for more information. Typing help attach
at a GDB console gives the following:
(gdb) help attach
附加到GDB之外的进程或文件。
此命令附加到另一个目标,与最后一个目标
命令(信息文件
将显示您的目标堆栈)。
该命令可以将进程ID,进程名
(可选的进程号作为后缀)或设备文件作为参数。
对于进程标识,您必须具有向进程发送信号
的权限,并且必须具有与调试器相同的有效uid。
当对现有进程使用 attach
时,调试器会在进程中查找
程序,首先查看当前工作
目录,或者(如果没有找到)使用源文件搜索路径
(请参阅目录
命令)。您也可以使用文件
命令
来指定程序,并加载其符号表。
Attach to a process or file outside of GDB.
This command attaches to another target, of the same type as your last
"target
" command ("info files
" will show your target stack).
The command may take as argument a process id, a process name
(with an optional process-id as a suffix), or a device file.
For a process id, you must have permission to send the process a signal,
and it must have the same effective uid as the debugger.
When using "attach
" to an existing process, the debugger finds the
program running in the process, looking first in the current working
directory, or (if not found there) using the source file search path
(see the "directory
" command). You can also use the "file
" command
to specify the program, and to load its symbol table.
这篇关于我可以使用GDB来调试正在运行的进程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!