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

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@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 */

Am 09.05.2018 um 22:16 schrieb Heinrich Schuchardt xypron.glpk@gmx.de:
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@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);
u16 values are quite bad for this. Non-thumb instruuctions are 32bit, so will be swapped in the output. Even with thumb you may get 32bit long ones.
Better just output everything as bytes. Then a simple xxd -ps -r can convert it into a binary you can throw objdump on.
Alex
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
participants (2)
-
Alexander Graf
-
Heinrich Schuchardt