aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-11-10 16:11:53 -0800
committerTim Newsome <tim@sifive.com>2022-12-14 16:54:29 -0800
commitb08e2ee7fab0f66bc9bb643db0375fb360c326f3 (patch)
tree586a3ec022ab24cf021d218754cf75ddb2179d4d
parent55bbcc8c06637a31cc01970881ba8072838a9121 (diff)
downloadriscv-tests-b08e2ee7fab0f66bc9bb643db0375fb360c326f3.zip
riscv-tests-b08e2ee7fab0f66bc9bb643db0375fb360c326f3.tar.gz
riscv-tests-b08e2ee7fab0f66bc9bb643db0375fb360c326f3.tar.bz2
debug: Add CeaseStepiTest.
Test that we work correctly when the hart we're debugging ceases to respond during stepi. Add wait parameter to Gdb.stepi(), in case stepi isn't expected to complete. Parse "could not read registers" error from gdb
-rwxr-xr-xdebug/gdbserver.py23
-rw-r--r--debug/testlib.py17
2 files changed, 37 insertions, 3 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index 6d7c197..6f27871 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -18,6 +18,7 @@ from testlib import assertGreater, assertRegex, assertLess
from testlib import GdbTest, GdbSingleHartTest, TestFailed
from testlib import TestNotApplicable, CompileError
from testlib import UnknownThread
+from testlib import CouldNotReadRegisters
MSTATUS_UIE = 0x00000001
MSTATUS_SIE = 0x00000002
@@ -1832,6 +1833,28 @@ class CeaseMultiTest(GdbTest):
self.gdb.p("$pc=_start")
self.exit()
+class CeaseStepiTest(ProgramTest):
+ """Test that we work correctly when the hart we're debugging ceases to
+ respond."""
+ def early_applicable(self):
+ return self.hart.support_cease
+
+ def test(self):
+ self.gdb.b("main")
+ output = self.gdb.c()
+ assertIn("Breakpoint", output)
+ assertIn("main", output)
+
+ self.gdb.p("$pc=cease")
+ self.gdb.stepi(wait=False)
+ self.gdb.expect(r"\S+ became unavailable.")
+ self.gdb.interrupt()
+ try:
+ self.gdb.p("$pc")
+ assert False, ("Registers shouldn't be accessible when the hart is "
+ "unavailable.")
+ except CouldNotReadRegisters:
+ pass
class FreeRtosTest(GdbTest):
def early_applicable(self):
diff --git a/debug/testlib.py b/debug/testlib.py
index 5c78bd7..58bb23e 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -476,6 +476,11 @@ class CouldNotFetch(Exception):
self.regname = regname
self.explanation = explanation
+class CouldNotReadRegisters(Exception):
+ def __init__(self, explanation):
+ Exception.__init__(self)
+ self.explanation = explanation
+
class NoSymbol(Exception):
def __init__(self, symbol):
Exception.__init__(self)
@@ -508,6 +513,8 @@ def tokenize(text):
(r"<repeats (\d+) times>", lambda m: Repeat(int(m.group(1)))),
(r"Could not fetch register \"(\w+)\"; (.*)$",
lambda m: CouldNotFetch(m.group(1), m.group(2))),
+ (r"Could not read registers; (.*)$",
+ lambda m: CouldNotReadRegisters(m.group(1))),
(r"Cannot access memory at address (0x[0-9a-f]+)",
lambda m: CannotAccess(int(m.group(1), 0))),
(r"Cannot insert breakpoint (\d+).",
@@ -857,9 +864,13 @@ class Gdb:
result[name] = parse_rhs(parts[1])
return result
- def stepi(self):
- output = self.command("stepi", ops=10)
- return output
+ def stepi(self, wait=True):
+ if wait:
+ return self.command("stepi", ops=10)
+ else:
+ self.active_child.sendline("stepi")
+ self.active_child.expect("stepi", timeout=self.timeout)
+ return ""
def expect(self, text, ops=1):
return self.active_child.expect(text, timeout=ops * self.timeout)