GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / powerpc / kernel / stacktrace.c
blobb0dbb1daa4df1a6ea309b9b79f228834c888f9cc
1 /*
2 * Stack trace utility
4 * Copyright 2008 Christoph Hellwig, IBM Corp.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
13 #include <linux/module.h>
14 #include <linux/sched.h>
15 #include <linux/stacktrace.h>
16 #include <asm/ptrace.h>
17 #include <asm/processor.h>
20 * Save stack-backtrace addresses into a stack_trace buffer.
22 static void save_context_stack(struct stack_trace *trace, unsigned long sp,
23 struct task_struct *tsk, int savesched)
25 for (;;) {
26 unsigned long *stack = (unsigned long *) sp;
27 unsigned long newsp, ip;
29 if (!validate_sp(sp, tsk, STACK_FRAME_OVERHEAD))
30 return;
32 newsp = stack[0];
33 ip = stack[STACK_FRAME_LR_SAVE];
35 if (savesched || !in_sched_functions(ip)) {
36 if (!trace->skip)
37 trace->entries[trace->nr_entries++] = ip;
38 else
39 trace->skip--;
42 if (trace->nr_entries >= trace->max_entries)
43 return;
45 sp = newsp;
49 void save_stack_trace(struct stack_trace *trace)
51 unsigned long sp;
53 asm("mr %0,1" : "=r" (sp));
55 save_context_stack(trace, sp, current, 1);
57 EXPORT_SYMBOL_GPL(save_stack_trace);
59 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
61 save_context_stack(trace, tsk->thread.ksp, tsk, 0);
63 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);