dtrace: expose dtrace_instr_size() to userland and implement it for riscv
dtrace_instr_size() is needed by the forthcoming RISC-V port of kinst, as well as by libdtrace in D38825 for both amd64 and RISC-V. Reviewed by: markj, mhorne MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39489
This commit is contained in:
parent
1a149d65ba
commit
080e56a6c9
@ -122,10 +122,14 @@ CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
|
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
|
||||||
SRCS+= dis_tables.c
|
SRCS+= dis_tables.c instr_size.c
|
||||||
DSRCS+= regs_x86.d
|
DSRCS+= regs_x86.d
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
.if ${MACHINE_CPUARCH} == "riscv"
|
||||||
|
SRCS+= instr_size.c
|
||||||
|
.endif
|
||||||
|
|
||||||
YFLAGS+=-d
|
YFLAGS+=-d
|
||||||
|
|
||||||
LIBADD= ctf elf proc pthread rtld_db
|
LIBADD= ctf elf proc pthread rtld_db
|
||||||
|
@ -2399,7 +2399,6 @@ extern void dtrace_safe_synchronous_signal(void);
|
|||||||
extern int dtrace_mach_aframes(void);
|
extern int dtrace_mach_aframes(void);
|
||||||
|
|
||||||
#if defined(__i386) || defined(__amd64)
|
#if defined(__i386) || defined(__amd64)
|
||||||
extern int dtrace_instr_size(uint8_t *instr);
|
|
||||||
extern int dtrace_instr_size_isa(uint8_t *, model_t, int *);
|
extern int dtrace_instr_size_isa(uint8_t *, model_t, int *);
|
||||||
extern void dtrace_invop_callsite(void);
|
extern void dtrace_invop_callsite(void);
|
||||||
#endif
|
#endif
|
||||||
@ -2428,6 +2427,10 @@ extern void dtrace_helpers_destroy(proc_t *);
|
|||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
#if defined(__i386) || defined(__amd64) || defined (__riscv)
|
||||||
|
extern int dtrace_instr_size(uint8_t *instr);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _ASM */
|
#endif /* _ASM */
|
||||||
|
|
||||||
#if defined(__i386) || defined(__amd64)
|
#if defined(__i386) || defined(__amd64)
|
||||||
|
22
sys/cddl/dev/dtrace/riscv/instr_size.c
Normal file
22
sys/cddl/dev/dtrace/riscv/instr_size.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: CDDL 1.0
|
||||||
|
*
|
||||||
|
* Copyright 2023 Christos Margiolis <christos@FreeBSD.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/dtrace.h>
|
||||||
|
|
||||||
|
#include <machine/riscvreg.h>
|
||||||
|
|
||||||
|
#define RVC_MASK 0x03
|
||||||
|
|
||||||
|
int
|
||||||
|
dtrace_instr_size(uint8_t *instr)
|
||||||
|
{
|
||||||
|
/* Detect compressed instructions. */
|
||||||
|
if ((~(*instr) & RVC_MASK) == 0)
|
||||||
|
return (INSN_SIZE);
|
||||||
|
else
|
||||||
|
return (INSN_C_SIZE);
|
||||||
|
}
|
@ -22,8 +22,12 @@ SRCS+= dis_tables.c \
|
|||||||
instr_size.c
|
instr_size.c
|
||||||
CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/intel \
|
CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/intel \
|
||||||
-I${SYSDIR}/cddl/dev/dtrace/x86
|
-I${SYSDIR}/cddl/dev/dtrace/x86
|
||||||
|
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
.if ${MACHINE_CPUARCH} == "riscv"
|
||||||
|
SRCS+= instr_size.c
|
||||||
|
.endif
|
||||||
|
|
||||||
CFLAGS+= ${OPENZFS_CFLAGS}
|
CFLAGS+= ${OPENZFS_CFLAGS}
|
||||||
|
|
||||||
SRCS+= bus_if.h device_if.h vnode_if.h
|
SRCS+= bus_if.h device_if.h vnode_if.h
|
||||||
|
Loading…
Reference in New Issue
Block a user