* [PATCH] [gdb/dap] Disable DAP for python <= 3.5
@ 2023-08-02 17:23 Tom de Vries
2023-08-02 20:45 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2023-08-02 17:23 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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
PR dap/30708
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30708
---
gdb/python/py-dap.c | 3 +++
gdb/testsuite/lib/gdb.exp | 25 +++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c
index 52188406982..3444eccb6fb 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 ()
{
+ /* The dap code uses module typing, available starting python 3.5. */
+#if PY_VERSION_HEX >= 0x03050000
interp_factory_register ("dap", [] (const char *name) -> interp *
{
return new dap_interp (name);
});
+#endif
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 87d6895d44e..36bf738c667 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1533,6 +1533,26 @@ proc gdb_test { args } {
return [gdb_test_multiple $command $message {*}$opts $user_code]
}
+# Return 1 if python version used is at least MAJOR.MINOR
+proc python_version_at_least { major minor } {
+ set python_script {print (sys.version_info\[0\], sys.version_info\[1\])}
+
+ set res [remote_exec host $::GDB \
+ "$::INTERNAL_GDBFLAGS -batch -ex \"python $python_script\""]
+ if { [lindex $res 0] != 0 } {
+ error "Couldn't get python version"
+ }
+
+ set python_version [lindex $res 1]
+ set python_version [string trim $python_version]
+
+ regexp {^([0-9]+) ([0-9]+)$} $python_version \
+ dummy python_version_major python_version_minor
+
+ return [version_compare [list $major $minor] \
+ <= [list $python_version_major $python_version_minor]]
+}
+
# Return 1 if tcl version used is at least MAJOR.MINOR
proc tcl_version_at_least { major minor } {
global tcl_version
@@ -2586,6 +2606,11 @@ gdb_caching_proc allow_dap_tests {} {
return 0
}
+ # The dap code uses module typing, available starting python 3.5.
+ if { ![python_version_at_least 3 5] } {
+ return 0
+ }
+
# ton.tcl uses "string is entier", supported starting tcl 8.6.
if { ![tcl_version_at_least 8 6] } {
return 0
base-commit: 86bb2d76c901a558e5b2dd29df95874ce6e78dae
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [gdb/dap] Disable DAP for python <= 3.5
2023-08-02 17:23 [PATCH] [gdb/dap] Disable DAP for python <= 3.5 Tom de Vries
@ 2023-08-02 20:45 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-08-02 20:45 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> DAP requires python module typing, which is supported starting python 3.5.
Tom> Make this formal by:
Tom> - disabling the dap interpreter for python version < 3.5
Tom> - returning 0 in allow_dap_tests for python version < 3.5
Tom> PR dap/30708
Tom> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30708
It's fine by me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-02 20:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 17:23 [PATCH] [gdb/dap] Disable DAP for python <= 3.5 Tom de Vries
2023-08-02 20:45 ` Tom Tromey
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).