[PATCH] allow xmon=bt to print a backtrace by default

Olaf Hering olh at suse.de
Wed Jun 1 06:29:31 EST 2005


xmon does not print a backtrace per default. This is bad on systems with
USB keyboard, the most needed info about the crash is lost.
Booting with xmon=bt enables the autobacktrace functionality.

Signed-off-by: Olaf Hering <olh at suse.de>

Index: linux-2.6.11/arch/ppc64/kernel/setup.c
===================================================================
--- linux-2.6.11.orig/arch/ppc64/kernel/setup.c
+++ linux-2.6.11/arch/ppc64/kernel/setup.c
@@ -633,7 +633,7 @@ void __init setup_system(void)
 	 * Initialize xmon
 	 */
 #ifdef CONFIG_XMON_DEFAULT
-	xmon_init();
+	xmon_init(0);
 #endif
 	/*
 	 * Register early console
@@ -1345,12 +1345,14 @@ static int __init early_xmon(char *p)
 {
 	/* ensure xmon is enabled */
 	if (p) {
+		if (strncmp(p, "bt", 2) == 0)
+			xmon_init(1);
 		if (strncmp(p, "on", 2) == 0)
-			xmon_init();
+			xmon_init(0);
 		if (strncmp(p, "early", 5) != 0)
 			return 0;
 	}
-	xmon_init();
+	xmon_init(0);
 	debugger(NULL);
 
 	return 0;
Index: linux-2.6.11/arch/ppc64/xmon/start.c
===================================================================
--- linux-2.6.11.orig/arch/ppc64/xmon/start.c
+++ linux-2.6.11/arch/ppc64/xmon/start.c
@@ -27,7 +27,7 @@ static void sysrq_handle_xmon(int key, s
 			      struct tty_struct *tty) 
 {
 	/* ensure xmon is enabled */
-	xmon_init();
+	xmon_init(0);
 	debugger(pt_regs);
 }
 
Index: linux-2.6.11/arch/ppc64/xmon/xmon.c
===================================================================
--- linux-2.6.11.orig/arch/ppc64/xmon/xmon.c
+++ linux-2.6.11/arch/ppc64/xmon/xmon.c
@@ -47,6 +47,7 @@ static int xmon_gate;
 #endif /* CONFIG_SMP */
 
 static unsigned long in_xmon = 0;
+static unsigned long xmon_auto_backtrace;
 
 static unsigned long adrs;
 static int size = 1;
@@ -131,6 +132,8 @@ static void csum(void);
 static void bootcmds(void);
 void dump_segments(void);
 static void symbol_lookup(void);
+static void xmon_show_stack(unsigned long sp, unsigned long lr,
+			    unsigned long pc);
 static void xmon_print_symbol(unsigned long address, const char *mid,
 			      const char *after);
 static const char *getvecname(unsigned long vec);
@@ -767,6 +770,9 @@ cmds(struct pt_regs *excp)
 
 	last_cmd = NULL;
 	xmon_regs = excp;
+	if (xmon_auto_backtrace)
+		xmon_show_stack(excp->gpr[1], excp->link, excp->nip);
+
 	for(;;) {
 #ifdef CONFIG_SMP
 		printf("%x:", smp_processor_id());
@@ -2485,8 +2491,10 @@ static void dump_stab(void)
 	}
 }
 
-void xmon_init(void)
+void xmon_init(int bt)
 {
+	if (bt)
+		xmon_auto_backtrace = 1;
 	__debugger = xmon;
 	__debugger_ipi = xmon_ipi;
 	__debugger_bpt = xmon_bpt;
Index: linux-2.6.11/include/asm-ppc64/system.h
===================================================================
--- linux-2.6.11.orig/include/asm-ppc64/system.h
+++ linux-2.6.11/include/asm-ppc64/system.h
@@ -88,7 +88,7 @@ DEBUGGER_BOILERPLATE(debugger_dabr_match
 DEBUGGER_BOILERPLATE(debugger_fault_handler)
 
 #ifdef CONFIG_XMON
-extern void xmon_init(void);
+extern void xmon_init(int bt);
 #endif
 
 #else



More information about the Linuxppc64-dev mailing list