linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org, Arnd Bergmann <arnd.bergmann@de.ibm.com>
Subject: [PATCH 3/9] Add a 'sd' command (spu dump) to xmon to dump spu local store
Date: Wed, 22 Nov 2006 18:55:26 +1100	[thread overview]
Message-ID: <20061122075531.EAB2D67CD5@ozlabs.org> (raw)
In-Reply-To: <1164182122.302443.256192350213.qpush@cradle>

Add a command to xmon to dump the memory of a spu's local store.
This mimics the 'd' command which dumps regular memory, but does
a little hand holding by taking the user supplied address and
finding that offset in the local store for the specified spu.

This makes it easy for example to look at what was executing on a spu:

1:mon> ss
...
Stopped spu 04 (was running)
...
1:mon> sf 4
Dumping spu fields at address c0000000019e0a00:
...
  problem->spu_npc_RW     = 0x228
...
1:mon> sd 4 0x228
d000080080318228 01a00c021cffc408 4020007f217ff488  |........@ ..!...|

Aha, 01a00c02, which is of course rdch $2,$ch24 !

--

Updated to only do the setjmp goo around the spu access, and not
around prdump because it does its own (via mread).

Also the num variable is now common between sf and sd, so you don't
have to keep typing the spu number in if you're repeating commands
on the same spu.

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

 arch/powerpc/xmon/xmon.c |   60 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 55 insertions(+), 5 deletions(-)

Index: cell/arch/powerpc/xmon/xmon.c
===================================================================
--- cell.orig/arch/powerpc/xmon/xmon.c
+++ cell/arch/powerpc/xmon/xmon.c
@@ -217,7 +217,8 @@ Commands:\n\
 #ifdef CONFIG_PPC_CELL
 "  ss	stop execution on all spus\n\
   sr	restore execution on stopped spus\n\
-  sf #	dump spu fields for spu # (in hex)\n"
+  sf  #	dump spu fields for spu # (in hex)\n\
+  sd  #	dump spu local store for spu # (in hex)\n"
 #endif
 "  S	print special registers\n\
   t	print backtrace\n\
@@ -2649,6 +2650,7 @@ struct spu_info {
 	struct spu *spu;
 	u64 saved_mfc_sr1_RW;
 	u32 saved_spu_runcntl_RW;
+	unsigned long dump_addr;
 	u8 stopped_ok;
 };
 
@@ -2668,6 +2670,8 @@ void xmon_register_spus(struct list_head
 
 		spu_info[spu->number].spu = spu;
 		spu_info[spu->number].stopped_ok = 0;
+		spu_info[spu->number].dump_addr = (unsigned long)
+				spu_info[spu->number].spu->local_store;
 	}
 }
 
@@ -2813,9 +2817,43 @@ static void dump_spu_fields(struct spu *
 	DUMP_FIELD(spu, "0x%p", priv2);
 }
 
+static void dump_spu_ls(unsigned long num)
+{
+	unsigned long offset, addr, ls_addr;
+
+	if (setjmp(bus_error_jmp) == 0) {
+		catch_memory_errors = 1;
+		sync();
+		ls_addr = (unsigned long)spu_info[num].spu->local_store;
+		sync();
+		__delay(200);
+	} else {
+		catch_memory_errors = 0;
+		printf("*** Error: accessing spu info for spu %d\n", num);
+		return;
+	}
+	catch_memory_errors = 0;
+
+	if (scanhex(&offset))
+		addr = ls_addr + offset;
+	else
+		addr = spu_info[num].dump_addr;
+
+	if (addr >= ls_addr + LS_SIZE) {
+		printf("*** Error: address outside of local store\n");
+		return;
+	}
+
+	prdump(addr, 64);
+	addr += 64;
+	last_cmd = "sd\n";
+
+	spu_info[num].dump_addr = addr;
+}
+
 static int do_spu_cmd(void)
 {
-	unsigned long num = 0;
+	static unsigned long num = 0;
 	int cmd;
 
 	cmd = inchar();
@@ -2827,10 +2865,22 @@ static int do_spu_cmd(void)
 		restart_spus();
 		break;
 	case 'f':
-		if (scanhex(&num) && num < XMON_NUM_SPUS && spu_info[num].spu)
-			dump_spu_fields(spu_info[num].spu);
-		else
+	case 'd':
+		scanhex(&num);
+		if (num >= XMON_NUM_SPUS || !spu_info[num].spu) {
 			printf("*** Error: invalid spu number\n");
+			return 0;
+		}
+
+		switch (cmd) {
+		case 'f':
+			dump_spu_fields(spu_info[num].spu);
+			break;
+		default:
+			dump_spu_ls(num);
+			break;
+		}
+
 		break;
 	default:
 		return -1;

  parent reply	other threads:[~2006-11-22  7:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-22  7:55 [PATCH 0/9] More xmon cell patches Michael Ellerman
2006-11-22  7:55 ` [PATCH 1/9] Fix sparse warning in xmon Cell code Michael Ellerman
2006-11-22  7:55 ` [PATCH 2/9] Show state of spus as they're stopped in Cell xmon helper Michael Ellerman
2006-11-22  7:55 ` Michael Ellerman [this message]
2006-11-22  7:55 ` [PATCH 4/9] Prepare for spu disassembly in xmon Michael Ellerman
2006-11-22  7:55 ` [PATCH 5/9] Import spu disassembly code into xmon Michael Ellerman
2006-11-22  7:55 ` [PATCH 6/9] Add spu disassembly to xmon Michael Ellerman
2006-11-22  7:55 ` [PATCH 7/9] Make xmon disassembly optional Michael Ellerman
2006-11-22  7:55 ` [PATCH 8/9] Make 64-bit cpu features defined on 32-bit Michael Ellerman
2006-11-22  7:55 ` [PATCH 9/9] Import updated version of ppc disassembly code for xmon Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061122075531.EAB2D67CD5@ozlabs.org \
    --to=michael@ellerman.id.au \
    --cc=arnd.bergmann@de.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).