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 safe_strerror instead of strerror where possible
Date: Tue, 26 Nov 2019 18:24:00 -0000	[thread overview]
Message-ID: <6d91ce9a659f5b65bb6ad2d30d74250da342150c@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 6d91ce9a659f5b65bb6ad2d30d74250da342150c ***

commit 6d91ce9a659f5b65bb6ad2d30d74250da342150c
Author:     Christian Biesinger <cbiesinger@google.com>
AuthorDate: Fri Nov 22 14:31:35 2019 -0600
Commit:     Christian Biesinger <cbiesinger@google.com>
CommitDate: Tue Nov 26 11:53:59 2019 -0600

    Use safe_strerror instead of strerror where possible
    
    This provides threadsafety. Unfortunately, since libinproctrace.so
    does not link to gnulib, we can't use it there, especially since it
    still includes the gnulib headers (so it is difficult to directly
    call the system strerror_r).
    
    gdb/ChangeLog:
    
    2019-11-26  Christian Biesinger  <cbiesinger@google.com>
    
            * linux-nat.c (detach_one_lwp): Call safe_strerror instead of
            strerror.
            * nto-procfs.c (nto_procfs_target::create_inferior): Likewise.
            * windows-nat.c (windows_nat_target::create_inferior): Likewise.
    
    gdb/gdbserver/ChangeLog:
    
    2019-11-26  Christian Biesinger  <cbiesinger@google.com>
    
            * debug.c (debug_set_output): Call safe_strerror instead of
            strerror.
            * linux-low.c (attach_proc_task_lwp_callback): Likewise.
            (linux_kill_one_lwp): Likewise.
            (linux_detach_one_lwp): Likewise.
            (linux_wait_for_event_filtered): Likewise.
            (store_register): Likewise.
            * lynx-low.c (lynx_attach): Likewise.
            * mem-break.c (insert_memory_breakpoint): Likewise.
            (remove_memory_breakpoint): Likewise.
            (delete_fast_tracepoint_jump): Likewise.
            (set_fast_tracepoint_jump): Likewise.
            (uninsert_fast_tracepoint_jumps_at): Likewise.
            (reinsert_fast_tracepoint_jumps_at): Likewise.
            * nto-low.c (nto_xfer_memory): Likewise.
            (nto_resume): Likewise.
    
    Change-Id: I9e259cdcaa6e11bbcc4ee6bdc5b7127d73e11abe

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fdba64eb2f..b4d7eb7afa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-11-26  Christian Biesinger  <cbiesinger@google.com>
+
+	* linux-nat.c (detach_one_lwp): Call safe_strerror instead of
+	strerror.
+	* nto-procfs.c (nto_procfs_target::create_inferior): Likewise.
+	* windows-nat.c (windows_nat_target::create_inferior): Likewise.
+
 2019-11-25  Tom de Vries  <tdevries@suse.de>
 
 	* contrib/words.sh: Add -c option.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index a5da6b584d..7b22cfd2f8 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,22 @@
+2019-11-26  Christian Biesinger  <cbiesinger@google.com>
+
+	* debug.c (debug_set_output): Call safe_strerror instead of
+	strerror.
+	* linux-low.c (attach_proc_task_lwp_callback): Likewise.
+	(linux_kill_one_lwp): Likewise.
+	(linux_detach_one_lwp): Likewise.
+	(linux_wait_for_event_filtered): Likewise.
+	(store_register): Likewise.
+	* lynx-low.c (lynx_attach): Likewise.
+	* mem-break.c (insert_memory_breakpoint): Likewise.
+	(remove_memory_breakpoint): Likewise.
+	(delete_fast_tracepoint_jump): Likewise.
+	(set_fast_tracepoint_jump): Likewise.
+	(uninsert_fast_tracepoint_jumps_at): Likewise.
+	(reinsert_fast_tracepoint_jumps_at): Likewise.
+	* nto-low.c (nto_xfer_memory): Likewise.
+	(nto_resume): Likewise.
+
 2019-11-20  Luis Machado  <luis.machado@linaro.org>
 
 	* linux-aarch64-low.c (is_sve_tdesc): Check against target feature
diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c
index a764df7688..d299b93409 100644
--- a/gdb/gdbserver/debug.c
+++ b/gdb/gdbserver/debug.c
@@ -55,7 +55,7 @@ debug_set_output (const char *new_debug_file)
   if (fptr == nullptr)
     {
       debug_printf ("Cannot open %s for writing. %s. Switching to stderr.\n",
-		    new_debug_file, strerror (errno));
+		    new_debug_file, safe_strerror (errno));
       return;
     }
 
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index d6b6ce7581..f34811cda2 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1159,7 +1159,7 @@ attach_proc_task_lwp_callback (ptid_t ptid)
 	    {
 	      debug_printf ("Cannot attach to lwp %d: "
 			    "thread is gone (%d: %s)\n",
-			    lwpid, err, strerror (err));
+			    lwpid, err, safe_strerror (err));
 	    }
 	}
       else if (err != 0)
@@ -1303,7 +1303,7 @@ linux_kill_one_lwp (struct lwp_info *lwp)
 
       debug_printf ("LKL:  kill_lwp (SIGKILL) %s, 0, 0 (%s)\n",
 		    target_pid_to_str (ptid_of (thr)),
-		    save_errno ? strerror (save_errno) : "OK");
+		    save_errno ? safe_strerror (save_errno) : "OK");
     }
 
   errno = 0;
@@ -1314,7 +1314,7 @@ linux_kill_one_lwp (struct lwp_info *lwp)
 
       debug_printf ("LKL:  PTRACE_KILL %s, 0, 0 (%s)\n",
 		    target_pid_to_str (ptid_of (thr)),
-		    save_errno ? strerror (save_errno) : "OK");
+		    save_errno ? safe_strerror (save_errno) : "OK");
     }
 }
 
@@ -1560,7 +1560,7 @@ linux_detach_one_lwp (struct lwp_info *lwp)
 	  if (ret == -1)
 	    {
 	      warning (_("Couldn't reap LWP %d while detaching: %s"),
-		       lwpid, strerror (errno));
+		       lwpid, safe_strerror (errno));
 	    }
 	  else if (!WIFEXITED (status) && !WIFSIGNALED (status))
 	    {
@@ -1573,7 +1573,7 @@ linux_detach_one_lwp (struct lwp_info *lwp)
 	{
 	  error (_("Can't detach %s: %s"),
 		 target_pid_to_str (ptid_of (thread)),
-		 strerror (save_errno));
+		 safe_strerror (save_errno));
 	}
     }
   else if (debug_threads)
@@ -2715,7 +2715,7 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
 
       if (debug_threads)
 	debug_printf ("LWFE: waitpid(-1, ...) returned %d, %s\n",
-		      ret, errno ? strerror (errno) : "ERRNO-OK");
+		      ret, errno ? safe_strerror (errno) : "ERRNO-OK");
 
       if (ret > 0)
 	{
@@ -5593,7 +5593,7 @@ store_register (const struct usrregs_info *usrregs,
 	    return;
 
 	  if ((*the_low_target.cannot_store_register) (regno) == 0)
-	    error ("writing register %d: %s", regno, strerror (errno));
+	    error ("writing register %d: %s", regno, safe_strerror (errno));
 	}
       regaddr += sizeof (PTRACE_XFER_TYPE);
     }
diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c
index 2bd24e7cee..dd4cdd8c90 100644
--- a/gdb/gdbserver/lynx-low.c
+++ b/gdb/gdbserver/lynx-low.c
@@ -316,7 +316,7 @@ lynx_attach (unsigned long pid)
 
   if (lynx_ptrace (PTRACE_ATTACH, ptid, 0, 0, 0) != 0)
     error ("Cannot attach to process %lu: %s (%d)\n", pid,
-	   strerror (errno), errno);
+	   safe_strerror (errno), errno);
 
   lynx_add_process (pid, 1);
   lynx_add_threads_after_attach (pid);
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index 582fcac163..e943915808 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -374,7 +374,7 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
       if (debug_threads)
 	debug_printf ("Failed to read shadow memory of"
 		      " breakpoint at 0x%s (%s).\n",
-		      paddress (bp->pc), strerror (err));
+		      paddress (bp->pc), safe_strerror (err));
     }
   else
     {
@@ -386,7 +386,7 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
 	{
 	  if (debug_threads)
 	    debug_printf ("Failed to insert breakpoint at 0x%s (%s).\n",
-			  paddress (bp->pc), strerror (err));
+			  paddress (bp->pc), safe_strerror (err));
 	}
     }
   return err != 0 ? -1 : 0;
@@ -415,7 +415,7 @@ remove_memory_breakpoint (struct raw_breakpoint *bp)
       if (debug_threads)
 	debug_printf ("Failed to uninsert raw breakpoint "
 		      "at 0x%s (%s) while deleting it.\n",
-		      paddress (bp->pc), strerror (err));
+		      paddress (bp->pc), safe_strerror (err));
     }
   return err != 0 ? -1 : 0;
 }
@@ -597,7 +597,7 @@ delete_fast_tracepoint_jump (struct fast_tracepoint_jump *todel)
 		  if (debug_threads)
 		    debug_printf ("Failed to uninsert fast tracepoint jump "
 				  "at 0x%s (%s) while deleting it.\n",
-				  paddress (bp->pc), strerror (ret));
+				  paddress (bp->pc), safe_strerror (ret));
 		  return ret;
 		}
 
@@ -660,7 +660,7 @@ set_fast_tracepoint_jump (CORE_ADDR where,
       if (debug_threads)
 	debug_printf ("Failed to read shadow memory of"
 		      " fast tracepoint at 0x%s (%s).\n",
-		      paddress (where), strerror (err));
+		      paddress (where), safe_strerror (err));
       free (jp);
       return NULL;
     }
@@ -684,7 +684,7 @@ set_fast_tracepoint_jump (CORE_ADDR where,
     {
       if (debug_threads)
 	debug_printf ("Failed to insert fast tracepoint jump at 0x%s (%s).\n",
-		      paddress (where), strerror (err));
+		      paddress (where), safe_strerror (err));
 
       /* Unlink it.  */
       proc->fast_tracepoint_jumps = jp->next;
@@ -739,7 +739,7 @@ uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc)
 	  if (debug_threads)
 	    debug_printf ("Failed to uninsert fast tracepoint jump at"
 			  " 0x%s (%s).\n",
-			  paddress (pc), strerror (err));
+			  paddress (pc), safe_strerror (err));
 	}
     }
 }
@@ -786,7 +786,7 @@ reinsert_fast_tracepoint_jumps_at (CORE_ADDR where)
       if (debug_threads)
 	debug_printf ("Failed to reinsert fast tracepoint jump at"
 		      " 0x%s (%s).\n",
-		      paddress (where), strerror (err));
+		      paddress (where), safe_strerror (err));
     }
 }
 
diff --git a/gdb/gdbserver/nto-low.c b/gdb/gdbserver/nto-low.c
index d77fda54b8..f267a9d786 100644
--- a/gdb/gdbserver/nto-low.c
+++ b/gdb/gdbserver/nto-low.c
@@ -247,7 +247,7 @@ nto_xfer_memory (off_t memaddr, unsigned char *myaddr, int len,
   if (nbytes == 0)
     {
       int e = errno;
-      TRACE ("Error in %s : errno=%d (%s)\n", __func__, e, strerror (e));
+      TRACE ("Error in %s : errno=%d (%s)\n", __func__, e, safe_strerror (e));
     }
   return nbytes;
 }
@@ -505,7 +505,7 @@ nto_resume (struct thread_resume *resume_info, size_t n)
 
   err = devctl (nto_inferior.ctl_fd, DCMD_PROC_RUN, &run, sizeof (run), 0);
   if (err != EOK)
-    TRACE ("Error: %d \"%s\"\n", err, strerror (err));
+    TRACE ("Error: %d \"%s\"\n", err, safe_strerror (err));
 }
 
 /* Wait for inferior's event.  
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index bc397961c8..2a63ac727d 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1420,7 +1420,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
 	  if (ret == -1)
 	    {
 	      warning (_("Couldn't reap LWP %d while detaching: %s"),
-		       lwpid, strerror (errno));
+		       lwpid, safe_strerror (errno));
 	    }
 	  else if (!WIFEXITED (status) && !WIFSIGNALED (status))
 	    {
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 0a199e7224..dcb0494e9c 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -1317,7 +1317,7 @@ nto_procfs_target::create_inferior (const char *exec_file,
     {
       /* FIXME: expected warning?  */
       /* warning( "Failed to set Kill-on-Last-Close flag: errno = %d(%s)\n",
-         errn, strerror(errn) ); */
+         errn, safe_strerror(errn) ); */
     }
   if (!target_is_pushed (ops))
     push_target (ops);
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index fdc21f38bf..d77828291c 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2710,7 +2710,7 @@ windows_nat_target::create_inferior (const char *exec_file,
 	redirect_inferior_handles (allargs, allargs_copy,
 				   &fd_inp, &fd_out, &fd_err);
       if (errno)
-	warning (_("Error in redirection: %s."), strerror (errno));
+	warning (_("Error in redirection: %s."), safe_strerror (errno));
       else
 	errno = e;
       allargs_len = strlen (allargs_copy);


             reply	other threads:[~2019-11-26 18:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 18:24 gdb-buildbot [this message]
2019-11-26 18:24 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot
2019-11-26 18:38 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-11-29  2:12 ` Failures on Fedora-i686, " gdb-buildbot
2019-11-29  2:13 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-11-29  2:14 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2019-11-29  2:53 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot
2019-11-29  2:56 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-11-29  2:57 ` Failures on Fedora-x86_64-native-extended-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=6d91ce9a659f5b65bb6ad2d30d74250da342150c@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).