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