X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=debug%2Ftestlib.py;h=b8ff5c2edceb3e6d6b1c6982f15d542ae5ae2f51;hb=9ff4594d26f485495f47d4473905af9c4f10caa8;hp=30c31c5325af3d4fd68aadbff1403f669c410e17;hpb=9e313f30205b8172290831c3af18b0779e9b15f2;p=riscv-tests.git diff --git a/debug/testlib.py b/debug/testlib.py index 30c31c5..b8ff5c2 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -1,4 +1,5 @@ import os.path +import random import re import shlex import subprocess @@ -82,7 +83,7 @@ class Spike(object): os.environ['REMOTE_BITBANG_HOST'] = 'localhost' self.infinite_loop = target.compile( "programs/checksum.c", "programs/tiny-malloc.c", - "programs/infinite_loop.c", "-DDEFINE_MALLOC", "-DDEFINE_FREE") + "programs/infinite_loop.S", "-DDEFINE_MALLOC", "-DDEFINE_FREE") cmd.append(self.infinite_loop) logfile = open(self.logname, "w") logfile.write("+ %s\n" % " ".join(cmd)) @@ -219,7 +220,12 @@ class Openocd(object): raise Exception("ERROR: Timed out waiting for OpenOCD to " "examine RISCV core") - self.port = self._get_gdb_server_port() + try: + self.port = self._get_gdb_server_port() + except: + header("OpenOCD log") + sys.stdout.write(log) + raise def _get_gdb_server_port(self): """Get port that OpenOCD's gdb server is listening on.""" @@ -586,9 +592,13 @@ class GdbTest(BaseTest): if self.server.port: self.gdb.command( "target extended-remote localhost:%d" % self.server.port) - # Force gdb to discover threads now, otherwise it might interrupt - # us at some point when it decides by itself to check. - self.gdb.command("info threads") + # Select a random thread. + # TODO: Allow a command line option to force a specific thread. + output = self.gdb.command("info threads") + threads = re.findall(r"Thread (\d+)", output) + if threads: + thread = random.choice(threads) + self.gdb.command("thread %s" % thread) # FIXME: OpenOCD doesn't handle PRIV now #self.gdb.p("$priv=3")