From patchwork Thu Jul 4 05:08:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 33530 Received: (qmail 66516 invoked by alias); 4 Jul 2019 05:08:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 66505 invoked by uid 89); 4 Jul 2019 05:08:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=14510 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 05:08:12 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1EFAE30832E1 for ; Thu, 4 Jul 2019 05:08:11 +0000 (UTC) Received: from f29-4.lan (ovpn-117-224.phx2.redhat.com [10.3.117.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0C128351E for ; Thu, 4 Jul 2019 05:08:10 +0000 (UTC) Date: Wed, 3 Jul 2019 22:08:10 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [PATCH v2 5/5] Improve test gdb.dwarf2/dw2-ranges-func.exp Message-ID: <20190703220810.4bd8b641@f29-4.lan> In-Reply-To: <20190704045503.1250-6-kevinb@redhat.com> References: <20190704045503.1250-1-kevinb@redhat.com> <20190704045503.1250-6-kevinb@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes I think that the dw2-ranges-func.exp portion of this patch is easier to review by ignoring white space changes. Here's just the diff (using -w) for that set of changes: diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp index ccf18b6983..fdc488ae92 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp @@ -30,7 +30,16 @@ if !$gcc_compiled { return 0 } -standard_testfile dw2-ranges-func.c dw2-ranges-func-dw.S +proc do_test {suffix} { + global gdb_test_file_name + global testfile binfile srcfile srcfile2 gdb_prompt hex + + # Don't use standard_testfile; we want different binaries for + # each suffix. + set testfile $gdb_test_file_name-$suffix + set binfile [standard_output_file ${testfile}] + set srcfile $testfile.c + set srcfile2 $testfile-dw2.S # We need to know the size of integer and address types in order to # write some of the debugging info we'd like to generate. @@ -56,9 +65,9 @@ Dwarf::assemble $asm_file { lassign [function_range foo [list ${srcdir}/${subdir}/$srcfile]] \ foo_start foo_len set foo_end "$foo_start + $foo_len" - lassign [function_range foo_low [list ${srcdir}/${subdir}/$srcfile]] \ - foo_low_start foo_low_len - set foo_low_end "$foo_low_start + $foo_low_len" + lassign [function_range foo_cold [list ${srcdir}/${subdir}/$srcfile]] \ + foo_cold_start foo_cold_len + set foo_cold_end "$foo_cold_start + $foo_cold_len" lassign [function_range bar [list ${srcdir}/${subdir}/$srcfile]] \ bar_start bar_len set bar_end "$bar_start + $bar_len" @@ -71,7 +80,7 @@ Dwarf::assemble $asm_file { cu {} { compile_unit { {language @DW_LANG_C} - {name dw-ranges-func.c} + {name dw-ranges-func2.c} {stmt_list $L DW_FORM_sec_offset} {low_pc 0 addr} {ranges ${cu_ranges_label} DW_FORM_sec_offset} @@ -145,10 +154,10 @@ Dwarf::assemble $asm_file { {DW_LNS_advance_line [expr [gdb_get_line_number "foo bar call"] - [gdb_get_line_number "foo prologue"]]} {DW_LNS_copy} {DW_LNE_set_address foo_label2} - {DW_LNS_advance_line [expr [gdb_get_line_number "foo foo_low call"] - [gdb_get_line_number "foo bar call"]]} + {DW_LNS_advance_line [expr [gdb_get_line_number "foo foo_cold call"] - [gdb_get_line_number "foo bar call"]]} {DW_LNS_copy} {DW_LNE_set_address foo_label3} - {DW_LNS_advance_line [expr [gdb_get_line_number "foo end"] - [gdb_get_line_number "foo foo_low call"]]} + {DW_LNS_advance_line [expr [gdb_get_line_number "foo end"] - [gdb_get_line_number "foo foo_cold call"]]} {DW_LNS_copy} {DW_LNE_set_address $foo_end} {DW_LNS_advance_line 1} @@ -171,16 +180,16 @@ Dwarf::assemble $asm_file { {DW_LNS_copy} {DW_LNE_end_sequence} - {DW_LNE_set_address $foo_low_start} - {DW_LNS_advance_line [expr [gdb_get_line_number "foo_low prologue"] - 1]} + {DW_LNE_set_address $foo_cold_start} + {DW_LNS_advance_line [expr [gdb_get_line_number "foo_cold prologue"] - 1]} {DW_LNS_copy} - {DW_LNE_set_address foo_low_label} - {DW_LNS_advance_line [expr [gdb_get_line_number "foo_low baz call"] - [gdb_get_line_number "foo_low prologue"]]} + {DW_LNE_set_address foo_cold_label} + {DW_LNS_advance_line [expr [gdb_get_line_number "foo_cold baz call"] - [gdb_get_line_number "foo_cold prologue"]]} {DW_LNS_copy} - {DW_LNE_set_address foo_low_label2} - {DW_LNS_advance_line [expr [gdb_get_line_number "foo_low end"] - [gdb_get_line_number "foo_low baz call"]]} + {DW_LNE_set_address foo_cold_label2} + {DW_LNS_advance_line [expr [gdb_get_line_number "foo_cold end"] - [gdb_get_line_number "foo_cold baz call"]]} {DW_LNS_copy} - {DW_LNE_set_address $foo_low_end} + {DW_LNE_set_address $foo_cold_end} {DW_LNS_advance_line 1} {DW_LNS_copy} {DW_LNE_end_sequence} @@ -191,11 +200,11 @@ Dwarf::assemble $asm_file { ranges {is_64 [is_64_target]} { func_ranges_label: sequence { {range {$foo_start } $foo_end} - {range {$foo_low_start} $foo_low_end} + {range {$foo_cold_start} $foo_cold_end} } cu_ranges_label: sequence { {range {$foo_start } $foo_end} - {range {$foo_low_start} $foo_low_end} + {range {$foo_cold_start} $foo_cold_end} {range {$main_start} $main_end} {range {$bar_start} $bar_end} {range {$baz_start} $baz_end} @@ -233,7 +242,7 @@ with_test_prefix "step-test-1" { "step into bar" gdb_test "step" \ - "foo \\(\\).*foo foo_low call.*" \ + "foo \\(\\).*foo foo_cold call.*" \ "step out of bar, back into foo" } @@ -272,7 +281,7 @@ with_test_prefix "step-test-2" { "step into bar" gdb_test "step" \ - "foo \\(\\).*foo foo_low call.*" \ + "foo \\(\\).*foo foo_cold call.*" \ "step out of bar, back into foo" } @@ -291,11 +300,11 @@ gdb_test_sequence "disassemble foo" "" [list \ "End of assembler dump\\." \ ] -set foo_low_addr -1 -set test "x/i foo_low" + set foo_cold_addr -1 + set test "x/i foo_cold" gdb_test_multiple $test $test { -re " ($hex) .*${gdb_prompt}" { - set foo_low_addr $expect_out(1,string) + set foo_cold_addr $expect_out(1,string) pass $test } } @@ -309,7 +318,7 @@ gdb_test_multiple $test $test { } } -gdb_assert {$foo_low_addr != $foo_addr} "foo and foo_low are at different addresses" + gdb_assert {$foo_cold_addr != $foo_addr} "foo and foo_cold are at different addresses" # This more permissive RE for "break foo" will allow a breakpoint on # multiple locations to PASS. */ @@ -327,11 +336,47 @@ gdb_test "continue" \ gdb_test_no_output "set variable e=1" # If GDB incorrectly places the foo breakpoint on multiple locations, -# then GDB will (incorrectly) stop in foo_low instead of in baz. + # then GDB will (incorrectly) stop in foo_cold instead of in baz. gdb_test "continue" \ "Breakpoint \\d+, (?:$hex in )?baz \\(\\).*" \ "continue to baz" + with_test_prefix "no-cold-names" { + + # Due to the calling sequence, this backtrace would normally + # show function foo_cold for frame #1. However, we don't want + # this to be the case due to placing it in the same block + # (albeit at a different range) as foo. Thus it is correct to + # see foo for frames #1 and #2. It is incorrect to see + # foo_cold at frame #1. + gdb_test_sequence "bt" "backtrace from baz" { + "\[\r\n\]#0 .*? baz \\(\\) " + "\[\r\n\]#1 .*? foo \\(\\) " + "\[\r\n\]#2 .*? foo \\(\\) " + "\[\r\n\]#3 .*? main \\(\\) " + } + + # Doing x/2i foo_cold should show foo_cold as the first symbolic + # address and an offset from foo for the second. We also check to + # make sure that the offset is not too large - we don't GDB to + # display really large offsets that would (try to) wrap around the + # address space. + set foo_cold_offset 0 + set test "x/2i foo_cold" + gdb_test_multiple $test $test { + -re " (?:$hex) .*?\n (?:$hex) .*${gdb_prompt}" { + set foo_cold_offset $expect_out(1,string) + pass $test + } + } + gdb_assert {$foo_cold_offset <= 10000} "offset to foo_cold is not too large" + + # Likewise, verify that second address shown by "info line" is at + # and offset from foo instead of foo_cold. + gdb_test "info line *foo_cold" "starts at address $hex and ends at $hex .*" + + } + with_test_prefix "step-test-3" { clean_restart ${testfile} if ![runto_main] { @@ -347,12 +392,12 @@ with_test_prefix "step-test-3" { "step into bar from foo" gdb_test "step" \ - "foo(_label2)? \\(\\).*foo_low \\(\\);.*foo foo_low call.*" \ + "foo(_label2)? \\(\\).*foo_cold \\(\\);.*foo foo_cold call.*" \ "step out of bar to foo" - # The tests in the "enable_foo_low_stepping" section, below, work + # The tests in the "enable_foo_cold_stepping" section, below, work # with some versions of gcc, though it's not clear that they - # should. This test case causes foo_low, originally a separate + # should. This test case causes foo_cold, originally a separate # function invoked via a subroutine call, to be considered as part # of foo via use of DW_AT_ranges. Real code that I've looked at # uses a branch instruction to cause code in the "cold" range to @@ -363,43 +408,53 @@ with_test_prefix "step-test-3" { # is a reasonable thing to do that should also be supported by # GDB. - set enable_foo_low_stepping false + set enable_foo_cold_stepping false - if { $enable_foo_low_stepping } { + if { $enable_foo_cold_stepping } { gdb_test_no_output "set variable e=1" - set test "step into foo_low from foo" + set test "step into foo_cold from foo" gdb_test_multiple "step" $test { - -re "foo(_low)? \\(\\).*\{.*foo_low prologue.*${gdb_prompt}" { + -re "foo(_low)? \\(\\).*\{.*foo_cold prologue.*${gdb_prompt}" { pass $test gdb_test "step" \ - "foo \\(\\).*baz \\(\\);.*foo_low baz call.*" \ - "step to baz call in foo_low" + "foo \\(\\).*baz \\(\\);.*foo_cold baz call.*" \ + "step to baz call in foo_cold" } - -re "foo(_low)? \\(\\).*baz \\(\\);.*foo_low baz call.*${gdb_prompt}" { + -re "foo(_low)? \\(\\).*baz \\(\\);.*foo_cold baz call.*${gdb_prompt}" { pass $test } } gdb_test "step" \ "baz \\(\\).*\}.*baz end.*" \ - "step into baz from foo_low" + "step into baz from foo_cold" gdb_test "step" \ - "foo(?:_low(?:_label2)?)? \\(\\).*\}.*foo_low end.*" \ - "step out of baz to foo_low" + "foo(?:_low(?:_label2)?)? \\(\\).*\}.*foo_cold end.*" \ + "step out of baz to foo_cold" gdb_test "step" \ "foo(?:_label3)? \\(\\).*\}.*foo end.*" \ - "step out of foo_low to foo" + "step out of foo_cold to foo" } else { gdb_test "next" \ ".*foo end.*" \ - "next over foo_low call" + "next over foo_cold call" } gdb_test "step" \ "main(?:_label2)? \\(\\).*" \ "step out of foo to main" } +} + +# foreach_with_prefix could be used here, but the log file output is somewhat +# less verbose when using an explicit "with_test_prefix". + +foreach test_suffix { "lo-cold" "hi-cold" } { + with_test_prefix $test_suffix { + do_test $test_suffix + } +}