1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #include <linux/sched/debug.h>
5 #include <linux/sched/task_stack.h>
6 #include <linux/stacktrace.h>
7 #include <linux/ftrace.h>
9 void save_stack_trace(struct stack_trace
*trace
)
11 save_stack_trace_tsk(current
, trace
);
13 EXPORT_SYMBOL_GPL(save_stack_trace
);
15 void save_stack_trace_tsk(struct task_struct
*tsk
, struct stack_trace
*trace
)
18 int skip
= trace
->skip
;
23 __asm__
__volatile__("\tori\t%0, $fp, #0\n":"=r"(fpn
));
26 fpn
= (unsigned long *)thread_saved_fp(tsk
);
30 while (!kstack_end(fpn
) && !((unsigned long)fpn
& 0x3)
31 && (fpn
>= (unsigned long *)TASK_SIZE
)) {
32 unsigned long lpp
, fpp
;
36 if (!__kernel_text_address(lpp
))
39 lpp
= ftrace_graph_ret_addr(tsk
, &graph_idx
, lpp
, NULL
);
41 if (savesched
|| !in_sched_functions(lpp
)) {
45 trace
->entries
[trace
->nr_entries
++] = lpp
;
46 if (trace
->nr_entries
>= trace
->max_entries
)
50 fpn
= (unsigned long *)fpp
;
53 EXPORT_SYMBOL_GPL(save_stack_trace_tsk
);