aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-02-14 07:03:11 -0700
committerTom Tromey <tromey@adacore.com>2023-02-14 09:01:18 -0700
commit81aa19c303c94f549cb9ae343cfe4b635b4e888c (patch)
tree804ffe2eec706e0e18732b5724ebcf5d737f9e7a /gdb/linux-nat.c
parent5bed9dc992a0136d403a7addb29a2ed822fd4fd2 (diff)
downloadgdb-81aa19c303c94f549cb9ae343cfe4b635b4e888c.zip
gdb-81aa19c303c94f549cb9ae343cfe4b635b4e888c.tar.gz
gdb-81aa19c303c94f549cb9ae343cfe4b635b4e888c.tar.bz2
Do not cast away const in agent_run_command
While investigating something else, I noticed some weird code in agent_run_command (use of memcpy rather than strcpy). Then I noticed that 'cmd' is used as both an in and out parameter, despite being const. Casting away const like this is bad. This patch removes the const and fixes the memcpy. I also added a static assert to assure myself that the code in gdbserver is correct -- gdbserver is passing its own buffer directly to agent_run_command. Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 2b206a4..d6e69e6 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4114,9 +4114,7 @@ linux_nat_target::static_tracepoint_markers_by_strid (const char *strid)
/* Pause all */
target_stop (ptid);
- memcpy (s, "qTfSTM", sizeof ("qTfSTM"));
- s[sizeof ("qTfSTM")] = 0;
-
+ strcpy (s, "qTfSTM");
agent_run_command (pid, s, strlen (s) + 1);
/* Unpause all. */
@@ -4133,8 +4131,7 @@ linux_nat_target::static_tracepoint_markers_by_strid (const char *strid)
}
while (*p++ == ','); /* comma-separated list */
- memcpy (s, "qTsSTM", sizeof ("qTsSTM"));
- s[sizeof ("qTsSTM")] = 0;
+ strcpy (s, "qTsSTM");
agent_run_command (pid, s, strlen (s) + 1);
p = s;
}