问题
In kernel version before 5.2, I use save_stack_trace_tsk to retrieve call stack.
But this method is no longer available in Linux kernel 5.2+, what should I use?
回答1:
This question seemed so tempting so I did some digging here is my findings.
TLDR; stack_trace_save() functions replaced by arch_stack_walk() interfaces*
this is part of consolidation plan and remove duplicate code. linux commit 214d8ca6ee854 provide common architecture to walking stack trace.
the new interface called arch_stack_walk
.
made it more generic.
this happened on 25th Apr 2019. and as per Kernel release History Wiki
It was last changed in 5.1. in linux commit 3599fe12a125f.
answer your last question
what should I use?
save_stack_trace_tsk -> stack_trace_save_tsk
have different function declaration.
回答2:
Solved by myself:
unsigned long store[64];
int len = stack_trace_save_tsk(current, store, 64, 0);
for (int i = 0; i < len; i ++) {
pr_info("stack at %p\n", store[i]);
}
来源:https://stackoverflow.com/questions/58459803/save-stack-trace-tsk-and-struct-stack-trace-is-no-longer-available-in-linux-5-2