有没有办法确定调试目标是核心转储还是“实时”进程?
最佳答案
据我所知,Python 中没有专门的方法来做到这一点,但是,您仍然可以使用
gdb.execute("<command>", to_string=<boolean>)
在 Python 中执行“CLI”命令,其中to_string
是True
将告诉 GDB 收集输出并将其作为字符串返回(参见 doc )maint print target-stack
它将打印内部使用的层以访问下层。如果核心调试层处于事件状态,您应该会看到“core (Local core dump file)
”。
总而言之,一些代码,例如
out = gdb.execute("maint print target-stack", to_string=True)
print "Local core dump file" in out
应该可以解决问题。
关于python - GDB+Python : Determining target type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7510865/