Commit 8637c09901049f061b94f684915d4f18ecf91d79
Committed by
Linus Torvalds
1 parent
f0a5c315eb
Exists in
master
and in
4 other branches
[PATCH] lockdep: stacktrace subsystem, core
Framework to generate and save stacktraces quickly, without printing anything to the console. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 4 changed files with 50 additions and 1 deletions Side-by-side Diff
include/linux/stacktrace.h
1 | +#ifndef __LINUX_STACKTRACE_H | |
2 | +#define __LINUX_STACKTRACE_H | |
3 | + | |
4 | +#ifdef CONFIG_STACKTRACE | |
5 | +struct stack_trace { | |
6 | + unsigned int nr_entries, max_entries; | |
7 | + unsigned long *entries; | |
8 | +}; | |
9 | + | |
10 | +extern void save_stack_trace(struct stack_trace *trace, | |
11 | + struct task_struct *task, int all_contexts, | |
12 | + unsigned int skip); | |
13 | + | |
14 | +extern void print_stack_trace(struct stack_trace *trace, int spaces); | |
15 | +#else | |
16 | +# define save_stack_trace(trace, task, all, skip) do { } while (0) | |
17 | +# define print_stack_trace(trace) do { } while (0) | |
18 | +#endif | |
19 | + | |
20 | +#endif |
kernel/Makefile
kernel/stacktrace.c
1 | +/* | |
2 | + * kernel/stacktrace.c | |
3 | + * | |
4 | + * Stack trace management functions | |
5 | + * | |
6 | + * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> | |
7 | + */ | |
8 | +#include <linux/sched.h> | |
9 | +#include <linux/kallsyms.h> | |
10 | +#include <linux/stacktrace.h> | |
11 | + | |
12 | +void print_stack_trace(struct stack_trace *trace, int spaces) | |
13 | +{ | |
14 | + int i, j; | |
15 | + | |
16 | + for (i = 0; i < trace->nr_entries; i++) { | |
17 | + unsigned long ip = trace->entries[i]; | |
18 | + | |
19 | + for (j = 0; j < spaces + 1; j++) | |
20 | + printk(" "); | |
21 | + print_ip_sym(ip); | |
22 | + } | |
23 | +} |
lib/Kconfig.debug
... | ... | @@ -107,7 +107,7 @@ |
107 | 107 | |
108 | 108 | config DEBUG_PREEMPT |
109 | 109 | bool "Debug preemptible kernel" |
110 | - depends on DEBUG_KERNEL && PREEMPT | |
110 | + depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT | |
111 | 111 | default y |
112 | 112 | help |
113 | 113 | If you say Y here then the kernel will use a debug variant of the |
... | ... | @@ -148,6 +148,10 @@ |
148 | 148 | help |
149 | 149 | If you say Y here, various routines which may sleep will become very |
150 | 150 | noisy if they are called with a spinlock held. |
151 | + | |
152 | +config STACKTRACE | |
153 | + bool | |
154 | + depends on STACKTRACE_SUPPORT | |
151 | 155 | |
152 | 156 | config DEBUG_KOBJECT |
153 | 157 | bool "kobject debugging" |