From 23a30cfe0abc1f380ab17ad1134beb4d38564334 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 17:07:32 +0000 Subject: [PATCH 1/2] Initial plan From 13fdfeb1e766819fe7067e46d2117386c2362f22 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Mar 2026 17:13:29 +0000 Subject: [PATCH 2/2] feat: Handle RISC-V MCAUSE interrupt causes (bit 31) Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com> --- monitor/filter_exception_decoder.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/monitor/filter_exception_decoder.py b/monitor/filter_exception_decoder.py index ce5d73c26..280531c65 100644 --- a/monitor/filter_exception_decoder.py +++ b/monitor/filter_exception_decoder.py @@ -237,6 +237,17 @@ class Esp32ExceptionDecoder(DeviceMonitorFilterBase): 0xf: "Store/AMO page fault", }) + # Standard RISC-V interrupt causes (MCAUSE with bit 31 set). + # Lower 31 bits of MCAUSE identify the interrupt source. + RISCV_INTERRUPT_CAUSES = types.MappingProxyType({ + 1: "Supervisor software interrupt", + 3: "Machine software interrupt", + 5: "Supervisor timer interrupt", + 7: "Machine timer interrupt", + 9: "Supervisor external interrupt", + 11: "Machine external interrupt", + }) + NON_CODE_REGISTERS = frozenset({ "EXCVADDR", "MTVAL", @@ -543,7 +554,17 @@ def get_xtensa_exception(self, code): return None def get_riscv_exception(self, code): - """Return the human-readable name of a RISC-V MCAUSE value, or None.""" + """Return a human-readable description for a RISC-V MCAUSE value. + + MCAUSE bit 31 distinguishes interrupts (1) from exceptions (0). + Returns a descriptive string, or None if the cause is unknown. + """ + if code & 0x80000000: + cause = code & 0x7FFFFFFF + desc = self.RISCV_INTERRUPT_CAUSES.get(cause) + if desc: + return "Interrupt: " + desc + return "Interrupt (cause %d)" % cause return self.RISCV_EXCEPTIONS.get(code) # -------------------------------------------------------------------------