From patchwork Thu May 21 23:18:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 6864 Received: (qmail 64351 invoked by alias); 21 May 2015 23:19:23 -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 64236 invoked by uid 89); 21 May 2015 23:19:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no 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; Thu, 21 May 2015 23:19:20 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 393B53674A8 for ; Thu, 21 May 2015 23:19:19 +0000 (UTC) Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4LNJEJ1027592 for ; Thu, 21 May 2015 19:19:18 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 03/18] remote.c/all-stop: Implement TARGET_WAITKIND_NO_RESUMED and TARGET_WNOHANG Date: Fri, 22 May 2015 00:18:59 +0100 Message-Id: <1432250354-2721-4-git-send-email-palves@redhat.com> In-Reply-To: <1432250354-2721-1-git-send-email-palves@redhat.com> References: <1432250354-2721-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 are no events to process. This can't happen currently, but later changes will trigger this. gdb/ChangeLog: 2015-05-21 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 dfe115b..db06def 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -6227,6 +6227,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 ()) { @@ -6245,7 +6253,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); @@ -6254,6 +6262,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;