From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sKuiAZTCB2CaTgAAWB0awg (envelope-from ) for ; Wed, 20 Jan 2021 00:41:40 -0500 Received: by simark.ca (Postfix, from userid 112) id 038581EF82; Wed, 20 Jan 2021 00:41:40 -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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 54A081EF80 for ; Wed, 20 Jan 2021 00:41:34 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B65C43948024; Wed, 20 Jan 2021 05:41:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B65C43948024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611121293; bh=tPgJg+qX7osSP5fFqjySssGFttjScLLMeyhezxtcsXw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=wj4PKRvuFShFNYeiSbiSaHWcTuM2t1EDAfeCfNNby8lJZWM8XNwvnbmtUHC/EHYAk AeUkdNlII3IIapavRP12OhwP0vDGP5AwCbBMBSJfOoTPduxuX2Da3TDvFNVvNOoTBN VZ8BLohGxA0HGkbFMhufVaklS33XmRq/tXKUfx5o= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id CEDEF3947C24 for ; Wed, 20 Jan 2021 05:41:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CEDEF3947C24 X-ASG-Debug-ID: 1611121287-0c856e67e246f780001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id jc0UGEasoMKMnkSb (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Jan 2021 00:41:27 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 05944441D64; Wed, 20 Jan 2021 00:41:27 -0500 (EST) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 13/13] gdb/testsuite: add test for .debug_{rng, loc}lists section without offset array Date: Wed, 20 Jan 2021 00:39:25 -0500 X-ASG-Orig-Subj: [PATCH 13/13] gdb/testsuite: add test for .debug_{rng, loc}lists section without offset array Message-Id: <20210120053925.142862-14-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210120053925.142862-1-simon.marchi@polymtl.ca> References: <20210120053925.142862-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1611121287 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 11964 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.87375 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Simon Marchi It is possible for the tables in the .debug_{rng,loc}lists sections to not have an array of offsets. In that case, the offset_entry_count field of the header is 0. The forms DW_FORM_{rng,loc}listx (reference by index) can't be used with that table. Instead, the DW_FORM_sec_offset form, which references a {rng,loc}list by direct offset in the section, must be used. From what I saw, this is what GCC currently produces. Add tests for this case. I didn't see any bug related to this, I just think that it would be nice to have coverage for this. A new `-with-offset-array` option is added to the `table` procs, used when generating {rng,loc}lists, to decide whether to generate the offset array. gdb/testsuite/ChangeLog: * lib/dwarf.exp (rnglists): Add -no-offset-array option to table proc. * gdb.dwarf2/rnglists-sec-offset.exp: Add test for .debug_rnglists table without offset array. * gdb.dwarf2/loclists-sec-offset.exp: Add test for .debug_loclists table without offset array. Change-Id: I8e34a7bf68c9682215ffbbf66600da5b7db91ef7 --- .../gdb.dwarf2/loclists-sec-offset.c | 16 +++++ .../gdb.dwarf2/loclists-sec-offset.exp | 70 ++++++++++++++++++- .../gdb.dwarf2/rnglists-sec-offset.exp | 34 ++++++++- gdb/testsuite/lib/dwarf.exp | 48 ++++++++++--- 4 files changed, 155 insertions(+), 13 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.c b/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.c index 924c6ccd4126..f8076406463f 100644 --- a/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.c +++ b/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.c @@ -43,6 +43,20 @@ func4 (void) return 4; } +static int +func5 (void) +{ + asm ("func5_label: .global func5_label\n"); + return 5; +} + +static int +func6 (void) +{ + asm ("func6_label: .global func6_label\n"); + return 6; +} + int main (void) { @@ -50,4 +64,6 @@ main (void) func2 (); func3 (); func4 (); + func5 (); + func6 (); } diff --git a/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp b/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp index ecd85ee116c1..573324af3d17 100644 --- a/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp +++ b/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp @@ -37,6 +37,8 @@ foreach_with_prefix is_64 {false true} { lassign [function_range func2 $srcdir/$subdir/$srcfile] func2_addr func2_len lassign [function_range func3 $srcdir/$subdir/$srcfile] func3_addr func3_len lassign [function_range func4 $srcdir/$subdir/$srcfile] func4_addr func4_len + lassign [function_range func5 $srcdir/$subdir/$srcfile] func5_addr func5_len + lassign [function_range func6 $srcdir/$subdir/$srcfile] func6_addr func6_len set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { @@ -44,6 +46,8 @@ foreach_with_prefix is_64 {false true} { global func2_addr func2_len global func3_addr func3_len global func4_addr func4_len + global func5_addr func5_len + global func6_addr func6_len global is_64 declare_labels cu_range_list foo_range_list @@ -56,7 +60,10 @@ foreach_with_prefix is_64 {false true} { } { declare_labels int_type1 declare_labels int_type2 - declare_labels foo_location_list bar_location_list + declare_labels int_type3 + declare_labels foo_location_list + declare_labels bar_location_list + declare_labels baz_location_list DW_TAG_compile_unit { } { @@ -123,6 +130,41 @@ foreach_with_prefix is_64 {false true} { } } + # This CU uses the DW_FORM_sec_offset form to refer to the + # .debug_loclists section. The corresponding contribution in the + # .debug_loclists section has no offset array. + cu { + version 5 + is_64 $is_64 + } { + DW_TAG_compile_unit { + } { + int_type3: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_data1} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name "int"} + } + + DW_TAG_variable { + {DW_AT_name "baz"} + {DW_AT_location $baz_location_list DW_FORM_sec_offset} + {DW_AT_type :$int_type3} + } + + DW_TAG_subprogram { + {DW_AT_name "func5"} + {DW_AT_low_pc $func5_addr} + {DW_AT_high_pc $func5_len DW_FORM_udata} + } + + DW_TAG_subprogram { + {DW_AT_name "func6"} + {DW_AT_low_pc $func6_addr} + {DW_AT_high_pc $func6_len DW_FORM_udata} + } + } + } + loclists -is-64 $is_64 { # The lists in this table are accessed by direct offset # (DW_FORM_sec_offset). @@ -153,6 +195,20 @@ foreach_with_prefix is_64 {false true} { } } } + + table -with-offset-array false { + baz_location_list: list_ { + start_length $func5_addr $func5_len { + DW_OP_constu 0x567890 + DW_OP_stack_value + } + + start_length $func6_addr $func6_len { + DW_OP_constu 0x678901 + DW_OP_stack_value + } + } + } } } @@ -170,6 +226,8 @@ foreach_with_prefix is_64 {false true} { gdb_breakpoint "func2" gdb_breakpoint "func3" gdb_breakpoint "func4" + gdb_breakpoint "func5" + gdb_breakpoint "func6" gdb_continue_to_breakpoint "func1" with_test_prefix "at func1" { @@ -190,4 +248,14 @@ foreach_with_prefix is_64 {false true} { with_test_prefix "at func4" { gdb_test "print /x bar" " = 0x456789" } + + gdb_continue_to_breakpoint "func5" + with_test_prefix "at func5" { + gdb_test "print /x baz" " = 0x567890" + } + + gdb_continue_to_breakpoint "func6" + with_test_prefix "at func6" { + gdb_test "print /x baz" " = 0x678901" + } } diff --git a/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp b/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp index 2bcbe0aeea8a..0733e90abc74 100644 --- a/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp +++ b/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp @@ -35,8 +35,8 @@ foreach_with_prefix is_64 {false true} { Dwarf::assemble $asm_file { global is_64 - declare_labels cu1_range_list cu2_range_list - declare_labels foo_range_list bar_range_list + declare_labels cu1_range_list cu2_range_list cu3_range_list + declare_labels foo_range_list bar_range_list baz_range_list # This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists # section. @@ -73,6 +73,23 @@ foreach_with_prefix is_64 {false true} { } } + # This CU uses the DW_FORM_sec_offset form to refer to the .debug_rnglists + # section. The corresponding contribution in the .debug_rnglists has no + # offset array. + cu { + version 5 + is_64 $is_64 + } { + DW_TAG_compile_unit { + {DW_AT_ranges $cu3_range_list DW_FORM_sec_offset} + } { + DW_TAG_subprogram { + {DW_AT_name "baz"} + {DW_AT_ranges $baz_range_list DW_FORM_sec_offset} + } + } + } + rnglists -is-64 $is_64 { # The lists in this table are accessed by direct offset # (DW_FORM_sec_offset). @@ -99,6 +116,18 @@ foreach_with_prefix is_64 {false true} { start_end 0x5000 0x5010 } } + + table -with-offset-array false { + # For the third CU. + cu3_range_list: list_ { + start_end 0x6000 0x7000 + } + + # For the baz function. + baz_range_list: list_ { + start_end 0x6000 0x6010 + } + } } } @@ -110,4 +139,5 @@ foreach_with_prefix is_64 {false true} { # Sanity checks to make sure GDB slurped the symbols correctly. gdb_test "p/x &foo" " = 0x4000" gdb_test "p/x &bar" " = 0x5000" + gdb_test "p/x &baz" " = 0x6000" } diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index b444ef36778a..10fd88f6e0fa 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -1392,6 +1392,10 @@ namespace eval Dwarf { # The -post-header-label option can be used to define a label just after # the header of the table. This is the label that a DW_AT_rnglists_base # attribute will usually refer to. + # + # The `-with-offset-array true|false` option can be used to control + # whether the headers of the location list tables have an array of + # offset. The default is true. proc table { args } { variable _debug_rnglists_table_count @@ -1399,7 +1403,10 @@ namespace eval Dwarf { variable _debug_rnglists_offset_size variable _debug_rnglists_is_64_dwarf - parse_args {{post-header-label ""}} + parse_args { + {post-header-label ""} + {with-offset-array true} + } if { [llength $args] != 1 } { error "table proc expects one positional argument (body)" @@ -1477,7 +1484,12 @@ namespace eval Dwarf { _op .2byte 5 "dwarf version" _op .byte $_debug_rnglists_addr_size "address size" _op .byte 0 "segment selector size" - _op .4byte "$_debug_rnglists_list_count" "offset entry count" + + if { ${with-offset-array} } { + _op .4byte "$_debug_rnglists_list_count" "offset entry count" + } else { + _op .4byte 0 "offset entry count" + } define_label $post_header_label @@ -1487,9 +1499,11 @@ namespace eval Dwarf { } # Emit the offset array. - for {set list_idx 0} {$list_idx < $_debug_rnglists_list_count} {incr list_idx} { - set list_label [_compute_list_label $list_idx] - _op .${_debug_rnglists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx" + if { ${with-offset-array} } { + for {set list_idx 0} {$list_idx < $_debug_rnglists_list_count} {incr list_idx} { + set list_label [_compute_list_label $list_idx] + _op .${_debug_rnglists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx" + } } # Emit the actual list data. @@ -1565,6 +1579,10 @@ namespace eval Dwarf { # The -post-header-label option can be used to define a label just after the # header of the table. This is the label that a DW_AT_loclists_base # attribute will usually refer to. + # + # The `-with-offset-array true|false` option can be used to control + # whether the headers of the location list tables have an array of + # offset. The default is true. proc table { args } { variable _debug_loclists_table_count @@ -1572,7 +1590,10 @@ namespace eval Dwarf { variable _debug_loclists_offset_size variable _debug_loclists_is_64_dwarf - parse_args {{post-header-label ""}} + parse_args { + {post-header-label ""} + {with-offset-array true} + } if { [llength $args] != 1 } { error "table proc expects one positional argument (body)" @@ -1672,7 +1693,12 @@ namespace eval Dwarf { _op .2byte 5 "DWARF version" _op .byte $_debug_loclists_addr_size "address size" _op .byte 0 "segment selector size" - _op .4byte $_debug_loclists_list_count "offset entry count" + + if { ${with-offset-array} } { + _op .4byte "$_debug_loclists_list_count" "offset entry count" + } else { + _op .4byte 0 "offset entry count" + } define_label $post_header_label @@ -1682,9 +1708,11 @@ namespace eval Dwarf { } # Emit the offset array. - for {set list_idx 0} {$list_idx < $_debug_loclists_list_count} {incr list_idx} { - set list_label [_compute_list_label $list_idx] - _op .${_debug_loclists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx" + if { ${with-offset-array} } { + for {set list_idx 0} {$list_idx < $_debug_loclists_list_count} {incr list_idx} { + set list_label [_compute_list_label $list_idx] + _op .${_debug_loclists_offset_size}byte "$list_label - $post_header_label" "offset of list $list_idx" + } } # Emit the actual list data. -- 2.30.0