]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: constify arg to sim_do_command
authorMike Frysinger <vapier@gentoo.org>
Thu, 20 Feb 2014 05:28:17 +0000 (00:28 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 11 Mar 2014 02:57:29 +0000 (22:57 -0400)
It is rare for people to want to modify the cmd arg.  In general, they
really shouldn't be, but a few still do.  For those who misbehave, dupe
the string locally so they can bang on it.

32 files changed:
include/gdb/ChangeLog
include/gdb/remote-sim.h
sim/arm/ChangeLog
sim/arm/wrapper.c
sim/avr/ChangeLog
sim/avr/interp.c
sim/common/ChangeLog
sim/common/sim-command.c
sim/common/sim-options.c
sim/common/sim-options.h
sim/cr16/ChangeLog
sim/cr16/interp.c
sim/d10v/ChangeLog
sim/d10v/interp.c
sim/erc32/ChangeLog
sim/erc32/interf.c
sim/m32c/ChangeLog
sim/m32c/gdb-if.c
sim/mcore/ChangeLog
sim/mcore/interp.c
sim/microblaze/ChangeLog
sim/microblaze/interp.c
sim/moxie/ChangeLog
sim/moxie/interp.c
sim/ppc/ChangeLog
sim/ppc/sim_calls.c
sim/rl78/ChangeLog
sim/rl78/gdb-if.c
sim/rx/ChangeLog
sim/rx/gdb-if.c
sim/sh/ChangeLog
sim/sh/interp.c

index f6d49328cf82241a628ac61a69b0966adc4938ed..135391d42427fba4260d5c8bf15956bfa6f32695 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * remote-sim.h (sim_do_command): Add const to cmd.
+
 2014-03-05  Alan Modra  <amodra@gmail.com>
 
        Update copyright notice.
index 03f87f5a553613b9a6011be83946c6a1e18923f1..c335d4f81b0c2b79721f4ad0866a874ba5bbb627 100644 (file)
@@ -273,7 +273,7 @@ void sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc);
    Simulators should be prepared to deal with any combination of NULL
    or empty CMD. */
 
-void sim_do_command (SIM_DESC sd, char *cmd);
+void sim_do_command (SIM_DESC sd, const char *cmd);
 
 /* Complete a command based on the available sim commands.  Returns an
    array of possible matches.  */
index 69e3447ae0c1f5a1a1bde205749eaae912cb5283..9910633ca716f1be8deeaf5036c34361c8224725 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * wrapper.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * wrapper.c (sim_load): Add const to prog.
index c475962bc42920bd2e65a43da94b67781f007f4a..064962b12551e7592db184f30169ef87366ac097 100644 (file)
@@ -936,7 +936,7 @@ sim_stop_reason (sd, reason, sigrc)
 void
 sim_do_command (sd, cmd)
      SIM_DESC sd ATTRIBUTE_UNUSED;
-     char *cmd ATTRIBUTE_UNUSED;
+     const char *cmd ATTRIBUTE_UNUSED;
 {  
   (*sim_callback->printf_filtered)
     (sim_callback,
index 56f79be8c3b4135ad6646a14d461d888028740b8..2b73b24b0860f23a873f32f67b4c6188c7e54ce6 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (sim_load): Add const to prog.
index 1ee6507eec8c0c77b7e0c9ce24ee66a27d542e4d..7c8f81b593d374d288a2fe3193d4a0a2088ce929 100644 (file)
@@ -1831,7 +1831,7 @@ sim_kill (SIM_DESC sd)
 }
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
   /* Nothing there yet; it's all an error.  */
   
index 9bf58e27af30b8f88325970762aa715142a0bc48..4d9fc3b4e89c37c8e79f4e70d7672b44aa76d754 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-command.c (sim_do_command): Add const to cmd.
+       * sim-options.c (sim_args_command): Add const to cmd.
+       * sim-options.h (sim_args_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * sim-hload.c (sim_load): Add const to prog.
index 7fa2b1faa5f46a68a65f6f56a95cc0017b3d63ba..86eac0322fd4b283c5eaa5f97b25e17a0c2a0321 100644 (file)
@@ -26,7 +26,7 @@
    which add custom options via sim_add_option_table().  */
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
   if (sim_args_command (sd, cmd) != SIM_RC_OK)
     sim_io_eprintf (sd, "Unknown sim command: \"%s\".  Try \"sim help\".\n",
index ed10dfe8954e6375fecdfb54989e3e0413ba5225..281a47f3b23a5bbc2d6d8fda27c424fb72de7881 100644 (file)
@@ -971,7 +971,7 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
 }
 
 SIM_RC
-sim_args_command (SIM_DESC sd, char *cmd)
+sim_args_command (SIM_DESC sd, const char *cmd)
 {
   /* something to do? */
   if (cmd == NULL)
index 778f4c15443ad839eb0563179020592b75c4cef0..4c318f941b0219aa074af39be765aab64a7741d6 100644 (file)
@@ -143,6 +143,6 @@ void sim_print_help (SIM_DESC sd, int is_command);
 
 /* Try to parse the command as if it is an option, Only fail when
    totally unsuccessful */
-SIM_RC sim_args_command (SIM_DESC sd, char *cmd);
+SIM_RC sim_args_command (SIM_DESC sd, const char *cmd);
 
 #endif /* SIM_OPTIONS_H */
index 9903ad4fa6f7de3582ae705604f6b2845ea6e031..dda7e60456a230b61ff33540cceec0fac2707bf4 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (sim_load): Add const to prog.
index 48da9167d937deb0c1fb1716555b0e8990b51832..e04ccc4db0c58647e57c992085b9e1462a162101 100644 (file)
@@ -1561,7 +1561,7 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
 void
 sim_do_command (sd, cmd)
      SIM_DESC sd;
-     char *cmd;
+     const char *cmd;
 { 
   (*cr16_callback->printf_filtered) (cr16_callback, "sim_do_command: %s\n",cmd);
 }
index 4a878b03306c487126d82ffafec66462e0f87d88..f13f83cbfb18b048c55728aa5970138b05273e16 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (sim_load): Add const to prog.
index f07520ed1a1e9a0d3f61d5edf4278fd5f092e244..86b5e5eba426fe99e6b4a1e68d3d06fc15d9a6ae 100644 (file)
@@ -1482,7 +1482,7 @@ sim_store_register (sd, rn, memory, length)
 void
 sim_do_command (sd, cmd)
      SIM_DESC sd;
-     char *cmd;
+     const char *cmd;
 { 
   (*d10v_callback->printf_filtered) (d10v_callback, "sim_do_command: %s\n",cmd);
 }
index 1592693738554ff56580eab6f9fb43ce326b544d..fbf8813dc035e983cce5f338ec0199b53dde89fc 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interf.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interf.c (sim_load): Add const to prog.
index 84229cd54d7c108e1392a2366bd971ba1fe15e02..63b3f38c97e7cefc809f7c75acd4f9e6408970a6 100644 (file)
@@ -479,7 +479,7 @@ sim_trace (sd)
 void
 sim_do_command(sd, cmd)
      SIM_DESC sd;
-    char           *cmd;
+     const char *cmd;
 {
     exec_cmd(&sregs, cmd);
 }
index e202191e4526aa2f5ab69c44a54bd16b4e7fcc81..2abe64336db006f667920e5db0d1dafed82f51d8 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * gdb-if.c (sim_do_command): Add const to cmd.  Move args
+       to top and add const.  Call strdup on cmd and free at end.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * gdb-if.c (sim_load): Add const to prog.
index bec9d48838ac0c151f6d234ba31b14995df99a61..a617b7cb1c2ef245f43ed2192e32a1ab56ee8c43 100644 (file)
@@ -650,11 +650,12 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p)
 }
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
-  check_desc (sd);
+  const char *args;
+  char *p = strdup (cmd);
 
-  char *p = cmd;
+  check_desc (sd);
 
   /* Skip leading whitespace.  */
   while (isspace (*p))
@@ -667,7 +668,6 @@ sim_do_command (SIM_DESC sd, char *cmd)
 
   /* Null-terminate the command word, and record the start of any
      further arguments.  */
-  char *args;
   if (*p)
     {
       *p = '\0';
@@ -701,6 +701,8 @@ sim_do_command (SIM_DESC sd, char *cmd)
   else
     printf ("The 'sim' command expects either 'trace' or 'verbose'"
            " as a subcommand.\n");
+
+  free (p);
 }
 
 char **
index c97a2c5c7c88c0854fe722dcd983ddbf0c06e830..d65fda293b5e95ab1b993ff2d1eac0bb23a5b476 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (sim_load): Add const to prog.
index 9b08de051afa9576ea2a821b21c87c5e136c60f3..73da9168e6d7dfba5a192a43aa78bb031f67a158 100644 (file)
@@ -2130,7 +2130,7 @@ sim_kill (sd)
 void
 sim_do_command (sd, cmd)
      SIM_DESC sd;
-     char * cmd;
+     const char *cmd;
 {
   /* Nothing there yet; it's all an error.  */
   
index 911a8b3769bb51901ac4d862d0037a160dc7bf7f..ba17d3574288fe28a6fba66b30ffd32eb677a74c 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (sim_load): Add const to prog.
index 8fcf9d964cd98a384193ea762cb569f7cce75907..cc612788a4ff97034d440888d5567d1dff6c6a78 100644 (file)
@@ -1006,7 +1006,7 @@ sim_kill (SIM_DESC sd)
 }
 
 void
-sim_do_command (SIM_DESC sd, char * cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
   /* Nothing there yet; it's all an error.  */
 
index 33a27852ffd7f68a1b913a638c40fcd1e47354f8..691d41ad7df733cf128307d804662c28eb1aaf4a 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (sim_load): Add const to prog.
index 32687322297ab4bbd06e873c361a0ff1edc7ba20..a3f238a00669b2e93ce071a6da976a04459d694a 100644 (file)
@@ -1350,7 +1350,7 @@ sim_kill (sd)
 void
 sim_do_command (sd, cmd)
      SIM_DESC sd;
-     char * cmd;
+     const char *cmd;
 {
   if (sim_args_command (sd, cmd) != SIM_RC_OK)
     sim_io_printf (sd, 
index 3f279fec1146535d94515140b922348280043d06..3ec45a58e79a0966a02d20a7a7850275022c8377 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim_calls.c (sim_do_command): Add const to cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * sim_calls.c (sim_load): Add const to prog.
index 27ee1fea1a796f6c6c87a7e0a1aa74f498b1dae5..4e61335c2d4e5b7b48cb1381a58cded60d4e4491 100644 (file)
@@ -247,7 +247,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
 }
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
   TRACE(trace_gdb, ("sim_do_commands(cmd=%s) called\n",
                    cmd ? cmd : "(null)"));
index 4b556cc8bebdbfdb7e936faf5afc9b64dfb2ba19..654d1d6a870efdc182eb4fca482160c0c051b70e 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * gdb-if.c (sim_do_command): Add const to cmd.  Move args
+       to top and add const.  Call strdup on cmd and free at end.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * gdb-if.c (sim_load): Add const to prog.
index 6c4b5b5fc896cf9e3ecd3d6de6fd4c339ebc7e0c..f8712bf7f7466f2b9b8b93b23f37c56b0a97f5f8 100644 (file)
@@ -499,9 +499,10 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p)
    command.  */
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
-  char *args;
+  const char *args;
+  char *p = strdup (cmd);
 
   check_desc (sd);
 
@@ -512,8 +513,6 @@ sim_do_command (SIM_DESC sd, char *cmd)
     }
   else
     {
-      char *p = cmd;
-
       /* Skip leading whitespace.  */
       while (isspace (*p))
        p++;
@@ -561,6 +560,8 @@ sim_do_command (SIM_DESC sd, char *cmd)
   else
     printf ("The 'sim' command expects either 'trace' or 'verbose'"
            " as a subcommand.\n");
+
+  free (p);
 }
 
 /* Stub for command completion.  */
index 3ce615e0ade2e7c15cb968e30ef9305e92d25b4b..674b82e9cfb72c0ed276aea97cd45d08f271ad86 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * gdb-if.c (sim_do_command): Add const to cmd.  Move args
+       to top and add const.  Call strdup on cmd and free at end.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * gdb-if.c (sim_load): Add const to prog.
index 77048a0a0f9dfeb585074309be25a2680925f88d..3ccea98df3d3f02abcda60bf6df4ddba0800cfda 100644 (file)
@@ -791,11 +791,12 @@ sim_stop_reason (SIM_DESC sd, enum sim_stop *reason_p, int *sigrc_p)
 }
 
 void
-sim_do_command (SIM_DESC sd, char *cmd)
+sim_do_command (SIM_DESC sd, const char *cmd)
 {
-  check_desc (sd);
+  const char *args;
+  char *p = strdup (cmd);
 
-  char *p = cmd;
+  check_desc (sd);
 
   /* Skip leading whitespace.  */
   while (isspace (*p))
@@ -808,7 +809,6 @@ sim_do_command (SIM_DESC sd, char *cmd)
 
   /* Null-terminate the command word, and record the start of any
      further arguments.  */
-  char *args;
   if (*p)
     {
       *p = '\0';
@@ -844,6 +844,8 @@ sim_do_command (SIM_DESC sd, char *cmd)
   else
     printf ("The 'sim' command expects either 'trace' or 'verbose'"
            " as a subcommand.\n");
+
+  free (p);
 }
 
 char **
index d479841edb788832ca49230e3237207818d98934..ac5f9548c4faa27560209f4813fa20378a09fc2f 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-10  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c (parse_and_set_memory_size): Add const to str.
+       (sim_do_command): Add const to cmd and sms_cmd.
+
 2014-03-05  Mike Frysinger  <vapier@gentoo.org>
 
        * interp.c (sim_load): Add const to prog.
index cf6fd8dae06ca16e3c496ecc714956c6e6864b32..c854174d2bd94cbb6b5ae90772b2eec921698c19 100644 (file)
@@ -473,7 +473,7 @@ int valid[16];
 #define UNDEF(x)
 #endif
 
-static void parse_and_set_memory_size (char *str);
+static void parse_and_set_memory_size (const char *str);
 static int IOMEM (int addr, int write, int value);
 static struct loop_bounds get_loop_bounds (int, int, unsigned char *,
                                           unsigned char *, int, int);
@@ -2663,7 +2663,7 @@ sim_open (kind, cb, abfd, argv)
 
 static void
 parse_and_set_memory_size (str)
-     char *str;
+     const char *str;
 {
   int n;
 
@@ -2739,9 +2739,9 @@ sim_create_inferior (sd, prog_bfd, argv, env)
 void
 sim_do_command (sd, cmd)
      SIM_DESC sd;
-     char *cmd;
+     const char *cmd;
 {
-  char *sms_cmd = "set-memory-size";
+  const char *sms_cmd = "set-memory-size";
   int cmdsize;
 
   if (cmd == NULL || *cmd == '\0')