mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [RFC PATCH 2/4] startup: wrap barebox startup in TRY/CATCH
Date: Wed,  1 Apr 2020 11:31:02 +0200	[thread overview]
Message-ID: <20200401093104.959691-3-ahmad@a3f.at> (raw)
In-Reply-To: <20200401093104.959691-1-ahmad@a3f.at>

Install a top level exception handler around barebox_main, so we may
catch THROWs that aren't contained in a TRY { } block.

Reviewed-by: Ahmad Fatoum <ahmad@a3f.at>
---
 common/startup.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index c417a4d0781a..41da1359def6 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -348,27 +348,35 @@ void __noreturn start_barebox(void)
 	if (!IS_ENABLED(CONFIG_SHELL_NONE) && IS_ENABLED(CONFIG_COMMAND_SUPPORT))
 		barebox_main = run_init;
 
-	for (initcall = __barebox_initcalls_start;
-			initcall < __barebox_initcalls_end; initcall++) {
-		pr_debug("initcall-> %pS\n", *initcall);
-		result = (*initcall)();
-		if (result)
-			pr_err("initcall %pS failed: %s\n", *initcall,
-					strerror(-result));
-	}
+	TRY {
+		for (initcall = __barebox_initcalls_start;
+				initcall < __barebox_initcalls_end; initcall++) {
+			pr_debug("initcall-> %pS\n", *initcall);
+			result = (*initcall)();
+			if (result)
+				pr_err("initcall %pS failed: %s\n", *initcall,
+						strerror(-result));
+		}
 
-	pr_debug("initcalls done\n");
+		pr_debug("initcalls done\n");
 
-	if (barebox_main)
-		barebox_main();
+		if (barebox_main)
+			barebox_main();
 
-	if (IS_ENABLED(CONFIG_SHELL_NONE)) {
-		pr_err("Nothing left to do\n");
-		hang();
-	} else {
-		while (1)
-			run_shell();
+		if (IS_ENABLED(CONFIG_SHELL_NONE)) {
+			pr_err("Nothing left to do\n");
+			hang();
+		} else {
+			while (1)
+				run_shell();
+		}
+	} CATCH_ALL {
+		panic("Unhandled exception");
 	}
+
+
+	ENDTRY;
+
 }
 
 void __noreturn hang (void)
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-04-01  9:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01  9:31 [RFC PATCH 0/4] ARM: introduce sjlj structured exception handling Ahmad Fatoum
2020-04-01  9:31 ` [RFC PATCH 1/4] ARM: implement sjlj-based TRY/CATCH " Ahmad Fatoum
2020-04-02 19:51   ` Roland Hieber
2020-04-03  6:09     ` Ahmad Fatoum
2020-04-01  9:31 ` Ahmad Fatoum [this message]
2020-04-01  9:31 ` [RFC PATCH 3/4] ARM: rethrow CPU exceptions as sjlj-exceptions Ahmad Fatoum
2020-04-01  9:31 ` [RFC PATCH 4/4] commands: implement except test command Ahmad Fatoum

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=20200401093104.959691-3-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --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