From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /EshJ5S4DmCAAQAAWB0awg (envelope-from ) for ; Mon, 25 Jan 2021 07:24:52 -0500 Received: by simark.ca (Postfix, from userid 112) id 914B11EF80; Mon, 25 Jan 2021 07:24:52 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 36F521E940 for ; Mon, 25 Jan 2021 07:24:52 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D1893951443; Mon, 25 Jan 2021 12:24:51 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id ABE433857800 for ; Mon, 25 Jan 2021 12:24:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ABE433857800 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 C857BAB9F; Mon, 25 Jan 2021 12:24:47 +0000 (UTC) Date: Mon, 25 Jan 2021 13:24:45 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/symtab] Handle DW_AT_ranges with DW_FORM_sec_off in partial DIE Message-ID: <20210125122444.GA15885@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-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 Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, While looking into a failure in gdb.go/package.exp with gcc-11, I noticed that gdb shows some complaints when loading the executable (also with gcc-10, where the test-case passes): ... $ gdb -batch -iex "set complaints 100" package.10 -ex start During symbol reading: Attribute value is not a constant (DW_FORM_sec_offset) Temporary breakpoint 1 at 0x402ae6: file gdb.go/package1.go, line 8. During symbol reading: Attribute value is not a constant (DW_FORM_sec_offset) During symbol reading: Invalid .debug_rnglists data (no base address) ... Fix this by using as_unsigned () to read DW_AT_ranges in the partial DIE reader, similar to how that is done in dwarf2_get_pc_bounds. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/symtab] Handle DW_AT_ranges with DW_FORM_sec_off in partial DIE gdb/ChangeLog: 2021-01-25 Tom de Vries * dwarf2/read.c (partial_die_info::read): Use as_unsigned () for DW_AT_ranges. gdb/testsuite/ChangeLog: 2021-01-25 Tom de Vries * gdb.dwarf2/dw2-ranges-psym.exp (gdb_load_no_complaints): New proc. * lib/gdb.exp: Use gdb_load_no_complaints. --- gdb/dwarf2/read.c | 2 +- gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp | 5 +++- gdb/testsuite/lib/gdb.exp | 36 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 309ff8331e7..5191d697ec7 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -19810,7 +19810,7 @@ partial_die_info::read (const struct die_reader_specs *reader, /* It would be nice to reuse dwarf2_get_pc_bounds here, but that requires a full DIE, so instead we just reimplement it. */ - unsigned int ranges_offset = (attr.constant_value (0) + unsigned int ranges_offset = (attr.as_unsigned () + (need_ranges_base ? cu->ranges_base : 0)); diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp index 72966aff820..3ad2d1c567c 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp @@ -120,11 +120,14 @@ Dwarf::assemble $asm_file { } } -if { [prepare_for_testing "failed to prepare" ${testfile} \ +if { [build_executable "failed to prepare" ${testfile} \ [list $srcfile $srcfile2 $asm_file] {nodebug}] } { return -1 } +clean_restart +gdb_load_no_complaints $binfile + if ![runto_main] { return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 03653ab1a7f..2a952c6146f 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5095,6 +5095,42 @@ proc gdb_load { arg } { return 0 } +# +# gdb_load_no_complaints -- As gdb_load, but in addition verifies that +# loading caused no symbol reading complaints. +# +proc gdb_load_no_complaints { arg } { + global gdb_prompt gdb_file_cmd_msg decimal + + # Save current setting of complaints. + set save "" + set show_complaints_re \ + "Max number of complaints about incorrect symbols is ($decimal)\\." + gdb_test_multiple "show complaints" "" { + -re -wrap $show_complaints_re { + set save $expect_out(1,string) + } + } + + # Fall back to regular gdb_load if we couldn't get the current setting + # of complaints. + if { $save == "" } { + return gdb_load $arg + } + + # Temporarily set complaint to a small non-zero number. + gdb_test_no_output "set complaints 5" "" + + gdb_load $arg + + # Verify that there were no complaints. + set re "^Reading symbols from \[^\r\n\]*\r\n$gdb_prompt $" + gdb_assert {[regexp $re $gdb_file_cmd_msg]} "No complaints" + + # Restore saved setting of complaints. + gdb_test_no_output "set complaints $save" "" +} + # gdb_reload -- load a file into the target. Called before "running", # either the first time or after already starting the program once, # for remote targets. Most files that override gdb_load should now