From cbe0dd1405cd2f33ef1cbbc67eda73bfe65d067e Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 28 Dec 2022 16:49:13 -0800 Subject: debug: Add etrigger test. --- debug/gdbserver.py | 19 +++++++++++++++++++ debug/programs/debug.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/debug/gdbserver.py b/debug/gdbserver.py index af8ddcf..1ffb15f 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -1953,6 +1953,25 @@ class StepThread2Test(GdbTest): # GDB's conception of the current thread assertEqual(before, after) +class EtriggerTest(DebugTest): + def setup(self): + DebugTest.setup(self) + self.gdb.b("main:start") + self.gdb.c() + self.gdb.b("handle_trap") + + def test(self): + # Set trigger on Load access fault + self.gdb.command("monitor riscv etrigger set m 0x20") + # Set fox to a null pointer so we'll get a load access exception later. + self.gdb.p("fox=(char*)0") + output = self.gdb.c() + # We should not be at handle_trap + assertNotIn("handle_trap", output) + # Instead, we should have hit a breakpoint at trap_entry, which is the + # actual exception handler. + assertIn("breakpoint", output) + assertIn("trap_entry", self.gdb.where()) parsed = None def main(): diff --git a/debug/programs/debug.c b/debug/programs/debug.c index 641aa4e..a5693a5 100644 --- a/debug/programs/debug.c +++ b/debug/programs/debug.c @@ -53,7 +53,7 @@ int main() volatile int i = 0; int j = 0; - char fox[] = "The quick brown fox jumps of the lazy dog."; + char *fox = "The quick brown fox jumps of the lazy dog."; unsigned int checksum = 0; volatile uint32_t i32 = 0xdeadbeef; volatile uint64_t i64 = 0x1122334455667788; -- cgit v1.1