uml: tidy process.c
[pv_ops_mirror.git] / arch / sh / kernel / stacktrace.c
blob0d5268afe80f35fff78b48cd2c559225c4fedb4a
1 /*
2 * arch/sh/kernel/stacktrace.c
4 * Stack trace management functions
6 * Copyright (C) 2006 Paul Mundt
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
12 #include <linux/sched.h>
13 #include <linux/stacktrace.h>
14 #include <linux/thread_info.h>
15 #include <asm/ptrace.h>
18 * Save stack-backtrace addresses into a stack_trace buffer.
20 void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
22 unsigned long *sp;
24 if (!task)
25 task = current;
26 if (task == current)
27 sp = (unsigned long *)current_stack_pointer;
28 else
29 sp = (unsigned long *)task->thread.sp;
31 while (!kstack_end(sp)) {
32 unsigned long addr = *sp++;
34 if (__kernel_text_address(addr)) {
35 if (trace->skip > 0)
36 trace->skip--;
37 else
38 trace->entries[trace->nr_entries++] = addr;
39 if (trace->nr_entries >= trace->max_entries)
40 break;