1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/ptrace.h>
6 int kstack_depth_to_print = 48;
8 void show_trace(unsigned long *stack)
10 unsigned long *endstack;
14 pr_info("Call Trace:\n");
15 addr = (unsigned long)stack + THREAD_SIZE - 1;
16 endstack = (unsigned long *)(addr & -THREAD_SIZE);
18 while (stack + 1 <= endstack) {
21 * If the address is either in the text segment of the
22 * kernel, or in the region which contains vmalloc'ed
23 * memory, it *may* be the address of a calling
24 * routine; if so, print it so that someone tracing
25 * down the cause of the crash will be able to figure
26 * out the call path that was taken.
28 if (__kernel_text_address(addr)) {
29 #ifndef CONFIG_KALLSYMS
33 pr_cont(" [<%08lx>] %pS\n", addr, (void *)addr);
40 void show_stack(struct task_struct *task, unsigned long *stack)
43 unsigned long *endstack;
48 stack = (unsigned long *)task->thread.esp0;
50 stack = (unsigned long *)&stack;
52 endstack = (unsigned long *)
53 (((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
55 pr_info("Stack from %08lx:", (unsigned long)stack);
57 for (i = 0; i < kstack_depth_to_print; i++) {
62 pr_cont(" %08lx", *p++);