This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] remote.c/all-stop: Implement TARGET_WAITKIND_NO_RESUMED and TARGET_WNOHANG


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=567420d10895611e03d5ee65e6b24c16a69a6e99

commit 567420d10895611e03d5ee65e6b24c16a69a6e99
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Aug 7 17:23:56 2015 +0100

    remote.c/all-stop: Implement TARGET_WAITKIND_NO_RESUMED and TARGET_WNOHANG
    
    Even though "target remote" supports target-async, the all-stop
    target_wait implementation ignores TARGET_WNOHANG.  If the core
    happens to poll for events and we've already read the stop reply out
    of the serial/socket, remote_wait_as hangs forever instead of
    returning an indication that there are no events to process.  This
    can't happen currently, but later changes will trigger this.
    
    gdb/ChangeLog:
    2015-08-07  Pedro Alves  <palves@redhat.com>
    
    	* remote.c (remote_wait_as): If not waiting for a stop reply,
    	return TARGET_WAITKIND_NO_RESUMED.  If TARGET_WNOHANG is
    	requested, don't block waiting forever.

Diff:
---
 gdb/ChangeLog |  6 ++++++
 gdb/remote.c  | 13 ++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7bec9c8..5bf3d75 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-07  Pedro Alves  <palves@redhat.com>
+
+	* remote.c (remote_wait_as): If not waiting for a stop reply,
+	return TARGET_WAITKIND_NO_RESUMED.  If TARGET_WNOHANG is
+	requested, don't block waiting forever.
+
 2015-08-07  Pedro Alves  <pedro@codesourcery.com>
 
 	* infrun.c (adjust_pc_after_break): Now takes thread_info and
diff --git a/gdb/remote.c b/gdb/remote.c
index c047f35..4b5eb8e 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6267,6 +6267,14 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
     {
       int ret;
       int is_notif;
+      int forever = ((options & TARGET_WNOHANG) == 0
+		     && wait_forever_enabled_p);
+
+      if (!rs->waiting_for_stop_reply)
+	{
+	  status->kind = TARGET_WAITKIND_NO_RESUMED;
+	  return minus_one_ptid;
+	}
 
       if (!target_is_async_p ())
 	{
@@ -6285,7 +6293,7 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
 	 However, before we do that we need to ensure that the caller
 	 knows how to take the target into/out of async mode.  */
       ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
-				  wait_forever_enabled_p, &is_notif);
+				  forever, &is_notif);
 
       if (!target_is_async_p ())
 	signal (SIGINT, ofunc);
@@ -6294,6 +6302,9 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
 	 not interesting.  */
       if (ret != -1 && is_notif)
 	return minus_one_ptid;
+
+      if (ret == -1 && (options & TARGET_WNOHANG) != 0)
+	return minus_one_ptid;
     }
 
   buf = rs->buf;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]