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

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

问题描述

我有一个简单的 C 程序,它派生一个进程然后运行一个可执行文件.

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

我想将子进程附加到 gdb.

I want to attach the child process to gdb.

我在控制台中运行主程序并打开另一个控制台以查找子进程的pid,然后使用以下命令启动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

其中 12271 是子进程 ID,但附加失败:

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

No such file or directory.

知道为什么吗?

推荐答案

尝试以下方法之一:

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

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

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

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