From patchwork Mon Nov 14 11:13:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 60579 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 2B56638518A5 for ; Mon, 14 Nov 2022 11:13:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B56638518A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668424418; bh=40gq07M2xs6slqqKJfmKA+4XLUAT9/U432mEJzhrzp0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=W6nFubglwIOV93icGKuG1Q+TrVLo9Q88gECjQOx72w0bJjne9Fu1ArwaI07fRS1Xn WE/o/IyYvK8OyoXEjaFl5jXSmNCv1CScWWF8fkCdDbFE59eMOtrzIytHevco1Y21nC 2WVfZTGlyVUsk6gYi5sc+R7nr3uUlCoW4x+7jEMc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 78F753858C52 for ; Mon, 14 Nov 2022 11:13:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 78F753858C52 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 816891FEA9 for ; Mon, 14 Nov 2022 11:13:06 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6DB4A13A8C for ; Mon, 14 Nov 2022 11:13:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 5mWaGcIicmOFcgAAMHmgww (envelope-from ) for ; Mon, 14 Nov 2022 11:13:06 +0000 To: gdb-patches@sourceware.org Subject: [pushed 1/3] [gdb/testsuite] Set completions to unlimited in get_set_option_choices Date: Mon, 14 Nov 2022 12:13:04 +0100 Message-Id: <20221114111306.8833-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" In some test-case I tried to use get_set_option_choices "set architecture" and ran into max-completions: ... set architecture simple^M set architecture tomcat^M set architecture xscale^M set architecture *** List may be truncated, max-completions reached. ***^M (gdb) PASS: gdb.base/foo.exp: complete set architecture ... There's only one test-case using this currently: gdb.base/parse_number.exp, and it locally sets max-completions to unlimited. Fix this by: - factoring out a new proc with_set out of proc with_complaints, and - using it to temporarily set max-completions to unlimited in get_set_option_choice. Tested on x86_64-linux, by running test-cases that excercise get_set_option_choice and with_complaints. --- gdb/testsuite/gdb.base/parse_number.exp | 10 ++--- gdb/testsuite/lib/gdb.exp | 54 ++++++++++++++----------- 2 files changed, 35 insertions(+), 29 deletions(-) base-commit: fadfefbf159291a685c9849ebf597c1d4d7f75dc diff --git a/gdb/testsuite/gdb.base/parse_number.exp b/gdb/testsuite/gdb.base/parse_number.exp index 70b0ad065d7..06bf1cd1714 100644 --- a/gdb/testsuite/gdb.base/parse_number.exp +++ b/gdb/testsuite/gdb.base/parse_number.exp @@ -346,18 +346,16 @@ proc test_parse_numbers {arch} { clean_restart -gdb_test_no_output "set language unknown" -gdb_test "p/x 0" \ - "expression parsing not implemented for language \"Unknown\"" - -gdb_test_no_output "set max-completions unlimited" - set supported_archs [get_set_option_choices "set architecture"] # There should be at least one more than "auto". gdb_assert {[llength $supported_archs] > 1} "at least one architecture" set all_languages [get_set_option_choices "set language"] +gdb_test_no_output "set language unknown" +gdb_test "p/x 0" \ + "expression parsing not implemented for language \"Unknown\"" + # If 1, test each arch. If 0, test one arch for each sizeof # short/int/long/longlong configuration. # For a build with --enable-targets=all, full_arch_testing == 0 takes 15s, diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 1240c2ef6f3..40a7c7728d1 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5911,34 +5911,31 @@ proc gdb_load { arg } { } # -# with_complaints -- Execute BODY and set complaints temporary to N for the +# with_set -- Execute BODY and set VAR temporary to VAL for the # duration. # -proc with_complaints { n body } { - global decimal - - # Save current setting of complaints. +proc with_set { var val body } { set save "" - set show_complaints_re \ - "Max number of complaints about incorrect symbols is ($decimal)\\." - gdb_test_multiple "show complaints" "" { - -re -wrap $show_complaints_re { + set show_re \ + "is (\[^\r\n\]+)\\." + gdb_test_multiple "show $var" "" { + -re -wrap $show_re { set save $expect_out(1,string) } } if { $save == "" } { - perror "Did not manage to set complaints" + perror "Did not manage to set $var" } else { - # Set complaints. - gdb_test_no_output -nopass "set complaints $n" + # Set var. + gdb_test_no_output -nopass "set $var $val" } set code [catch {uplevel 1 $body} result] - # Restore saved setting of complaints. + # Restore saved setting. if { $save != "" } { - gdb_test_no_output -nopass "set complaints $save" + gdb_test_no_output -nopass "set $var $save" } if {$code == 1} { @@ -5949,6 +5946,14 @@ proc with_complaints { n body } { } } +# +# with_complaints -- Execute BODY and set complaints temporary to N for the +# duration. +# +proc with_complaints { n body } { + return [uplevel [list with_set complaints $n $body]] +} + # # gdb_load_no_complaints -- As gdb_load, but in addition verifies that # loading caused no symbol reading complaints. @@ -9108,20 +9113,23 @@ gdb_caching_proc has_hw_wp_support { # Return a list of all the accepted values of the set command SET_CMD. proc get_set_option_choices {set_cmd} { - global gdb_prompt - set values {} + set cmd "complete $set_cmd " set test "complete $set_cmd" - gdb_test_multiple "complete $set_cmd " "$test" { - -re "$set_cmd (\[^\r\n\]+)\r\n" { - lappend values $expect_out(1,string) - exp_continue - } - -re "$gdb_prompt " { - pass $test + + with_set max-completions unlimited { + gdb_test_multiple $cmd $test { + -re "\r\n$set_cmd (\[^\r\n\]+)" { + lappend values $expect_out(1,string) + exp_continue + } + -re -wrap "" { + pass $gdb_test_name + } } } + return $values }