From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id L16/OkgOAGA5HgAAWB0awg (envelope-from ) for ; Thu, 14 Jan 2021 04:26:32 -0500 Received: by simark.ca (Postfix, from userid 112) id E29DE1EF80; Thu, 14 Jan 2021 04:26:32 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DA0181E590 for ; Thu, 14 Jan 2021 04:26:31 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64EDA393D02A; Thu, 14 Jan 2021 09:26:31 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 5AFA1393D02A for ; Thu, 14 Jan 2021 09:26:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5AFA1393D02A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 71495AFA0; Thu, 14 Jan 2021 09:26:27 +0000 (UTC) To: Andrew Burgess References: <20210113000929.GA14297@delia> <20210113194755.GD265215@embecosm.com> From: Tom de Vries Subject: Re: [PATCH][gdb/testsuite] Fix gdb.base/style.exp with -m32 Message-ID: <08ec3d0f-24c2-4f02-e789-54c9b810409f@suse.de> Date: Thu, 14 Jan 2021 10:26:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20210113194755.GD265215@embecosm.com> Content-Type: multipart/mixed; boundary="------------B3B803A0D3E800EC9E0822FF" Content-Language: en-US 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: , Cc: Tom Tromey , gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This is a multi-part message in MIME format. --------------B3B803A0D3E800EC9E0822FF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 1/13/21 8:47 PM, Andrew Burgess wrote: > All of the above is really just a way to select between two different > output patterns, the choice of which is based on the length of argv. > > So, could we not just skip the complexity, and instead do: > > set argv_value [get_hexadecimal_valueof "argv" "??"] > if { [string length $argv_value] > 12 } { > # Choose the first pattern... > } else { > # Choose the second pattern... > } > foreach_with_prefix width {20 30} { > # Run the tests using the selected pattern... > } > > Seems like this might be a simpler solution? In my mind, the pattern matching is the easier solution, and the picking apart the line buildup and determining where it is wrapped the more complex (and more fragile) one. But agreed, the resulting code is less complex. Updated the patch to use the approach you suggested, and committed. Thanks, - Tom --------------B3B803A0D3E800EC9E0822FF Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-testsuite-Fix-gdb.base-style.exp-with-m32.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="0001-gdb-testsuite-Fix-gdb.base-style.exp-with-m32.patch" [gdb/testsuite] Fix gdb.base/style.exp with -m32 When running test-case gdb.base/style.exp with target board unix/-m32, we= run into (stripped styling from output, shortened file name): =2E.. (gdb) frame argv=3D0xffffc714) at src/gdb/testsuite/gdb.base/style.c:45 45 return some_called_function (); /* break here */ (gdb) FAIL: gdb.base/style.exp: frame when width=3D20 =2E.. while with native we have instead: =2E.. (gdb) frame argv=3D0x7fffffffd478) at src/gdb/testsuite/gdb.base/style.c:45 45 return some_called_function (); /* break here */ (gdb) PASS: gdb.base/style.exp: frame when width=3D20 =2E.. The problem is that due to argv having a different length for -m32, we ge= t a different layout, and the test-case doesn't accommodate for that. Fix this by using a different regexp depending on the length of argv. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-01-13 Tom de Vries PR testsuite/24590 * gdb.base/style.exp: Handle shorter argv in frame command output. --- gdb/testsuite/gdb.base/style.exp | 49 ++++++++++++++++++++++++++++++++++= +----- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/st= yle.exp index cc143b43292..aec1d0f42ed 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -46,6 +46,16 @@ save_vars { env(TERM) } { set main_line [gdb_get_line_number "break here"] gdb_test "list $main_line,$main_line" "return.*some_called_function.= *" =20 + gdb_test_no_output "set style enabled off" + + set argv "" + gdb_test_multiple "frame" "frame without styling" { + -re -wrap "main \\(argc=3D.*, (argv=3D$hex)\\).*style\\.c:\[0-9\].*" { + set argv $expect_out(1,string) + pass $gdb_test_name + } + } + gdb_test_no_output "set style enabled on" =20 set main_expr [style main function] @@ -60,7 +70,7 @@ save_vars { env(TERM) } { gdb_test_no_output "set style sources off" gdb_test "frame" \ "\r\n\[^\033\]*break here.*" \ - "frame without styling" + "frame without sources styling" gdb_test_no_output "set style sources on" =20 gdb_test "break -q main" "file $base_file_expr.*" @@ -71,20 +81,47 @@ save_vars { env(TERM) } { # wrong spot with styling. There were different bugs at different # widths, so try two. foreach width {20 30} { - gdb_test_no_output "set width $width" + set argv_len [string length $argv] + if { $argv_len =3D=3D 0 } { + continue + } + # There was also a bug where the styling could be wrong in the # line listing; this is why the words from the source code are # spelled out in the final result line of the test. - gdb_test "frame" \ + set re1_styled \ [multi_line \ "#0 *$main_expr.*$arg_expr.*" \ ".*$arg_expr.*" \ ".* at .*$file_expr.*" \ - "\[0-9\]+.*return.* break here .*" - ] \ - "frame when width=3D$width" + "\[0-9\]+.*return.* break here .*"] + set re2_styled \ + [multi_line \ + "#0 *$main_expr.*$arg_expr.*" \ + ".*$arg_expr.* at .*$file_expr.*" \ + "\[0-9\]+.*return.* break here .*"] + + # The length of the line containing argv containing: + # - 4 leading spaces + # - argv string + # - closing parenthesis + set line_len [expr 4 + $argv_len + 1] + + if { $line_len > $width } { + # At on the next line. + set re_styled $re1_styled + } else { + # At on the same line as argv. + set re_styled $re2_styled + } + + gdb_test_no_output "set width $width" + gdb_test "frame" $re_styled "frame when width=3D$width" } =20 + # Reset width back to 0. + gdb_test_no_output "set width 0" + if {$test_macros} { set macro_line [gdb_get_line_number "\#define SOME_MACRO"] gdb_test "info macro SOME_MACRO" \ --------------B3B803A0D3E800EC9E0822FF--