[PATCH 59/78] ARM: aarch64: implement show_regs()

Sascha Hauer s.hauer at pengutronix.de
Fri Mar 16 05:53:35 PDT 2018


Do something useful in an exception and at least print the current
register contents.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/cpu/interrupts_64.c  |  8 ++++++++
 arch/arm/include/asm/ptrace.h | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/arch/arm/cpu/interrupts_64.c b/arch/arm/cpu/interrupts_64.c
index b3bd0aa5a4..ffdb87af94 100644
--- a/arch/arm/cpu/interrupts_64.c
+++ b/arch/arm/cpu/interrupts_64.c
@@ -30,6 +30,14 @@
  */
 void show_regs(struct pt_regs *regs)
 {
+	int i;
+
+	printf("elr: %016lx lr : %016lx\n", regs->elr, regs->regs[30]);
+
+	for (i = 0; i < 29; i += 2)
+		printf("x%-2d: %016lx x%-2d: %016lx\n",
+			i, regs->regs[i], i + 1, regs->regs[i + 1]);
+	printf("\n");
 }
 
 static void __noreturn do_exception(struct pt_regs *pt_regs)
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index 6520a0a73a..7fbd8d9b6f 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -10,6 +10,23 @@
 #ifndef __ASM_ARM_PTRACE_H
 #define __ASM_ARM_PTRACE_H
 
+#ifdef CONFIG_CPU_64
+
+#ifndef __ASSEMBLY__
+
+/*
+ * This struct defines the way the registers are stored
+ * on the stack during an exception.
+ */
+struct pt_regs {
+	unsigned long elr;
+	unsigned long regs[31];
+};
+
+#endif  /* __ASSEMBLY__ */
+
+#else   /* CONFIG_CPU_64 */
+
 #define PTRACE_GETREGS		12
 #define PTRACE_SETREGS		13
 #define PTRACE_GETFPREGS	14
@@ -141,4 +158,6 @@ extern void show_regs(struct pt_regs *);
 
 #endif /* __ASSEMBLY__ */
 
+#endif /* CONFIG_CPU_64 */
+
 #endif
-- 
2.16.1




More information about the barebox mailing list