linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Make the 32 bit Frame Pointer backtracer fall back to traditional
@ 2008-01-10  6:05 Arjan van de Ven
  2008-01-10  6:21 ` Harvey Harrison
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Arjan van de Ven @ 2008-01-10  6:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, akpm, torvalds


Subject: Make the 32 bit Frame Pointer backtracer fall back to traditional
From: Arjan van de Ven <arjan@linux.intel.com>

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 fall back to the non-framepointer
backtracer if the EBP value isn't within the expected range; so on weird
stack corruption cases we get at least something out...

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>

---
 arch/x86/kernel/traps_32.c |   43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

Index: linux-2.6.24-rc7/arch/x86/kernel/traps_32.c
===================================================================
--- linux-2.6.24-rc7.orig/arch/x86/kernel/traps_32.c
+++ linux-2.6.24-rc7/arch/x86/kernel/traps_32.c
@@ -119,26 +119,28 @@ static inline unsigned long print_contex
 {
 #ifdef	CONFIG_FRAME_POINTER
 	struct stack_frame *frame = (struct stack_frame *)ebp;
-	while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) {
-		struct stack_frame *next;
-		unsigned long addr;
-
-		addr = frame->return_address;
-		if (__kernel_text_address(addr))
-			ops->address(data, addr);
-		/*
-		 * break out of recursive entries (such as
-		 * end_of_stack_stop_unwind_function). Also,
-		 * we can never allow a frame pointer to
-		 * move downwards!
-		 */
-		next = frame->next_frame;
-		ebp = (unsigned long) next;
-		if (next <= frame)
-			break;
-		frame = next;
-	}
-#else
+	if (valid_stack_ptr(tinfo, frame, sizeof(*frame)))
+		while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) {
+			struct stack_frame *next;
+			unsigned long addr;
+
+			addr = frame->return_address;
+			if (__kernel_text_address(addr))
+				ops->address(data, addr);
+			/*
+			 * break out of recursive entries (such as
+			 * end_of_stack_stop_unwind_function). Also,
+			 * we can never allow a frame pointer to
+			 * move downwards!
+			 */
+			next = frame->next_frame;
+			ebp = (unsigned long) next;
+			if (next <= frame)
+				break;
+			frame = next;
+		}
+	else
+#endif
 	while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) {
 		unsigned long addr;
 
@@ -146,7 +148,6 @@ static inline unsigned long print_contex
 		if (__kernel_text_address(addr))
 			ops->address(data, addr);
 	}
-#endif
 	return ebp;
 }
 

-- 
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-01-11 22:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-10  6:05 Make the 32 bit Frame Pointer backtracer fall back to traditional Arjan van de Ven
2008-01-10  6:21 ` Harvey Harrison
2008-01-10 12:46   ` Ingo Molnar
2008-01-10 15:15     ` Arjan van de Ven
2008-01-10  6:55 ` Ingo Molnar
2008-01-10 16:36 ` Linus Torvalds
2008-01-10 16:49   ` Arjan van de Ven
2008-01-11  4:35   ` Arjan van de Ven
2008-01-11 11:54     ` Olaf Dietsche
2008-01-11 19:41     ` Linus Torvalds
2008-01-11 19:56       ` Arjan van de Ven
2008-01-11 22:01       ` Theodore Tso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).