debug: need to clear satp before changing priv
[riscv-tests.git] / debug / gdbserver.py
index f0385d568441b3eeb8d1d73dc5f71b19b2a7d221..af9a33456b5855c348f2fa28f209c2d276f6a9a4 100755 (executable)
@@ -136,6 +136,19 @@ class SimpleF18Test(SimpleRegisterTest):
     def test(self):
         self.check_reg("f18", "fs2")
 
+class SimpleNoExistTest(GdbTest):
+    def test(self):
+        try:
+            self.gdb.p("$csr2288")
+            assert False, "Reading csr2288 should have failed"
+        except testlib.CouldNotFetch:
+            pass
+        try:
+            self.gdb.p("$csr2288=5")
+            assert False, "Writing csr2288 should have failed"
+        except testlib.CouldNotFetch:
+            pass
+
 class SimpleMemoryTest(GdbTest):
     def access_test(self, size, data_type):
         assertEqual(self.gdb.p("sizeof(%s)" % data_type), size)
@@ -822,7 +835,7 @@ class DownloadTest(GdbTest):
     def test(self):
         self.gdb.load()
         self.gdb.command("b _exit")
-        self.gdb.c(timeout=60)
+        self.gdb.c()
         assertEqual(self.gdb.p("status"), self.crc)
         os.unlink(self.download_c.name)
 
@@ -868,6 +881,13 @@ class PrivRw(PrivTest):
             # PMP registers are optional
             pass
 
+        # Ensure Virtual Memory is disabled if applicable (SATP register is not reset)
+        try:
+           self.gdb.p("$satp=0")
+        except testlib.CouldNotFetch:
+           # SATP only exists if you have S mode.
+           pass
+        
         # Leave the PC at _start, where the first 4 instructions should be
         # legal in any mode.
         for privilege in range(4):