1
2
3
4
5
6
7
8
9
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/perf_event.h>
13#include <linux/percpu.h>
14#include <asm/unwinder.h>
15#include <asm/ptrace.h>
16
17static int callchain_stack(void *data, char *name)
18{
19 return 0;
20}
21
22static void callchain_address(void *data, unsigned long addr, int reliable)
23{
24 struct perf_callchain_entry_ctx *entry = data;
25
26 if (reliable)
27 perf_callchain_store(entry, addr);
28}
29
30static const struct stacktrace_ops callchain_ops = {
31 .stack = callchain_stack,
32 .address = callchain_address,
33};
34
35void
36perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
37{
38 perf_callchain_store(entry, regs->pc);
39
40 unwind_stack(NULL, regs, NULL, &callchain_ops, entry);
41}
42