2 * arch/x86_64/kernel/stacktrace.c
4 * Stack trace management functions
6 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
8 #include <linux/sched.h>
9 #include <linux/stacktrace.h>
10 #include <linux/module.h>
11 #include <asm/stacktrace.h>
13 static void save_stack_warning(void *data, char *msg)
18 save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
22 static int save_stack_stack(void *data, char *name)
24 struct stack_trace *trace = (struct stack_trace *)data;
25 return trace->all_contexts ? 0 : -1;
28 static void save_stack_address(void *data, unsigned long addr)
30 struct stack_trace *trace = (struct stack_trace *)data;
31 if (trace->skip > 0) {
35 if (trace->nr_entries < trace->max_entries)
36 trace->entries[trace->nr_entries++] = addr;
39 static struct stacktrace_ops save_stack_ops = {
40 .warning = save_stack_warning,
41 .warning_symbol = save_stack_warning_symbol,
42 .stack = save_stack_stack,
43 .address = save_stack_address,
47 * Save stack-backtrace addresses into a stack_trace buffer.
49 void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
51 dump_trace(task, NULL, NULL, &save_stack_ops, trace);
52 if (trace->nr_entries < trace->max_entries)
53 trace->entries[trace->nr_entries++] = ULONG_MAX;
55 EXPORT_SYMBOL(save_stack_trace);