Decode a RISC-V trap cause
decode_riscv_trapDecodes the mcause value of a 32-bit RISC-V core into the exception or interrupt it names, and says what mepc and mtval hold for that cause and what to check. Use it when a RISC-V microcontroller, such as an ESP32-C3 or a GD32V, stops in its trap handler and the register values are known. It covers the causes of the RISC-V privileged specification, not vendor-specific ones.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"mcause": "<mcause>"
},
"name": "decode_riscv_trap"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mepc | No | The mepc register: the program counter that the core saved when it took the trap. | |
| mtval | No | The mtval register: the faulting address or instruction, depending on the cause. | |
| mcause | Yes | The mcause register. Bit 31 set means an interrupt. |