From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Wnt8HwUnp2oDtwkAWB0awg (envelope-from ) for ; Sun, 13 Sep 2026 18:43:17 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=kKAlTEoN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5B0D41E033; Sun, 13 Sep 2026 18:43:17 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 787471E033 for ; Sun, 13 Sep 2026 18:43:16 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B0B44BB24D0 for ; Sun, 13 Sep 2026 22:43:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B0B44BB24D0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=kKAlTEoN Received: from mail-wr2-x10.google.com (mail-wr2-x10.google.com [IPv6:2a00:1450:4864:30::10]) by sourceware.org (Postfix) with ESMTPS id 9207B4B9DB61 for ; Sun, 13 Sep 2026 22:42:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9207B4B9DB61 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9207B4B9DB61 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:30::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789339370; cv=none; b=L1eNa0ARsugJK7ukyJUcUioxfP/GGGyOGl7a66/1SD5BSEjsye89eZmzoxuQzanBGlj52aC5ThArjUvaed+nFe8agus8wEIKIM+sFLS0LgWLBN9gjLov7aNoNcPgoIXpCCww6IqslCtsG/vVLgtL/2rjMs3pH11QfL7UD7DbW90= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789339370; c=relaxed/simple; bh=eis3Bd6Ec27lC807NSAgFSSkfydoTKVAn74vFRVuPwI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EpMT+0R5DsP+Oz1ZPUomuLEzfmBvW9vvpfmvkrVHLwVDHt8SHXcyPdnQA+xPq6AO/gNeHcQD5/JmDhvK88ZA3g2rwQfZBRBJs60oE4KLKk5d8P3tYihy/TosnP98kOsKHOwr3t4fpwdBG5yV8phjZIim7uk6lUbBpTZiFUteCok= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=kKAlTEoN DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9207B4B9DB61 Received: by mail-wr2-x10.google.com with SMTP id ffacd0b85a97d-482f6350f88so674924f8f.2 for ; Sun, 13 Sep 2026 15:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789339369; x=1789944169; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=aYgQwz24TLHf1MkYN1dDXzfI99sUO75rwkHSVX3hM2A=; b=kKAlTEoNizKrW159IGY8yq2XigSsO2G5MSSbx6u8pg+ck1gJs4zD7uMxaFbWijwJQm unACWJH7GFfLjvkyT/AHHHRGtuUsSikcn6WFE12UjuDGqMvexcqRTI8HGye1nSwFh9WX LqsCAuwGwFnwmPO17oL4yQpj8ezpoiepao5AdDaXWLy2kFiEq9y5cFIsown+Q4jbPnHB km4kXSak/f73l/4ThSvJYM4aqlWJ5EqW8/i9Zt1Keaw7VrS1HFPAecYufkZGsemAU89i o6qQhOWh710mLrgIkMgi0UtEVU6noPL6/67BLwxUgdLITJFcKjgN1zA4+PLB8x3yTWBu 9iOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789339369; x=1789944169; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aYgQwz24TLHf1MkYN1dDXzfI99sUO75rwkHSVX3hM2A=; b=sC1Y8OPUSPsfJKUrJK7rzxBaZY2Dc3OE6lPE6YEgbVLDnvLua0kVD53ETnlF2gZdMw IrsKWi9y7aHvTo0bkMEOzAKCyWJXMW0TOt+GxNBN0g/JaKaKFkZDbuO/xWEUbaOEmxbP s+ExYIIty3jr1qEx0e3ynJ7FPV2Sj1fQEcJ3jYar+sgzz7kvD8zPSVdvSlApKj/7eO8I yg2s9OoKBZOVnN5wUx9gGOuSL9CpLn0ciYTDBJDEeMOA96FBasDDkUzW0XvJ8tB5p52y HK9eYDnp4+od4P+bMudGXp4hqlvlrFRAnZyuwygNAARGp19tl/WbhqlPpm6qLGOw0fUx 3hXg== X-Gm-Message-State: AFuF++knMCXqbtPdUv86/DciwK5p7fsQOws2UaPO5chH1IqjhYVQDLaJ 2+LXpuTEPscl7HlAH2ny7Lq7wCQv0iFVNHBhALzxVwB8O7bC7tho5N5p0zsxNg== X-Gm-Gg: AYBFou3jkb3iuGqYW4Bxr48YdAVBfrn1bAMLbZqg59jhkjYZWbD1fiBNnr56VJppfvp AngHyvgkJJ5JGg/ygcCu45yWrI9djqz3q4AajQcG2agj/LE6SNCcSI6OMsn3U6ExG0ePc0vBp7y 9rjgjMP7dOE76nZy7a/on2D5BrRRFHqpA7Sp4dpKIFoMSjHI+sHpPT1onwS/zb9ry0M6GSjCxmQ qnsCqw79KIipT/1BOjOVq5Ca9aqShaneCJo2x5xOkj23lvn5JV6WughXfkAt3jCqFIRJe8jg6pL 7Q6CTpaxd8y+DcGdRj7K1yb21iqGe1iZBHCHb3COLacg7Lr+QG78keuF4p7W0bNFi49JvuY4jwn igRgaSKGpRhqHwdVjLY5XeHMGVh2wJj4rW/ddqp0+ptPK9jPrO/Z8PpG+DVT5ufjYS9eOMMi3WZ +dnzKJX6dEkYn8UMml8M2gOGsr5p099ORjWUhnTtJw9IQjBomL5rLLacBhUEnI46jMtGmNSwqbF 8W3/zofHetpwOClZvKbYYdUWR3YewCHnnbfEyPUMjPH+iKH0t5Sm3T6oTcWpuqnXaWa X-Received: by 2002:a05:600c:4e54:b0:49c:dada:f581 with SMTP id 5b1f17b1804b1-49e7a5ed78amr241685e9.0.1789339369282; Sun, 13 Sep 2026 15:42:49 -0700 (PDT) Received: from Mein-PC (p200300ed8f441a0024c1028e800bc45b.dip0.t-ipconnect.de. [2003:ed:8f44:1a00:24c1:28e:800b:c45b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e6499d57bsm391846555e9.3.2026.09.13.15.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 15:42:48 -0700 (PDT) From: Oleg Tolmatcev To: gdb-patches@sourceware.org Cc: Oleg Tolmatcev Subject: [PATCH] gdb/dap: Return only actual completions Date: Mon, 14 Sep 2026 00:40:07 +0200 Message-ID: <20260913224006.1748-2-oleg.tolmatcev@gmail.com> X-Mailer: git-send-email 2.55.0.windows.5 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The MI completion result may repeat the input text when completion is ambiguous. Do not expose that common-prefix value as a DAP completion item; return only the actual matches instead. Update the completion test to compare the complete label list and verify that the input text is omitted. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34592 --- gdb/python/lib/gdb/dap/completions.py | 12 ------------ gdb/testsuite/gdb.dap/completions.exp | 23 ++++++++++++++--------- 2 files changed, 14 insertions(+), 21 deletions(-) This patch is based on the patch in https://sourceware.org/pipermail/gdb-patches/2026-September/230035.html. diff --git a/gdb/python/lib/gdb/dap/completions.py b/gdb/python/lib/gdb/dap/completions.py index 8495e4f8b6b..48f698a084f 100644 --- a/gdb/python/lib/gdb/dap/completions.py +++ b/gdb/python/lib/gdb/dap/completions.py @@ -46,18 +46,6 @@ def completions( text = "" mi_result = exec_mi_and_log("-complete", text) result = [] - completion = None - if "completion" in mi_result: - completion = mi_result["completion"] - result.append({"label": completion, "length": len(text)}) - # If `-complete' finds one match then `completion' and `matches' - # will contain the same one match. - if ( - completion is not None - and len(mi_result["matches"]) == 1 - and completion == mi_result["matches"][0] - ): - return {"targets": result} for match in mi_result["matches"]: result.append({"label": match, "length": len(text)}) return {"targets": result} diff --git a/gdb/testsuite/gdb.dap/completions.exp b/gdb/testsuite/gdb.dap/completions.exp index f79f9ba07a1..b5b0ad840b7 100644 --- a/gdb/testsuite/gdb.dap/completions.exp +++ b/gdb/testsuite/gdb.dap/completions.exp @@ -58,11 +58,18 @@ set pfx "print unique_enough_prefix_" set col [string length $pfx] proc check_results {actual args} { - foreach item $actual suffix $args { - set value [dict get $item label] - gdb_assert {$value == [string cat $::pfx $suffix]} \ - "checking suffix $suffix" + set actual_labels {} + foreach item $actual { + lappend actual_labels [dict get $item label] } + + set expected_labels {} + foreach suffix $args { + lappend expected_labels [string cat $::pfx $suffix] + } + + gdb_assert {$actual_labels == $expected_labels} \ + "checking completion results" } set result [lindex [dap_check_request_and_response \ @@ -72,7 +79,7 @@ set result [lindex [dap_check_request_and_response \ 0] with_test_prefix inner_frame { - check_results [dict get $result body targets] "" 1 2 4 + check_results [dict get $result body targets] 1 2 4 } set result [lindex [dap_check_request_and_response \ @@ -82,9 +89,7 @@ set result [lindex [dap_check_request_and_response \ 0] with_test_prefix outer_frame { - # The empty string here is wrong. gdb should not return the - # argument text. See PR dap/34592. - check_results [dict get $result body targets] "" 1 2 3 + check_results [dict get $result body targets] 1 2 3 } set result [lindex [dap_check_request_and_response \ @@ -96,7 +101,7 @@ set result [lindex [dap_check_request_and_response \ with_test_prefix "no frame" { # Note that the result '3' here is actually wrong. gdb should # ignore the selected frame. See PR dap/34591. - check_results [dict get $result body targets] "" 1 2 3 + check_results [dict get $result body targets] 1 2 3 } # The result here isn't important, this is just checking that the -- 2.55.0.windows.5