1c9e208faSJiri Olsa // SPDX-License-Identifier: GPL-2.0 2c9e208faSJiri Olsa // Copyright (c) 2018 Facebook 3c9e208faSJiri Olsa 4c9e208faSJiri Olsa #include <vmlinux.h> 5c9e208faSJiri Olsa #include <bpf/bpf_helpers.h> 6c9e208faSJiri Olsa #include <bpf/bpf_tracing.h> 7c9e208faSJiri Olsa 8c9e208faSJiri Olsa #ifndef PERF_MAX_STACK_DEPTH 9c9e208faSJiri Olsa #define PERF_MAX_STACK_DEPTH 127 10c9e208faSJiri Olsa #endif 11c9e208faSJiri Olsa 12c9e208faSJiri Olsa typedef __u64 stack_trace_t[PERF_MAX_STACK_DEPTH]; 13c9e208faSJiri Olsa 14c9e208faSJiri Olsa struct { 15c9e208faSJiri Olsa __uint(type, BPF_MAP_TYPE_STACK_TRACE); 16c9e208faSJiri Olsa __uint(max_entries, 16384); 17c9e208faSJiri Olsa __type(key, __u32); 18c9e208faSJiri Olsa __type(value, stack_trace_t); 19c9e208faSJiri Olsa } stackmap SEC(".maps"); 20c9e208faSJiri Olsa 21c9e208faSJiri Olsa extern bool CONFIG_UNWINDER_ORC __kconfig __weak; 22c9e208faSJiri Olsa 23c9e208faSJiri Olsa /* 24c9e208faSJiri Olsa * This function is here to have CONFIG_UNWINDER_ORC 25c9e208faSJiri Olsa * used and added to object BTF. 26c9e208faSJiri Olsa */ 27c9e208faSJiri Olsa int unused(void) 28c9e208faSJiri Olsa { 29c9e208faSJiri Olsa return CONFIG_UNWINDER_ORC ? 0 : 1; 30c9e208faSJiri Olsa } 31c9e208faSJiri Olsa 32c9e208faSJiri Olsa __u32 stack_key; 33c9e208faSJiri Olsa 34c9e208faSJiri Olsa SEC("kprobe.multi") 35c9e208faSJiri Olsa int kprobe_multi_test(struct pt_regs *ctx) 36c9e208faSJiri Olsa { 37c9e208faSJiri Olsa stack_key = bpf_get_stackid(ctx, &stackmap, 0); 38c9e208faSJiri Olsa return 0; 39c9e208faSJiri Olsa } 40c9e208faSJiri Olsa 41*3490d299SJiri Olsa SEC("raw_tp/bpf_testmod_test_read") 42*3490d299SJiri Olsa int rawtp_test(void *ctx) 43*3490d299SJiri Olsa { 44*3490d299SJiri Olsa /* Skip ebpf program entry in the stack. */ 45*3490d299SJiri Olsa stack_key = bpf_get_stackid(ctx, &stackmap, 0); 46*3490d299SJiri Olsa return 0; 47*3490d299SJiri Olsa } 48*3490d299SJiri Olsa 49c9e208faSJiri Olsa char _license[] SEC("license") = "GPL"; 50