From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 894FD38518B5 for ; Wed, 23 Nov 2022 18:58:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 894FD38518B5 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 2ANIwpfG007706 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 13:58:55 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 2ANIwpfG007706 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1669229936; bh=fowY2okJEtJeKsh3+6Fi6a6adSC6KsWDQiyeFIOLLmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qc63Zk6KHpvv07BujYSFsv0Pr5zHRJrLHxrowqy3zhioS9yAC2o6KLSP2n/D3rXcq mJz6X1jBfG2qqOMhPtGOSq+q2ycrlon6YbCcgal1GUcRoUWrtifCaBHZTRto6odhYU TWS8o9h6qTPlgYmZzGy6f7caW88+ObwZIc+TPUhU= Received: from simark.localdomain (unknown [217.28.27.60]) (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 ESMTPSA id B91B11E128; Wed, 23 Nov 2022 13:40:03 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 04/14] gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue Date: Wed, 23 Nov 2022 13:39:49 -0500 Message-Id: <20221123183959.2476477-5-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123183959.2476477-1-simon.marchi@polymtl.ca> References: <20221123183959.2476477-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 23 Nov 2022 18:58:51 +0000 X-Spam-Status: No, score=-3189.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 List-Id: Change-Id: Ibf17033c8ce72aa5cfe1b739be2902e84a5e945d --- gdb/testsuite/gdb.base/break.exp | 99 ++++++++++++++++---------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index a9728798fab9..7e410b4adeec 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -773,68 +773,65 @@ test_next_with_recursion # build a new file with optimization enabled so that we can try breakpoints # on targets with optimized prologues -if { [prepare_for_testing "failed to prepare" "breako2" {break.c break1.c} {debug nowarnings optimize=-O2}] } { +if { [build_executable "failed to prepare" "breako2" {break.c break1.c} {debug nowarnings optimize=-O2}] } { return -1 } -# -# test break at function -# -gdb_test "break -q main" \ - "Breakpoint.*at.* file .*, line.*" \ - "breakpoint function, optimized file" - -# -# test break at function -# -gdb_test "break marker4" \ - "Breakpoint.*at.* file .*$srcfile1, line.*" \ - "breakpoint small function, optimized file" - -# -# run until the breakpoint at main is hit. For non-stubs-using targets. -# -gdb_run_cmd - -set test "run until function breakpoint, optimized file" -gdb_test_multiple "" $test { - -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { - pass $test - } - -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" { - pass "$test (code motion)" - } -} +proc_with_prefix test_break_optimized_prologue {} { + clean_restart breako2 -# -# run until the breakpoint at a small function -# + # test break at function + gdb_test "break -q main" \ + "Breakpoint.*at.* file .*, line.*" \ + "breakpoint function, optimized file" -# -# Add a second pass pattern. The behavior differs here between stabs -# and dwarf for one-line functions. Stabs preserves two line symbols -# (one before the prologue and one after) with the same line number, -# but dwarf regards these as duplicates and discards one of them. -# Therefore the address after the prologue (where the breakpoint is) -# has no exactly matching line symbol, and GDB reports the breakpoint -# as if it were in the middle of a line rather than at the beginning. + # test break at function + gdb_test "break marker4" \ + "Breakpoint.*at.* file .*$::srcfile1, line.*" \ + "breakpoint small function, optimized file" -set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] + # run until the breakpoint at main is hit. For non-stubs-using targets. + gdb_run_cmd -gdb_test_multiple "continue" \ - "run until breakpoint set at small function, optimized file" { - -re "Breakpoint $decimal, marker4 \\(d=(d@entry=)?177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" { - pass "run until breakpoint set at small function, optimized file (line bp_location14)" + set test "run until function breakpoint, optimized file" + gdb_test_multiple "" $test { + -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$::srcfile:$::bp_location6.*$::bp_location6\[\t \]+if .argc.* \{.*$::gdb_prompt $" { + pass $test } - -re "Breakpoint $decimal, factorial \\(.*\\) .*\{\r\n$gdb_prompt" { - # GCC 4.3 emits bad line number information - see gcc/36748. - if { [test_compiler_info "gcc-4-3-*"] } { - setup_xfail *-*-* - } - fail "run until breakpoint set at small function, optimized file" + -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$::gdb_prompt $" { + pass "$test (code motion)" } } + # run until the breakpoint at a small function + # + # Add a second pass pattern. The behavior differs here between stabs + # and dwarf for one-line functions. Stabs preserves two line symbols + # (one before the prologue and one after) with the same line number, + # but dwarf regards these as duplicates and discards one of them. + # Therefore the address after the prologue (where the breakpoint is) + # has no exactly matching line symbol, and GDB reports the breakpoint + # as if it were in the middle of a line rather than at the beginning. + + set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $::srcfile1] + + gdb_test_multiple "continue" \ + "run until breakpoint set at small function, optimized file" { + -re "Breakpoint $::decimal, marker4 \\(d=(d@entry=)?177601976\\) at .*$::srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" { + pass "run until breakpoint set at small function, optimized file (line bp_location14)" + } + -re "Breakpoint $::decimal, factorial \\(.*\\) .*\{\r\n$::gdb_prompt" { + # GCC 4.3 emits bad line number information - see gcc/36748. + if { [test_compiler_info "gcc-4-3-*"] } { + setup_xfail *-*-* + } + fail "run until breakpoint set at small function, optimized file" + } + } +} + +test_break_optimized_prologue + # test that 'rbreak' on a symbol that may be from a shared library doesn't # cause a "Junk at end of arguments." error. # -- 2.38.1