Paul Mundt | afbfb52 | 2006-12-04 18:17:28 +0900 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/kernel/stacktrace.c |
| 3 | * |
| 4 | * Stack trace management functions |
| 5 | * |
| 6 | * Copyright (C) 2006 Paul Mundt |
| 7 | * |
| 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. |
| 11 | */ |
| 12 | #include <linux/sched.h> |
| 13 | #include <linux/stacktrace.h> |
| 14 | #include <linux/thread_info.h> |
| 15 | #include <asm/ptrace.h> |
| 16 | |
| 17 | /* |
| 18 | * Save stack-backtrace addresses into a stack_trace buffer. |
| 19 | */ |
Paul Mundt | a3cf4ea8 | 2007-05-09 18:55:14 +0900 | [diff] [blame] | 20 | void save_stack_trace(struct stack_trace *trace) |
Paul Mundt | afbfb52 | 2006-12-04 18:17:28 +0900 | [diff] [blame] | 21 | { |
Christoph Hellwig | ab1b6f0 | 2007-05-08 00:23:29 -0700 | [diff] [blame] | 22 | unsigned long *sp = (unsigned long *)current_stack_pointer; |
Paul Mundt | afbfb52 | 2006-12-04 18:17:28 +0900 | [diff] [blame] | 23 | |
| 24 | while (!kstack_end(sp)) { |
| 25 | unsigned long addr = *sp++; |
| 26 | |
| 27 | if (__kernel_text_address(addr)) { |
| 28 | if (trace->skip > 0) |
| 29 | trace->skip--; |
| 30 | else |
| 31 | trace->entries[trace->nr_entries++] = addr; |
| 32 | if (trace->nr_entries >= trace->max_entries) |
| 33 | break; |
| 34 | } |
| 35 | } |
| 36 | } |