X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=sim%2Fcommon%2Frun.c;h=196d5325e87bdb72a1feb6b6ccc02a109d55ae29;hb=aadc9410ba24ecf777fcc515afda69ef94d74248;hp=d8c86cdd701011f914ff54788ade4ccf4d70dba7;hpb=3c25f8c7b071182238e0833c72552ee0e72fd2ae;p=thirdparty%2Fbinutils-gdb.git diff --git a/sim/common/run.c b/sim/common/run.c index d8c86cdd701..196d5325e87 100644 --- a/sim/common/run.c +++ b/sim/common/run.c @@ -1,25 +1,25 @@ /* run front end support for all the simulators. - Copyright (C) 1992, 93-96, 1997, 2002 Free Software Foundation, Inc. + Copyright (C) 1992-2015 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. +the Free Software Foundation; either version 3 of the License, 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. */ +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ /* Steve Chamberlain sac@cygnus.com, and others at Cygnus. */ -#include "config.h" -#include "tconfig.h" +#ifdef HAVE_CONFIG_H +#include "cconfig.h" +#endif #include #include @@ -47,8 +47,17 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "gdb/remote-sim.h" #include "ansidecl.h" #include "run-sim.h" +#include "version.h" + +#ifdef SIM_USE_DEPRECATED_RUN_FRONTEND +# warning "This sim is using the deprecated run.c; please migrate to nrun.c." +#else +# error "Please do not create new sim ports using run.c; use nrun.c instead." \ + "New submissions using run.c will not be accepted." +#endif -static void usage PARAMS ((void)); +static void usage (int help); +static void print_version (void); extern int optind; extern char *optarg; @@ -60,7 +69,7 @@ extern int getopt (); #ifdef NEED_UI_LOOP_HOOK /* Gdb foolery. This is only needed for gdb using a gui. */ -int (*ui_loop_hook) PARAMS ((int signo)); +int (*deprecated_ui_loop_hook) (int signo); #endif static SIM_DESC sd; @@ -76,9 +85,7 @@ cntrl_c (int sig ATTRIBUTE_UNUSED) } int -main (ac, av) - int ac; - char **av; +main (int ac, char **av) { RETSIGTYPE (*prev_sigint) (); bfd *abfd; @@ -116,14 +123,23 @@ main (ac, av) ac = sim_target_parse_command_line (ac, av); #endif + for (i = 1; av[i]; ++i) + { + if (strcmp (av[i], "--help") == 0) + { + usage (1); + } + else if (strcmp (av[i], "--version") == 0) + { + print_version (); + return 0; + } + } + /* FIXME: This is currently being rewritten to have each simulator do all argv processing. */ -#ifdef SIM_H8300 /* FIXME: quick hack */ - while ((i = getopt (ac, av, "a:c:m:op:s:hStv")) != EOF) -#else while ((i = getopt (ac, av, "a:c:m:op:s:tv")) != EOF) -#endif switch (i) { case 'a': @@ -156,7 +172,7 @@ main (ac, av) target. */ operating_p = 1; break; -#endif SIM_HAVE_ENVIRONMENT +#endif #ifdef SIM_HAVE_PROFILE case 'p': sim_set_profile (atoi (optarg)); @@ -176,22 +192,14 @@ main (ac, av) /* sim_set_verbose (1); */ break; /* FIXME: Quick hack, to be replaced by more general facility. */ -#ifdef SIM_H8300 - case 'h': - set_h8300h (1, 0); - break; - case 'S': - set_h8300h (1, 1); - break; -#endif default: - usage (); + usage (0); } ac -= optind; av += optind; if (ac <= 0) - usage (); + usage (0); name = *av; prog_args = av; @@ -288,11 +296,6 @@ main (ac, av) 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) { @@ -311,41 +314,48 @@ main (ac, av) break; } -#endif return sigrc; } static void -usage () +usage (int help) { - fprintf (stderr, "Usage: %s [options] program [program args]\n", myname); - fprintf (stderr, "Options:\n"); - fprintf (stderr, "-a args Pass `args' to simulator.\n"); + FILE *stream = help ? stdout : stderr; + + fprintf (stream, "Usage: %s [options] program [program args]\n", myname); + fprintf (stream, "Options:\n"); + fprintf (stream, "-a args Pass `args' to simulator.\n"); #ifdef SIM_HAVE_SIMCACHE - fprintf (stderr, "-c size Set simulator cache size to `size'.\n"); -#endif -#ifdef SIM_H8300 - fprintf (stderr, "-h Executable is for h8/300h.\n"); - fprintf (stderr, "-S Executable is for h8/300s.\n"); + fprintf (stream, "-c size Set simulator cache size to `size'.\n"); #endif - fprintf (stderr, "-m size Set memory size of simulator, in bytes.\n"); + fprintf (stream, "-m size Set memory size of simulator, in bytes.\n"); #ifdef SIM_HAVE_ENVIRONMENT - fprintf (stderr, "-o Select operating (kernel) environment.\n"); + fprintf (stream, "-o Select operating (kernel) environment.\n"); #endif #ifdef SIM_HAVE_PROFILE - fprintf (stderr, "-p freq Set profiling frequency.\n"); - fprintf (stderr, "-s size Set profiling size.\n"); + fprintf (stream, "-p freq Set profiling frequency.\n"); + fprintf (stream, "-s size Set profiling size.\n"); #endif - fprintf (stderr, "-t Perform instruction tracing.\n"); - fprintf (stderr, " Note: Very few simulators support tracing.\n"); - fprintf (stderr, "-v Verbose output.\n"); - fprintf (stderr, "\n"); - fprintf (stderr, "program args Arguments to pass to simulated program.\n"); - fprintf (stderr, " Note: Very few simulators support this.\n"); + fprintf (stream, "-t Perform instruction tracing.\n"); + fprintf (stream, " Note: Very few simulators support tracing.\n"); + fprintf (stream, "-v Verbose output.\n"); + fprintf (stream, "\n"); + fprintf (stream, "program args Arguments to pass to simulated program.\n"); + fprintf (stream, " Note: Very few simulators support this.\n"); #ifdef SIM_TARGET_SWITCHES - fprintf (stderr, "\nTarget specific options:\n"); - sim_target_display_usage (); + fprintf (stream, "\nTarget specific options:\n"); + sim_target_display_usage (help); #endif - exit (1); + + if (help && REPORT_BUGS_TO[0]) + printf ("Report bugs to %s\n", REPORT_BUGS_TO); + + exit (help ? 0 : 1); +} + +static void +print_version (void) +{ + printf ("GNU simulator %s%s\n", PKGVERSION, version); }