aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Horne <mhorne@FreeBSD.org>2023-06-20 14:52:26 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2023-06-20 14:54:14 +0000
commit7756232199adf60343ae0b940e2b27fe363905bc (patch)
tree702f5004f1e6bfbfa2622bef0861f6056f8b6a97
parent474d9290eb9e9f0e636c7f814d0d10ba5147149f (diff)
downloadsrc-7756232199adf60343ae0b940e2b27fe363905bc.tar.gz
src-7756232199adf60343ae0b940e2b27fe363905bc.zip
riscv: improve KTR_TRAP trace entries
For more informative records of exceptions, include key details such as the exception code and stval register contents. Remove the curthread argument as it is redundant (saved with every ktr entry), and the trapframe as it is somewhat meaningless. Add a new KTR_TRAP trace record for interrupts. Reviewed by: markj, jhb MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40584
-rw-r--r--sys/riscv/riscv/intr_machdep.c3
-rw-r--r--sys/riscv/riscv/trap.c8
2 files changed, 7 insertions, 4 deletions
diff --git a/sys/riscv/riscv/intr_machdep.c b/sys/riscv/riscv/intr_machdep.c
index d84f4ea1cb91..1ee2c0984205 100644
--- a/sys/riscv/riscv/intr_machdep.c
+++ b/sys/riscv/riscv/intr_machdep.c
@@ -163,6 +163,9 @@ riscv_cpu_intr(struct trapframe *frame)
active_irq = frame->tf_scause & SCAUSE_CODE;
+ CTR3(KTR_TRAP, "%s: irq=%d, umode=%d", __func__, active_irq,
+ TRAPF_USERMODE(frame));
+
switch (active_irq) {
case IRQ_SOFTWARE_USER:
case IRQ_SOFTWARE_SUPERVISOR:
diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c
index 11ecfa702054..ac481c313e15 100644
--- a/sys/riscv/riscv/trap.c
+++ b/sys/riscv/riscv/trap.c
@@ -291,8 +291,8 @@ do_trap_supervisor(struct trapframe *frame)
return;
#endif
- CTR3(KTR_TRAP, "do_trap_supervisor: curthread: %p, sepc: %lx, frame: %p",
- curthread, frame->tf_sepc, frame);
+ CTR4(KTR_TRAP, "%s: exception=%lu, sepc=%lx, stval=%lx", __func__,
+ exception, frame->tf_sepc, frame->tf_stval);
switch (exception) {
case SCAUSE_LOAD_ACCESS_FAULT:
@@ -365,8 +365,8 @@ do_trap_user(struct trapframe *frame)
}
intr_enable();
- CTR3(KTR_TRAP, "do_trap_user: curthread: %p, sepc: %lx, frame: %p",
- curthread, frame->tf_sepc, frame);
+ CTR4(KTR_TRAP, "%s: exception=%lu, sepc=%lx, stval=%lx", __func__,
+ exception, frame->tf_sepc, frame->tf_stval);
switch (exception) {
case SCAUSE_LOAD_ACCESS_FAULT: