From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id D214D383543A for ; Tue, 8 Jun 2021 15:39:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D214D383543A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EB9C6219AA for ; Tue, 8 Jun 2021 15:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623166765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=jMemOAxe2htDUKiNgPCBVjHGohRXTAUGSlWyvqcgOAU=; b=LLHSUnNFRANADY8HM/r5+l3VltzluVeRLyH36eNfXbV8bZcHkuHcwpx+MMTwhF8Fwk1g9X cBn4jgPzn37fFXXYieMokZ8xDeP8TMyej0AWAMVfA1IBQJc+lqHTpimH6Lp/KYg1qMYgHY Bm847V0dePBZqsLr3aTMa2eCiTsbkjs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623166765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=jMemOAxe2htDUKiNgPCBVjHGohRXTAUGSlWyvqcgOAU=; b=dsEW+vu3j8rRgk13YaAkCpXyfyQ8cGYVxG4M2//uRYdJ0Q98d0ePFIOMWY3AiebPYqC4PJ Pfr0aLqCh+QvD0Bg== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id CB60D118DD for ; Tue, 8 Jun 2021 15:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623166765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=jMemOAxe2htDUKiNgPCBVjHGohRXTAUGSlWyvqcgOAU=; b=LLHSUnNFRANADY8HM/r5+l3VltzluVeRLyH36eNfXbV8bZcHkuHcwpx+MMTwhF8Fwk1g9X cBn4jgPzn37fFXXYieMokZ8xDeP8TMyej0AWAMVfA1IBQJc+lqHTpimH6Lp/KYg1qMYgHY Bm847V0dePBZqsLr3aTMa2eCiTsbkjs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623166765; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=jMemOAxe2htDUKiNgPCBVjHGohRXTAUGSlWyvqcgOAU=; b=dsEW+vu3j8rRgk13YaAkCpXyfyQ8cGYVxG4M2//uRYdJ0Q98d0ePFIOMWY3AiebPYqC4PJ Pfr0aLqCh+QvD0Bg== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id 7e4iMC2Pv2DVOAAALh3uQQ (envelope-from ) for ; Tue, 08 Jun 2021 15:39:25 +0000 Date: Tue, 8 Jun 2021 17:39:24 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb/testsuite] Disallow single argument in multi_line Message-ID: <20210608153923.GA14720@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.8 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Tue, 08 Jun 2021 15:39:28 -0000 Hi, It's a common mistake of mine to do: ... set l [list "foo" "bar"] set re [multi_line $l] ... and to get "foo bar" while I was expecting "foo\r\nbar", which I get after doing instead: ... set re [multi_line {*}$l] ... Detect this type of mistake by erroring out in multi_line when only one argument is passed. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/testsuite] Disallow single argument in multi_line gdb/testsuite/ChangeLog: 2021-06-08 Tom de Vries * lib/gdb.exp (multi_line): Require more than one argument. * gdb.base/gdbinit-history.exp: Update multi_line call. * gdb.base/jit-reader.exp: Remove multi_line call. * gdb.fortran/dynamic-ptype-whatis.exp: Same. --- gdb/testsuite/gdb.base/gdbinit-history.exp | 6 +++++- gdb/testsuite/gdb.base/jit-reader.exp | 4 +--- gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp | 2 +- gdb/testsuite/lib/gdb.exp | 4 ++++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp index 8e3994e6052..36f4a114a71 100644 --- a/gdb/testsuite/gdb.base/gdbinit-history.exp +++ b/gdb/testsuite/gdb.base/gdbinit-history.exp @@ -144,7 +144,11 @@ proc check_history { hist } { lappend hist_lines " $idx $h" incr idx } - set pattern [eval multi_line $hist_lines] + if { [llength $hist_lines] == 1 } { + set pattern [lindex $hist_lines 0] + } else { + set pattern [eval multi_line $hist_lines] + } # Check the history. gdb_test "show commands" "$pattern.*" diff --git a/gdb/testsuite/gdb.base/jit-reader.exp b/gdb/testsuite/gdb.base/jit-reader.exp index 25d1100ca60..83e403653d6 100644 --- a/gdb/testsuite/gdb.base/jit-reader.exp +++ b/gdb/testsuite/gdb.base/jit-reader.exp @@ -240,9 +240,7 @@ proc jit_reader_test {} { # the built-in unwinder cannot backtrace through the mangled # stack pointer. gdb_test "bt" \ - [multi_line \ - "Backtrace stopped: Cannot access memory at address $sp_after_mangling" \ - ] \ + "Backtrace stopped: Cannot access memory at address $sp_after_mangling" \ "bt shows error" gdb_test "info frame" "Cannot access memory at address.*" \ diff --git a/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp b/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp index d2ffd6d73f7..5ea2aa48a05 100644 --- a/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp +++ b/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.exp @@ -73,7 +73,7 @@ gdb_test "whatis var4%t2_array" "type = Type type1, allocatable \\(3\\)" gdb_test "whatis var5%t3_array" "type = Type type1 \\(3\\)" gdb_test "whatis var6%t4_array" "type = Type type2, allocatable \\(3\\)" gdb_test "whatis var7%t5_array" "type = Type type2 \\(4\\)" -gdb_test "ptype var3%t1_i" [ multi_line "type = integer\\(kind=4\\)" ] +gdb_test "ptype var3%t1_i" "type = integer\\(kind=4\\)" gdb_test "ptype var4%t2_array" [ multi_line "type = Type type1" \ " integer\\(kind=4\\) :: spacer" \ " integer\\(kind=4\\) :: t1_i" \ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f7ab2198a25..8469ec9801c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -7294,6 +7294,10 @@ proc capture_command_output { command prefix } { # being. proc multi_line { args } { + if { [llength $args] == 1 } { + set hint "forgot {*} before list argument?" + error "multi_line called with one argument ($hint)" + } return [join $args "\r\n"] }