[patch 1/1] Dump text for xmon

Jake Moilanen moilanen at austin.ibm.com
Sat Jun 26 06:08:01 EST 2004


> Here's a patch to dump text in xmon.  The 'dt' command works
> just like any other dump command, it takes an address and an
> optional number of lines.
>
> All non-printable characters are printed w/ a '.' instead.
>
> If no one has any objections, I'll push it to ames sometime
> late next week.

Olof pointed out I forgot to mread the character.  Here's a revised
version.

Thanks,
Jake





---


diff -puN arch/ppc64/xmon/xmon.c~xmon-text-dump arch/ppc64/xmon/xmon.c
--- linux-2.6/arch/ppc64/xmon/xmon.c~xmon-text-dump	Wed Jun 23 11:29:27 2004
+++ linux-2.6-moilanen/arch/ppc64/xmon/xmon.c	Fri Jun 25 15:00:23 2004
@@ -48,6 +48,7 @@ static unsigned long adrs;
 static int size = 1;
 static unsigned long ndump = 64;
 static unsigned long nidump = 16;
+static unsigned long ntdump = 16;
 static unsigned long ncsum = 4096;
 static int termch;
 static char tmpstr[128];
@@ -81,6 +82,8 @@ static int bsesc(void);
 static void dump(void);
 static void prdump(unsigned long, long);
 static int ppc_inst_dump(unsigned long, long);
+static int ppc_txt_dump(unsigned long, long);
+
 void print_address(unsigned long);
 static void backtrace(struct pt_regs *);
 static void excprint(struct pt_regs *);
@@ -156,6 +159,7 @@ Commands:\n\
   di	dump instructions\n\
   df	dump float values\n\
   dd	dump double values\n\
+  dt	dump text\n\
   e	print exception information\n\
   f	flush cache\n\
   la	lookup symbol+offset of specified address\n\
@@ -1543,6 +1547,13 @@ dump()
 			nidump = 16;
 		adrs += ppc_inst_dump(adrs, nidump);
 		last_cmd = "di\n";
+	} else if ( c == 't' ){
+		scanhex(&ntdump);
+		if( ntdump == 0 ) {
+			ntdump = 16;
+		}
+		adrs += ppc_txt_dump(adrs, ntdump);
+		last_cmd = "dt\n";
 	} else {
 		scanhex(&ndump);
 		if( ndump == 0 )
@@ -1590,6 +1601,37 @@ prdump(unsigned long adrs, long ndump)
 		if( nr < r )
 			break;
 	}
+}
+
+static int
+ppc_txt_dump(unsigned long adr, long count)
+{
+	unsigned long first_adr;
+	long nr;
+	char c;
+
+	for (first_adr = adr; count > 0; adr++) {
+
+		nr = mread(adr, &c, 1);
+
+		if (!nr)
+			break;
+
+		if (c <= 31 || c >= 127) {
+			count--;
+
+			if (c != '\n') {
+				printf(".");
+				continue;
+			}
+		}
+
+		printf("%c", c);
+	}
+
+	printf("%.16lx ", adr);
+
+	return adr - first_adr;
 }

 int

_

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list