From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id DBFCB386F442 for ; Wed, 6 May 2020 05:08:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DBFCB386F442 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.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9BCCBAEAC for ; Wed, 6 May 2020 05:08:30 +0000 (UTC) Date: Wed, 6 May 2020 07:08:26 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8 Message-ID: <20200506050824.GA3362@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=-20.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Wed, 06 May 2020 05:08:32 -0000 Hi, When running test-case gdb.base/consecutive.exp with gcc-8 instead of gcc-7, we get: ... (gdb) step^M ^M -Breakpoint 3, 0x00000000004004b1 in foo () at consecutive.c:10^M +Breakpoint 3, foo () at consecutive.c:10^M 10 return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6];^M -(gdb) PASS: gdb.base/consecutive.exp: stopped at bp, 2nd instr +(gdb) FAIL: gdb.base/consecutive.exp: stopped at bp, 2nd instr ... This is due to the fact that gcc-8 generates more precise line info, making the breakpoint address a "recommended breakpoint location", and consequently gdb doesn't print the address prefix anymore. Fix the FAIL by checking in the test-case whether the breakpoint address is at "recommended breakpoint location" or not. Committed to trunk. Thanks, - Tom [gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8 gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries * lib/gdb.exp (is_stmt_addresses, hex_in_list): New proc, factored out of ... * gdb.base/async.exp: ... here. * gdb.base/consecutive.exp: Handle if 2nd breakpoint is at a "recommended breakpoint location". --- gdb/testsuite/gdb.base/async.exp | 14 ++------------ gdb/testsuite/gdb.base/consecutive.exp | 15 ++++++++++++++- gdb/testsuite/lib/gdb.exp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp index bf124ca56a9..1a4d3fbee83 100644 --- a/gdb/testsuite/gdb.base/async.exp +++ b/gdb/testsuite/gdb.base/async.exp @@ -79,16 +79,7 @@ test_background "step&" "" ".*y = foo \\(\\).*" "step& #1" test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2" -set is_stmt [list] -gdb_test_multiple "maint info line-table async.c" "" { - -re "\r\n$decimal\[ \t\]+$decimal\[ \t\]+($hex)\[ \t\]+Y\[^\r\n\]*" { - lappend is_stmt $expect_out(1,string) - exp_continue - } - -re -wrap "" { - pass $gdb_test_name - } -} +set is_stmt [is_stmt_addresses $srcfile] # Get the next instruction address. set next_insn_addr "" @@ -99,8 +90,7 @@ gdb_test_multiple {x/2i $pc} "$test" { pass "$test" } } -set next_insn_is_stmt \ - [expr [lsearch -regexp $is_stmt 0x0*$next_insn_addr] != -1] +set next_insn_is_stmt [hex_in_list $next_insn_addr $is_stmt] if { $next_insn_is_stmt } { set prefix "" diff --git a/gdb/testsuite/gdb.base/consecutive.exp b/gdb/testsuite/gdb.base/consecutive.exp index afbe335efc6..d0f541f1a25 100644 --- a/gdb/testsuite/gdb.base/consecutive.exp +++ b/gdb/testsuite/gdb.base/consecutive.exp @@ -35,6 +35,8 @@ if ![runto_main] then { continue } +set is_stmt [is_stmt_addresses $srcfile] + set nl "\[\r\n\]+" gdb_breakpoint foo @@ -55,7 +57,7 @@ gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \ "set bp, 2nd instr" gdb_test_multiple "step" "stopped at bp, 2nd instr" { - -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { + -re -wrap "Breakpoint $decimal, ($hex) in foo.*" { set stop_addr $expect_out(1,string) if [eval expr "$bp_addr == $stop_addr"] then { pass "stopped at bp, 2nd instr" @@ -63,5 +65,16 @@ gdb_test_multiple "step" "stopped at bp, 2nd instr" { fail "stopped at bp, 2nd instr (wrong address)" } } + -re -wrap "Breakpoint $decimal, foo.*" { + set stop_addr [get_valueof "/x" "\$pc" "" "value of pc"] + set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt] + if { ! $stop_addr_is_stmt } { + fail "stopped at bp, 2nd instr (missing hex prefix)" + } elseif [eval expr "$bp_addr == $stop_addr"] then { + pass "stopped at bp, 2nd instr" + } else { + fail "stopped at bp, 2nd instr (wrong address)" + } + } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 37326144141..239871114d2 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -7136,5 +7136,37 @@ proc debug_types { } { return 0 } +# Return the addresses in the line table for FILE for which is_stmt is true. + +proc is_stmt_addresses { file } { + global decimal + global hex + + set is_stmt [list] + + gdb_test_multiple "maint info line-table $file" "" { + -re "\r\n$decimal\[ \t\]+$decimal\[ \t\]+($hex)\[ \t\]+Y\[^\r\n\]*" { + lappend is_stmt $expect_out(1,string) + exp_continue + } + -re -wrap "" { + } + } + + return $is_stmt +} + +# Return 1 if hex number VAL is an element of HEXLIST. + +proc hex_in_list { val hexlist } { + # Normalize val by removing 0x prefix, and leading zeros. + set val [regsub ^0x $val ""] + set val [regsub ^0+ $val "0"] + + set re 0x0*$val + set index [lsearch -regexp $hexlist $re] + return [expr $index != -1] +} + # Always load compatibility stuff. load_lib future.exp