aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-11-02 12:09:31 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-11-06 14:03:11 -0600
commitca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d (patch)
tree13e76a87a14d4363437ff398b2e89aed63f2f1eb /gdb/nat
parent848288b363337e49bcd54104cd83d4b8fb2247b8 (diff)
downloadgdb-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/nat')
-rw-r--r--gdb/nat/linux-osdata.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index 67f9f3a..84357e2 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -566,11 +566,12 @@ linux_xfer_osdata_cpus (struct buffer *buffer)
char *key, *value;
int i = 0;
- key = strtok (buf, ":");
+ char *saveptr;
+ key = strtok_r (buf, ":", &saveptr);
if (key == NULL)
continue;
- value = strtok (NULL, ":");
+ value = strtok_r (NULL, ":", &saveptr);
if (value == NULL)
continue;
@@ -1216,36 +1217,36 @@ linux_xfer_osdata_modules (struct buffer *buffer)
{
if (fgets (buf, sizeof (buf), fp.get ()))
{
- char *name, *dependencies, *status, *tmp;
+ char *name, *dependencies, *status, *tmp, *saveptr;
unsigned int size;
unsigned long long address;
int uses;
- name = strtok (buf, " ");
+ name = strtok_r (buf, " ", &saveptr);
if (name == NULL)
continue;
- tmp = strtok (NULL, " ");
+ tmp = strtok_r (NULL, " ", &saveptr);
if (tmp == NULL)
continue;
if (sscanf (tmp, "%u", &size) != 1)
continue;
- tmp = strtok (NULL, " ");
+ tmp = strtok_r (NULL, " ", &saveptr);
if (tmp == NULL)
continue;
if (sscanf (tmp, "%d", &uses) != 1)
continue;
- dependencies = strtok (NULL, " ");
+ dependencies = strtok_r (NULL, " ", &saveptr);
if (dependencies == NULL)
continue;
- status = strtok (NULL, " ");
+ status = strtok_r (NULL, " ", &saveptr);
if (status == NULL)
continue;
- tmp = strtok (NULL, "\n");
+ tmp = strtok_r (NULL, "\n", &saveptr);
if (tmp == NULL)
continue;
if (sscanf (tmp, "%llx", &address) != 1)