d9b0c6fbf7
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
""" debug utilities """
|
|
|
|
import os
|
|
import pexpect
|
|
import sys
|
|
|
|
from sanity_run_vpp import SanityTestCase
|
|
from shutil import rmtree
|
|
from config import available_cpus
|
|
|
|
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
|
|
)
|
|
|
|
|
|
def start_vpp_in_gdb():
|
|
# here we use SanityTestCase as a dummy to inherit functionality,
|
|
# but any test case class could be used ...
|
|
SanityTestCase.set_debug_flags("attach")
|
|
SanityTestCase.tempdir = SanityTestCase.get_tempdir()
|
|
SanityTestCase.assign_cpus(available_cpus[: SanityTestCase.get_cpus_required()])
|
|
SanityTestCase.setUpConstants()
|
|
vpp_cmdline = SanityTestCase.vpp_cmdline
|
|
print("Hacking cmdline to make VPP interactive.")
|
|
vpp_cmdline.insert(vpp_cmdline.index("nodaemon"), "interactive")
|
|
print("VPP cmdline is %s" % " ".join(vpp_cmdline))
|
|
print("Running GDB.")
|
|
|
|
if os.path.isfile(gdb_path) and os.access(gdb_path, os.X_OK):
|
|
gdb_cmdline = "%s --args %s " % (gdb_path, " ".join(vpp_cmdline))
|
|
print("GDB cmdline is %s" % gdb_cmdline)
|
|
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
|
|
)
|