开发者

start gdb using a pid

In general i see the process's pid which is running in the background and start dbx on that process using the command dbx -a <pid>

simi开发者_如何学Clarly how could i do it using gdb?


In addition to the previous you can directly use

gdb -p <pid>


There are two ways.

From the command line, include the pid as an argument after the executable name:

gdb /path/to/prog PID

From within gdb, you can use the attach command:

gdb /path/to/prog
gdb> attach PID

While the specifying on the command line is more concise, there is a slight risk that if you have a core file that has a name that is the same as the pid (i.e. for pid 2345, the core file would have to be named "2345") then gdb will open the core file. Admittedly, the chance of this happening is minuscule.


From the gdb man page:

You can, instead, specify a process ID as a second argument, if you want to debug a running process:

gdb program 1234
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜