dtrace: Add a partial implementation of dtrace_getarg() on arm64

For invop providers (i.e., fbt and kinst) we can simply reach into the
invop trapframe to fetch argument registers for arguments 0-7; for
argument 8 and beyond we have to read the value off of the stack.

Reviewed by:	Domagoj Stolfa, avg
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D45649
This commit is contained in:
Mark Johnston 2024-06-20 12:41:01 -04:00
parent 70c712a86d
commit bae00433f0

View file

@ -238,14 +238,37 @@ dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit)
printf("IMPLEMENT ME: %s\n", __func__);
}
/*ARGSUSED*/
uint64_t
dtrace_getarg(int arg, int aframes)
dtrace_getarg(int arg, int aframes __unused)
{
struct trapframe *tf;
printf("IMPLEMENT ME: %s\n", __func__);
/*
* We only handle invop providers here.
*/
if ((tf = curthread->t_dtrace_trapframe) == NULL) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
return (0);
} else if (arg < 8) {
return (tf->tf_x[arg]);
} else {
uintptr_t p;
uint64_t val;
return (0);
p = (tf->tf_sp + (arg - 8) * sizeof(uint64_t));
if ((p & 7) != 0) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADALIGN);
cpu_core[curcpu].cpuc_dtrace_illval = p;
return (0);
}
if (!kstack_contains(curthread, p, sizeof(uint64_t))) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[curcpu].cpuc_dtrace_illval = p;
return (0);
}
memcpy(&val, (void *)p, sizeof(uint64_t));
return (val);
}
}
int