From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xylCB8zPmWrPQCYAWB0awg (envelope-from ) for ; Thu, 03 Sep 2026 15:51:40 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=GOFI+ut5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D9D8B1E033; Thu, 03 Sep 2026 15:51:39 -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,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 758F91E033 for ; Thu, 03 Sep 2026 15:51:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 507334BB24CF for ; Thu, 3 Sep 2026 19:51:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 507334BB24CF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=GOFI+ut5 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by sourceware.org (Postfix) with ESMTPS id 07D204BAE7EB for ; Thu, 3 Sep 2026 19:51:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07D204BAE7EB Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 07D204BAE7EB Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788465073; cv=none; b=Cid+kbEW9rOLwuB+5REc1rOzAzziJTVQajiw3UDjwlQ+ysofuKXEp5pe+Bgf7mQPOFSbMb/WipVJrhFp1mTS2Y+D0DVFg0oTOtyf+AyihgNQZbX+bZcfeV5mAwZkFcsyywUtdUTHt4zvzRyA5+1OcbNxxIP7vY5PU28UVwwhwho= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788465073; c=relaxed/simple; bh=vDAGjA6lfhPEnM3kV9SBOHN5aubljSMzSW1WUxP9flc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KzhGqlKkTesKgaPWoPiZarZhi6N9F9V2qxJ2eK/08c2RLW+QxbaTgWXoP417uTp0ptEVJxGXvYlHspiTRdcBnaMiTiqwK1hDjiVwJEkxOTGQIDrFZluBeKni0o2YsUr0f4Cm7WjVsBfP1y8ViKCkx2WxspKfVrk62hHaSKLH5Y8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=GOFI+ut5 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07D204BAE7EB Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-46ac530b9ebso168015fac.0 for ; Thu, 03 Sep 2026 12:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1788465071; x=1789069871; 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=JVwgX+z8D9k/saNV08JTUk2BJCFdZFXR+Y87rA5JMlM=; b=GOFI+ut5o/DRZS/Uk8vd/tMmLwdQNiyZn3ThJ9ER2k73Yym75pNqX1Mg1ZD4zuH4ug CFnIXgg2wrzXo02rFs9kbwndhTscd++QTZdZdOmnyXxDpFXo0Cjyda5qPxtuH45C2YU1 FxDrCDUYOgoPiAcdurExd+mZrkniFlON48os5+rlGmZHUS9KD1Wh/lLFB9SiOjGhGOi/ mUw0iuJAEM1R80Z6cUiWXlSWkdMSy/m0WgPTf5X2uxRjSanHZlLxRJbyr0yCA4Wu+k1Z 8vGXYlnQSlrAhAWzppXoiI2Iz5V+HKmBwEvlEKBdKuCIWBo2nbu6lwjOjYoz53TxmoSD o39A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788465071; x=1789069871; 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=JVwgX+z8D9k/saNV08JTUk2BJCFdZFXR+Y87rA5JMlM=; b=F0eWq/t56xQUKGG36Bm1oLWn01n5k9uEbFteYa8KNegBtb/J9aYWycHF5q6XzggW/t PGhJw999nAAlLhzF1j45o8HOzZrPfS2ox0fkKkK9xvRMGLCfGnNIq/sw22tSI4gK0cwn tvv988o2ZrD/c06cfBDfFRpz/Lj8o3DIGWDOkSomdh3zBRntN2nJfQj0+zai9WpB+ePE U8KnEunpLqrNC+7gHlAc9dy/ukfBP7IzYlzl36n28UmmOGkFsBbXFP1/2CBlRAa1wWYa 5GBcorChe9iz+GVGsNN4SyJxOqXv8KHH2252DJNk8+aON5u76nYUUMpdlLYyNV5Pu8Ac OBUg== X-Gm-Message-State: AFuF++n1PpChy116uCV4V0tayN6azbf/u0PV2IJVwqdLinCoOHZZRmG5 fji+YBEZ6v6mpRQ6/fq6J9T654rK/igiAT/bd8El16jdF83tgAzRUXHdGxE4ebHadH9bI1ZiYAY MY6ZgYQ== X-Gm-Gg: AYBFou0K6gesFTDdfH8DIAbu7jcTyIRDEM+sAmG9rzge4Mq2F7PN0u8Pd/DJkPABd3N rqoprP3YQkX993tbG2o6F2R1JpGRJ1Oq1MLo6yjCHmGPYgOXW4Utzc4gFe8WH+997iX6pRYRrFX nsmxK4KKc96O10tPnQpoK9Xi2dCmiwF4tocoauHWH6mJKn5b/4U+KzNafyVWk4v0VmWqTSRu1qq sV35c/zSwT2MfMO/jDO55rF29XHK1arrwrNjFrb3Q2vYOttO3iB8nlsbPsNyS6I2S+rHJbHCZwT YaaORuBYlLtl3DbEmpqqv2bA+EXyvNHSrx4vbrKWN82I1UOmLRDfIXYf040pYWofJD7h5QwgK/y t5HZbbHRH61ESZyRZcIPlroO9Q/TY69BDBA3TT1FJNdCV2Heml1Z5xrxf1kesDdTL/8kTYctEzI 6PJLL4UkFi6vD4o9HRzCkpTYlCuAI7SkJEl6DiCp3z60gCA8tn8SumVPT4juRRHpTJp5rqlhCoQ AS5 X-Received: by 2002:a05:6871:68c6:b0:456:4c6b:773a with SMTP id 586e51a60fabf-4757b5318afmr79740fac.9.1788465071260; Thu, 03 Sep 2026 12:51:11 -0700 (PDT) Received: from bapiya (97-122-117-2.hlrn.qwest.net. [97.122.117.2]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-475550aed36sm445490fac.18.2026.09.03.12.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 12:51:10 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Add DAP completion test Date: Thu, 3 Sep 2026 13:51:08 -0600 Message-ID: <20260903195108.3974413-1-tromey@adacore.com> X-Mailer: git-send-email 2.55.0 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 This adds a test for the DAP completions request. While working on this I found a couple of buglets in the DAP completions implementation. I've filed these in bugzilla. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34592 --- gdb/testsuite/gdb.dap/completions.c | 32 ++++++++ gdb/testsuite/gdb.dap/completions.exp | 107 ++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 gdb/testsuite/gdb.dap/completions.c create mode 100644 gdb/testsuite/gdb.dap/completions.exp diff --git a/gdb/testsuite/gdb.dap/completions.c b/gdb/testsuite/gdb.dap/completions.c new file mode 100644 index 00000000000..858f087074f --- /dev/null +++ b/gdb/testsuite/gdb.dap/completions.c @@ -0,0 +1,32 @@ +/* Copyright 2026 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +int unique_enough_prefix_1 = 23; + +int unique_enough_prefix_2 = 91; + +int inner_func () +{ + int unique_enough_prefix_4 = 19; + return unique_enough_prefix_4 - 19; /* BREAK */ +} + +int main () +{ + int unique_enough_prefix_3 = 17; + return inner_func () + unique_enough_prefix_3 - 17; +} diff --git a/gdb/testsuite/gdb.dap/completions.exp b/gdb/testsuite/gdb.dap/completions.exp new file mode 100644 index 00000000000..f79f9ba07a1 --- /dev/null +++ b/gdb/testsuite/gdb.dap/completions.exp @@ -0,0 +1,107 @@ +# Copyright 2026 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 . + +# Test "completions" request. + +require allow_dap_tests + +load_lib dap-support.exp + +standard_testfile + +if {[build_executable ${testfile}.exp $testfile] == -1} { + return +} + +if {[dap_initialize] == ""} { + return +} + +set launch_id [dap_launch $testfile] + +set line [gdb_get_line_number "BREAK"] +set obj [dap_check_request_and_response "set breakpoint by line number" \ + setBreakpoints \ + [format {o source [o path [%s]] breakpoints [a [o line [i %d]]]} \ + [list s $srcfile] $line]] +set line_bpno [dap_get_breakpoint_number $obj] + +dap_check_request_and_response "configurationDone" configurationDone + +dap_check_response "launch response" launch $launch_id + +dap_wait_for_event_and_check "inferior started" thread "body reason" started + +dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ + "body reason" breakpoint \ + "body hitBreakpointIds" $line_bpno + +set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \ + {o threadId [i 1]}] \ + 0] +set inner_frame_id [dict get [lindex [dict get $bt body stackFrames] 0] id] +set outer_frame_id [dict get [lindex [dict get $bt body stackFrames] 1] id] + +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 result [lindex [dap_check_request_and_response \ + "completions in inner frame" completions \ + [format {o frameId [i %s] text [s {%s}] column [i %s]} \ + $inner_frame_id $pfx $col]] \ + 0] + +with_test_prefix inner_frame { + check_results [dict get $result body targets] "" 1 2 4 +} + +set result [lindex [dap_check_request_and_response \ + "completions in outer frame" completions \ + [format {o frameId [i %s] text [s {%s}] column [i %s]} \ + $outer_frame_id $pfx $col]] \ + 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 +} + +set result [lindex [dap_check_request_and_response \ + "completions without frame" completions \ + [format {o text [s {%s}] column [i %s]} \ + $pfx $col]] \ + 0] + +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 +} + +# The result here isn't important, this is just checking that the +# request doesn't fail. +dap_check_request_and_response "completion of empty string" completions \ + {o text [s {}] column [i 0]} + +dap_shutdown base-commit: f09597461f2a1a9d88e5986a044abe7171c922e4 -- 2.55.0