diff options
author | Christian Biesinger <cbiesinger@google.com> | 2019-11-02 12:09:31 -0500 |
---|---|---|
committer | Christian Biesinger <cbiesinger@google.com> | 2019-11-06 14:03:11 -0600 |
commit | ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d (patch) | |
tree | 13e76a87a14d4363437ff398b2e89aed63f2f1eb /gdb/gdbserver | |
parent | 848288b363337e49bcd54104cd83d4b8fb2247b8 (diff) | |
download | gdb-ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d.zip gdb-ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d.tar.gz gdb-ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d.tar.bz2 |
Use strtok_r instead of strtok
Improves threadsafety. This will be important when the patch series at
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176
lands.
gdb/ChangeLog:
2019-11-06 Christian Biesinger <cbiesinger@google.com>
* linux-tdep.c (linux_info_proc): Use strtok_r instead of strtok.
* mi/mi-main.c (output_cores): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_cpus): Likewise.
(linux_xfer_osdata_modules): Likewise.
* remote.c (register_remote_support_xml): Likewise.
* sparc64-tdep.c (adi_is_addr_mapped): Likewise.
* xml-syscall.c (syscall_create_syscall_desc): Likewise.
gdb/gdbserver/ChangeLog:
2019-11-06 Christian Biesinger <cbiesinger@google.com>
* linux-x86-low.c (x86_linux_process_qsupported): Use strtok_r
instead of strtok.
* server.c (handle_query): Likewise.
(captured_main): Likewise.
Change-Id: Ief6138965a24398e5fc064598cd8f2abd3b5047c
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-low.c | 6 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 14 |
3 files changed, 21 insertions, 9 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 35684db..9d0afaa 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,13 @@ +2019-11-06 Christian Biesinger <cbiesinger@google.com> + + * linux-tdep.c (linux_info_proc): Use strtok_r instead of strtok. + * mi/mi-main.c (output_cores): Likewise. + * nat/linux-osdata.c (linux_xfer_osdata_cpus): Likewise. + (linux_xfer_osdata_modules): Likewise. + * remote.c (register_remote_support_xml): Likewise. + * sparc64-tdep.c (adi_is_addr_mapped): Likewise. + * xml-syscall.c (syscall_create_syscall_desc): Likewise. + 2019-11-01 Christian Biesinger <cbiesinger@google.com> * configure: Regenerate. diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index cafff6b..54bd2a2 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -912,9 +912,11 @@ x86_linux_process_qsupported (char **features, int count) if (startswith (feature, "xmlRegisters=")) { char *copy = xstrdup (feature + 13); - char *p; - for (p = strtok (copy, ","); p != NULL; p = strtok (NULL, ",")) + char *saveptr; + for (char *p = strtok_r (copy, ",", &saveptr); + p != NULL; + p = strtok_r (NULL, ",", &saveptr)) { if (strcmp (p, "i386") == 0) { diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 59e8a55..c5f7176 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -2268,9 +2268,10 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) /* Two passes, to avoid nested strtok calls in target_process_qsupported. */ - for (p = strtok (p + 1, ";"); + char *saveptr; + for (p = strtok_r (p + 1, ";", &saveptr); p != NULL; - p = strtok (NULL, ";")) + p = strtok_r (NULL, ";", &saveptr)) { count++; qsupported = XRESIZEVEC (char *, qsupported, count); @@ -3633,12 +3634,11 @@ captured_main (int argc, char *argv[]) } else if (startswith (*next_arg, "--disable-packet=")) { - char *packets, *tok; - - packets = *next_arg += sizeof ("--disable-packet=") - 1; - for (tok = strtok (packets, ","); + char *packets = *next_arg += sizeof ("--disable-packet=") - 1; + char *saveptr; + for (char *tok = strtok_r (packets, ",", &saveptr); tok != NULL; - tok = strtok (NULL, ",")) + tok = strtok_r (NULL, ",", &saveptr)) { if (strcmp ("vCont", tok) == 0) disable_packet_vCont = true; |