sim: start a unified sim_do_command
authorMike Frysinger <vapier@gentoo.org>
Tue, 5 Jul 2011 19:06:38 +0000 (19:06 +0000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 5 Jul 2011 19:06:38 +0000 (19:06 +0000)
Since sim_do_command for many people simply calls sim_args_command, start
a unified version of it.  For people who handle their own options, they
could switch to this by using sim_add_option_table instead.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
27 files changed:
sim/bfin/ChangeLog
sim/bfin/interp.c
sim/common/ChangeLog
sim/common/Make-common.in
sim/common/sim-command.c [new file with mode: 0644]
sim/cris/ChangeLog
sim/cris/sim-if.c
sim/frv/ChangeLog
sim/frv/sim-if.c
sim/h8300/ChangeLog
sim/h8300/compile.c
sim/iq2000/ChangeLog
sim/iq2000/sim-if.c
sim/lm32/ChangeLog
sim/lm32/sim-if.c
sim/m32r/ChangeLog
sim/m32r/sim-if.c
sim/m68hc11/ChangeLog
sim/m68hc11/interp.c
sim/mips/ChangeLog
sim/mips/interp.c
sim/mn10300/ChangeLog
sim/mn10300/interp.c
sim/sh64/ChangeLog
sim/sh64/sim-if.c
sim/v850/ChangeLog
sim/v850/interp.c

index bb79cde2dbfa0a9fb623ad8bb2596d5e3b63814a..4d246bad024d3d6a07c63fcb9d9060f01d884615 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Delete.
+
 2011-07-01  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (cb_linux_stat_map_32, cb_linux_stat_map_64): Rename from
index f22c378dc7e0dda016d460f76ca520637f06d362..4e7a45c6dc7725c57baf2d1aadb6278d2272617f 100644 (file)
@@ -1256,10 +1256,3 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
 
   return SIM_RC_OK;
 }
-
-void
-sim_do_command (SIM_DESC sd, char *cmd)
-{
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-}
index 821248d12303c53de2c56496b87c5f47e5b91b4c..f4f823188ee7e8d7e8beac361e94cf73fabec655 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-command.c: New file.
+       * Make-common.in (SIM_NEW_COMMON_OBJS): Add sim-command.o.
+       (sim-command.o): New rule.
+
 2011-05-27  Mike Frysinger  <vapier@gentoo.org>
 
        * sim-options.c (standard_option_handler): Remove arg[0] check
index 351f4a078e95cae274bebf4466b95b9b04933172..42e31928fd448d4270259f5326df2017fd875059 100644 (file)
@@ -162,6 +162,7 @@ SIM_COMMON_HW_OBJS = \
 SIM_NEW_COMMON_OBJS = \
        sim-arange.o \
        sim-bits.o \
+       sim-command.o \
        sim-config.o \
        sim-core.o \
        sim-endian.o \
@@ -425,6 +426,9 @@ sim-bits.o: $(srccom)/sim-bits.c $(sim-bits_h) $(sim-n-bits_h) \
          $(SIM_EXTRA_DEPS)
        $(CC) -c $(srccom)/sim-bits.c $(ALL_CFLAGS)
 
+sim-command.o: $(srccom)/sim-command.c $(sim_main_headers)
+       $(CC) -c $(srccom)/sim-command.c $(ALL_CFLAGS)
+
 sim-config.o: $(srccom)/sim-config.c $(sim-config_h) sim-main.h \
          $(SIM_EXTRA_DEPS)
        $(CC) -c $(srccom)/sim-config.c $(ALL_CFLAGS)
diff --git a/sim/common/sim-command.c b/sim/common/sim-command.c
new file mode 100644 (file)
index 0000000..b6d0a19
--- /dev/null
@@ -0,0 +1,33 @@
+/* Miscellaneous simulator utilities.
+
+   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+   Contributed by Analog Devices, Inc.
+
+   This file is part of simulators.
+
+   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 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, see <http://www.gnu.org/licenses/>.  */
+
+#include "sim-main.h"
+#include "sim-utils.h"
+
+/* Generic implementation of sim_do_command that works with simulators
+   which add custom options via sim_add_option_table().  */
+
+void
+sim_do_command (SIM_DESC sd, char *cmd)
+{
+  if (sim_args_command (sd, cmd) != SIM_RC_OK)
+    sim_io_eprintf (sd, "Unknown sim command: \"%s\".  Try \"sim help\".\n",
+                   cmd);
+}
index d9fdf60b0df1502a47b183bea932fa5df07be880..7e3abca738ba41ee26c2feda6b259cb666b8d59f 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_do_command): Delete.
+
 2010-10-09  Alan Modra  <amodra@gmail.com>
 
        * cris-desc.h: Regenerate.
index 9dc7e3459c4c906ed2919d75ae2734ed48a0f7e9..64a758cbc0cfbbc7410494a2684f25b4f374ff2a 100644 (file)
@@ -1094,13 +1094,6 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
 
   return SIM_RC_OK;
 }
-
-void
-sim_do_command (SIM_DESC sd, char *cmd)
-{
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-}
 \f
 /* Disassemble an instruction.  */
 
index b35c6595d8e42eb1681da99661062a5a58c2d8e0..987791bd4a84f48fba3180064a6ae5605c8dee46 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_do_command): Delete.
+
 2010-04-21  Mike Frysinger  <vapier@gentoo.org>
 
        * profile.c (sim_profile_print_bar): Add cpu argument.
index 2d1596565b1a2431faf05af42cf51e057bb6676a..37cc23a98c29f9cf41ab7afb819fd10d2356613e 100644 (file)
@@ -240,12 +240,3 @@ sim_create_inferior (sd, abfd, argv, envp)
 
   return SIM_RC_OK;
 }
-
-void
-sim_do_command (sd, cmd)
-     SIM_DESC sd;
-     char *cmd;
-{ 
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-}
index 81d9d01683b3119f17530a58b2575d9a9e89c0c1..04278f8151c394b773e444a8a8f693058066318f 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * compile.c (sim_do_command): Delete.
+
 2011-01-11  Andrew Burgess  <aburgess@broadcom.com>
 
        * compile.c (sim_store_register): Update return value to
index b249080dd884dd3d258809f63913c4c318e6d48e..7b4a5fad31cca6fba703ad2f8b608de95e0c0d97 100644 (file)
@@ -5107,13 +5107,6 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env)
   return SIM_RC_OK;
 }
 
-void
-sim_do_command (SIM_DESC sd, char *cmd)
-{
-  (*sim_callback->printf_filtered) (sim_callback,
-                                   "This simulator does not accept any commands.\n");
-}
-
 void
 sim_set_callbacks (struct host_callback_struct *ptr)
 {
index c25f903170d1b8a5f9da0d2d5b66201866b28303..1459841357514f685e563cc803f83a94a3cee9e7 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_do_command): Delete.
+
 2011-02-14  Mike Frysinger  <vapier@gentoo.org>
 
        * iq2000.c (do_syscall): Change zfree to free.
index 0efae1aed7bf6ce9d841ba29d2cd5ed6dadc7a04..e0ff86b2ec66294f2a3870b71ec81bb602502bfe 100644 (file)
@@ -189,15 +189,3 @@ sim_create_inferior (sd, abfd, argv, envp)
 
   return SIM_RC_OK;
 }
-
-void
-sim_do_command (sd, cmd)
-     SIM_DESC sd;
-     char *cmd;
-{ 
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-}
-
-
-
index 5bb114e02ceff789aed902784a1a9d5f40f7618b..2c3561641afa95df666567473f6121fa9b25e1b1 100755 (executable)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_do_command): Delete.
+
 2010-02-11  Doug Evans  <dje@sebabeach.org>
 
        * cpu.h, * decode.c, * model.c, * sem-switch.c, * sem.c: Regenerate.
index 6d3c734e71476beb4ad7ec3582f2a0bb9a95526e..d9bb21945036dbe00e7e6706c8bd5644eeb12c52 100644 (file)
@@ -279,12 +279,3 @@ sim_create_inferior (sd, abfd, argv, envp)
 
   return SIM_RC_OK;
 }
-
-void
-sim_do_command (sd, cmd)
-     SIM_DESC sd;
-     char *cmd;
-{
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-}
index 4c4ca6cbb9287ccba548b71ec7e8155d05fa200c..801149ab1d5e363d561e0be268b008512ab8c64b 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_do_command): Delete.
+
 2010-03-30  Mike Frysinger  <vapier@gentoo.org>
 
        * devices.c (device_error): Add const to message.
index 6235abd9524ede648317d914bc67869a942d7b16..610bd859c55824f5dc87c8b08fa6f4c6cd6ee775 100644 (file)
@@ -256,51 +256,3 @@ print_m32r_misc_cpu (SIM_CPU *cpu, int verbose)
                                       CPU_M32R_MISC_PROFILE (cpu)->parallel_count));
     }
 }
-
-void
-sim_do_command (sd, cmd)
-     SIM_DESC sd;
-     char *cmd;
-{ 
-  char **argv;
-
-  if (cmd == NULL)
-    return;
-
-  argv = buildargv (cmd);
-
-  if (argv[0] != NULL
-      && strcasecmp (argv[0], "info") == 0
-      && argv[1] != NULL
-      && strncasecmp (argv[1], "reg", 3) == 0)
-    {
-      SI val;
-
-      /* We only support printing bbpsw,bbpc here as there is no equivalent
-        functionality in gdb.  */
-      if (argv[2] == NULL)
-       sim_io_eprintf (sd, "Missing register in `%s'\n", cmd);
-      else if (argv[3] != NULL)
-       sim_io_eprintf (sd, "Too many arguments in `%s'\n", cmd);
-      else if (strcasecmp (argv[2], "bbpsw") == 0)
-       {
-         val = m32rbf_h_cr_get (STATE_CPU (sd, 0), H_CR_BBPSW);
-         sim_io_printf (sd, "bbpsw 0x%x %d\n", val, val);
-       }
-      else if (strcasecmp (argv[2], "bbpc") == 0)
-       {
-         val = m32rbf_h_cr_get (STATE_CPU (sd, 0), H_CR_BBPC);
-         sim_io_printf (sd, "bbpc 0x%x %d\n", val, val);
-       }
-      else
-       sim_io_eprintf (sd, "Printing of register `%s' not supported with `sim info'\n",
-                       argv[2]);
-    }
-  else
-    {
-      if (sim_args_command (sd, cmd) != SIM_RC_OK)
-       sim_io_eprintf (sd, "Unknown sim command `%s'\n", cmd);
-    }
-
-  freeargv (argv);
-}
index 295173ea808dded6ead49ce2193c94ac8ccd3842..fe2f74a21e60a25efff5bc1d1481c80de67c2343 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Delete.
+
 2010-01-09  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * configure: Regenerate.
index b4d17c3fd644787c8588cb20a88a5609e56dbfc8..d391286d0f0abe2649ad9985b267ebeaf201c4b5 100644 (file)
@@ -711,33 +711,6 @@ sim_size (int s)
   ;
 }
 
-void
-sim_do_command (SIM_DESC sd, char *cmd)
-{
-  char *mm_cmd = "memory-map";
-  char *int_cmd = "interrupt";
-  sim_cpu *cpu;
-
-  cpu = STATE_CPU (sd, 0);
-  /* Commands available from GDB:   */
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    {
-      if (strncmp (cmd, "info", sizeof ("info") - 1) == 0)
-       sim_get_info (sd, &cmd[4]);
-      else if (strncmp (cmd, mm_cmd, strlen (mm_cmd) == 0))
-       sim_io_eprintf (sd,
-                       "`memory-map' command replaced by `sim memory'\n");
-      else if (strncmp (cmd, int_cmd, strlen (int_cmd)) == 0)
-       sim_io_eprintf (sd, "`interrupt' command replaced by `sim watch'\n");
-      else
-       sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-    }
-
-  /* If the architecture changed, re-configure.  */
-  if (STATE_ARCHITECTURE (sd) != cpu->cpu_configured_arch)
-    sim_hw_configure (sd);
-}
-
 /* Halt the simulator after just one instruction */
 
 static void
index b19991fb433094aed6e3480610bc50c9a6ba0ba7..2f4a8d5ebc73d4aa244bae8c5bd146caf92d3452 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Delete.
+
 2011-02-14  Mike Frysinger  <vapier@gentoo.org>
 
        * dv-tx3904sio.c (tx3904sio_fifo_push): Change zfree to free.
index 492ae604af0fa230a686f02a1f4dd6c282f1963c..edd4250e22cec381fa33f721b1d118160c082749 100644 (file)
@@ -1142,16 +1142,6 @@ sim_create_inferior (sd, abfd, argv,env)
   return SIM_RC_OK;
 }
 
-void
-sim_do_command (sd,cmd)
-     SIM_DESC sd;
-     char *cmd;
-{
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_printf (sd, "Error: \"%s\" is not a valid MIPS simulator command.\n",
-                  cmd);
-}
-
 /*---------------------------------------------------------------------------*/
 /*-- Private simulator support interface ------------------------------------*/
 /*---------------------------------------------------------------------------*/
index 1543b03cfb78460900971357063fb2b8cd2ffb28..beb4194bb626fd4333a26d9820624862f585bb10 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Delete.
+
 2011-06-20  Nick Clifton  <nickc@redhat.com>
 
        * am33.igen (sub Rm,Rn,Rd): Fix computation of carry flag.
index 1230bf55cb5eeef7b1ce86bbd14290d55b9702b8..e06ae59079352669f7e537ffb0c1fe87ff28b448 100644 (file)
@@ -328,23 +328,6 @@ sim_create_inferior (SIM_DESC sd,
   return SIM_RC_OK;
 }
 
-void
-sim_do_command (SIM_DESC sd, char *cmd)
-{
-  char *mm_cmd = "memory-map";
-  char *int_cmd = "interrupt";
-
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    {
-      if (strncmp (cmd, mm_cmd, strlen (mm_cmd) == 0))
-       sim_io_eprintf (sd, "`memory-map' command replaced by `sim memory'\n");
-      else if (strncmp (cmd, int_cmd, strlen (int_cmd)) == 0)
-       sim_io_eprintf (sd, "`interrupt' command replaced by `sim watch'\n");
-      else
-       sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-    }
-}
-
 /* FIXME These would more efficient to use than load_mem/store_mem,
    but need to be changed to use the memory map.  */
 
index cc7d5d94bc963e93b2244974e12f7ec4275ab47f..ea8948d33698c1fe32f45eee5835d77eeaaa9dcb 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-if.c (sim_do_command): Delete.
+
 2011-02-14  Mike Frysinger  <vapier@gentoo.org>
 
        * sh64.c (trap_handler): Change zfree to free.
index 3c3ce6e60613450cf978f6fe300be58d7679e65f..b85f20cc9bda1b584d5cdd11416f9fa4013fd549 100644 (file)
@@ -193,16 +193,6 @@ sim_create_inferior (sd, abfd, argv, envp)
 
   return SIM_RC_OK;
 }
-
-void
-sim_do_command (sd, cmd)
-     SIM_DESC sd;
-     char *cmd;
-{ 
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-}
-
 \f
 /* Disassemble an instruction.  */
 
index e548f7c16bedb80dae794954b43ffb7af971eeb4..ca2aeb0bd13009964fb0fa4cda3c507398057f4d 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Delete.
+
 2011-03-21  Kevin Buettner  <kevinb@redhat.com>
 
        * simops (OP_10007E0): Update errno handling as most traps
index 21b587eeedf19e8099b17a50ca475c64a2fab035..2c113072a262dfb1747d81ba875da86441bfc849 100644 (file)
@@ -329,22 +329,3 @@ sim_store_register (sd, rn, memory, length)
   State.regs[rn] = T2H_4 (*(unsigned32*)memory);
   return length;
 }
-
-void
-sim_do_command (sd, cmd)
-     SIM_DESC sd;
-     char *cmd;
-{
-  char *mm_cmd = "memory-map";
-  char *int_cmd = "interrupt";
-
-  if (sim_args_command (sd, cmd) != SIM_RC_OK)
-    {
-      if (strncmp (cmd, mm_cmd, strlen (mm_cmd) == 0))
-       sim_io_eprintf (sd, "`memory-map' command replaced by `sim memory'\n");
-      else if (strncmp (cmd, int_cmd, strlen (int_cmd)) == 0)
-       sim_io_eprintf (sd, "`interrupt' command replaced by `sim watch'\n");
-      else
-       sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
-    }
-}
This page took 0.040463 seconds and 4 git commands to generate.