From patchwork Tue Apr 7 12:49:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 6047 Received: (qmail 130172 invoked by alias); 7 Apr 2015 12:50:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 130091 invoked by uid 89); 7 Apr 2015 12:50:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 07 Apr 2015 12:49:59 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t37Cnvle020808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 7 Apr 2015 08:49:57 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t37Cnowp022139 for ; Tue, 7 Apr 2015 08:49:57 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 05/23] remote.c/all-stop: Implement TARGET_WAITKIND_NO_RESUMED and TARGET_WNOHANG Date: Tue, 7 Apr 2015 13:49:32 +0100 Message-Id: <1428410990-28560-6-git-send-email-palves@redhat.com> In-Reply-To: <1428410990-28560-1-git-send-email-palves@redhat.com> References: <1428410990-28560-1-git-send-email-palves@redhat.com> 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 aren't events to process. This can't happen currently, but later changes will trigger this. gdb/ChangeLog: 2015-04-07 Pedro Alves * 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. --- gdb/remote.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/remote.c b/gdb/remote.c index 69a67a8..0bf8b87 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5953,6 +5953,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 ()) { @@ -5971,7 +5979,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); @@ -5980,6 +5988,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;