From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/6] Clean up handling of DAP not-stopped response
Date: Fri, 01 Dec 2023 08:40:57 -0700 [thread overview]
Message-ID: <20231201-dap-cancel-v1-1-872022fc328a@adacore.com> (raw)
In-Reply-To: <20231201-dap-cancel-v1-0-872022fc328a@adacore.com>
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.
---
gdb/python/lib/gdb/dap/server.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index ead911d11da..d865dee31a8 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
--
2.41.0
next prev parent reply other threads:[~2023-12-01 15:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 15:40 [PATCH 0/6] Implement DAP cancellation Tom Tromey
2023-12-01 15:40 ` Tom Tromey [this message]
2023-12-01 15:40 ` [PATCH 2/6] Move DAP JSON reader to its own thread Tom Tromey
2023-12-01 15:40 ` [PATCH 3/6] Introduce gdb.interrupt Tom Tromey
2023-12-01 15:56 ` Eli Zaretskii
2023-12-11 15:49 ` Tom Tromey
2023-12-01 15:41 ` [PATCH 4/6] Rename a couple of DAP procs in the testsuite Tom Tromey
2023-12-01 15:41 ` [PATCH 5/6] Catch BaseException in send_gdb_with_response Tom Tromey
2023-12-01 16:29 ` Kévin Le Gouguec
2023-12-01 17:51 ` Tom Tromey
2023-12-01 15:41 ` [PATCH 6/6] Implement DAP cancellation Tom Tromey
2023-12-01 15:57 ` Eli Zaretskii
2023-12-11 15:05 ` Tom Tromey
2023-12-11 15:44 ` Eli Zaretskii
2023-12-05 9:17 ` [PATCH 0/6] " Kévin Le Gouguec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231201-dap-cancel-v1-1-872022fc328a@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).