public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Gregory Anders <greg@gpanders.com>
To: gdb-patches@sourceware.org
Cc: Gregory Anders <greg@gpanders.com>
Subject: [PATCH v2 2/4] gdb/dap: ignore unused keyword args in step_out
Date: Fri,  1 Sep 2023 16:02:18 -0500	[thread overview]
Message-ID: <20230901210422.58003-3-greg@gpanders.com> (raw)
In-Reply-To: <20230901210422.58003-1-greg@gpanders.com>

Some DAP clients may send additional parameters in the stepOut command
(e.g. "granularity") which are not used by GDB, but should nonetheless
be accepted without error.
---
 gdb/python/lib/gdb/dap/next.py   | 2 +-
 gdb/python/lib/gdb/dap/server.py | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gdb/python/lib/gdb/dap/next.py b/gdb/python/lib/gdb/dap/next.py
index 8b112770..5d49c871 100644
--- a/gdb/python/lib/gdb/dap/next.py
+++ b/gdb/python/lib/gdb/dap/next.py
@@ -69,7 +69,7 @@ def step_in(
 
 
 @request("stepOut")
-def step_out(*, threadId: int, singleThread: bool = False):
+def step_out(*, threadId: int, singleThread: bool = False, **args):
     send_gdb(lambda: _handle_thread_step(threadId, singleThread))
     send_gdb(ExecutionInvoker("finish", StopKinds.STEP))
 
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index db7893a3..d84bca5d 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -13,6 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import inspect
 import json
 import queue
 import sys
@@ -165,6 +166,12 @@ def request(name):
 
     def wrap(func):
         global _commands
+        code = func.__code__
+        # We don't permit requests to have positional arguments.
+        assert code.co_posonlyargcount == 0
+        assert code.co_argcount == 0
+        # A request must have a **args parameter.
+        assert code.co_flags & inspect.CO_VARKEYWORDS
         # All requests must run in the DAP thread.
         # Also type-check the calls.
         func = in_dap_thread(type_check(func))
-- 
2.42.0


  parent reply	other threads:[~2023-09-01 21:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-01 21:02 [PATCH v2 0/4] DAP fixups Gregory Anders
2023-09-01 21:02 ` [PATCH v2 1/4] gdb/dap: check for breakpoint source before unpacking Gregory Anders
2023-09-01 21:02 ` Gregory Anders [this message]
2023-09-01 21:02 ` [PATCH v2 3/4] gdb/dap: use breakpoint fullname to resolve source Gregory Anders
2023-09-01 21:02 ` [PATCH v2 4/4] gdb/dap: only include sourceReference if file path does not exist Gregory Anders
2023-09-20 17:40 ` [PATCH v2 0/4] DAP fixups Tom Tromey

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=20230901210422.58003-3-greg@gpanders.com \
    --to=greg@gpanders.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).