From 1099c0dadd3c315d81ba5ef2e8712b6c08076ae2 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 22 Aug 2016 17:54:51 -0700 Subject: [PATCH] Add test for address triggers. --- debug/gdbserver.py | 25 ++++++++++++++++++++++++- debug/testlib.py | 5 +++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/debug/gdbserver.py b/debug/gdbserver.py index 8558a2b..ca11762 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -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): diff --git a/debug/testlib.py b/debug/testlib.py index c186a17..b2bfa8e 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -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 -- 2.30.2