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

(cherry picked from commit 7d35b38972)
This commit is contained in:
Mark Johnston 2024-01-07 11:35:06 -05:00
parent 9895c3a227
commit 6f2a87c6f1

View file

@ -58,6 +58,8 @@
#include <sys/dtrace.h>
#include <sys/dtrace_bsd.h>
#include <cddl/dev/dtrace/dtrace_cddl.h>
#define PROF_NAMELEN 15
#define PROF_PROFILE 0
@ -246,12 +248,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