blob: 54d1f61aa00778c22cb55552e5fc18197e12d3b8 [file] [log] [blame]
Paul Mundtafbfb522006-12-04 18:17:28 +09001/*
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>
Heiko Carstens8b95d912008-07-14 23:32:32 +020015#include <linux/module.h>
Paul Mundtafbfb522006-12-04 18:17:28 +090016#include <asm/ptrace.h>
17
18/*
19 * Save stack-backtrace addresses into a stack_trace buffer.
20 */
Paul Mundta3cf4ea82007-05-09 18:55:14 +090021void save_stack_trace(struct stack_trace *trace)
Paul Mundtafbfb522006-12-04 18:17:28 +090022{
Christoph Hellwigab1b6f02007-05-08 00:23:29 -070023 unsigned long *sp = (unsigned long *)current_stack_pointer;
Paul Mundtafbfb522006-12-04 18:17:28 +090024
25 while (!kstack_end(sp)) {
26 unsigned long addr = *sp++;
27
28 if (__kernel_text_address(addr)) {
29 if (trace->skip > 0)
30 trace->skip--;
31 else
32 trace->entries[trace->nr_entries++] = addr;
33 if (trace->nr_entries >= trace->max_entries)
34 break;
35 }
36 }
37}
Ingo Molnar7b4c9502008-07-03 09:17:55 +020038EXPORT_SYMBOL_GPL(save_stack_trace);