如何获取gdb中当前已调试进程的pid? [英] How does one obtain the pid of the currently debugged process in gdb?
本文介绍了如何获取gdb中当前已调试进程的pid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在gdb内,什么命令将提供正在调试的进程的pid?
Inside gdb, what command will provide the pid of the process getting debugged?
Most of the google results discuss only how to attach gdb to a process once we know the pid.
推荐答案
一种简单的方法是info inferior
.在这里,我正在用自身调试gdb,此命令显示了被调试对象的PID:
One simple way is info inferior
. Here I'm debugging gdb with itself and this command shows the PID of the debuggee:
(top-gdb) info inferior
Num Description Executable
* 1 process 14068 /home/tromey/gdb/build/gdb/gdb
您也可以只调用普通的C函数:
You can also just call the ordinary C function:
(top-gdb) print getpid()
$3 = 14068
这篇关于如何获取gdb中当前已调试进程的pid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文