Browse Source

[POWERPC] print backtrace when entering xmon

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.
print a backtrace during the very first xmon entry.

Booting with xmon=nobt disables the autobacktrace functionality.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Olaf Hering 18 years ago
parent
commit
26c8af5f01
3 changed files with 16 additions and 0 deletions
  1. 2 0
      arch/powerpc/Kconfig.debug
  2. 4 0
      arch/powerpc/kernel/setup-common.c
  3. 10 0
      arch/powerpc/xmon/xmon.c

+ 2 - 0
arch/powerpc/Kconfig.debug

@@ -88,6 +88,8 @@ config XMON
 	  very early during boot. 'xmon=on' will just enable the xmon
 	  very early during boot. 'xmon=on' will just enable the xmon
 	  debugger hooks.  'xmon=off' will disable the debugger hooks
 	  debugger hooks.  'xmon=off' will disable the debugger hooks
 	  if CONFIG_XMON_DEFAULT is set.
 	  if CONFIG_XMON_DEFAULT is set.
+	  xmon will print a backtrace on the very first invocation.
+	  'xmon=nobt' will disable this autobacktrace.
 
 
 config XMON_DEFAULT
 config XMON_DEFAULT
 	bool "Enable xmon by default"
 	bool "Enable xmon by default"

+ 4 - 0
arch/powerpc/kernel/setup-common.c

@@ -441,6 +441,8 @@ void __init smp_setup_cpu_maps(void)
 
 
 int __initdata do_early_xmon;
 int __initdata do_early_xmon;
 #ifdef CONFIG_XMON
 #ifdef CONFIG_XMON
+extern int xmon_no_auto_backtrace;
+
 static int __init early_xmon(char *p)
 static int __init early_xmon(char *p)
 {
 {
 	/* ensure xmon is enabled */
 	/* ensure xmon is enabled */
@@ -449,6 +451,8 @@ static int __init early_xmon(char *p)
 			xmon_init(1);
 			xmon_init(1);
 		if (strncmp(p, "off", 3) == 0)
 		if (strncmp(p, "off", 3) == 0)
 			xmon_init(0);
 			xmon_init(0);
+		if (strncmp(p, "nobt", 4) == 0)
+			xmon_no_auto_backtrace = 1;
 		if (strncmp(p, "early", 5) != 0)
 		if (strncmp(p, "early", 5) != 0)
 			return 0;
 			return 0;
 	}
 	}

+ 10 - 0
arch/powerpc/xmon/xmon.c

@@ -137,10 +137,14 @@ static void bootcmds(void);
 static void proccall(void);
 static void proccall(void);
 void dump_segments(void);
 void dump_segments(void);
 static void symbol_lookup(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,
 static void xmon_print_symbol(unsigned long address, const char *mid,
 			      const char *after);
 			      const char *after);
 static const char *getvecname(unsigned long vec);
 static const char *getvecname(unsigned long vec);
 
 
+int xmon_no_auto_backtrace;
+
 extern int print_insn_powerpc(unsigned long, unsigned long, int);
 extern int print_insn_powerpc(unsigned long, unsigned long, int);
 
 
 extern void xmon_enter(void);
 extern void xmon_enter(void);
@@ -736,6 +740,12 @@ cmds(struct pt_regs *excp)
 
 
 	last_cmd = NULL;
 	last_cmd = NULL;
 	xmon_regs = excp;
 	xmon_regs = excp;
+
+	if (!xmon_no_auto_backtrace) {
+		xmon_no_auto_backtrace = 1;
+		xmon_show_stack(excp->gpr[1], excp->link, excp->nip);
+	}
+
 	for(;;) {
 	for(;;) {
 #ifdef CONFIG_SMP
 #ifdef CONFIG_SMP
 		printf("%x:", smp_processor_id());
 		printf("%x:", smp_processor_id());