[U-Boot] [PATCH 1/1] arm: print instructions pointed to by pc

Heinrich Schuchardt xypron.glpk at gmx.de
Wed May 9 20:16:53 UTC 2018


If an exception occurs in a loaded image and the relocation offset is
unknown, it is helful to know the instructions pointed to by the
program counter. This patch adds the missing output.

A possible output is:
*pc: defe e7ff 8010 e8bd abb9 9ffc f7d5 9ffc

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 arch/arm/lib/interrupts.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/lib/interrupts.c b/arch/arm/lib/interrupts.c
index cda4d48460..24fa3d433d 100644
--- a/arch/arm/lib/interrupts.c
+++ b/arch/arm/lib/interrupts.c
@@ -60,6 +60,8 @@ static void show_efi_loaded_images(struct pt_regs *regs)
 void show_regs (struct pt_regs *regs)
 {
 	unsigned long __maybe_unused flags;
+	/* The least significant bit chooses thumb, remove it. */
+	u16 *pc = (u16 *)(instruction_pointer(regs) & ~1);
 	const char __maybe_unused *processor_modes[] = {
 	"USER_26",	"FIQ_26",	"IRQ_26",	"SVC_26",
 	"UK4_26",	"UK5_26",	"UK6_26",	"UK7_26",
@@ -97,6 +99,8 @@ void show_regs (struct pt_regs *regs)
 		fast_interrupts_enabled (regs) ? "on" : "off",
 		processor_modes[processor_mode (regs)],
 		thumb_mode (regs) ? " (T)" : "");
+	printf("*pc: %04x %04x %04x %04x %04x %04x %04x %04x\n",
+	       pc[0], pc[1], pc[2], pc[3], pc[4], pc[5], pc[6], pc[7]);
 }
 
 /* fixup PC to point to the instruction leading to the exception */
-- 
2.17.0



More information about the U-Boot mailing list