Commit | Line | Data |
---|---|---|
21b32bbf | 1 | /* |
21b32bbf IM |
2 | * Stack trace management functions |
3 | * | |
4 | * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> | |
5 | */ | |
6 | #include <linux/sched.h> | |
7 | #include <linux/stacktrace.h> | |
c0b766f1 AK |
8 | #include <linux/module.h> |
9 | #include <asm/stacktrace.h> | |
21b32bbf | 10 | |
c0b766f1 | 11 | static void save_stack_warning(void *data, char *msg) |
21b32bbf | 12 | { |
21b32bbf IM |
13 | } |
14 | ||
c0b766f1 AK |
15 | static void |
16 | save_stack_warning_symbol(void *data, char *msg, unsigned long symbol) | |
21b32bbf | 17 | { |
21b32bbf IM |
18 | } |
19 | ||
c0b766f1 | 20 | static int save_stack_stack(void *data, char *name) |
21b32bbf | 21 | { |
ab1b6f03 | 22 | return -1; |
c0b766f1 | 23 | } |
21b32bbf | 24 | |
c0b766f1 AK |
25 | static void save_stack_address(void *data, unsigned long addr) |
26 | { | |
27 | struct stack_trace *trace = (struct stack_trace *)data; | |
28 | if (trace->skip > 0) { | |
29 | trace->skip--; | |
30 | return; | |
21b32bbf | 31 | } |
006e84ee | 32 | if (trace->nr_entries < trace->max_entries) |
c0b766f1 | 33 | trace->entries[trace->nr_entries++] = addr; |
21b32bbf IM |
34 | } |
35 | ||
c0b766f1 AK |
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, | |
41 | }; | |
21b32bbf IM |
42 | |
43 | /* | |
44 | * Save stack-backtrace addresses into a stack_trace buffer. | |
21b32bbf | 45 | */ |
ab1b6f03 | 46 | void save_stack_trace(struct stack_trace *trace) |
21b32bbf | 47 | { |
ab1b6f03 | 48 | dump_trace(current, NULL, NULL, &save_stack_ops, trace); |
006e84ee CM |
49 | if (trace->nr_entries < trace->max_entries) |
50 | trace->entries[trace->nr_entries++] = ULONG_MAX; | |
21b32bbf | 51 | } |
c0b766f1 | 52 | EXPORT_SYMBOL(save_stack_trace); |