From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by sourceware.org (Postfix) with ESMTPS id B61193857C79 for ; Mon, 6 Jul 2020 19:03:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B61193857C79 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wm1-f67.google.com with SMTP id g75so40391280wme.5 for ; Mon, 06 Jul 2020 12:03:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=RtCLoRJlckyyH/c4GaSGMaswjfuOkPjMSlruDaBvNGg=; b=glSriwFT6xURliw68SE4QymF0cDJob/Qb+NIRRKuyiOH0nm7a24g1CtLqOi1izkuSY lo+WsuNWk9CPr4RziqqWcHzS8pIHxmZAK/D/2TH+wfk0akiyUKAXxlk2GFLMaPM95r56 j0d/fpUpCUory8wBqHzxiGkyzscEyHwtyIVIQm1S6iRiHjZd4yTHMUadVFPqLKGlllNU BltGGz32Xm+yWsGNf0rcDI1RtimL8FzmZHlMG85K+tKMrVVAeo3gGIVL9y6SPxz9XzMY cDCsF9GxEgDE2GaIbEIWiYrmlm6NNOlLA+w0pp+/Ri1bYxGjqPE11nxRx3ZWXdU9NU7S +M/Q== X-Gm-Message-State: AOAM531TWHMHkOF1qLrEi7CdXNIZ8PizQWYwJrBe/o9WqeFXgx/OMr0/ 4ZI8Bx7Z4Zt1RsJeeI6PL8jY9j5xWjUuHA== X-Google-Smtp-Source: ABdhPJwH69WW2/LUuL0l+knmnUiILnODx7VtzD3yRYiDhCuZVdkRVYmvTXnMa98EEpbVO+7rO95WvQ== X-Received: by 2002:a1c:6102:: with SMTP id v2mr595096wmb.6.1594062184644; Mon, 06 Jul 2020 12:03:04 -0700 (PDT) Received: from localhost ([2001:8a0:f91a:c400:8728:8fef:5b85:5934]) by smtp.gmail.com with ESMTPSA id s8sm24906079wru.38.2020.07.06.12.03.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jul 2020 12:03:03 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 3/7] Avoid constant stream of TARGET_WAITKIND_NO_RESUMED Date: Mon, 6 Jul 2020 20:02:48 +0100 Message-Id: <20200706190252.22552-4-pedro@palves.net> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20200706190252.22552-1-pedro@palves.net> References: <20200706190252.22552-1-pedro@palves.net> X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2020 19:03:07 -0000 If we hit the synchronous execution command case described by handle_no_resumed, and handle_no_resumed determines that the event should be ignored, because it found a thread that is executing, we end up in prepare_to_wait. There, if the current target is not registered in the event loop right now, we call mark_infrun_async_event_handler. With that event handler marked, the event loop calls again into fetch_inferior_event, which calls target_wait, which returns TARGET_WAITKIND_NO_RESUMED, and we end up in handle_no_resumed, again ignoring the event and marking infrun_async_event_handler. The result is that GDB is now always keeping the CPU 100% busy in this loop, even though it continues to be able to react to input and to real target events, because we still go through the event-loop. The problem is that marking of the infrun_async_event_handler in prepare_to_wait. That is there to handle targets that don't support asynchronous execution. So the correct predicate is whether async execution is supported, not whether the target is async right now. gdb/ChangeLog: PR gdb/26199 * infrun.c (prepare_to_wait): Check target_can_async_p instead of target_is_async_p. --- gdb/infrun.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 6b655d4430..a01e0969cb 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8116,7 +8116,11 @@ prepare_to_wait (struct execution_control_state *ecs) ecs->wait_some_more = 1; - if (!target_is_async_p ()) + /* If the target can't async, emulate it by marking the infrun event + handler such that as soon as we get back to the event-loop, we + immediately end up in fetch_inferior_event again calling + target_wait. */ + if (!target_can_async_p ()) mark_infrun_async_event_handler (); } -- 2.14.5