1 // SPDX-License-Identifier: GPL-2.0
8 #include "tests/tests.h"
10 #define STACK_SIZE 8192
12 static int sample_ustack(struct perf_sample *sample,
13 struct thread *thread, u64 *regs)
15 struct stack_dump *stack = &sample->user_stack;
20 buf = malloc(STACK_SIZE);
22 pr_debug("failed to allocate sample uregs data\n");
26 sp = (unsigned long) regs[PERF_REG_ARM64_SP];
28 map = map_groups__find(thread->mg, (u64)sp);
30 pr_debug("failed to get stack map\n");
35 stack_size = map->end - sp;
36 stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
38 memcpy(buf, (void *) sp, stack_size);
39 stack->data = (char *) buf;
40 stack->size = stack_size;
44 int test__arch_unwind_sample(struct perf_sample *sample,
45 struct thread *thread)
47 struct regs_dump *regs = &sample->user_regs;
50 buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
52 pr_debug("failed to allocate sample uregs data\n");
57 regs->abi = PERF_SAMPLE_REGS_ABI;
59 regs->mask = PERF_REGS_MASK;
61 return sample_ustack(sample, thread, buf);