diff options
Diffstat (limited to 'debug/testlib.py')
-rw-r--r-- | debug/testlib.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/debug/testlib.py b/debug/testlib.py index bd83d56..e003fdc 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -29,8 +29,18 @@ def find_file(path): return relpath return None +class CompileError(Exception): + def __init__(self, stdout, stderr): + self.stdout = stdout + self.stderr = stderr + +gcc_cmd = None def compile(args): # pylint: disable=redefined-builtin - cmd = ["riscv64-unknown-elf-gcc", "-g"] + if gcc_cmd: + cmd = [gcc_cmd] + else: + cmd = ["riscv64-unknown-elf-gcc"] + cmd.append("-g") for arg in args: found = find_file(arg) if found: @@ -43,10 +53,10 @@ def compile(args): # pylint: disable=redefined-builtin stderr=subprocess.PIPE) stdout, stderr = process.communicate() if process.returncode: - print(stdout, end=" ") - print(stderr, end=" ") + print(stdout.decode('ascii'), end=" ") + print(stderr.decode('ascii'), end=" ") header("") - raise Exception("Compile failed!") + raise CompileError(stdout, stderr) class Spike: # pylint: disable=too-many-instance-attributes @@ -666,10 +676,15 @@ class Gdb: self.select_child(child) self.interrupt() - def x(self, address, size='w'): - output = self.command("x/%s %s" % (size, address)) - value = int(output.split(':')[1].strip(), 0) - return value + def x(self, address, size='w', count=1): + output = self.command("x/%d%s %s" % (count, size, address)) + values = [] + for line in output.splitlines(): + for value in line.split(':')[1].strip().split(): + values.append(int(value, 0)) + if len(values) == 1: + return values[0] + return values def p_raw(self, obj): output = self.command("p %s" % obj) @@ -806,6 +821,8 @@ def run_all_tests(module, target, parsed): global gdb_cmd # pylint: disable=global-statement gdb_cmd = parsed.gdb + global gcc_cmd # pylint: disable=global-statement + gcc_cmd = parsed.gcc examine_added = False for hart in target.harts: @@ -889,6 +906,8 @@ def add_test_run_options(parser): help="Print out a list of tests, and exit immediately.") parser.add_argument("test", nargs='*', help="Run only tests that are named here.") + parser.add_argument("--gcc", + help="The command to use to start gcc.") parser.add_argument("--gdb", help="The command to use to start gdb.") parser.add_argument("--misaval", |