[PATCH] ppc64: xmon: Add dl command to dump contents of __log_buf

Michael Ellerman michael at ellerman.id.au
Wed Mar 23 22:41:45 EST 2005


Hi Paulus,

As you know there's a small window during boot on PPC64 when things are being
printk'ed but don't hit the console yet, although xmon works (??).

There's also times when you get a box which is sitting in xmon but the console
log has scolled off.

In both these cases it's sometimes useful to print the console log,  but using
xmon's 'd' command produces hard to read output.

This patch adds a command 'dl' to xmon which simply looks up the __log_buf
symbol and prints the contents in slightly more readable form.

I'm not really sure what's going on here with the catch_memory_errors business,
but this looked sensible going by other examples in xmon.c

cheers

Signed-off-by: Michael Ellerman <michael at ellerman.id.au>

Index: 2.6.12-rc1-mem-limit/arch/ppc64/xmon/xmon.c
===================================================================
--- 2.6.12-rc1-mem-limit.orig/arch/ppc64/xmon/xmon.c
+++ 2.6.12-rc1-mem-limit/arch/ppc64/xmon/xmon.c
@@ -99,6 +99,7 @@ static int bsesc(void);
 static void dump(void);
 static void prdump(unsigned long, long);
 static int ppc_inst_dump(unsigned long, long, int);
+static void dump_log_buf(void);
 void print_address(unsigned long);
 static void backtrace(struct pt_regs *);
 static void excprint(struct pt_regs *);
@@ -175,6 +176,7 @@ Commands:\n\
   di	dump instructions\n\
   df	dump float values\n\
   dd	dump double values\n\
+  dl	dump the kernel log buffer\n\
   e	print exception information\n\
   f	flush cache\n\
   la	lookup symbol+offset of specified address\n\
@@ -1950,6 +1952,8 @@ dump(void)
 			nidump = MAX_DUMP;
 		adrs += ppc_inst_dump(adrs, nidump, 1);
 		last_cmd = "di\n";
+	} else if (c == 'l') {
+		dump_log_buf();
 	} else {
 		scanhex(&ndump);
 		if (ndump == 0)
@@ -2046,6 +2050,50 @@ print_address(unsigned long addr)
 	xmon_print_symbol(addr, "\t# ", "");
 }
 
+void
+dump_log_buf(void)
+{
+	const unsigned long size = 128;
+	unsigned long i, end, addr;
+	unsigned char buf[size + 1];
+
+	addr = 0;
+	buf[size] = '\0';
+
+	if (setjmp(bus_error_jmp) != 0) {
+		printf("Unable to lookup symbol __log_buf!\n");
+		return;
+	}
+
+	catch_memory_errors = 1;
+	sync();
+	addr = kallsyms_lookup_name("__log_buf");
+
+	if (! addr)
+		printf("Symbol __log_buf not found!\n");
+	else {
+		end = addr + (1 << CONFIG_LOG_BUF_SHIFT);
+		while (addr < end) {
+			if (! mread(addr, buf, size)) {
+				printf("Can't read memory at address 0x%lx\n", addr);
+				break;
+			}
+	
+			printf("%s", buf);
+	
+			if (strlen(buf) < size)
+				break;
+
+			addr += size;
+		}
+	}
+
+	sync();
+	/* wait a little while to see if we get a machine check */
+	__delay(200);
+	catch_memory_errors = 0;
+}
+
 
 /*
  * Memory operations - move, set, print differences



More information about the Linuxppc64-dev mailing list