From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 0E0A33858C56; Fri, 17 Nov 2023 15:44:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E0A33858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700235865; bh=p22ECw5geaFSwx12ZJeWydm+Y5IZ9cMC3t9d/1HRwc4=; h=From:To:Subject:Date:From; b=KtMiSZUmIutlpKPWIawPOxLlYYLRuYwveuzHu8ncX3b3U/O5/+gt7xFyKi+kVyH33 egVognXEq6IFEppvMXnLQvO09K/M/NmEi8W9YsttpMc6qnRgBk7Uwzqnwd59qPTAH5 Rg6+yvL9cPa+pMcozxWOFe/uny3nmTVVSOToaj1Q= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb/gdb-14-branch] Remove ExecutionInvoker X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/gdb-14-branch X-Git-Oldrev: de5b5fcb891ffaaa54f91f7379cf1e396b4b480d X-Git-Newrev: c558c8d5f6c86c93b84ad9d44595be8166930667 Message-Id: <20231117154425.0E0A33858C56@sourceware.org> Date: Fri, 17 Nov 2023 15:44:25 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc558c8d5f6c8= 6c93b84ad9d44595be8166930667 commit c558c8d5f6c86c93b84ad9d44595be8166930667 Author: Tom Tromey Date: Mon Nov 6 14:29:06 2023 -0700 Remove ExecutionInvoker =20 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. =20 Reviewed-by: K=C3=A9vin Le Gouguec =20 (cherry picked from commit 68caad9d0b06d0ac231ce083ff62410a5a1806c1) Diff: --- 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/even= ts.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 =20 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 =20 =20 @@ -111,29 +111,14 @@ _expected_stop =3D None =20 =20 @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 =3D 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 =3D expected - - @in_gdb_thread - def __call__(self): - expect_stop(self.expected) - global _suppress_cont - _suppress_cont =3D True - # FIXME if the call fails should we clear _suppress_cont? - super().__call__() + global _suppress_cont + _suppress_cont =3D True + # FIXME if the call fails should we clear _suppress_cont? + exec_and_log(cmd) =20 =20 @in_gdb_thread diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/laun= ch.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 =20 -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 =20 @@ -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 431020e32e1..eedc26f28a5 100644 --- a/gdb/python/lib/gdb/dap/next.py +++ b/gdb/python/lib/gdb/dap/next.py @@ -15,7 +15,7 @@ =20 import gdb =20 -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 =3D "next" if granularity =3D=3D "instruction": cmd +=3D "i" - ExecutionInvoker(cmd, StopKinds.STEP)() + exec_and_expect_stop(cmd, StopKinds.STEP) =20 =20 @capability("supportsSteppingGranularity") @@ -70,13 +70,13 @@ def step_in( cmd =3D "step" if granularity =3D=3D "instruction": cmd +=3D "i" - ExecutionInvoker(cmd, StopKinds.STEP)() + exec_and_expect_stop(cmd, StopKinds.STEP) =20 =20 @request("stepOut", response=3DFalse) def step_out(*, threadId: int, singleThread: bool =3D False, **args): _handle_thread_step(threadId, singleThread, True) - ExecutionInvoker("finish", StopKinds.STEP)() + exec_and_expect_stop("finish", StopKinds.STEP) =20 =20 # This is a server-side request because it is funny: it wants to @@ -87,5 +87,5 @@ def step_out(*, threadId: int, singleThread: bool =3D Fal= se, **args): @request("continue", on_dap_thread=3DTrue) def continue_request(*, threadId: int, singleThread: bool =3D False, **arg= s): locked =3D 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 . =20 -from .events import StopKinds, ExecutionInvoker +from .events import StopKinds, exec_and_expect_stop from .server import request =20 =20 @request("pause", response=3DFalse) def pause(**args): - ExecutionInvoker("interrupt -a", StopKinds.PAUSE)() + exec_and_expect_stop("interrupt -a", StopKinds.PAUSE)