dtrace: Avoid including dtrace_isa.c directly into dtrace.c

This was done in the original DTrace import, presumably because that
made it a bit easier to handle includes.  However, this can cause
dtrace_getpcstack() to be inlined into dtrace_probe(), resulting in a
missing frame in stack traces since dtrace_getpcstack() takes care to
bump "aframes" to account for its own stack frame.

To avoid this, compile dtrace_isa.c separately on all platforms.  Add
requisite includes.

MFC after:	2 weeks
Sponsored by:	Innovate UK
This commit is contained in:
Mark Johnston 2024-07-24 16:10:33 -04:00
parent 1c30cf9509
commit 82283cad12
11 changed files with 15 additions and 4 deletions

View file

@ -18446,7 +18446,6 @@ static struct cdevsw helper_cdevsw = {
#include <dtrace_unload.c>
#include <dtrace_vtime.c>
#include <dtrace_hacks.c>
#include <dtrace_isa.c>
SYSINIT(dtrace_load, SI_SUB_DTRACE, SI_ORDER_FIRST, dtrace_load, NULL);
SYSUNINIT(dtrace_unload, SI_SUB_DTRACE, SI_ORDER_FIRST, dtrace_unload, NULL);

View file

@ -27,6 +27,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dtrace_impl.h>
#include <sys/kernel.h>
#include <sys/stack.h>
#include <sys/pcpu.h>
@ -46,6 +47,8 @@
#include <ddb/ddb.h>
#include <sys/kdb.h>
#include <cddl/dev/dtrace/dtrace_cddl.h>
#include "regset.h"
#define MAX_USTACK_DEPTH 2048

View file

@ -27,6 +27,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dtrace_impl.h>
#include <sys/kernel.h>
#include <sys/stack.h>
#include <sys/pcpu.h>
@ -368,7 +369,7 @@ dtrace_getarg(int arg, int aframes)
for (i = 1; i <= aframes; i++) {
fp = fp->f_frame;
if (P2ROUNDUP(fp->f_retaddr, 16) ==
if (roundup2(fp->f_retaddr, 16) ==
(long)dtrace_invop_callsite) {
/*
* In the case of amd64, we will use the pointer to the

View file

@ -27,6 +27,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dtrace_impl.h>
#include <sys/kernel.h>
#include <sys/stack.h>
#include <sys/pcpu.h>

View file

@ -27,6 +27,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dtrace_impl.h>
#include <sys/kernel.h>
#include <sys/stack.h>
#include <sys/pcpu.h>
@ -428,7 +429,7 @@ dtrace_getarg(int arg, int aframes)
for (i = 1; i <= aframes; i++) {
fp = fp->f_frame;
if (P2ROUNDUP(fp->f_retaddr, 4) ==
if (roundup2(fp->f_retaddr, 4) ==
(long)dtrace_invop_callsite) {
/*
* If we pass through the invalid op handler, we will

View file

@ -29,6 +29,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dtrace_impl.h>
#include <sys/kernel.h>
#include <sys/stack.h>
#include <sys/sysent.h>
@ -37,6 +38,7 @@
#include <machine/frame.h>
#include <machine/md_var.h>
#include <machine/psl.h>
#include <machine/reg.h>
#include <machine/stack.h>
#include <vm/vm.h>

View file

@ -29,6 +29,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/dtrace_impl.h>
#include <sys/kernel.h>
#include <sys/stack.h>
#include <sys/pcpu.h>

View file

@ -54,7 +54,7 @@
#define FBT_PATCHVAL 0xf0
#endif
#define FBT_AFRAMES 2
#define FBT_AFRAMES 3
int
fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t scratch __unused)

View file

@ -76,6 +76,7 @@ arm/arm/unwind.c optional ddb | kdtrace_hooks | stack
arm/arm/vm_machdep.c standard
arm/arm/vfp.c optional vfp
cddl/dev/dtrace/arm/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}"
cddl/dev/dtrace/arm/dtrace_isa.c optional dtrace compile-with "${DTRACE_C}"
cddl/dev/dtrace/arm/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}"
cddl/dev/fbt/arm/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}"

View file

@ -1,4 +1,5 @@
cddl/dev/dtrace/riscv/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}"
cddl/dev/dtrace/riscv/dtrace_isa.c optional dtrace compile-with "${DTRACE_C}"
cddl/dev/dtrace/riscv/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}"
cddl/dev/dtrace/riscv/instr_size.c optional dtrace compile-with "${DTRACE_C}"
cddl/dev/fbt/riscv/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}"

View file

@ -12,6 +12,7 @@ KMOD= dtrace
SRCS= dtrace.c \
dtrace_xoroshiro128_plus.c \
dtrace_asm.S \
dtrace_isa.c \
dtrace_subr.c
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"