aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-11-30 13:53:23 -0700
committerTom Tromey <tromey@adacore.com>2023-12-11 11:44:19 -0700
commit080530d8b6c3be802c53c0bb8a84032f355c2380 (patch)
tree3b2d5038a42d2ac0ff82474f395101dcb3e8168a /gdb/python
parent7729e7c0bdd01027a003181a99d58aadd981896a (diff)
downloadgdb-080530d8b6c3be802c53c0bb8a84032f355c2380.zip
gdb-080530d8b6c3be802c53c0bb8a84032f355c2380.tar.gz
gdb-080530d8b6c3be802c53c0bb8a84032f355c2380.tar.bz2
Clean up handling of DAP not-stopped response
This patch introduces a new NotStoppedException type and changes the DAP implementation of "not stopped" to use it. I was already touching some code in this area and I thought this looked a little cleaner. This also has the advantage that we can now choose not to log the exception -- previously I was sometimes a bit alarmed when seeing this in the logs, even though it is harmless. Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/dap/server.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index ead911d..d865dee 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -42,6 +42,12 @@ _commands = {}
_server = None
+# A subclass of Exception that is used solely for reporting that a
+# request needs the inferior to be stopped, but it is not stopped.
+class NotStoppedException(Exception):
+ pass
+
+
class Server:
"""The DAP server class."""
@@ -78,6 +84,9 @@ class Server:
if body is not None:
result["body"] = body
result["success"] = True
+ except NotStoppedException:
+ result["success"] = False
+ result["message"] = "notStopped"
except BaseException as e:
log_stack()
result["success"] = False
@@ -169,7 +178,7 @@ def _check_not_running(func):
from .events import inferior_running
if inferior_running:
- raise Exception("notStopped")
+ raise NotStoppedException()
return func(*args, **kwargs)
return check