From bff849823551b6bafd5814540f74bddc2d3b5819 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 8 Jun 2006 06:55:17 +0000 Subject: * libgloss/m68k/bdm-system.c (_system): Properly encode non failure exit code. --- ChangeLog.csl | 5 +++++ libgloss/m68k/bdm-system.c | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog.csl b/ChangeLog.csl index 8bea8328f..5e038bd00 100644 --- a/ChangeLog.csl +++ b/ChangeLog.csl @@ -1,3 +1,8 @@ +2006-06-08 Nathan Sidwell + + * libgloss/m68k/bdm-system.c (_system): Properly encode non + failure exit code. + 2006-06-05 Nathan Sidwell * libgloss/m68k/Makefile.in (BDM_SYSOBJS): Remove bdm-inbyte.o. diff --git a/libgloss/m68k/bdm-system.c b/libgloss/m68k/bdm-system.c index 3514f2620..433713072 100644 --- a/libgloss/m68k/bdm-system.c +++ b/libgloss/m68k/bdm-system.c @@ -19,7 +19,7 @@ #include #include #include - +#include /* * system: execute command on (remote) host * input parameters: @@ -32,10 +32,24 @@ int _system (const char *command) { + int e; gdb_parambuf_t parameters; + parameters[0] = (uint32_t) command; parameters[1] = (uint32_t) strlen (command) + 1; BDM_TRAP (BDM_SYSTEM, (uint32_t)parameters); errno = convert_from_gdb_errno (parameters[1]); - return parameters[0]; + e = parameters[0]; + if (e >= 0) + { + /* We have to convert e, an exit status to the encoded status of + the command. To avoid hard coding the exit status, we simply + loop until we find the right position. */ + int exit_code; + + for (exit_code = e; e && WEXITSTATUS (e) != exit_code; e <<= 1) + continue; + } + + return e; } -- cgit v1.2.3