aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-06-08 10:17:54 -0700
committerTim Newsome <tim@sifive.com>2022-11-29 09:52:45 -0800
commitca937823c376c5c852a623470e9d5ea84fd4dcd6 (patch)
treeedf8e2cbaae1c7a0fc2172679a6f805ecde171c0
parent788c8a1a0e60b3d945cc5ceecd1d73df148305ef (diff)
downloadriscv-tests-ca937823c376c5c852a623470e9d5ea84fd4dcd6.zip
riscv-tests-ca937823c376c5c852a623470e9d5ea84fd4dcd6.tar.gz
riscv-tests-ca937823c376c5c852a623470e9d5ea84fd4dcd6.tar.bz2
Add CeaseTest
To test OpenOCD behavior when one or more harts are powered down.
-rwxr-xr-xdebug/gdbserver.py27
-rwxr-xr-xdebug/programs/entry.S5
-rw-r--r--debug/testlib.py4
3 files changed, 34 insertions, 2 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index cc054a4..9da069c 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -1813,6 +1813,33 @@ class EbreakTest(GdbSingleHartTest):
output = self.gdb.c()
assertIn("_exit", output)
+class CeaseTest(ProgramTest):
+ """Test that we work correctly when a hart ceases to respond (e.g. because
+ it's powered down)."""
+
+ def early_applicable(self):
+ return len(self.target.harts) > 1
+
+ def setup(self):
+ ProgramTest.setup(self)
+ self.parkOtherHarts("cease")
+
+ def test(self):
+ self.gdb.b("main")
+ output = self.gdb.c()
+ assertIn("Breakpoint", output)
+ assertIn("main", output)
+
+ for hart in self.target.harts:
+ # Try to read the PC on the ceased harts
+ if hart != self.hart:
+ self.gdb.select_hart(hart)
+ self.gdb.p("$pc")
+
+ self.gdb.select_hart(self.hart)
+
+ self.exit()
+
class FreeRtosTest(GdbTest):
def early_applicable(self):
return self.target.freertos_binary
diff --git a/debug/programs/entry.S b/debug/programs/entry.S
index 091efa4..84bebe2 100755
--- a/debug/programs/entry.S
+++ b/debug/programs/entry.S
@@ -204,6 +204,11 @@ trap_entry:
loop_forever:
j loop_forever
+ .align 2
+cease:
+ .word 0x30500073 // cease
+ j loop_forever
+
// Fill the stack with data so we can see if it was overrun.
.section .data
.align 4
diff --git a/debug/testlib.py b/debug/testlib.py
index 6c185d4..65f0598 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -1231,13 +1231,13 @@ class GdbTest(BaseTest):
del self.gdb
BaseTest.classTeardown(self)
- def parkOtherHarts(self):
+ def parkOtherHarts(self, symbol="loop_forever"):
"""Park harts besides the currently selected one in loop_forever()."""
for hart in self.target.harts:
# Park all harts that we're not using in a safe place.
if hart != self.hart:
self.gdb.select_hart(hart)
- self.gdb.p("$pc=loop_forever")
+ self.gdb.p("$pc=%s" % symbol)
self.gdb.select_hart(self.hart)