aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-11-06 14:29:06 -0700
committerTom Tromey <tromey@adacore.com>2023-11-17 08:43:04 -0700
commitc558c8d5f6c86c93b84ad9d44595be8166930667 (patch)
tree2fb14d42fb6e75c9afac8d359d0811b2701b8b73
parentde5b5fcb891ffaaa54f91f7379cf1e396b4b480d (diff)
downloadbinutils-c558c8d5f6c86c93b84ad9d44595be8166930667.zip
binutils-c558c8d5f6c86c93b84ad9d44595be8166930667.tar.gz
binutils-c558c8d5f6c86c93b84ad9d44595be8166930667.tar.bz2
Remove ExecutionInvoker
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. Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com> (cherry picked from commit 68caad9d0b06d0ac231ce083ff62410a5a1806c1)
-rw-r--r--gdb/python/lib/gdb/dap/events.py29
-rw-r--r--gdb/python/lib/gdb/dap/launch.py4
-rw-r--r--gdb/python/lib/gdb/dap/next.py10
-rw-r--r--gdb/python/lib/gdb/dap/pause.py4
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 e9ddcab..09214ec 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 e81d284..ab704c7 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 431020e..eedc26f 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", on_dap_thread=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 d96172c..d276ab1 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 <http://www.gnu.org/licenses/>.
-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)