From patchwork Tue Apr 4 17:08:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 67276 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22008385703A for ; Tue, 4 Apr 2023 17:10:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22008385703A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680628215; bh=HazBnl2lVz8zPPQU9aQrQ7hcz7JLg4566IjruQ6JdOQ=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=tyFlQzF2B5/7WrRaR3I9ebo7CqrZ8CKKbJboCchQ5rV4/PhJpPSpI/BDzJnL9dLwZ UIlk6oZOVH8ezXrMbUh5Mwszl/wybgGqSM96SkH3m/OZaZs+apmksUY6mMTPDdyqD3 lTu2q6ebq8F5SrHzgQp84LHFOLZFdj1+31RSccu0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id D58243858428 for ; Tue, 4 Apr 2023 17:08:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D58243858428 Received: by mail-il1-x132.google.com with SMTP id q8so2812018ilo.1 for ; Tue, 04 Apr 2023 10:08:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680628136; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HazBnl2lVz8zPPQU9aQrQ7hcz7JLg4566IjruQ6JdOQ=; b=Cw3J5i343WvzSF0Ox8alehdl3ZJoB+pdbnrbWDnFedZixjFgCjoAgjnEBh3X7X8SN5 sVkxcdgbOrqkOVWAQJeWXgGz5K5EqCdxxgOnPyLe96lNbuDEzNRfpyOubt5n0CgXWw1X 80OutLguBew/V6A4vhI1i0JD0NskTYkqmXtqDRteW6UY4RpfCn5xEdGny9aexZ3UC6J6 hWl32YjsiIP6hURXAzFRoqG1hPOvNATg1XDm+5YnuPFgEPDPASioxH2cLkHj2hEIsesW x7FbUmlZR7gNIMSFN4RgaIkKgB9HYn2fX8kHEMteqrir6Gl3cHUeb+/zVeeqPVy/PPAb ZqRA== X-Gm-Message-State: AAQBX9e18oFZmTHyu2DDVmV2IkC2eqmUAvqPmSpiZhB/Lo2BgbWa5jeQ ZLWH19WXC8gDmSYPFQsTj2M+Hnk5dLaVlRkvHsIIjQ== X-Google-Smtp-Source: AKy350au1oYzSVlsA3nNmpl0/d7c4MaPSU1NdIGVzBpQMaXpusZbHb7kJuiBM856Pideb6gcSvWAaw== X-Received: by 2002:a92:db11:0:b0:326:2df9:3f18 with SMTP id b17-20020a92db11000000b003262df93f18mr2340937iln.20.1680628136431; Tue, 04 Apr 2023 10:08:56 -0700 (PDT) Received: from localhost.localdomain (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id f4-20020a02a104000000b0040b4c29010fsm1188306jag.140.2023.04.04.10.08.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 10:08:56 -0700 (PDT) Date: Tue, 04 Apr 2023 11:08:57 -0600 Subject: [PATCH 9/9] Implement DAP loadedSources request MIME-Version: 1.0 Message-Id: <20230404-dap-loaded-sources-v1-9-75c796bd644b@adacore.com> References: <20230404-dap-loaded-sources-v1-0-75c796bd644b@adacore.com> In-Reply-To: <20230404-dap-loaded-sources-v1-0-75c796bd644b@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This implements the DAP loadedSources request, using gdb.execute_mi to avoid having to write another custom Python API. --- gdb/data-directory/Makefile.in | 1 + gdb/python/lib/gdb/dap/__init__.py | 1 + gdb/python/lib/gdb/dap/sources.py | 40 +++++++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.dap/basic-dap.exp | 3 +++ 4 files changed, 45 insertions(+) diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index 39979037245..a95c2d7ab37 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in @@ -101,6 +101,7 @@ PYTHON_FILE_LIST = \ gdb/dap/pause.py \ gdb/dap/scopes.py \ gdb/dap/server.py \ + gdb/dap/sources.py \ gdb/dap/startup.py \ gdb/dap/state.py \ gdb/dap/threads.py \ diff --git a/gdb/python/lib/gdb/dap/__init__.py b/gdb/python/lib/gdb/dap/__init__.py index 014fd086f4b..f07228e46ce 100644 --- a/gdb/python/lib/gdb/dap/__init__.py +++ b/gdb/python/lib/gdb/dap/__init__.py @@ -29,6 +29,7 @@ from . import memory from . import next from . import pause from . import scopes +from . import sources from . import threads from .server import Server diff --git a/gdb/python/lib/gdb/dap/sources.py b/gdb/python/lib/gdb/dap/sources.py new file mode 100644 index 00000000000..2dd26710d31 --- /dev/null +++ b/gdb/python/lib/gdb/dap/sources.py @@ -0,0 +1,40 @@ +# 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, in_gdb_thread + + +@in_gdb_thread +def _sources(): + result = [] + for elt in gdb.execute_mi("file-list-exec-source-files")["files"]: + result.append( + { + "name": elt["file"], + "path": elt["fullname"], + } + ) + return { + "sources": result, + } + + +@request("loadedSources") +@capability("supportsLoadedSourcesRequest") +def sources(**extra): + return send_gdb_with_response(_sources) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index 0026690ba44..f28239d8268 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -168,4 +168,7 @@ set obj [dap_check_request_and_response "command repl" \ set response [lindex $obj 0] gdb_assert {[dict get $response body result] == 23} +set obj [dap_check_request_and_response sources loadedSources] +gdb_assert {[string first basic-dap.c $obj] != -1} + dap_shutdown