Skip to content

Commit b621d23

Browse files
ekyoooyonghong-song
authored andcommitted
libbpf-tools/wakeuptime: Add offset to kernel stack trace
Include symbol base offset in the kernel stack trace to accurately pinpoint the location of function calls. The offset is commonly used in various debugging tools, including those for the Linux kernel. Before: # ./wakeuptime target: kworker/1:0 ffffffffc0001239 bpf_prog_01d43570d6219d0c_sched_wakeup ffffffffc0001239 bpf_prog_01d43570d6219d0c_sched_wakeup ffffffff8118ca87 bpf_trace_run1 ffffffff810a9804 __traceiter_sched_wakeup ffffffff810b5dcb ttwu_do_activate.isra.141 ffffffff810b5ec6 sched_ttwu_pending ffffffff81132c16 __flush_smp_call_function_queue ffffffff8104ffa3 __sysvec_call_function_single ffffffff81dc72d9 sysvec_call_function_single ffffffff81e00dc6 asm_sysvec_call_function_single waker: test-strlen-abc 77 After: # ./wakeuptime target: kworker/1:0 ffffffffc0001279 bpf_prog_01d43570d6219d0c_sched_wakeup+0xe5 ffffffffc0001279 bpf_prog_01d43570d6219d0c_sched_wakeup+0xe5 ffffffff8118ca87 bpf_trace_run1+0x47 ffffffff810a9804 __traceiter_sched_wakeup+0x24 ffffffff810b5dcb ttwu_do_activate.isra.141+0x11b ffffffff810b5ec6 sched_ttwu_pending+0x96 ffffffff81132c16 __flush_smp_call_function_queue+0x146 ffffffff8104ffa3 __sysvec_call_function_single+0x13 ffffffff81dc72d9 sysvec_call_function_single+0x39 ffffffff81e00dc6 asm_sysvec_call_function_single+0x16 waker: test-strlen-abc 237
1 parent 4578cd9 commit b621d23

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libbpf-tools/wakeuptime.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ static void print_map(struct ksyms *ksyms, struct wakeuptime_bpf *obj)
186186
}
187187
for (i = 0; i < env.perf_max_stack_depth && ip[i]; i++) {
188188
ksym = ksyms__map_addr(ksyms, ip[i]);
189-
printf(" %-16lx %s\n", ip[i], ksym ? ksym->name: "Unknown");
189+
if (ksym)
190+
printf(" %-16lx %s+0x%lx\n", ip[i], ksym->name, ip[i] - ksym->addr);
191+
else
192+
printf(" %-16lx Unknown\n", ip[i]);
190193
}
191194
printf(" %16s %s\n","waker:", next_key.waker);
192195
/*to convert val in microseconds*/

0 commit comments

Comments
 (0)