mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/5] ARM: print exception reports to stderr
Date: Wed, 31 Jul 2024 09:14:14 +0200	[thread overview]
Message-ID: <20240731071416.2558182-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240731071416.2558182-1-a.fatoum@pengutronix.de>

We already print stack traces to stderr, but exception cause and
register dump is printed to stdout still. Fix that by using eprintf
instead of printf.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/cpu/interrupts_32.c | 26 +++++++++++++-------------
 arch/arm/cpu/interrupts_64.c | 24 ++++++++++++------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch/arm/cpu/interrupts_32.c b/arch/arm/cpu/interrupts_32.c
index 468dcdd30e93..623efb3966f0 100644
--- a/arch/arm/cpu/interrupts_32.c
+++ b/arch/arm/cpu/interrupts_32.c
@@ -42,21 +42,21 @@ void show_regs (struct pt_regs *regs)
 
 	flags = condition_codes (regs);
 
-	printf ("pc : [<%08lx>]    lr : [<%08lx>]\n"
+	eprintf("pc : [<%08lx>]    lr : [<%08lx>]\n"
 		"sp : %08lx  ip : %08lx  fp : %08lx\n",
 		instruction_pointer (regs),
 		regs->ARM_lr, regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
-	printf ("r10: %08lx  r9 : %08lx  r8 : %08lx\n",
+	eprintf("r10: %08lx  r9 : %08lx  r8 : %08lx\n",
 		regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
-	printf ("r7 : %08lx  r6 : %08lx  r5 : %08lx  r4 : %08lx\n",
+	eprintf("r7 : %08lx  r6 : %08lx  r5 : %08lx  r4 : %08lx\n",
 		regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
-	printf ("r3 : %08lx  r2 : %08lx  r1 : %08lx  r0 : %08lx\n",
+	eprintf("r3 : %08lx  r2 : %08lx  r1 : %08lx  r0 : %08lx\n",
 		regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
-	printf ("Flags: %c%c%c%c",
+	eprintf("Flags: %c%c%c%c",
 		flags & PSR_N_BIT ? 'N' : 'n',
 		flags & PSR_Z_BIT ? 'Z' : 'z',
 		flags & PSR_C_BIT ? 'C' : 'c', flags & PSR_V_BIT ? 'V' : 'v');
-	printf ("  IRQs %s  FIQs %s  Mode %s%s\n",
+	eprintf("  IRQs %s  FIQs %s  Mode %s%s\n",
 		interrupts_enabled (regs) ? "on" : "off",
 		fast_interrupts_enabled (regs) ? "on" : "off",
 		processor_modes[processor_mode (regs)],
@@ -79,7 +79,7 @@ static void __noreturn do_exception(struct pt_regs *pt_regs)
  */
 void do_undefined_instruction (struct pt_regs *pt_regs)
 {
-	printf ("undefined instruction\n");
+	eprintf("undefined instruction\n");
 	do_exception(pt_regs);
 }
 
@@ -92,7 +92,7 @@ void do_undefined_instruction (struct pt_regs *pt_regs)
  */
 void do_software_interrupt (struct pt_regs *pt_regs)
 {
-	printf ("software interrupt\n");
+	eprintf("software interrupt\n");
 	do_exception(pt_regs);
 }
 
@@ -104,7 +104,7 @@ void do_software_interrupt (struct pt_regs *pt_regs)
  */
 void do_prefetch_abort (struct pt_regs *pt_regs)
 {
-	printf ("prefetch abort\n");
+	eprintf("prefetch abort\n");
 	do_exception(pt_regs);
 }
 
@@ -136,8 +136,8 @@ void do_data_abort (struct pt_regs *pt_regs)
 
 	asm volatile ("mrc     p15, 0, %0, c6, c0, 0" : "=r" (far) : : "cc");
 
-	printf("unable to handle %s at address 0x%08x\n",
-	       data_abort_reason(far), far);
+	eprintf("unable to handle %s at address 0x%08x\n",
+		data_abort_reason(far), far);
 
 	do_exception(pt_regs);
 }
@@ -150,7 +150,7 @@ void do_data_abort (struct pt_regs *pt_regs)
  */
 void do_fiq (struct pt_regs *pt_regs)
 {
-	printf ("fast interrupt request\n");
+	eprintf("fast interrupt request\n");
 	do_exception(pt_regs);
 }
 
@@ -162,7 +162,7 @@ void do_fiq (struct pt_regs *pt_regs)
  */
 void do_irq (struct pt_regs *pt_regs)
 {
-	printf ("interrupt request\n");
+	eprintf("interrupt request\n");
 	do_exception(pt_regs);
 }
 
diff --git a/arch/arm/cpu/interrupts_64.c b/arch/arm/cpu/interrupts_64.c
index 6262ba8872db..8933cfeb4288 100644
--- a/arch/arm/cpu/interrupts_64.c
+++ b/arch/arm/cpu/interrupts_64.c
@@ -76,12 +76,12 @@ void show_regs(struct pt_regs *regs)
 {
 	int i;
 
-	printf("elr: %016lx lr : %016lx\n", regs->elr, regs->regs[30]);
+	eprintf("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",
+		eprintf("x%-2d: %016lx x%-2d: %016lx\n",
 			i, regs->regs[i], i + 1, regs->regs[i + 1]);
-	printf("\n");
+	eprintf("\n");
 }
 
 static void __noreturn do_exception(struct pt_regs *pt_regs)
@@ -101,7 +101,7 @@ static void __noreturn do_exception(struct pt_regs *pt_regs)
  */
 void do_fiq(struct pt_regs *pt_regs)
 {
-	printf ("fast interrupt request\n");
+	eprintf("fast interrupt request\n");
 	do_exception(pt_regs);
 }
 
@@ -113,31 +113,31 @@ void do_fiq(struct pt_regs *pt_regs)
  */
 void do_irq(struct pt_regs *pt_regs)
 {
-	printf ("interrupt request\n");
+	eprintf("interrupt request\n");
 	do_exception(pt_regs);
 }
 
 void do_bad_sync(struct pt_regs *pt_regs)
 {
-	printf("bad sync\n");
+	eprintf("bad sync\n");
 	do_exception(pt_regs);
 }
 
 void do_bad_irq(struct pt_regs *pt_regs)
 {
-	printf("bad irq\n");
+	eprintf("bad irq\n");
 	do_exception(pt_regs);
 }
 
 void do_bad_fiq(struct pt_regs *pt_regs)
 {
-	printf("bad fiq\n");
+	eprintf("bad fiq\n");
 	do_exception(pt_regs);
 }
 
 void do_bad_error(struct pt_regs *pt_regs)
 {
-	printf("bad error\n");
+	eprintf("bad error\n");
 	do_exception(pt_regs);
 }
 
@@ -174,15 +174,15 @@ void do_sync(struct pt_regs *pt_regs, unsigned int esr, unsigned long far)
 		extra = data_abort_reason(far);
 	}
 
-	printf("%s%s exception (ESR 0x%08x) at 0x%016lx\n", extra ?: "",
-	       esr_get_class_string(esr), esr, far);
+	eprintf("%s%s exception (ESR 0x%08x) at 0x%016lx\n", extra ?: "",
+		esr_get_class_string(esr), esr, far);
 	do_exception(pt_regs);
 }
 
 
 void do_error(struct pt_regs *pt_regs)
 {
-	printf("error exception\n");
+	eprintf("error exception\n");
 	do_exception(pt_regs);
 }
 
-- 
2.39.2




  parent reply	other threads:[~2024-07-31  7:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31  7:14 [PATCH 1/5] console: provide veprintf and eputchar helpers Ahmad Fatoum
2024-07-31  7:14 ` [PATCH 2/5] KASan: report: print shadow memory state to stderr Ahmad Fatoum
2024-07-31  7:14 ` Ahmad Fatoum [this message]
2024-07-31  7:14 ` [PATCH 4/5] common: print panic " Ahmad Fatoum
2024-07-31  7:14 ` [PATCH 5/5] RISC-V: stacktrace: output stack traces to standard error Ahmad Fatoum
2024-08-01 11:33 ` [PATCH 1/5] console: provide veprintf and eputchar helpers Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240731071416.2558182-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox