Add test for address triggers.
authorTim Newsome <tim@sifive.com>
Tue, 23 Aug 2016 00:54:51 +0000 (17:54 -0700)
committerTim Newsome <tim@sifive.com>
Thu, 1 Sep 2016 23:35:15 +0000 (16:35 -0700)
debug/gdbserver.py
debug/testlib.py

index 8558a2b80db778bb56d82315164a3413302e5234..ca117622921863b35a84c1f4b5fed3c78299085e 100755 (executable)
@@ -52,6 +52,8 @@ def gdb(
     if port:
         gdb.command("target extended-remote localhost:%d" % port)
 
+    gdb.p("$priv=3")
+
     return gdb
 
         
@@ -316,6 +318,27 @@ class DebugTest(DeleteServer):
         # tests may fail.
         self.gdb.command("D")
 
+    def test_address_trigger(self):
+        self.gdb.b("main:start")
+        self.gdb.c()
+        self.gdb.command("watch fox[13]");
+
+        output = self.gdb.c()
+        self.assertNotIn("Could not insert", output)
+        self.assertIn("rot13", output)
+        output = self.gdb.command("up")
+        self.assertIn("in main", output)
+        self.assertEqual(self.gdb.p_string("fox"),
+                "Gur dhvpx oebjn fox jumps of the lazy dog.")
+
+        output = self.gdb.c()
+        self.assertNotIn("Could not insert", output)
+        self.assertIn("rot13", output)
+        output = self.gdb.command("up")
+        self.assertIn("in main", output)
+        self.assertEqual(self.gdb.p_string("fox"),
+                "The quick browa sbk whzcf bs gur ynml qbt.")
+
     def test_registers(self):
         # Get to a point in the code where some registers have actually been
         # used.
@@ -551,7 +574,7 @@ class SpikeTarget(Target):
     directory = "spike"
     ram = 0x80010000
     ram_size = 5 * 1024 * 1024
-    instruction_hardware_breakpoint_count = 0
+    instruction_hardware_breakpoint_count = 4
     reset_vector = 0x1000
 
 class Spike64Target(SpikeTarget):
index c186a175a5cc9d50a8c26d7c49618fa474dd6e2f..b2bfa8ed4c2bbb1acd8fb4e0e1d273415e119d6c 100644 (file)
@@ -186,6 +186,11 @@ class Gdb(object):
         value = int(output.split('=')[-1].strip(), 0)
         return value
 
+    def p_string(self, obj):
+        output = self.command("p %s" % obj)
+        value = shlex.split(output.split('=')[-1].strip())[1]
+        return value
+
     def stepi(self):
         output = self.command("stepi")
         assert "Cannot" not in output