[Crash-utility] [PATCH v1 2/4] [ppc] Function to print the PPC register set

Suzuki K. Poulose suzuki at in.ibm.com
Tue Nov 15 03:58:13 UTC 2011


This patch moves the register dumping code to a routine, so that
it may be reused.

Signed-off-by: Suzuki K. Poulose <suzuki at in.ibm.com>
---

 ppc.c |   62 ++++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/ppc.c b/ppc.c
index 1ec8e70..869b066 100755
--- a/ppc.c
+++ b/ppc.c
@@ -880,6 +880,43 @@ ppc_print_stack_entry(int frame,
 }
 
 /*
+ * Print the register set for ppc32
+ */
+
+static void
+ppc_print_regs(struct ppc_pt_regs *regs)
+{
+	int i;
+
+	/* print out the gprs... */
+	for(i=0; i<32; i++) {
+		if(!(i % 4))
+			fprintf(fp, "\n");
+
+		fprintf(fp, "R%d:%s %08lx   ", i,
+			((i < 10) ? " " : ""), regs->gpr[i]);
+	}
+
+	fprintf(fp, "\n");
+
+	/* print out the rest of the registers */
+	fprintf(fp, "NIP: %08lx   ", regs->nip);
+	fprintf(fp, "MSR: %08lx   ", regs->msr);
+	fprintf(fp, "OR3: %08lx   ", regs->orig_gpr3);
+	fprintf(fp, "CTR: %08lx\n", regs->ctr);
+
+	fprintf(fp, "LR:  %08lx   ", regs->link);
+	fprintf(fp, "XER: %08lx   ", regs->xer);
+	fprintf(fp, "CCR: %08lx   ", regs->ccr);
+	fprintf(fp, "MQ:  %08lx\n", regs->mq);
+	fprintf(fp, "DAR: %08lx ", regs->dar);
+	fprintf(fp, "DSISR: %08lx ", regs->dsisr);
+	fprintf(fp, "       Syscall Result: %08lx\n", regs->result);
+
+	fprintf(fp, "\n");
+}
+
+/*
  *  Print exception frame information for PowerPC
  */
 static void
@@ -939,31 +976,8 @@ ppc_exception_frame(ulong addr, struct bt_info *bt, struct gnu_request *req)
 	}
 
 	fprintf(fp, " [%lx] exception frame:", regs.trap);
+	ppc_print_regs(&regs);
 
-	/* print out the gprs... */
-	for(i=0; i<32; i++) {
-		if(!(i % 4))
-			fprintf(fp, "\n");
-
-		fprintf(fp, "R%d:%s %08lx   ", i,
-			((i < 10) ? " " : ""), regs.gpr[i]);
-	}
-
-	fprintf(fp, "\n");
-
-	/* print out the rest of the registers */
-	fprintf(fp, "NIP: %08lx   ", regs.nip);
-	fprintf(fp, "MSR: %08lx   ", regs.msr);
-	fprintf(fp, "OR3: %08lx   ", regs.orig_gpr3);
-	fprintf(fp, "CTR: %08lx\n", regs.ctr);
-
-	fprintf(fp, "LR:  %08lx   ", regs.link);
-	fprintf(fp, "XER: %08lx   ", regs.xer);
-	fprintf(fp, "CCR: %08lx   ", regs.ccr);
-	fprintf(fp, "MQ:  %08lx\n", regs.mq);
-	fprintf(fp, "DAR: %08lx ", regs.dar);
-	fprintf(fp, "DSISR: %08lx ", regs.dsisr);
-	fprintf(fp, "       Syscall Result: %08lx\n", regs.result);
 }
 
 /*




More information about the Crash-utility mailing list