Fix TCL error in gdb.python/py-format-string.exp.
[deliverable/binutils-gdb.git] / sim / ppc / psim.c
index a574fe77941b6515b0bde9c038a5998e6400cc95..3e322e3820f83830d5076cf46fe7e69ee48804b8 100644 (file)
@@ -4,7 +4,7 @@
 
     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
 
     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 of the License, or
+    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,
     (at your option) any later version.
 
     This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
     GNU General Public License for more details.
  
     You should have received a copy of the GNU General Public License
     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.
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
  
     */
 
  
     */
 
@@ -50,7 +49,7 @@
 
 #include "bfd.h"
 #include "libiberty.h"
 
 #include "bfd.h"
 #include "libiberty.h"
-
+#include "gdb/signals.h"
 
 /* system structure, actual size of processor array determined at
    runtime */
 
 /* system structure, actual size of processor array determined at
    runtime */
@@ -119,7 +118,7 @@ find_arg(char *err_msg,
 
 INLINE_PSIM\
 (void)
 
 INLINE_PSIM\
 (void)
-psim_usage(int verbose)
+psim_usage (int verbose, int help, SIM_OPEN_KIND kind)
 {
   printf_filtered("Usage:\n");
   printf_filtered("\n");
 {
   printf_filtered("Usage:\n");
   printf_filtered("\n");
@@ -217,7 +216,13 @@ psim_usage(int verbose)
     printf_filtered("\n");
     print_options();
   }
     printf_filtered("\n");
     print_options();
   }
-  error("");
+
+  if (kind == SIM_OPEN_STANDALONE)
+    {
+      if (REPORT_BUGS_TO[0])
+       printf ("Report bugs to %s\n", REPORT_BUGS_TO);
+      exit (help ? 0 : 1);
+    }
 }
 
 /* Test "string" for containing a string of digits that form a number
 }
 
 /* Test "string" for containing a string of digits that form a number
@@ -245,7 +250,8 @@ int is_num( char *string, int min, int max, int err)
 INLINE_PSIM\
 (char **)
 psim_options(device *root,
 INLINE_PSIM\
 (char **)
 psim_options(device *root,
-            char **argv)
+            char **argv,
+            SIM_OPEN_KIND kind)
 {
   device *current = root;
   int argp;
 {
   device *current = root;
   int argp;
@@ -258,9 +264,9 @@ psim_options(device *root,
     while (*p != '\0') {
       switch (*p) {
       default:
     while (*p != '\0') {
       switch (*p) {
       default:
-       psim_usage(0);
-       error ("");
-       break;
+       printf_filtered ("Invalid Option: %s\n", argv[argp]);
+       psim_usage (0, 0, kind);
+       return NULL;
       case 'c':
        param = find_arg("Missing <count> option for -c (max-iterations)\n", &argp, argv);
        tree_parse(root, "/openprom/options/max-iterations %s", param);
       case 'c':
        param = find_arg("Missing <count> option for -c (max-iterations)\n", &argp, argv);
        tree_parse(root, "/openprom/options/max-iterations %s", param);
@@ -279,7 +285,8 @@ psim_options(device *root,
        else
          {
            printf_filtered ("Invalid <endian> option for -E (target-endian)\n");
        else
          {
            printf_filtered ("Invalid <endian> option for -E (target-endian)\n");
-           psim_usage (0);
+           psim_usage (0, 0, kind);
+           return NULL;
          }
        break;
       case 'f':
          }
        break;
       case 'f':
@@ -288,11 +295,11 @@ psim_options(device *root,
        break;
       case 'h':
       case '?':
        break;
       case 'h':
       case '?':
-       psim_usage(1);
-       break;
+       psim_usage (1, 1, kind);
+       return NULL;
       case 'H':
       case 'H':
-       psim_usage(2);
-       break;
+       psim_usage (2, 1, kind);
+       return NULL;
       case 'i':
        if (isdigit(p[1])) {
          tree_parse(root, "/openprom/trace/print-info %c", p[1]);
       case 'i':
        if (isdigit(p[1])) {
          tree_parse(root, "/openprom/trace/print-info %c", p[1]);
@@ -352,8 +359,30 @@ psim_options(device *root,
          p = argv[argp] + strlen(argv[argp]) - 1;
          printf_filtered("Warning - architecture parameter ignored\n");
         }
          p = argv[argp] + strlen(argv[argp]) - 1;
          printf_filtered("Warning - architecture parameter ignored\n");
         }
+       else if (strcmp (argv[argp], "--help") == 0)
+         {
+           psim_usage (0, 1, kind);
+           return NULL;
+         }
+       else if (strncmp (argv[argp], "--sysroot=",
+                         sizeof ("--sysroot=") - 1) == 0)
+         /* Ignore this option.  */
+         p = argv[argp] + strlen(argv[argp]) - 1;
+       else if (strcmp (argv[argp], "--version") == 0)
+         {
+           extern const char version[];
+           printf ("GNU simulator %s%s\n", PKGVERSION, version);
+           if (kind == SIM_OPEN_STANDALONE)
+             exit (0);
+           else
+             return NULL;
+         }
        else
        else
-         error("Unrecognized option");
+         {
+           printf_filtered ("Invalid option: %s\n", argv[argp]);
+           psim_usage (0, 0, kind);
+           return NULL;
+         }
        break;
       }
       p += 1;
        break;
       }
       p += 1;
@@ -572,7 +601,7 @@ cntrl_c_simulation(void *data)
   psim_halt(system,
            psim_nr_cpus(system),
            was_continuing,
   psim_halt(system,
            psim_nr_cpus(system),
            was_continuing,
-           SIGINT);
+           GDB_SIGNAL_INT);
 }
 
 INLINE_PSIM\
 }
 
 INLINE_PSIM\
This page took 0.025653 seconds and 4 git commands to generate.