aboutsummaryrefslogtreecommitdiff
path: root/debug/gdbserver.py
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-12-14 16:53:08 -0800
committerGitHub <noreply@github.com>2022-12-14 16:53:08 -0800
commit55bbcc8c06637a31cc01970881ba8072838a9121 (patch)
tree2a8912e7bbc3ecafa3039a251fd2117cb9c12bd0 /debug/gdbserver.py
parent898c20bf0b74b2899d7491823cbbac84b5508751 (diff)
downloadriscv-tests-55bbcc8c06637a31cc01970881ba8072838a9121.zip
riscv-tests-55bbcc8c06637a31cc01970881ba8072838a9121.tar.gz
riscv-tests-55bbcc8c06637a31cc01970881ba8072838a9121.tar.bz2
debug: Create CeaseMultiTest. (#436)
Confirm basic debug still works when other harts have been parked using a `cease` instruction. Check that the unavailable harts are inaccessible from gdb. Add Gdb.expect() Parse "unknown thread" error from gdb.
Diffstat (limited to 'debug/gdbserver.py')
-rwxr-xr-xdebug/gdbserver.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index ac7b162..6d7c197 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -12,10 +12,12 @@ import re
import targets
import testlib
-from testlib import assertEqual, assertNotEqual, assertIn, assertNotIn
+from testlib import assertEqual, assertNotEqual
+from testlib import assertIn, assertNotIn
from testlib import assertGreater, assertRegex, assertLess
from testlib import GdbTest, GdbSingleHartTest, TestFailed
from testlib import TestNotApplicable, CompileError
+from testlib import UnknownThread
MSTATUS_UIE = 0x00000001
MSTATUS_SIE = 0x00000002
@@ -1788,6 +1790,49 @@ class EbreakTest(GdbSingleHartTest):
output = self.gdb.c()
assertIn("_exit", output)
+class CeaseMultiTest(GdbTest):
+ """Test that we work correctly when a hart ceases to respond (e.g. because
+ it's powered down)."""
+ compile_args = ("programs/counting_loop.c", "-DDEFINE_MALLOC",
+ "-DDEFINE_FREE")
+
+ def early_applicable(self):
+ return self.hart.support_cease and len(self.target.harts) > 1
+
+ def setup(self):
+ ProgramTest.setup(self)
+ self.parkOtherHarts("precease")
+
+ def test(self):
+ # Run all the way to the infinite loop in exit
+ self.gdb.c(wait=False)
+ self.gdb.expect(r"\S+ became unavailable.")
+ self.gdb.interrupt()
+
+ for hart in self.target.harts:
+ # Try to read misa on the ceased harts
+ if hart != self.hart:
+ try:
+ self.gdb.select_hart(hart)
+ self.gdb.p("$misa")
+ assert False, \
+ "Shouldn't be able to access unavailable hart."
+ except UnknownThread:
+ pass
+
+ # Check that the main hart can still be debugged.
+ self.gdb.select_hart(self.hart)
+ main_addr = self.gdb.p("$pc=main")
+ self.gdb.stepi()
+ # Assume the first instruction of main is not a jump.
+ pc = self.gdb.p("$pc")
+ assertGreater(pc, main_addr)
+ assertLess(pc, main_addr + 8)
+
+ self.gdb.p("$pc=_start")
+
+ self.exit()
+
class FreeRtosTest(GdbTest):
def early_applicable(self):
return self.target.freertos_binary