git: 82283cad12a4 - main - dtrace: Avoid including dtrace_isa.c directly into dtrace.c
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Jul 2024 21:24:55 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=82283cad12a417abfb1469d899b2d7cfb1d38f77 commit 82283cad12a417abfb1469d899b2d7cfb1d38f77 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-07-24 20:10:33 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-07-24 21:24:46 +0000 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 --- sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c | 1 - sys/cddl/dev/dtrace/aarch64/dtrace_isa.c | 3 +++ sys/cddl/dev/dtrace/amd64/dtrace_isa.c | 3 ++- sys/cddl/dev/dtrace/arm/dtrace_isa.c | 1 + sys/cddl/dev/dtrace/i386/dtrace_isa.c | 3 ++- sys/cddl/dev/dtrace/powerpc/dtrace_isa.c | 2 ++ sys/cddl/dev/dtrace/riscv/dtrace_isa.c | 1 + sys/cddl/dev/fbt/x86/fbt_isa.c | 2 +- sys/conf/files.arm | 1 + sys/conf/files.riscv | 1 + sys/modules/dtrace/dtrace/Makefile | 1 + 11 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index ce02676e0dc1..d3e40e96e897 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -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); diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c index 72944e8a5ae2..ff0e068006bd 100644 --- a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c @@ -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 diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c index 0b7162998536..9db5a16190db 100644 --- a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c @@ -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 diff --git a/sys/cddl/dev/dtrace/arm/dtrace_isa.c b/sys/cddl/dev/dtrace/arm/dtrace_isa.c index c3783b77c2d4..ed03e5ca0006 100644 --- a/sys/cddl/dev/dtrace/arm/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/arm/dtrace_isa.c @@ -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> diff --git a/sys/cddl/dev/dtrace/i386/dtrace_isa.c b/sys/cddl/dev/dtrace/i386/dtrace_isa.c index 64c8de2a8d3a..7a30587120ba 100644 --- a/sys/cddl/dev/dtrace/i386/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/i386/dtrace_isa.c @@ -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 diff --git a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c index 7185a01c125d..acde4f0aeab2 100644 --- a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c @@ -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> diff --git a/sys/cddl/dev/dtrace/riscv/dtrace_isa.c b/sys/cddl/dev/dtrace/riscv/dtrace_isa.c index 87f52b809dfa..7a66d93d4ba9 100644 --- a/sys/cddl/dev/dtrace/riscv/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/riscv/dtrace_isa.c @@ -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> diff --git a/sys/cddl/dev/fbt/x86/fbt_isa.c b/sys/cddl/dev/fbt/x86/fbt_isa.c index 387a3f1582c3..ee05d37b383e 100644 --- a/sys/cddl/dev/fbt/x86/fbt_isa.c +++ b/sys/cddl/dev/fbt/x86/fbt_isa.c @@ -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) diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 825680b73165..5ada97ccad30 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -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}" diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index 5b94eb327f93..89fb6f3cbe5a 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -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}" diff --git a/sys/modules/dtrace/dtrace/Makefile b/sys/modules/dtrace/dtrace/Makefile index 765a8477f3f2..472de0ff944b 100644 --- a/sys/modules/dtrace/dtrace/Makefile +++ b/sys/modules/dtrace/dtrace/Makefile @@ -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"