aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-02-20 00:28:17 -0500
committerMike Frysinger <vapier@gentoo.org>2014-03-10 22:57:29 -0400
commit60d847df0b9691b7cb38bfba41b9d6aafd97efc2 (patch)
treea2fa4e54d1c4bc8a82cdc5fbd65f5958875356cf /sim
parent61d1ce24e894c08a701efc5794012161ef101a60 (diff)
downloadfsf-binutils-gdb-60d847df0b9691b7cb38bfba41b9d6aafd97efc2.zip
fsf-binutils-gdb-60d847df0b9691b7cb38bfba41b9d6aafd97efc2.tar.gz
fsf-binutils-gdb-60d847df0b9691b7cb38bfba41b9d6aafd97efc2.tar.bz2
sim: constify arg to sim_do_command
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.
Diffstat (limited to 'sim')
-rw-r--r--sim/arm/ChangeLog4
-rw-r--r--sim/arm/wrapper.c2
-rw-r--r--sim/avr/ChangeLog4
-rw-r--r--sim/avr/interp.c2
-rw-r--r--sim/common/ChangeLog6
-rw-r--r--sim/common/sim-command.c2
-rw-r--r--sim/common/sim-options.c2
-rw-r--r--sim/common/sim-options.h2
-rw-r--r--sim/cr16/ChangeLog4
-rw-r--r--sim/cr16/interp.c2
-rw-r--r--sim/d10v/ChangeLog4
-rw-r--r--sim/d10v/interp.c2
-rw-r--r--sim/erc32/ChangeLog4
-rw-r--r--sim/erc32/interf.c2
-rw-r--r--sim/m32c/ChangeLog5
-rw-r--r--sim/m32c/gdb-if.c10
-rw-r--r--sim/mcore/ChangeLog4
-rw-r--r--sim/mcore/interp.c2
-rw-r--r--sim/microblaze/ChangeLog4
-rw-r--r--sim/microblaze/interp.c2
-rw-r--r--sim/moxie/ChangeLog4
-rw-r--r--sim/moxie/interp.c2
-rw-r--r--sim/ppc/ChangeLog4
-rw-r--r--sim/ppc/sim_calls.c2
-rw-r--r--sim/rl78/ChangeLog5
-rw-r--r--sim/rl78/gdb-if.c9
-rw-r--r--sim/rx/ChangeLog5
-rw-r--r--sim/rx/gdb-if.c10
-rw-r--r--sim/sh/ChangeLog5
-rw-r--r--sim/sh/interp.c8
30 files changed, 95 insertions, 28 deletions
diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog
index 69e3447..9910633 100644
--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -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.
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index c475962..064962b 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -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,
diff --git a/sim/avr/ChangeLog b/sim/avr/ChangeLog
index 56f79be..2b73b24 100644
--- a/sim/avr/ChangeLog
+++ b/sim/avr/ChangeLog
@@ -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.
diff --git a/sim/avr/interp.c b/sim/avr/interp.c
index 1ee6507..7c8f81b 100644
--- a/sim/avr/interp.c
+++ b/sim/avr/interp.c
@@ -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. */
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 9bf58e2..4d9fc3b 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -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.
diff --git a/sim/common/sim-command.c b/sim/common/sim-command.c
index 7fa2b1f..86eac03 100644
--- a/sim/common/sim-command.c
+++ b/sim/common/sim-command.c
@@ -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",
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index ed10dfe..281a47f 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -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)
diff --git a/sim/common/sim-options.h b/sim/common/sim-options.h
index 778f4c1..4c318f9 100644
--- a/sim/common/sim-options.h
+++ b/sim/common/sim-options.h
@@ -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 */
diff --git a/sim/cr16/ChangeLog b/sim/cr16/ChangeLog
index 9903ad4..dda7e60 100644
--- a/sim/cr16/ChangeLog
+++ b/sim/cr16/ChangeLog
@@ -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.
diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
index 48da916..e04ccc4 100644
--- a/sim/cr16/interp.c
+++ b/sim/cr16/interp.c
@@ -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);
}
diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog
index 4a878b0..f13f83c 100644
--- a/sim/d10v/ChangeLog
+++ b/sim/d10v/ChangeLog
@@ -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.
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index f07520e..86b5e5e 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -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);
}
diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog
index 1592693..fbf8813 100644
--- a/sim/erc32/ChangeLog
+++ b/sim/erc32/ChangeLog
@@ -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.
diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c
index 84229cd..63b3f38 100644
--- a/sim/erc32/interf.c
+++ b/sim/erc32/interf.c
@@ -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);
}
diff --git a/sim/m32c/ChangeLog b/sim/m32c/ChangeLog
index e202191..2abe643 100644
--- a/sim/m32c/ChangeLog
+++ b/sim/m32c/ChangeLog
@@ -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.
diff --git a/sim/m32c/gdb-if.c b/sim/m32c/gdb-if.c
index bec9d48..a617b7c 100644
--- a/sim/m32c/gdb-if.c
+++ b/sim/m32c/gdb-if.c
@@ -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 **
diff --git a/sim/mcore/ChangeLog b/sim/mcore/ChangeLog
index c97a2c5..d65fda2 100644
--- a/sim/mcore/ChangeLog
+++ b/sim/mcore/ChangeLog
@@ -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.
diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index 9b08de0..73da916 100644
--- a/sim/mcore/interp.c
+++ b/sim/mcore/interp.c
@@ -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. */
diff --git a/sim/microblaze/ChangeLog b/sim/microblaze/ChangeLog
index 911a8b3..ba17d35 100644
--- a/sim/microblaze/ChangeLog
+++ b/sim/microblaze/ChangeLog
@@ -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.
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index 8fcf9d9..cc61278 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -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. */
diff --git a/sim/moxie/ChangeLog b/sim/moxie/ChangeLog
index 33a27852..691d41a 100644
--- a/sim/moxie/ChangeLog
+++ b/sim/moxie/ChangeLog
@@ -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.
diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
index 3268732..a3f238a 100644
--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -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,
diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index 3f279fe..3ec45a5 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -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.
diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c
index 27ee1fe..4e61335 100644
--- a/sim/ppc/sim_calls.c
+++ b/sim/ppc/sim_calls.c
@@ -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)"));
diff --git a/sim/rl78/ChangeLog b/sim/rl78/ChangeLog
index 4b556cc..654d1d6 100644
--- a/sim/rl78/ChangeLog
+++ b/sim/rl78/ChangeLog
@@ -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.
diff --git a/sim/rl78/gdb-if.c b/sim/rl78/gdb-if.c
index 6c4b5b5..f8712bf 100644
--- a/sim/rl78/gdb-if.c
+++ b/sim/rl78/gdb-if.c
@@ -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. */
diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog
index 3ce615e..674b82e 100644
--- a/sim/rx/ChangeLog
+++ b/sim/rx/ChangeLog
@@ -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.
diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c
index 77048a0..3ccea98 100644
--- a/sim/rx/gdb-if.c
+++ b/sim/rx/gdb-if.c
@@ -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 **
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index d479841..ac5f954 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -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.
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index cf6fd8d..c854174 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -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')