From: Eric Botcazou <ebotcazou@adacore.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] target-arm: return more meaningful exit status
Date: Mon, 07 Apr 2014 23:42:34 +0200 [thread overview]
Message-ID: <5047457.AHxDUeBxbN@polaris> (raw)
Hi,
this partially addresses a long-standing limitation of the ARM semi-hosting
mode, whereby the only exit status of the emulator is 0, whatever the exit
status of the target executable, by mapping arguments of the SYS_EXIT syscall.
See https://lists.gnu.org/archive/html/qemu-devel/2011-02/msg02178.html for
an earlier attempt.
It's only a partial solution because EXIT_SUCCESS will be returned in all
cases as before, except when the target execution is stopped with SIGABRT.
But that's sufficient to run the testsuite of the compiler for bare board
ARM, e.g. arm-none-eabi with newlib.
Signed-off-by: Eric Botcazou <ebotcazou@adacore.com>
---
target-arm/arm-semi.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c
index ebb5235..dd6c2d9 100644
--- a/target-arm/arm-semi.c
+++ b/target-arm/arm-semi.c
@@ -58,6 +58,9 @@
#define TARGET_SYS_HEAPINFO 0x16
#define TARGET_SYS_EXIT 0x18
+#define ADP_Stopped_ApplicationExit ((2 << 16) + 38)
+#define ADP_Stopped_RunTimeError ((2 << 16) + 35)
+
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@ -551,8 +554,24 @@ uint32_t do_arm_semihosting(CPUARMState *env)
return 0;
}
case TARGET_SYS_EXIT:
- gdb_exit(env, 0);
- exit(0);
+ {
+ int code;
+
+ switch (args) {
+ case ADP_Stopped_ApplicationExit:
+ code = EXIT_SUCCESS;
+ break;
+ case ADP_Stopped_RunTimeError:
+ code = EXIT_FAILURE;
+ break;
+ default:
+ code = -EXIT_FAILURE;
+ break;
+ }
+
+ gdb_exit(env, code);
+ exit(code);
+ }
default:
fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr);
cpu_dump_state(cs, stderr, fprintf, 0);
--
1.7.7
--
Eric Botcazou
next reply other threads:[~2014-04-07 21:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-07 21:42 Eric Botcazou [this message]
2014-04-08 7:53 ` [Qemu-devel] [PATCH] target-arm: return more meaningful exit status Peter Maydell
2014-04-08 8:34 ` Eric Botcazou
2014-04-08 9:38 ` Peter Maydell
2014-04-08 10:00 ` Eric Botcazou
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=5047457.AHxDUeBxbN@polaris \
--to=ebotcazou@adacore.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).