2 * Stack trace management functions
4 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
6 #include <linux/sched.h>
7 #include <linux/stacktrace.h>
8 #include <linux/module.h>
9 #include <asm/stacktrace.h>
11 static void save_stack_warning(void *data, char *msg)
16 save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
20 static int save_stack_stack(void *data, char *name)
25 static void save_stack_address(void *data, unsigned long addr)
27 struct stack_trace *trace = (struct stack_trace *)data;
28 if (trace->skip > 0) {
32 if (trace->nr_entries < trace->max_entries)
33 trace->entries[trace->nr_entries++] = addr;
36 static struct stacktrace_ops save_stack_ops = {
37 .warning = save_stack_warning,
38 .warning_symbol = save_stack_warning_symbol,
39 .stack = save_stack_stack,
40 .address = save_stack_address,
44 * Save stack-backtrace addresses into a stack_trace buffer.
46 void save_stack_trace(struct stack_trace *trace)
48 dump_trace(current, NULL, NULL, &save_stack_ops, trace);
49 if (trace->nr_entries < trace->max_entries)
50 trace->entries[trace->nr_entries++] = ULONG_MAX;
52 EXPORT_SYMBOL(save_stack_trace);