Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cddl/dev/dtrace/riscv/dtrace_isa.c
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, | ||||
__asm __volatile("mv %0, sp" : "=&r" (sp)); | __asm __volatile("mv %0, sp" : "=&r" (sp)); | ||||
state.fp = (uintptr_t)__builtin_frame_address(0); | state.fp = (uintptr_t)__builtin_frame_address(0); | ||||
state.sp = sp; | state.sp = sp; | ||||
state.pc = (uintptr_t)dtrace_getpcstack; | state.pc = (uintptr_t)dtrace_getpcstack; | ||||
while (depth < pcstack_limit) { | while (depth < pcstack_limit) { | ||||
if (unwind_frame(&state)) | if (!unwind_frame(curthread, &state)) | ||||
break; | break; | ||||
if (!INKERNEL(state.pc) || !INKERNEL(state.fp)) | if (!INKERNEL(state.pc) || !INKERNEL(state.fp)) | ||||
break; | break; | ||||
/* | /* | ||||
* NB: Unlike some other architectures, we don't need to | * NB: Unlike some other architectures, we don't need to | ||||
* explicitly insert cpu_dtrace_caller as it appears in the | * explicitly insert cpu_dtrace_caller as it appears in the | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
dtrace_getstackdepth(int aframes) | dtrace_getstackdepth(int aframes) | ||||
{ | { | ||||
struct unwind_state state; | struct unwind_state state; | ||||
int scp_offset; | int scp_offset; | ||||
register_t sp; | register_t sp; | ||||
int depth; | int depth; | ||||
int done; | bool done; | ||||
depth = 1; | depth = 1; | ||||
done = 0; | done = false; | ||||
__asm __volatile("mv %0, sp" : "=&r" (sp)); | __asm __volatile("mv %0, sp" : "=&r" (sp)); | ||||
state.fp = (uintptr_t)__builtin_frame_address(0); | state.fp = (uintptr_t)__builtin_frame_address(0); | ||||
state.sp = sp; | state.sp = sp; | ||||
state.pc = (uintptr_t)dtrace_getstackdepth; | state.pc = (uintptr_t)dtrace_getstackdepth; | ||||
do { | do { | ||||
done = unwind_frame(&state); | done = !unwind_frame(curthread, &state); | ||||
if (!INKERNEL(state.pc) || !INKERNEL(state.fp)) | if (!INKERNEL(state.pc) || !INKERNEL(state.fp)) | ||||
break; | break; | ||||
depth++; | depth++; | ||||
} while (!done); | } while (!done); | ||||
if (depth < aframes) | if (depth < aframes) | ||||
return (0); | return (0); | ||||
else | else | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |