From: Tim Newsome Date: Fri, 2 Sep 2016 19:27:14 +0000 (-0700) Subject: Fix/add to instant trigger tests. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f70e91e5413306cd6da3ea4730921f65dac9c7c;p=riscv-tests.git Fix/add to instant trigger tests. --- diff --git a/debug/gdbserver.py b/debug/gdbserver.py index 851644b..b2a7c16 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -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") diff --git a/debug/programs/trigger.S b/debug/programs/trigger.S index 25d2b89..ebfce1c 100644 --- a/debug/programs/trigger.S +++ b/debug/programs/trigger.S @@ -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)