我尝试使用 gdb 调试一个由脚本创建的新进程。 在 linux shell 中,我试过这个:
ps -ef | grep -i [m]yprocess | awk '{print "gdb -p " $2}' | sh
每次,gdb都会自动得到一个‘quit’然后退出:
***0xf7788430 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install glibc-2.17-105.i686 libgcc-4.8.3-10.i686
(gdb) quit
A debugging session is active.
Inferior 1 [process 834] will be detached.
Quit anyway? (y or n) [answered Y; input not from terminal]***
我该怎么做才能解决这个问题?
最佳答案
你可以这样做
gdb -p `pgrep myprocess`
我猜奇怪的行为是由于 STDIN 不是终端而是 awk
的管道造成的。
关于linux - 在脚本中运行 gdb 时自动退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43423798/