如何在gdb中附加一个进程 [英] How to attach a process in gdb

查看:120
本文介绍了如何在gdb中附加一个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的C程序,它分叉一个进程然后运行一个可执行文件。

我想将子进程附加到gdb。



我在控制台中运行主程序并打开另一个控制台来查找子进程的pid,然后使用以下命令启动gdb:

  gdb附加12271 

其中 12271 是子进程ID,但是连接失败:

 没有这样的文件或目录。 

任何想法为什么?

解决方案

尝试以下方法之一:

  gdb -p 12271 
gdb / path / to / exe 12271

gdb / path / to / exe
(gdb)attach 12271


I have a simple C program that forks a process and then runs an executable.

I want to attach the child process to gdb.

I run the main program in a console and open another console to find the pid of the child process, then I start gdb with the following command:

gdb attach 12271

where 12271 is the child process id, but the attach fails with:

No such file or directory.

Any idea why?

解决方案

Try one of these:

gdb -p 12271
gdb /path/to/exe 12271

gdb /path/to/exe
(gdb) attach 12271

这篇关于如何在gdb中附加一个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆