Fix/add to instant trigger tests.
authorTim Newsome <tim@sifive.com>
Fri, 2 Sep 2016 19:27:14 +0000 (12:27 -0700)
committerTim Newsome <tim@sifive.com>
Fri, 2 Sep 2016 19:27:14 +0000 (12:27 -0700)
debug/gdbserver.py
debug/programs/trigger.S

index 851644b0e586c9a686e2428ee3ca309f8797d025..b2a7c167f4b52e1534e1997d10a5ed1442de75d1 100755 (executable)
@@ -393,7 +393,7 @@ class TriggerTest(DeleteServer):
         self.assertIn("Breakpoint", output)
         self.assertIn("_exit", output)
 
-    def test_execute_immediate(self):
+    def test_execute_instant(self):
         """Test an execute breakpoint on the first instruction executed out of
         debug mode."""
         main = self.gdb.p("$pc")
@@ -409,14 +409,17 @@ class TriggerTest(DeleteServer):
                 self.gdb.p("(&data)+1"))
         self.exit()
 
-    def test_load_address_immediate(self):
+    def test_load_address_instant(self):
         """Test a load address breakpoint on the first instruction executed out
         of debug mode."""
-        write_loop = self.gdb.p("&write_loop")
+        self.gdb.command("b just_before_read_loop")
+        self.gdb.c()
+        read_loop = self.gdb.p("&read_loop")
         self.gdb.command("rwatch data");
         self.gdb.c()
-        self.assertEqual(self.gdb.p("$pc"), write_loop)
-        self.assertEqual(self.gdb.p("$a0"), self.gdb.p("(&data)+1"))
+        # Accept hitting the breakpoint before or after the load instruction.
+        self.assertIn(self.gdb.p("$pc"), [read_loop, read_loop + 4])
+        self.assertEqual(self.gdb.p("$a0"), self.gdb.p("&data"))
 
     def test_store_address(self):
         self.gdb.command("watch *((&data)+3)");
@@ -426,6 +429,18 @@ class TriggerTest(DeleteServer):
                 self.gdb.p("(&data)+3"))
         self.exit()
 
+    def test_store_address_instant(self):
+        """Test a store address breakpoint on the first instruction executed out
+        of debug mode."""
+        self.gdb.command("b just_before_write_loop")
+        self.gdb.c()
+        write_loop = self.gdb.p("&write_loop")
+        self.gdb.command("watch data");
+        self.gdb.c()
+        # Accept hitting the breakpoint before or after the store instruction.
+        self.assertIn(self.gdb.p("$pc"), [write_loop, write_loop + 4])
+        self.assertEqual(self.gdb.p("$a0"), self.gdb.p("&data"))
+
     def test_dmode(self):
         self.gdb.command("hbreak handle_trap")
         self.gdb.p("$pc=write_valid")
index 25d2b898f9c0361596c96594b2eaa09942781ba5..ebfce1ca4ffdf94ba5135759f612bf13db6b4163 100644 (file)
@@ -17,14 +17,16 @@ main:
 
         la      a0, data
         li      t0, 0
+just_before_read_loop:
         li      t2, 16
 read_loop:
         lw      t1, 0(a0)
-        addi    a0, a0, 4
         addi    t0, t0, 1
+        addi    a0, a0, 4
         blt     t0, t2, read_loop
 
         la      a0, data
+just_before_write_loop:
         li      t0, 1
 write_loop:
         sw      t0, 0(a0)