aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edelsohn <dje.gcc@gmail.com>1997-04-17 12:43:31 +0000
committerDavid Edelsohn <dje.gcc@gmail.com>1997-04-17 12:43:31 +0000
commitc95d08a8d6f4256eab674aedd92d1c8736f5b9ae (patch)
tree5face4986342ff9cc448490e63e704a2a71305f8
parent4b364b00cfb153d2371dc0b9f74d29dec432dbb6 (diff)
downloadgdb-c95d08a8d6f4256eab674aedd92d1c8736f5b9ae.zip
gdb-c95d08a8d6f4256eab674aedd92d1c8736f5b9ae.tar.gz
gdb-c95d08a8d6f4256eab674aedd92d1c8736f5b9ae.tar.bz2
* Make-common.in (nrun.o): Add rule for.
* nrun.c: New file.
-rw-r--r--sim/common/.Sanitize1
-rw-r--r--sim/common/ChangeLog2
-rw-r--r--sim/common/Make-common.in3
-rw-r--r--sim/common/nrun.c119
4 files changed, 125 insertions, 0 deletions
diff --git a/sim/common/.Sanitize b/sim/common/.Sanitize
index efdd29c..b7b086a 100644
--- a/sim/common/.Sanitize
+++ b/sim/common/.Sanitize
@@ -34,6 +34,7 @@ configure
gentmap.c
gentvals.sh
nltvals.def
+nrun.c
run.c
run.1
sim-assert.h
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 9ebf3e3..18d9906 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -2,6 +2,8 @@ Thu Apr 17 02:25:11 1997 Doug Evans <dje@canuck.cygnus.com>
* sim-options.c, sim-options.h: New files.
* sim-config.h (WITH_DEBUG): Provide default value of zero.
+ * Make-common.in (nrun.o): Add rule for.
+ * nrun.c: New file.
* run.c (main): Check return value of sim_open.
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 6c7ef6d..e4bdde6 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -268,6 +268,9 @@ sim-utils.o: $(srcdir)/../common/sim-utils.c $(sim_main_headers) \
sim-load.o: $(srcdir)/../common/sim-load.c
$(CC) -c $(srcdir)/../common/sim-load.c $(ALL_CFLAGS)
+nrun.o: $(srcdir)/../common/nrun.c config.h tconfig.h \
+ $(srcroot)/include/callback.h $(sim_main_headers)
+ $(CC) -c $(srcdir)/../common/nrun.c $(ALL_CFLAGS)
install: install-common $(SIM_EXTRA_INSTALL)
diff --git a/sim/common/nrun.c b/sim/common/nrun.c
new file mode 100644
index 0000000..17fdfcc
--- /dev/null
+++ b/sim/common/nrun.c
@@ -0,0 +1,119 @@
+/* New version of run front end support for simulators.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "sim-main.h"
+
+#ifdef HAVE_ENVIRON
+extern char **environ;
+#endif
+
+static void usage PARAMS ((void));
+
+extern host_callback default_callback;
+
+static char *myname;
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ char *name;
+ char **prog_argv = NULL;
+ enum sim_stop reason;
+ int sigrc;
+ SIM_DESC sd;
+
+ myname = argv[0] + strlen (argv[0]);
+ while (myname > argv[0] && myname[-1] != '/')
+ --myname;
+
+ sim_set_callbacks (NULL, &default_callback);
+ default_callback.init (&default_callback);
+
+ /* Create an instance of the simulator. */
+ sd = sim_open (SIM_OPEN_STANDALONE, argv);
+ if (sd == 0)
+ exit (1);
+
+ /* Was there a program to run? */
+ prog_argv = STATE_PROG_ARGV (sd);
+ if (prog_argv == NULL || *prog_argv == NULL)
+ usage ();
+
+ name = *prog_argv;
+
+ if (STATE_VERBOSE_P (sd))
+ printf ("%s %s\n", myname, name);
+
+ /* Load the program into the simulator. */
+ if (sim_load (sd, name, NULL, 0) == SIM_RC_FAIL)
+ exit (1);
+
+ /* Prepare the program for execution. */
+#ifdef HAVE_ENVIRON
+ sim_create_inferior (sd, prog_argv, environ);
+#else
+ sim_create_inferior (sd, prog_argv, NULL);
+#endif
+
+ /* Run the program. */
+ sim_resume (sd, 0, 0);
+
+ /* Print any stats the simulator collected. */
+ sim_info (sd, 0);
+
+ /* Find out why the program exited. */
+ sim_stop_reason (sd, &reason, &sigrc);
+
+ /* Shutdown the simulator. */
+ sim_close (sd, 0);
+
+ /* If reason is sim_exited, then sigrc holds the exit code which we want
+ to return. If reason is sim_stopped or sim_signalled, then sigrc holds
+ the signal that the simulator received; we want to return that to
+ indicate failure. */
+
+#ifdef SIM_H8300 /* FIXME: Ugh. grep for SLEEP in compile.c */
+ if (sigrc == SIGILL)
+ abort ();
+ sigrc = 0;
+#else
+ /* Why did we stop? */
+ switch (reason)
+ {
+ case sim_signalled:
+ case sim_stopped:
+ if (sigrc != 0)
+ fprintf (stderr, "program stopped with signal %d.\n", sigrc);
+ break;
+
+ case sim_exited:
+ break;
+ }
+#endif
+
+ return sigrc;
+}
+
+static void
+usage ()
+{
+ fprintf (stderr, "Usage: %s [options] program [program args]\n", myname);
+ fprintf (stderr, "Run `%s --help' for full list of options.\n", myname);
+ exit (1);
+}