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, whereto_string
beingTrue
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.
精彩评论