save_stack_trace_tsk and struct stack_trace is no longer available in Linux 5.2+

▼魔方 西西 提交于 2021-01-27 05:42:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!