From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eG0EGxyCSmUouQAAWB0awg (envelope-from ) for ; Tue, 07 Nov 2023 13:29:48 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=kLs/RsHo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 6842F1E0C1; Tue, 7 Nov 2023 13:29:48 -0500 (EST) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 565F31E0BB for ; Tue, 7 Nov 2023 13:29:46 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 15F303858C5E for ; Tue, 7 Nov 2023 18:29:46 +0000 (GMT) Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 3A59F3858C5E for ; Tue, 7 Nov 2023 18:29:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A59F3858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3A59F3858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699381775; cv=none; b=O+GY+9IDLl1p7ruRVIvf3qPFkCtlFoijTDRgqCRA+Lc+54TxYvS4MOpUA+UJ9GO/z0QzJhYjpppn8YsZPWkdxbKJKR3NSqv3bbBJBN9sZM4EGUdhtvF4kIxR1GXvKssp1cKmVk1TEDqh4H1u1A/a3IsxuOSvyq3F+1t1gyKJ580= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699381775; c=relaxed/simple; bh=xaPwUeeNRi53NcAFhrVAzONe7dZ7Fdk+CK7kiaeHO70=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=WO42q4rNrtUFwf/Q7bAtX22fmXF81GA+rW+wUD2rbS/PPoOIEseZ7+qZLyQ3zIyllyqcW5UiNUGL3c6I4QF0YYCn9gUwKMqPUY5MXaB+R4bxzO6kaATyPwf92yx9iiZtOSNi8LMMMY5bWadf3nrGHSykVtJ9fd93wO+zVAM49QQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3b5aee410f2so1038137b6e.1 for ; Tue, 07 Nov 2023 10:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699381773; x=1699986573; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OTUmgBKr4CZH4dNd4QOpsX7WknLcY0bSBFR7AjJZ/rE=; b=kLs/RsHoCMVl8DIY+HGlwFZxP5xuDMfUDFgM0tRGc36b+GjB+tKbsi/jH5CNrlVE0I 2sdClMqFkMv2XvRUidxYSFaIutB/IGaWgfRH+H3w82AB2gd69QtudkuAMx+mrT0BMdmk KYGaEsdDFNmvwp47hYTW2dEm/fCBMCiff7AP0/W0hkC4cmKmvUG66bBk4dSimaT/LSRc +ZqxrRnTKDoFjIKfN5TyShJobCWxfmys1NIqzaFErWZgWCgqF/ZAFgsQVSXeDNClYJRH Xd8UL66t+PP5Q4oj7692DEl/EqktaBQWw+pWtw62Ac4ns/ghw92Ywa1AMRSux7ukGVBl 0IXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699381773; x=1699986573; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OTUmgBKr4CZH4dNd4QOpsX7WknLcY0bSBFR7AjJZ/rE=; b=cY9iPeaVXGZ2puHMQ5wtCfKUECN03alR1cM5/OapxFX7IhbD8n7MDScCMS8hYpr82R IjmQL9UAp9VZOuYqkGse+peQ18XiVYRUxTdp42pZJHXtMNVTkNN6s6FkGqUsurxX9/bz 8EGg0S59Bnj6qpCFK2Y7bkk0FIjqTLsUJBftgMcmAzbQxnpKTuSoD4/2rUdgUm2fNKw5 lFUO9ARf1jbOCSUGbDfgQkJyjAoUTZ6+YQ1cP40A29gYYpIVJKb3NeiGhAGxPapGmpok HSZrbY6gTNIxngiEgARQ4bRlFDa1yi0p3Ix4n5/QGf6nX/EyixK5zzTCuMFjRK3Kzntz 10uA== X-Gm-Message-State: AOJu0YxK+wmWTNEtMpPjcxQZAiiVcFWvrrciSmxMzwnQD79oBmuJRgAT kQ2aW5OD9dr1d0ZnV9LL2Z5gMsn6z2CrSe9hu+QY+Q== X-Google-Smtp-Source: AGHT+IGojLSW4QsMy39tCO/8Wr96uOSaACjS3zd3icCUeuQrhg3LbB+UAybXHM9/BslujXZVkW0aBw== X-Received: by 2002:a05:6808:f08:b0:3b2:f5be:4fd5 with SMTP id m8-20020a0568080f0800b003b2f5be4fd5mr36930472oiw.14.1699381773486; Tue, 07 Nov 2023 10:29:33 -0800 (PST) Received: from localhost.localdomain (97-122-77-73.hlrn.qwest.net. [97.122.77.73]) by smtp.gmail.com with ESMTPSA id gs25-20020a0566382d9900b0042b2f0b77aasm2776726jab.95.2023.11.07.10.29.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 10:29:33 -0800 (PST) From: Tom Tromey Date: Tue, 07 Nov 2023 11:29:30 -0700 Subject: [PATCH 2/3] Remove ExecutionInvoker MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231107-dap-not-stopped-v1-2-3d91c935255d@adacore.com> References: <20231107-dap-not-stopped-v1-0-3d91c935255d@adacore.com> In-Reply-To: <20231107-dap-not-stopped-v1-0-3d91c935255d@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org ExecutionInvoker is no longer really needed, due to the previous DAP refactoring. This patch removes it in favor of an ordinary function. One spot (the 'continue' request) could still have used it, but is more succinctly expressed as a lambda. --- gdb/python/lib/gdb/dap/events.py | 29 +++++++---------------------- gdb/python/lib/gdb/dap/launch.py | 4 ++-- gdb/python/lib/gdb/dap/next.py | 10 +++++----- gdb/python/lib/gdb/dap/pause.py | 4 ++-- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py index e9ddcab135f..09214ec3dc8 100644 --- a/gdb/python/lib/gdb/dap/events.py +++ b/gdb/python/lib/gdb/dap/events.py @@ -17,7 +17,7 @@ import enum import gdb from .server import send_event -from .startup import in_gdb_thread, Invoker, log +from .startup import exec_and_log, in_gdb_thread, log from .modules import is_module, make_module @@ -111,29 +111,14 @@ _expected_stop = None @in_gdb_thread -def expect_stop(reason): - """Indicate that a stop is expected, for the reason given.""" +def exec_and_expect_stop(cmd, reason): + """Indicate that a stop is expected, then execute CMD""" global _expected_stop _expected_stop = reason - - -# A wrapper for Invoker that also sets the expected stop. -class ExecutionInvoker(Invoker): - """A subclass of Invoker that sets the expected stop. - Note that this assumes that the command will restart the inferior, - so it will also cause ContinuedEvents to be suppressed.""" - - def __init__(self, cmd, expected): - super().__init__(cmd) - self.expected = expected - - @in_gdb_thread - def __call__(self): - expect_stop(self.expected) - global _suppress_cont - _suppress_cont = True - # FIXME if the call fails should we clear _suppress_cont? - super().__call__() + global _suppress_cont + _suppress_cont = True + # FIXME if the call fails should we clear _suppress_cont? + exec_and_log(cmd) @in_gdb_thread diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py index e81d2849a8e..ab704c7a7cc 100644 --- a/gdb/python/lib/gdb/dap/launch.py +++ b/gdb/python/lib/gdb/dap/launch.py @@ -18,7 +18,7 @@ import gdb # These are deprecated in 3.9, but required in older versions. from typing import Mapping, Optional, Sequence -from .events import ExecutionInvoker +from .events import exec_and_expect_stop from .server import request, capability from .startup import in_gdb_thread, exec_and_log @@ -85,4 +85,4 @@ def config_done(**args): if _program is not None: # Suppress the continue event, but don't set any particular # expected stop. - ExecutionInvoker("run", None)() + exec_and_expect_stop("run", None) diff --git a/gdb/python/lib/gdb/dap/next.py b/gdb/python/lib/gdb/dap/next.py index ddab9d304a1..d12267ea354 100644 --- a/gdb/python/lib/gdb/dap/next.py +++ b/gdb/python/lib/gdb/dap/next.py @@ -15,7 +15,7 @@ import gdb -from .events import StopKinds, ExecutionInvoker +from .events import StopKinds, exec_and_expect_stop from .server import capability, request from .startup import in_gdb_thread, send_gdb, send_gdb_with_response from .state import set_thread @@ -57,7 +57,7 @@ def next( cmd = "next" if granularity == "instruction": cmd += "i" - ExecutionInvoker(cmd, StopKinds.STEP)() + exec_and_expect_stop(cmd, StopKinds.STEP) @capability("supportsSteppingGranularity") @@ -70,13 +70,13 @@ def step_in( cmd = "step" if granularity == "instruction": cmd += "i" - ExecutionInvoker(cmd, StopKinds.STEP)() + exec_and_expect_stop(cmd, StopKinds.STEP) @request("stepOut", response=False) def step_out(*, threadId: int, singleThread: bool = False, **args): _handle_thread_step(threadId, singleThread, True) - ExecutionInvoker("finish", StopKinds.STEP)() + exec_and_expect_stop("finish", StopKinds.STEP) # This is a server-side request because it is funny: it wants to @@ -87,5 +87,5 @@ def step_out(*, threadId: int, singleThread: bool = False, **args): @request("continue", server=True) def continue_request(*, threadId: int, singleThread: bool = False, **args): locked = send_gdb_with_response(lambda: _handle_thread_step(threadId, singleThread)) - send_gdb(ExecutionInvoker("continue", None)) + send_gdb(lambda: exec_and_expect_stop("continue", None)) return {"allThreadsContinued": not locked} diff --git a/gdb/python/lib/gdb/dap/pause.py b/gdb/python/lib/gdb/dap/pause.py index d96172c0757..d276ab1cb92 100644 --- a/gdb/python/lib/gdb/dap/pause.py +++ b/gdb/python/lib/gdb/dap/pause.py @@ -13,10 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from .events import StopKinds, ExecutionInvoker +from .events import StopKinds, exec_and_expect_stop from .server import request @request("pause", response=False) def pause(**args): - ExecutionInvoker("interrupt -a", StopKinds.PAUSE)() + exec_and_expect_stop("interrupt -a", StopKinds.PAUSE) -- 2.41.0