[2/4] gdb/dap: ignore unused keyword args in step_out

Message ID 20230901180323.22328-7-greg@gpanders.com
State New
Headers
Series DAP fixups |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Gregory Anders Sept. 1, 2023, 5:55 p.m. UTC
  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 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Tom Tromey Sept. 1, 2023, 7:07 p.m. UTC | #1
>>>>> "Gregory" == Gregory Anders via Gdb-patches <gdb-patches@sourceware.org> writes:

Gregory> Some DAP clients may send additional parameters in the stepOut command
Gregory> (e.g. "granularity") which are not used by GDB, but should nonetheless
Gregory> be accepted without error.

Nice catch, thank you.

I came up with the appended to ensure this remains true in the future.

I may land this one out of sequence -- we can accept some very small
patches without a copyright assignment -- and then the self-check patch
afterward.

Let me know what you think.

Tom

diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index db7893a387b..d84bca5d1fc 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))
  
Gregory Anders Sept. 5, 2023, 2:12 p.m. UTC | #2
On Fri, 01 Sep 2023 13:07 -0600, Tom Tromey wrote:
>I came up with the appended to ensure this remains true in the future.
>
>I may land this one out of sequence -- we can accept some very small
>patches without a copyright assignment -- and then the self-check patch
>afterward.
>
>Let me know what you think.

LGTM, I included your suggestion in the v2 patchset I sent on Friday.

Greg
  

Patch

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))