diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2008-01-30 07:33:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:33:07 -0500 |
commit | e9d4efddbec3d852d435b370b9c40ff7ac24afe6 (patch) | |
tree | 5cfb9de18cb756cdde51a529c6aabbfaae3a13c0 /arch | |
parent | bc850d6b374fffd08336996f4b4d3bbd6bf427f6 (diff) |
x86: improve the 32 bit Frame Pointer backtracer to also use the traditional backtrace
The 32 bit Frame Pointer backtracer code checks if the EBP is valid
to do a backtrace; however currently on a failure it just gives up
and prints nothing. That's not very nice; we can do better and still
print a decent backtrace.
This patch changes the backtracer to use the regular backtracing algorithm
at the same time as the EBP backtracer; the EBP backtracer is basically
used to figure out which part of the backtrace are reliable vs those
which are likely to be noise.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/traps_32.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c index 8ef8a9ddfec6..959d40edecd5 100644 --- a/arch/x86/kernel/traps_32.c +++ b/arch/x86/kernel/traps_32.c | |||
@@ -118,36 +118,32 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo, | |||
118 | unsigned long *stack, unsigned long bp, | 118 | unsigned long *stack, unsigned long bp, |
119 | const struct stacktrace_ops *ops, void *data) | 119 | const struct stacktrace_ops *ops, void *data) |
120 | { | 120 | { |
121 | #ifdef CONFIG_FRAME_POINTER | ||
122 | struct stack_frame *frame = (struct stack_frame *)bp; | 121 | struct stack_frame *frame = (struct stack_frame *)bp; |
123 | while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) { | ||
124 | struct stack_frame *next; | ||
125 | unsigned long addr; | ||
126 | 122 | ||
127 | addr = frame->return_address; | 123 | /* |
128 | if (__kernel_text_address(addr)) | 124 | * if EBP is "deeper" into the stack than the actual stack pointer, |
129 | ops->address(data, addr, 1); | 125 | * we need to rewind the stack pointer a little to start at the |
130 | /* | 126 | * first stack frame, but only if EBP is in this stack frame. |
131 | * break out of recursive entries (such as | 127 | */ |
132 | * end_of_stack_stop_unwind_function). Also, | 128 | if (stack > (unsigned long *) bp |
133 | * we can never allow a frame pointer to | 129 | && valid_stack_ptr(tinfo, frame, sizeof(*frame))) |
134 | * move downwards! | 130 | stack = (unsigned long *) bp; |
135 | */ | 131 | |
136 | next = frame->next_frame; | ||
137 | bp = (unsigned long) next; | ||
138 | if (next <= frame) | ||
139 | break; | ||
140 | frame = next; | ||
141 | } | ||
142 | #else | ||
143 | while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) { | 132 | while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) { |
144 | unsigned long addr; | 133 | unsigned long addr; |
145 | 134 | ||
146 | addr = *stack++; | 135 | addr = *stack; |
147 | if (__kernel_text_address(addr)) | 136 | if (__kernel_text_address(addr)) { |
148 | ops->address(data, addr, 1); | 137 | if ((unsigned long) stack == bp + 4) { |
138 | ops->address(data, addr, 1); | ||
139 | frame = frame->next_frame; | ||
140 | bp = (unsigned long) frame; | ||
141 | } else { | ||
142 | ops->address(data, addr, 0); | ||
143 | } | ||
144 | } | ||
145 | stack++; | ||
149 | } | 146 | } |
150 | #endif | ||
151 | return bp; | 147 | return bp; |
152 | } | 148 | } |
153 | 149 | ||