Make -H halt the core right out of reset.
[riscv-isa-sim.git] / tests / gdbserver.py
index 297960604e0d9578f06d3265ca771e9db36044d6..0f9ee1dd624083192b1e8e84ab7c24ccdad2d5c6 100755 (executable)
@@ -6,6 +6,25 @@ import unittest
 import tempfile
 import time
 
+class InstantHaltTest(unittest.TestCase):
+    def setUp(self):
+        self.binary = testlib.compile("debug.c")
+        self.spike, self.port = testlib.spike(self.binary, halted=True)
+        self.gdb = testlib.Gdb()
+        self.gdb.command("file %s" % self.binary)
+        self.gdb.command("target extended-remote localhost:%d" % self.port)
+
+    def tearDown(self):
+        self.spike.kill()
+        self.spike.wait()
+
+    def test_instant_halt(self):
+        self.assertEqual(0x1000, self.gdb.p("$pc"))
+        # For some reason instret resets to 0.
+        self.assertLess(self.gdb.p("$instret"), 8)
+        self.gdb.command("stepi")
+        self.assertNotEqual(0x1000, self.gdb.p("$pc"))
+
 class DebugTest(unittest.TestCase):
     def setUp(self):
         self.binary = testlib.compile("debug.c")
@@ -137,5 +156,22 @@ class RegsTest(unittest.TestCase):
         self.assertEqual(9, self.gdb.p("$x1"))
         self.assertEqual(9, self.gdb.p("$csr1"))
 
+#class MprvTest(unittest.TestCase):
+#    def setUp(self):
+#        self.binary = testlib.compile("mprv.S")
+#        self.spike, self.port = testlib.spike(self.binary, halted=False)
+#        self.gdb = testlib.Gdb()
+#        self.gdb.command("file %s" % self.binary)
+#        self.gdb.command("target extended-remote localhost:%d" % self.port)
+#
+#    def tearDown(self):
+#        self.spike.kill()
+#        self.spike.wait()
+#
+#    def test_mprv(self):
+#        """Test that the debugger can access memory when MPRV is set."""
+#        output = self.gdb.command("p/x data");
+#        self.assertIn("0xbead", output)
+
 if __name__ == '__main__':
     unittest.main()