I ran the gdb.dap tests on a system with python 3.4, and ran into a couple of syntax error issues, which are fixed by: ... diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 27745eb..a6465e2 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -199,7 +199,7 @@ def _rewrite_src_breakpoint( condition: Optional[str] = None, hitCondition: Optional[str] = None, logMessage: Optional[str] = None, - **args, + **args ): return { "source": source["path"], @@ -238,7 +238,7 @@ def _rewrite_fn_breakpoint( name: str, condition: Optional[str] = None, hitCondition: Optional[str] = None, - **args, + **args ): return { "function": name, @@ -267,7 +267,7 @@ def _rewrite_insn_breakpoint( offset: Optional[int] = None, condition: Optional[str] = None, hitCondition: Optional[str] = None, - **args, + **args ): # There's no way to set an explicit address breakpoint from # Python, so we rely on "spec" instead. @@ -300,7 +300,7 @@ def _catch_exception(filterId, **args): elif filterId == "exception": cmd = "-catch-exception" else: - raise Exception(f"Invalid exception filterID: {filterId}") + raise Exception("Invalid exception filterID: %s" % filterId) result = gdb.execute_mi(cmd) # A little lame that there's no more direct way. for bp in gdb.breakpoints(): @@ -323,7 +323,7 @@ def _rewrite_exception_breakpoint( filterId: str, condition: Optional[str] = None, # Note that exception breakpoints do not support a hit count. - **args, + **args ): return { "filterId": filterId, diff --git a/gdb/python/lib/gdb/dap/evaluate.py b/gdb/python/lib/gdb/dap/evaluate.py index 63e8033..9622f3c 100644 --- a/gdb/python/lib/gdb/dap/evaluate.py +++ b/gdb/python/lib/gdb/dap/evaluate.py @@ -95,7 +95,7 @@ def eval_request( expression: str, frameId: Optional[int] = None, context: str = "variables", - **args, + **args ): if context in ("watch", "variables"): # These seem to be expression-like. ... But then we run into the use of module typing, which is available starting version 3.5. Commit 510586589e7 ("Add type-checking to DAP requests") says: ... I've tried to make this code compatible with older versions of Python, but I've only been able to try it with 3.9 and 3.10. ... Its use is extensive: ... breakpoint.py:21:from typing import Optional, Sequence evaluate.py:19:from typing import Optional launch.py:19:from typing import Mapping, Optional, Sequence locations.py:19:from typing import Optional typecheck.py:20:import typing ... Maybe we should just require a higher python version for dap?
(In reply to Tom de Vries from comment #0) > - **args, > + **args I suspect black will just add these back. > - raise Exception(f"Invalid exception filterID: {filterId}") > + raise Exception("Invalid exception filterID: %s" % filterId) Sorry, I thought I got rid of all of these. > But then we run into the use of module typing, which is available starting > version 3.5. We can maybe work around this if it's important. > Maybe we should just require a higher python version for dap? I wonder if any DAP client runs on whatever platform this is.
(In reply to Tom Tromey from comment #1) > > Maybe we should just require a higher python version for dap? > > I wonder if any DAP client runs on whatever platform this is. FTR, this is ubuntu 14.04.6 i686.
Something like this would work: ... diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c index 52188406982..7289c5ec25c 100644 --- a/gdb/python/py-dap.c +++ b/gdb/python/py-dap.c @@ -91,8 +91,11 @@ void _initialize_py_interp (); void _initialize_py_interp () { + /* Dap requires the types module, introduced in python 3.5. */ +#if PY_VERSION_HEX >= 0x03050000 interp_factory_register ("dap", [] (const char *name) -> interp * { return new dap_interp (name); }); +#endif } ... and if there's a command to list available interpreters, we can check that one in allow_dap_tests.
https://sourceware.org/pipermail/gdb-patches/2023-August/201293.html
The master branch has been updated by Tom de Vries <vries@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3c3e54d7b5f7da003292710fe810e670d45832d8 commit 3c3e54d7b5f7da003292710fe810e670d45832d8 Author: Tom de Vries <tdevries@suse.de> Date: Wed Aug 2 23:14:58 2023 +0200 [gdb/dap] Disable DAP for python <= 3.5 DAP requires python module typing, which is supported starting python 3.5. Make this formal by: - disabling the dap interpreter for python version < 3.5 - returning 0 in allow_dap_tests for python version < 3.5 Approved-By: Tom Tromey <tom@tromey.com> PR dap/30708 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30708
Fixed by commit.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5c9adb880eb1ed259007a376b305027d397948e8 commit 5c9adb880eb1ed259007a376b305027d397948e8 Author: Tom Tromey <tromey@adacore.com> Date: Thu Aug 3 10:25:18 2023 -0600 Remove f-string from DAP One more f-string snuck into the DAP code, in breakpoint.py. Most of them were removed here: https://sourceware.org/pipermail/gdb-patches/2023-June/200023.html but I think this one landed after that patch. While DAP only supports Python 3.5 and later, f-strings were added in 3.6, so remove this. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30708