From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by sourceware.org (Postfix) with ESMTPS id E7DD73858C20 for ; Fri, 28 Jul 2023 17:09:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E7DD73858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-78362f57500so99344839f.3 for ; Fri, 28 Jul 2023 10:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1690564159; x=1691168959; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Y42TuSPA4RszaEukXXKEv0/KamPotTHi2ZlqLQOSt4w=; b=Vx60IsouLmZWBc7Hh3+80LA91fjEPI+hOQfXXIPxAjohswtYU2kPUCZ7jxTSLcD/tt UsgpjXGnG+QcJomhOTX9XgYyrSwAWQDcr4lIxyqPMj4HgArFCl5MMnPAWtbh0BpJ24tk WDUP/EMCfnVcvHHgjmMwjokPemDlZUPk6tOqed8Ut+CZbuHVJWl6vdk0uykWcZ2v/5Kd hnQMVGFKJ8XxCIXJ5FwB3oKekVuITAqYpA3Fi/ULLZqjRCCP3uJWF4/3uGgAKLBvoUPe C1trZuxxw2pIqqCBDgzM5ggOL4NLXPeUm8kGPuYfXE2gGXLuDRA0nKFtQnNPwzPg6aXE qNWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690564159; x=1691168959; 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=Y42TuSPA4RszaEukXXKEv0/KamPotTHi2ZlqLQOSt4w=; b=WAxOy5vDyb5aSnOHvTMK4L51nakMobGzgoKFJVhhW92WfZlHr639AeR2zkbvjupKhr 35L1cVHvq9rR0tV55btizIb0VujyRxBYU35Tr1Yp1sn3Utr/m2IGAuGO2c01HSio/Ytm xBp1poTo3b5KMJsECJ6oJRpihi7XxWcunRU3sjWD7Kaw8+WrZSV2N99wmWQ5afYIeZrE H7W99cM1deFOEzNbaLk2j3IJ8KNfRaPekDg2cQMMCf+rBshXXbkVWLOtp6HTHnPjmwpk IFijtefMZoeCmDWr4NfuCAz47/yYRxXlXSwJsJj0pf9v6eBP/BS7rVf2eG7IKNhWaqal g5cQ== X-Gm-Message-State: ABy/qLZNTl2+Yk8daQ16VreqRurIxFk905/Zy2C/mEMgZVhBeWLgOGCr Hrg9+CFNwjPH6wLBK2vmV2u35gmKyJOmEMiWF2BGeA== X-Google-Smtp-Source: APBJJlHQ3/rbJubZcC5OaTnajiCfn01xaWlMvExtSV+fgzFjCxEFVGpWRd2bz+90eESHeTdptEq8tw== X-Received: by 2002:a5d:9146:0:b0:786:25cf:421f with SMTP id y6-20020a5d9146000000b0078625cf421fmr153466ioq.19.1690564159019; Fri, 28 Jul 2023 10:09:19 -0700 (PDT) Received: from localhost.localdomain (75-166-135-140.hlrn.qwest.net. [75.166.135.140]) by smtp.gmail.com with ESMTPSA id k17-20020a5e8911000000b0077e3566a801sm1279269ioj.29.2023.07.28.10.09.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 10:09:18 -0700 (PDT) From: Tom Tromey Date: Fri, 28 Jul 2023 11:09:16 -0600 Subject: [PATCH 2/3] Handle Source in DAP breakpointLocations MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230728-dap-source-refs-v1-2-1bcc5cdffd44@adacore.com> References: <20230728-dap-source-refs-v1-0-1bcc5cdffd44@adacore.com> In-Reply-To: <20230728-dap-source-refs-v1-0-1bcc5cdffd44@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 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,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: This changes the DAP breakpointLocations request to accept a Source and to decode it properly. --- gdb/python/lib/gdb/dap/locations.py | 12 ++++-------- gdb/python/lib/gdb/dap/sources.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/gdb/python/lib/gdb/dap/locations.py b/gdb/python/lib/gdb/dap/locations.py index 594f1bad45b..a299e8da959 100644 --- a/gdb/python/lib/gdb/dap/locations.py +++ b/gdb/python/lib/gdb/dap/locations.py @@ -19,11 +19,13 @@ import gdb from typing import Optional from .server import capability, request +from .sources import decode_source from .startup import in_gdb_thread, send_gdb_with_response @in_gdb_thread -def _find_lines(filename, start_line, end_line): +def _find_lines(source, start_line, end_line): + filename = decode_source(source) lines = set() for entry in gdb.execute_mi("-symbol-list-lines", filename)["lines"]: line = entry["line"] @@ -44,10 +46,4 @@ def _find_lines(filename, start_line, end_line): def breakpoint_locations(*, source, line: int, endLine: Optional[int] = None, **extra): if endLine is None: endLine = line - if "path" in source: - filename = source["path"] - elif "name" in source: - filename = source["name"] - else: - raise Exception("") - return send_gdb_with_response(lambda: _find_lines(filename, line, endLine)) + return send_gdb_with_response(lambda: _find_lines(source, line, endLine)) diff --git a/gdb/python/lib/gdb/dap/sources.py b/gdb/python/lib/gdb/dap/sources.py index 50b5909ed1d..806352836db 100644 --- a/gdb/python/lib/gdb/dap/sources.py +++ b/gdb/python/lib/gdb/dap/sources.py @@ -54,6 +54,22 @@ def make_source(fullname, filename): return result +@in_gdb_thread +def decode_source(source): + """Decode a Source object. + + Finds and returns the filename of a given Source object.""" + if "path" in source: + return source["path"] + if "sourceReference" not in source: + raise Exception("either 'path' or 'sourceReference' must appear in Source") + ref = source["sourceReference"] + global _id_map + if ref not in _id_map: + raise Exception("no sourceReference " + str(ref)) + return _id_map[ref]["path"] + + @in_gdb_thread def _sources(): result = [] -- 2.40.1