[PATCH v1] gdb/DAP - Add completionsRequest
Simon Farre
simon.farre.cx@gmail.com
Wed Jun 28 16:26:16 GMT 2023
Self-explanatory.
---
gdb/data-directory/Makefile.in | 1 +
gdb/python/lib/gdb/dap/__init__.py | 1 +
gdb/python/lib/gdb/dap/completion.py | 45 ++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
create mode 100644 gdb/python/lib/gdb/dap/completion.py
diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
index a3775a4a666..c1794b5acc7 100644
--- a/gdb/data-directory/Makefile.in
+++ b/gdb/data-directory/Makefile.in
@@ -89,6 +89,7 @@ PYTHON_FILE_LIST = \
gdb/command/xmethods.py \
gdb/dap/breakpoint.py \
gdb/dap/bt.py \
+ gdb/dap/completion.py \
gdb/dap/disassemble.py \
gdb/dap/evaluate.py \
gdb/dap/events.py \
diff --git a/gdb/python/lib/gdb/dap/__init__.py b/gdb/python/lib/gdb/dap/__init__.py
index f3dd3ff7ea8..e2dcde251ee 100644
--- a/gdb/python/lib/gdb/dap/__init__.py
+++ b/gdb/python/lib/gdb/dap/__init__.py
@@ -32,6 +32,7 @@ from . import pause
from . import scopes
from . import sources
from . import threads
+from . import completion
from .server import Server
diff --git a/gdb/python/lib/gdb/dap/completion.py b/gdb/python/lib/gdb/dap/completion.py
new file mode 100644
index 00000000000..861d1b28ac9
--- /dev/null
+++ b/gdb/python/lib/gdb/dap/completion.py
@@ -0,0 +1,45 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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 gdb
+
+from .server import request, capability
+from .startup import send_gdb_with_response
+
+from typing import Optional
+
+
+def _completions(text: str, column: int, line: Optional[int], frameId: Optional[int]):
+ cmd_output = gdb.execute("complete " + text, to_string=True)
+ result = []
+ for line in cmd_output.splitlines():
+ if "List may be truncated" not in line:
+ result.append({"label": line, "type": "function", "length": len(text)})
+ return {"targets": result}
+
+
+@request("completions")
+@capability("supportsCompletionsRequest")
+@capability("completionTriggerCharacters", [" ", "."])
+def completions(
+ *,
+ text: str,
+ column: int,
+ line: Optional[int] = None,
+ frameId: Optional[int] = None,
+ **extra
+):
+
+ return send_gdb_with_response(lambda: _completions(text, column, line, frameId))
--
2.41.0
More information about the Gdb-patches
mailing list