aboutsummaryrefslogtreecommitdiffstats
path: root/test/debug.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/debug.py')
-rw-r--r--test/debug.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/debug.py b/test/debug.py
new file mode 100644
index 00000000000..4516b8c150b
--- /dev/null
+++ b/test/debug.py
@@ -0,0 +1,23 @@
+""" debug utilities """
+
+import os
+import pexpect
+
+gdb_path = '/usr/bin/gdb'
+
+
+def spawn_gdb(binary_path, core_path, logger):
+ 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:
+ logger.error("Debugger '%s' does not exist or is not an "
+ "executable.." % gdb_path)