public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Use strtok_r instead of strtok
Date: Wed, 06 Nov 2019 21:03:00 -0000	[thread overview]
Message-ID: <ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d ***

commit ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d
Author:     Christian Biesinger <cbiesinger@google.com>
AuthorDate: Sat Nov 2 12:09:31 2019 -0500
Commit:     Christian Biesinger <cbiesinger@google.com>
CommitDate: Wed Nov 6 14:03:11 2019 -0600

    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

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 048c2dd484..f43d3a5aed 100644
--- a/gdb/ChangeLog
+++ b/gdb/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-06  Tom Tromey  <tom@tromey.com>
 
 	* tui/tui-interp.c: Don't include readline.h.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 35684dbe82..9d0afaaf28 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 cafff6b109..54bd2a26de 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 59e8a55313..c5f7176cff 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;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 567b01c5d1..18cee91dd3 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -839,9 +839,10 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
 			   "      Size", "    Offset", "objfile");
 	    }
 
-	  for (line = strtok (map.get (), "\n");
+	  char *saveptr;
+	  for (line = strtok_r (map.get (), "\n", &saveptr);
 	       line;
-	       line = strtok (NULL, "\n"))
+	       line = strtok_r (NULL, "\n", &saveptr))
 	    {
 	      ULONGEST addr, endaddr, offset, inode;
 	      const char *permissions, *device, *mapping_filename;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 0e99fa39bd..c14897a5f7 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -696,8 +696,9 @@ output_cores (struct ui_out *uiout, const char *field_name, const char *xcores)
   ui_out_emit_list list_emitter (uiout, field_name);
   auto cores = make_unique_xstrdup (xcores);
   char *p = cores.get ();
+  char *saveptr;
 
-  for (p = strtok (p, ","); p;  p = strtok (NULL, ","))
+  for (p = strtok_r (p, ",", &saveptr); p;  p = strtok_r (NULL, ",", &saveptr))
     uiout->field_string (NULL, p);
 }
 
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index 67f9f3a425..84357e2955 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)
diff --git a/gdb/remote.c b/gdb/remote.c
index 8ea52d355a..1ac9013408 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5169,7 +5169,8 @@ register_remote_support_xml (const char *xml)
   else
     {
       char *copy = xstrdup (remote_support_xml + 13);
-      char *p = strtok (copy, ",");
+      char *saveptr;
+      char *p = strtok_r (copy, ",", &saveptr);
 
       do
 	{
@@ -5180,7 +5181,7 @@ register_remote_support_xml (const char *xml)
 	      return;
 	    }
 	}
-      while ((p = strtok (NULL, ",")) != NULL);
+      while ((p = strtok_r (NULL, ",", &saveptr)) != NULL);
       xfree (copy);
 
       remote_support_xml = reconcat (remote_support_xml,
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 873fbaa49b..fc73b23145 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -316,8 +316,10 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt)
   if (data)
     {
       adi_stat_t adi_stat = get_adi_info (pid);
-      char *line;
-      for (line = strtok (data.get (), "\n"); line; line = strtok (NULL, "\n"))
+      char *saveptr;
+      for (char *line = strtok_r (data.get (), "\n", &saveptr);
+	   line;
+	   line = strtok_r (NULL, "\n", &saveptr))
         {
           ULONGEST addr, endaddr;
 
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index dc988dfae8..3830faa436 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -221,9 +221,10 @@ syscall_create_syscall_desc (struct syscalls_info *syscalls_info,
   /*  Add syscall to its groups.  */
   if (groups != NULL)
     {
-      for (char *group = strtok (groups, ",");
+      char *saveptr;
+      for (char *group = strtok_r (groups, ",", &saveptr);
 	   group != NULL;
-	   group = strtok (NULL, ","))
+	   group = strtok_r (NULL, ",", &saveptr))
 	syscall_group_add_syscall (syscalls_info, sysdesc, group);
     }
 }


             reply	other threads:[~2019-11-06 21:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 21:03 gdb-buildbot [this message]
2019-11-06 21:03 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, branch master gdb-buildbot
2019-11-23  4:18 ` Failures on Fedora-i686, " gdb-buildbot
2019-11-23  6:13 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2019-11-23  6:44 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2019-11-23  7:01 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca3a04f65d2b31ab55364c7dc2a82cff8aa20b0d@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).