blob: d1c89c66f3c419ea81b2fac414c6c9d334623dc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
""" debug utilities """
import os
import pexpect
import sys
gdb_path = '/usr/bin/gdb'
def spawn_gdb(binary_path, core_path):
if os.path.isfile(gdb_path) and os.access(gdb_path, os.X_OK):
# automatically attach gdb
gdb_cmdline = "%s %s %s" % (gdb_path, binary_path, core_path)
gdb = pexpect.spawn(gdb_cmdline)
gdb.interact()
try:
gdb.terminate(True)
except:
pass
if gdb.isalive():
raise Exception("GDB refused to die...")
else:
sys.stderr.write("Debugger '%s' does not exist or is not "
"an executable..\n" % gdb_path)
|