[Blackfin] arch: Remove the circular buffering mechanism for exceptions
[linux-2.6/mini2440.git] / arch / powerpc / kernel / stacktrace.c
blobe3638eeaaae7e9e1a1d8ad1b41a201ff0e3dcba1
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/sched.h>
14 #include <linux/stacktrace.h>
15 #include <asm/ptrace.h>
16 #include <asm/asm-offsets.h>
19 * Save stack-backtrace addresses into a stack_trace buffer.
21 void save_stack_trace(struct stack_trace *trace)
23 unsigned long sp;
25 asm("mr %0,1" : "=r" (sp));
27 for (;;) {
28 unsigned long *stack = (unsigned long *) sp;
29 unsigned long newsp, ip;
31 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
32 return;
34 newsp = stack[0];
35 ip = stack[STACK_FRAME_LR_SAVE];
37 if (!trace->skip)
38 trace->entries[trace->nr_entries++] = ip;
39 else
40 trace->skip--;
42 if (trace->nr_entries >= trace->max_entries)
43 return;
45 sp = newsp;