开发者

GDB+Python: Determining target type

Is there a way to determ开发者_如何学编程ine whether the debugged target is a core dump or a 'live' process?


As far as I know, there is no dedicated way to do it in Python, however, you can still use

  • gdb.execute("<command>", to_string=<boolean>) to execute a "CLI" command in Python, where to_string being True will tell GDB to collect the output and return it as a string (cf. doc)

  • maint print target-stack which will print the layers used internally to access the inferior. You should see "core (Local core dump file)" if the core-debugging layer is active.

So all-in-all, a bit of code like

out = gdb.execute("maint print target-stack", to_string=True)
print "Local core dump file" in out

should do the trick.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜