diff options
author | Tim Newsome <tim@sifive.com> | 2022-01-06 09:29:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 09:29:44 -0800 |
commit | cf04274f50621fd9ef9147793cca6dd1657985c7 (patch) | |
tree | 43294b7097490943d45c5e86aa5e1dfe5d7e75a6 /debug/testlib.py | |
parent | 0266ef52ea94554bf71c741b963461b21ac82dba (diff) | |
download | riscv-tests-cf04274f50621fd9ef9147793cca6dd1657985c7.zip riscv-tests-cf04274f50621fd9ef9147793cca6dd1657985c7.tar.gz riscv-tests-cf04274f50621fd9ef9147793cca6dd1657985c7.tar.bz2 |
Add gdb.interact() for debug tests. (#367)
This feature lets you easily interact with the gdb after the test has
run to a certain point.
Diffstat (limited to 'debug/testlib.py')
-rw-r--r-- | debug/testlib.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/debug/testlib.py b/debug/testlib.py index 25ff5be..bb4ac25 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -681,6 +681,24 @@ class Gdb: self.active_child.expect(r"\(gdb\)", timeout=timeout) return self.active_child.before.strip().decode("utf-8", errors="ignore") + def interact(self): + """Call this from a test at a point where you just want to interact with + gdb directly. This is useful when you're debugging a problem and just + want to take over at a certain point in the test.""" + saved_stdout = sys.stdout + sys.stdout = real_stdout + try: + print() + print("Interact with the gdb instance created by the test.") + print("This is not a true gdb prompt, so things like tab ") + print("completion won't work.") + while True: + command = input("(gdb) ") + print(self.command(command)) + finally: + sys.stdout = saved_stdout + + def global_command(self, command): """Execute this command on every gdb that we control.""" with PrivateState(self): |