From 7d35b389729ef5a3efcac75ad265139ada3f8e69 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Sun, 7 Jan 2024 11:35:06 -0500 Subject: [PATCH] dtrace/profile: Set t_dtrace_trapframe for profile probes profile provider probes fire in the context of a timer interrupt. Thus, the "regs" action can make use of the interrupt trap frame to get register values when the interrupt happened in kernel mode. Make that trap frame available when possible so that "regs" works more or less as it already does with the fbt and kinst providers. MFC after: 1 week --- sys/cddl/dev/profile/profile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/cddl/dev/profile/profile.c b/sys/cddl/dev/profile/profile.c index 42753393a33..677c7543795 100644 --- a/sys/cddl/dev/profile/profile.c +++ b/sys/cddl/dev/profile/profile.c @@ -57,6 +57,8 @@ #include #include +#include + #define PROF_NAMELEN 15 #define PROF_PROFILE 0 @@ -245,12 +247,15 @@ profile_probe(profile_probe_t *prof, hrtime_t late) if (frame != NULL) { if (TRAPF_USERMODE(frame)) upc = TRAPF_PC(frame); - else + else { pc = TRAPF_PC(frame); + td->t_dtrace_trapframe = frame; + } } else if (TD_IS_IDLETHREAD(td)) pc = (uintfptr_t)&cpu_idle; dtrace_probe(prof->prof_id, pc, upc, late, 0, 0); + td->t_dtrace_trapframe = NULL; } static void