From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id B9A193858D35 for ; Wed, 28 Jun 2023 16:26:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9A193858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4fb77f21c63so5213471e87.2 for ; Wed, 28 Jun 2023 09:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687969603; x=1690561603; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=defr83bKYfVwhg3omrcoeSB8wIfsiPNmxW5R5XoGnJU=; b=jgFlx5QaTJmtWCJZjZCUkQ31Cd/JZmE7fVrshtUg3DauCzpvE9MknwFVD3RE1P4a24 J4h0AML8UrfSABTHrCGRy70H8NX8HqMCJ34E+6sbAaxPVUcQL+jB8uUk1I+Y+2KaoXxy 7aCiDDaVvrLxknF6K2BAgQhYO4v530orUKee6Akbk4sdpHB+la2GGQ0+T91kSZMm1zE+ SJiZnloAfCZkJlT13wFtTAmbKgOP6o7vvRhVMQdHWfZwmEJ5kFxQtulmJ09qcyRheSKM Cyd8T2wWQPNBf4tJlxPKhfI9XKmLZAeySMzT1GhJ0/b3mVIpkSIcEauDlIxmezFmamT3 ts9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687969603; x=1690561603; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=defr83bKYfVwhg3omrcoeSB8wIfsiPNmxW5R5XoGnJU=; b=e1gBOqswWoyluKbfpTnHMbFT8GeFxyKbBLGvleyZPPtSHmtyo90ktV+DpAxylXbyCv twEX5CjvTdFDe6sbaq0RvJQ2qucT1ypYEIvUxa1bXIqg7eZAE3JTNmwDsc7nPph63d3o pGwKGBTPCjywoN5D9c2r/Qb0X+olUhUDUj2SDHbl47Y+njh2WoXPteYwd9F4ci74astI /QLyH/idgPGuPSJhFay6sepWBa2ls+4mEAqls6GRhNNyXS2+E/2pml3QxyGq56K9A0I7 m++Ui9uxe+IvOXjGCuuD++5UGfgHEgZ1lscv2BZTZQkZgGc4ybFjYTzjCc/KBU+gfZZx aYOQ== X-Gm-Message-State: AC+VfDzTCt80dCGuV7ldkmP7JxoHPX7AxCIugcizo+bKq7s73R7WxC7l LomjnCi7WNYISNYwaRqpCQ7ShCL9544= X-Google-Smtp-Source: ACHHUZ5B10Sw+19QKxpY16hVGHqAkrdNkOijQoasYc96vSgtVfU8/voYbTVSnfAUqWpUmFDOogJ4nQ== X-Received: by 2002:a19:6555:0:b0:4f8:5f32:b1da with SMTP id c21-20020a196555000000b004f85f32b1damr18500963lfj.24.1687969602374; Wed, 28 Jun 2023 09:26:42 -0700 (PDT) Received: from fedora.. (78-73-77-63-no2450.tbcn.telia.com. [78.73.77.63]) by smtp.gmail.com with ESMTPSA id q23-20020ac24a77000000b004f7618c67a7sm1996330lfp.76.2023.06.28.09.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 09:26:41 -0700 (PDT) From: Simon Farre To: gdb-patches@sourceware.org Cc: Simon Farre Subject: [PATCH v1] gdb/DAP - Add completionsRequest Date: Wed, 28 Jun 2023 18:26:16 +0200 Message-ID: <20230628162616.102268-1-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 . + +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