[3/6] Downgrade fatal to warning in linux_async

Message ID 1407340688-13721-4-git-send-email-gbenson@redhat.com
State Committed
Headers

Commit Message

Gary Benson Aug. 6, 2014, 3:58 p.m. UTC
  This commit downgrades a fatal error to a warning in linux_async.
linux_async is called from two different places in gdbserver:

 Via target_async from handle_accept_event.  The argument
   is always zero, so The warning will never be printed here

 Via start_non_stop from handle_general_set.  This prints
   its own error message to stderr on failure, which will
   be preceded by the warning if it is emitted.

gdb/gdbserver/
2014-08-06  Gary Benson  <gbenson@redhat.com>

	* linux-low.c (linux_async): Replace fatal with warning.
	Tidy up and return.
	(linux_start_non_stop): Return -1 if linux_async failed.
---
 gdb/gdbserver/ChangeLog   |    6 ++++++
 gdb/gdbserver/linux-low.c |   13 ++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
  

Comments

Pedro Alves Aug. 20, 2014, 4:18 p.m. UTC | #1
On 08/06/2014 04:58 PM, Gary Benson wrote:
> This commit downgrades a fatal error to a warning in linux_async.
> linux_async is called from two different places in gdbserver:
> 
>  Via target_async from handle_accept_event.  The argument
>    is always zero, so The warning will never be printed here

Typo "The" and period.

>  Via start_non_stop from handle_general_set.  This prints
>    its own error message to stderr on failure, which will
>    be preceded by the warning if it is emitted.
> 
> gdb/gdbserver/
> 2014-08-06  Gary Benson  <gbenson@redhat.com>
> 
> 	* linux-low.c (linux_async): Replace fatal with warning.
> 	Tidy up and return.
> 	(linux_start_non_stop): Return -1 if linux_async failed.

This is OK.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 4eaf2d2..819fcf2 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5111,7 +5111,14 @@  linux_async (int enable)
       if (enable)
 	{
 	  if (pipe (linux_event_pipe) == -1)
-	    fatal ("creating event pipe failed.");
+	    {
+	      linux_event_pipe[0] = -1;
+	      linux_event_pipe[1] = -1;
+	      sigprocmask (SIG_UNBLOCK, &mask, NULL);
+
+	      warning ("creating event pipe failed.");
+	      return previous;
+	    }
 
 	  fcntl (linux_event_pipe[0], F_SETFL, O_NONBLOCK);
 	  fcntl (linux_event_pipe[1], F_SETFL, O_NONBLOCK);
@@ -5144,6 +5151,10 @@  linux_start_non_stop (int nonstop)
 {
   /* Register or unregister from event-loop accordingly.  */
   linux_async (nonstop);
+
+  if (target_is_async_p () != (nonstop != 0))
+    return -1;
+
   return 0;
 }