Received: from eggs.gnu.org ([2001:4830:134:3::10]:40406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqoTE-0000Dm-2P for qemu-devel@nongnu.org; Tue, 18 Nov 2014 14:29:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqoT8-0000uP-Rq for qemu-devel@nongnu.org; Tue, 18 Nov 2014 14:29:48 -0500 Received: from [109.99.239.84] (port=47337 helo=ilg-mbp.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqoT8-0000uI-KR for qemu-devel@nongnu.org; Tue, 18 Nov 2014 14:29:42 -0500 From: Liviu Ionescu Date: Tue, 18 Nov 2014 21:29:23 +0200 Message-Id: <1416338963-97608-2-git-send-email-ilg@livius.net> In-Reply-To: <1416338963-97608-1-git-send-email-ilg@livius.net> References: <1416338963-97608-1-git-send-email-ilg@livius.net> Subject: [Qemu-devel] [PATCH] pass semihosting exit code back to system List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, ilg@livius.net Signed-off-by: Liviu Ionescu --- target-arm/arm-semi.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c index ebb5235..4b982ad 100644 --- a/target-arm/arm-semi.c +++ b/target-arm/arm-semi.c @@ -58,6 +58,11 @@ #define TARGET_SYS_HEAPINFO 0x16 #define TARGET_SYS_EXIT 0x18 +/* ADP_Stopped_ApplicationExit is used for exit(0), + * anything else is implemented as exit(1) */ +#define ADP_Stopped_ApplicationExit ((2 << 16) + 38) +#define ADP_Stopped_RunTimeError ((2 << 16) + 35) + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -551,8 +556,11 @@ uint32_t do_arm_semihosting(CPUARMState *env) return 0; } case TARGET_SYS_EXIT: - gdb_exit(env, 0); - exit(0); + /* ARM specifies only Stopped_ApplicationExit as normal + * exit, everything else is considered an error */ + ret = (args == ADP_Stopped_ApplicationExit) ? 0 : 1; + gdb_exit(env, ret); + exit(ret); default: fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr); cpu_dump_state(cs, stderr, fprintf, 0); -- 1.9.3 (Apple Git-50)