All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc
@ 2018-05-10 14:38 Heinrich Schuchardt
  2018-05-13 12:22 ` Tuomas Tynkkynen
  0 siblings, 1 reply; 5+ messages in thread
From: Heinrich Schuchardt @ 2018-05-10 14:38 UTC (permalink / raw)
  To: u-boot

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: fb de f7 e7 1e ff 2f e1 01 00 50 e3 f0 4d 2d e9 01 80 a0 e1

The output can be disassembled with
    xxd -pc -r - > a.out
    $(CROSS_COMPILE)objdump -D -marm -b binary a.out

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	print bytes not halfwords
---
 arch/arm/lib/interrupts.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/lib/interrupts.c b/arch/arm/lib/interrupts.c
index 28ba3f14f36..25489e34462 100644
--- a/arch/arm/lib/interrupts.c
+++ b/arch/arm/lib/interrupts.c
@@ -59,6 +59,9 @@ 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. */
+	u8 *pc = (u8 *)(instruction_pointer(regs) & ~1);
+	int i;
 	const char __maybe_unused *processor_modes[] = {
 	"USER_26",	"FIQ_26",	"IRQ_26",	"SVC_26",
 	"UK4_26",	"UK5_26",	"UK6_26",	"UK7_26",
@@ -96,6 +99,10 @@ void show_regs (struct pt_regs *regs)
 		fast_interrupts_enabled (regs) ? "on" : "off",
 		processor_modes[processor_mode (regs)],
 		thumb_mode (regs) ? " (T)" : "");
+	printf("*pc:");
+	for (i = 0; i < 24; ++i)
+		printf(" %02x", pc[i]);
+	printf("\n");
 }
 
 /* fixup PC to point to the instruction leading to the exception */
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc
  2018-05-10 14:38 [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc Heinrich Schuchardt
@ 2018-05-13 12:22 ` Tuomas Tynkkynen
  2018-05-13 14:45   ` Marek Vasut
  0 siblings, 1 reply; 5+ messages in thread
From: Tuomas Tynkkynen @ 2018-05-13 12:22 UTC (permalink / raw)
  To: u-boot

Hi,

On Thu, 10 May 2018 16:38:30 +0200
Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:

> 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: fb de f7 e7 1e ff 2f e1 01 00 50 e3 f0 4d 2d e9 01 80 a0 e1
> 
> The output can be disassembled with
>     xxd -pc -r - > a.out
>     $(CROSS_COMPILE)objdump -D -marm -b binary a.out
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> v2
> 	print bytes not halfwords

Note that Linux already comes with a scripts/decodecode tool where you paste the
output of an Oops and it disassembles the "Code: " line from the dump. So I'd
vote for importing scripts/decodecode from Linux and making U-Boot's output
compatible with Linux.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc
  2018-05-13 12:22 ` Tuomas Tynkkynen
@ 2018-05-13 14:45   ` Marek Vasut
  2018-05-24  8:57     ` Alexander Graf
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2018-05-13 14:45 UTC (permalink / raw)
  To: u-boot

On 05/13/2018 02:22 PM, Tuomas Tynkkynen wrote:
> Hi,
> 
> On Thu, 10 May 2018 16:38:30 +0200
> Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> 
>> 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: fb de f7 e7 1e ff 2f e1 01 00 50 e3 f0 4d 2d e9 01 80 a0 e1
>>
>> The output can be disassembled with
>>     xxd -pc -r - > a.out
>>     $(CROSS_COMPILE)objdump -D -marm -b binary a.out
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>> v2
>> 	print bytes not halfwords
> 
> Note that Linux already comes with a scripts/decodecode tool where you paste the
> output of an Oops and it disassembles the "Code: " line from the dump. So I'd
> vote for importing scripts/decodecode from Linux and making U-Boot's output
> compatible with Linux.

Sounds good.

btw if you get exception because the memory at PC is inaccessible, this
will trigger a double-fault I think.

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc
  2018-05-13 14:45   ` Marek Vasut
@ 2018-05-24  8:57     ` Alexander Graf
  2018-05-24  9:06       ` Marek Vasut
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2018-05-24  8:57 UTC (permalink / raw)
  To: u-boot



On 13.05.18 16:45, Marek Vasut wrote:
> On 05/13/2018 02:22 PM, Tuomas Tynkkynen wrote:
>> Hi,
>>
>> On Thu, 10 May 2018 16:38:30 +0200
>> Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>>> 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: fb de f7 e7 1e ff 2f e1 01 00 50 e3 f0 4d 2d e9 01 80 a0 e1
>>>
>>> The output can be disassembled with
>>>     xxd -pc -r - > a.out
>>>     $(CROSS_COMPILE)objdump -D -marm -b binary a.out
>>>
>>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>> ---
>>> v2
>>> 	print bytes not halfwords
>>
>> Note that Linux already comes with a scripts/decodecode tool where you paste the
>> output of an Oops and it disassembles the "Code: " line from the dump. So I'd
>> vote for importing scripts/decodecode from Linux and making U-Boot's output
>> compatible with Linux.
> 
> Sounds good.
> 
> btw if you get exception because the memory at PC is inaccessible, this
> will trigger a double-fault I think.

Yes, but it will only trigger it at the end of the handler at which
point we're panicking anyways, no?

Alex

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc
  2018-05-24  8:57     ` Alexander Graf
@ 2018-05-24  9:06       ` Marek Vasut
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2018-05-24  9:06 UTC (permalink / raw)
  To: u-boot

On 05/24/2018 10:57 AM, Alexander Graf wrote:
> 
> 
> On 13.05.18 16:45, Marek Vasut wrote:
>> On 05/13/2018 02:22 PM, Tuomas Tynkkynen wrote:
>>> Hi,
>>>
>>> On Thu, 10 May 2018 16:38:30 +0200
>>> Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>>
>>>> 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: fb de f7 e7 1e ff 2f e1 01 00 50 e3 f0 4d 2d e9 01 80 a0 e1
>>>>
>>>> The output can be disassembled with
>>>>     xxd -pc -r - > a.out
>>>>     $(CROSS_COMPILE)objdump -D -marm -b binary a.out
>>>>
>>>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>>> ---
>>>> v2
>>>> 	print bytes not halfwords
>>>
>>> Note that Linux already comes with a scripts/decodecode tool where you paste the
>>> output of an Oops and it disassembles the "Code: " line from the dump. So I'd
>>> vote for importing scripts/decodecode from Linux and making U-Boot's output
>>> compatible with Linux.
>>
>> Sounds good.
>>
>> btw if you get exception because the memory at PC is inaccessible, this
>> will trigger a double-fault I think.
> 
> Yes, but it will only trigger it at the end of the handler at which
> point we're panicking anyways, no?

Linux prints the faulting function at the top.

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-24  9:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-10 14:38 [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc Heinrich Schuchardt
2018-05-13 12:22 ` Tuomas Tynkkynen
2018-05-13 14:45   ` Marek Vasut
2018-05-24  8:57     ` Alexander Graf
2018-05-24  9:06       ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.