aboutsummaryrefslogtreecommitdiff
path: root/debug/testlib.py
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-10-07 09:46:28 -0700
committerTim Newsome <tim@sifive.com>2022-10-07 09:58:32 -0700
commita0e34c70e16e219c84bb15723d48a72065a5829e (patch)
tree2a8649caa7c83189705cc2003cdf28e64c1caa78 /debug/testlib.py
parent828c5c714ca0b1f44f57764bdc6d728cbd3da028 (diff)
downloadriscv-tests-a0e34c70e16e219c84bb15723d48a72065a5829e.zip
riscv-tests-a0e34c70e16e219c84bb15723d48a72065a5829e.tar.gz
riscv-tests-a0e34c70e16e219c84bb15723d48a72065a5829e.tar.bz2
debug: Add --debug_server arg to open gdb on OpenOCD
Not as useful as I'd like because we don't connect until after examine() has completed, and the test is likely to time out while debugging. But good to have, and maybe I'll expand on it one day.
Diffstat (limited to 'debug/testlib.py')
-rw-r--r--debug/testlib.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/debug/testlib.py b/debug/testlib.py
index bbca9fe..67f2e5b 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -293,8 +293,9 @@ class Openocd:
logname = logfile.name
def __init__(self, server_cmd=None, config=None, debug=False, timeout=60,
- freertos=False):
+ freertos=False, debug_openocd=False):
self.timeout = timeout
+ self.debug_openocd = debug_openocd
if server_cmd:
cmd = shlex.split(server_cmd)
@@ -387,7 +388,7 @@ class Openocd:
self.gdb_ports.append(int(m.group(1)))
if "telnet server disabled" in line:
- return process
+ break
if not messaged and time.time() - start > 1:
messaged = True
@@ -396,6 +397,12 @@ class Openocd:
raise Exception("Timed out waiting for OpenOCD to "
"listen for gdb")
+ if self.debug_openocd:
+ # pylint: disable=consider-using-with
+ self.debugger = subprocess.Popen(["gnome-terminal", "-e",
+ f"gdb --pid={process.pid}"])
+ return process
+
except Exception:
print_log(Openocd.logname)
raise