aboutsummaryrefslogtreecommitdiff
path: root/sim/sh/run.c
diff options
context:
space:
mode:
authorJim Wilson <wilson@tuliptree.org>1995-08-12 01:03:16 +0000
committerJim Wilson <wilson@tuliptree.org>1995-08-12 01:03:16 +0000
commitf2d1b56f40d1723e46a7969f36ff1c20c73fc204 (patch)
tree17045f4e1b727ddb2f29a729466be7625ec95979 /sim/sh/run.c
parent3d0f44462fa570797da07ffaca6e48afae614688 (diff)
downloadgdb-f2d1b56f40d1723e46a7969f36ff1c20c73fc204.zip
gdb-f2d1b56f40d1723e46a7969f36ff1c20c73fc204.tar.gz
gdb-f2d1b56f40d1723e46a7969f36ff1c20c73fc204.tar.bz2
For Sega/Hitachi, when simulator exits, check to see if it was because
of a signal.
Diffstat (limited to 'sim/sh/run.c')
-rw-r--r--sim/sh/run.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/sim/sh/run.c b/sim/sh/run.c
index 02fdd40..9dffb58 100644
--- a/sim/sh/run.c
+++ b/sim/sh/run.c
@@ -21,12 +21,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Steve Chamberlain
sac@cygnus.com */
+#include <signal.h>
#include <stdio.h>
#include <varargs.h>
#include "bfd.h"
#include "sysdep.h"
#include "remote-sim.h"
+#ifndef SIGQUIT
+#define SIGQUIT SIGTERM
+#endif
+
void usage();
extern int optind;
extern char *optarg;
@@ -45,6 +50,8 @@ main (ac, av)
int verbose = 0;
int trace = 0;
char *name = "";
+ enum sim_stop reason;
+ int sigrc;
while ((i = getopt (ac, av, "m:p:s:tv")) != EOF)
switch (i)
@@ -116,14 +123,20 @@ main (ac, av)
if (verbose)
sim_info (0);
- /* Assume we left through the exit system call,
- in which case r5 has the exit code */
- {
- unsigned char b[4];
- sim_fetch_register (5, b);
- return b[3];
- }
+ sim_stop_reason (&reason, &sigrc);
+ /* Check to see if we left through the exit system call.
+ If we did, then we will have gotten a SIGQUIT and the exit
+ code is in r5. Otherwise, report the error number as the
+ exit code. */
+ if (sigrc == SIGQUIT)
+ {
+ unsigned char b[4];
+ sim_fetch_register (5, b);
+ return b[3];
+ }
+ else
+ return sigrc;
}
}