1 """ debug utilities """
7 from sanity_run_vpp import SanityTestCase
8 from shutil import rmtree
9 from config import available_cpus
11 gdb_path = '/usr/bin/gdb'
14 def spawn_gdb(binary_path, core_path):
15 if os.path.isfile(gdb_path) and os.access(gdb_path, os.X_OK):
16 # automatically attach gdb
17 gdb_cmdline = "%s %s %s" % (gdb_path, binary_path, core_path)
18 gdb = pexpect.spawn(gdb_cmdline)
25 raise Exception("GDB refused to die...")
27 sys.stderr.write("Debugger '%s' does not exist or is not "
28 "an executable..\n" % gdb_path)
31 def start_vpp_in_gdb():
32 # here we use SanityTestCase as a dummy to inherit functionality,
33 # but any test case class could be used ...
34 SanityTestCase.set_debug_flags("attach")
35 SanityTestCase.tempdir = SanityTestCase.get_tempdir()
36 SanityTestCase.assign_cpus(
37 available_cpus[:SanityTestCase.get_cpus_required()])
38 SanityTestCase.setUpConstants()
39 vpp_cmdline = SanityTestCase.vpp_cmdline
40 print("Hacking cmdline to make VPP interactive.")
41 vpp_cmdline.insert(vpp_cmdline.index("nodaemon"), "interactive")
42 print("VPP cmdline is %s" % " ".join(vpp_cmdline))
45 if os.path.isfile(gdb_path) and os.access(gdb_path, os.X_OK):
46 gdb_cmdline = "%s --args %s " % (gdb_path, " ".join(vpp_cmdline))
47 print("GDB cmdline is %s" % gdb_cmdline)
48 gdb = pexpect.spawn(gdb_cmdline)
55 raise Exception("GDB refused to die...")
57 sys.stderr.write("Debugger '%s' does not exist or is not "
58 "an executable..\n" % gdb_path)