aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdebug/gdbserver.py46
-rw-r--r--debug/testlib.py17
2 files changed, 60 insertions, 3 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index 6d7c197..af8ddcf 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,51 @@ 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 CeaseRunTest(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=precease")
+ self.gdb.c(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)