From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49811 invoked by alias); 14 Oct 2019 16:35:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 49733 invoked by uid 89); 14 Oct 2019 16:35:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_2 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Oct 2019 16:35:21 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id A9F57208F0; Mon, 14 Oct 2019 12:35:19 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 177F62080A; Mon, 14 Oct 2019 12:35:15 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id F047529ECF; Mon, 14 Oct 2019 12:35:14 -0400 (EDT) X-Gerrit-PatchSet: 2 Date: Mon, 14 Oct 2019 16:35:00 -0000 From: "Tom de Vries (Code Review)" To: Andrew Burgess , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: Change in binutils-gdb[master]: [gdb/symtab] Prefer var def over decl X-Gerrit-Change-Id: Id92326cb8ef9903b121ef9e320658eb565d0f5a9 X-Gerrit-Change-Number: 29 X-Gerrit-ChangeURL: X-Gerrit-Commit: f885ed071fe8d3124112e010fc0446374eb5aaf1 In-Reply-To: References: Reply-To: tdevries@suse.de, sergiodj@sergiodj.net, andrew.burgess@embecosm.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3 Content-Type: text/plain; charset=UTF-8 Message-Id: <20191014163514.F047529ECF@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-10/txt/msg00371.txt.bz2 Hello Andrew Burgess, I'd like you to reexamine a change. Please visit https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/29 to look at the new patch set (#2). Change subject: [gdb/symtab] Prefer var def over decl ...................................................................... [gdb/symtab] Prefer var def over decl Consider the DWARF as generated by gcc with the tentative patch to fix gcc PR91507 - "wrong debug for completed array with previous incomplete declaration": ... <1>: Abbrev Number: 2 (DW_TAG_array_type) DW_AT_type : <0xff> DW_AT_sibling : <0xff> <2>: Abbrev Number: 3 (DW_TAG_subrange_type) <2>: Abbrev Number: 0 <1>: Abbrev Number: 4 (DW_TAG_pointer_type) <100> DW_AT_byte_size : 8 <101> DW_AT_type : <0x105> <1><105>: Abbrev Number: 5 (DW_TAG_base_type) <106> DW_AT_byte_size : 1 <107> DW_AT_encoding : 6 (signed char) <108> DW_AT_name : (indirect string, offset: 0x19f): char <1><10c>: Abbrev Number: 6 (DW_TAG_variable) <10d> DW_AT_name : zzz <111> DW_AT_decl_file : 1 <112> DW_AT_decl_line : 1 <113> DW_AT_decl_column : 14 <114> DW_AT_type : <0xf4> <118> DW_AT_external : 1 <118> DW_AT_declaration : 1 <1><118>: Abbrev Number: 2 (DW_TAG_array_type) <119> DW_AT_type : <0xff> <11d> DW_AT_sibling : <0x128> <1><12f>: Abbrev Number: 8 (DW_TAG_variable) <130> DW_AT_specification: <0x10c> <134> DW_AT_decl_line : 2 <135> DW_AT_decl_column : 7 <136> DW_AT_type : <0x118> <13a> DW_AT_location : 9 byte block: 3 30 10 60 0 0 0 0 0 (DW_OP_addr: 601030) ... The DWARF will result in two entries in the symbol table, a decl with type char *[] and a def with type char*[2]. When trying to print the value of zzz: ... $ gdb a.spec.out -batch -ex "p zzz" ... the decl (rather than the def) will be found in the symbol table, which is missing the location information, and consequently we get: ... $1 = 0x601030 ... [ There is a fallback mechanism that finds the address of the variable in the minimal symbol table, but that's not used here, because the type of the decl does not specify a size. We could use the symbol size here to get the size of the type, but that's currently not done: PR exp/24989. Still, fixing that PR would not fix the generic case, where minimal symbol info is not available. ] Fix this by preferring defs over decls when searching in the symbol table. Build and reg-tested on x86_64-linux. [ The test-case is a bit simpler than the DWARF example listed above, because the new variable varval3 that is used is not listed in the minimal symbols, so there's no need to work around the fallback mechanism to trigger the problem. ] gdb/ChangeLog: 2019-09-10 Tom de Vries PR symtab/24971 * block.c (best_symbol, better_symbol): New function. (block_lookup_symbol_primary): Prefer def over decl. gdb/testsuite/ChangeLog: 2019-09-10 Tom de Vries * gdb.dwarf2/varval.exp: Add decl before def test. Change-Id: Id92326cb8ef9903b121ef9e320658eb565d0f5a9 --- M gdb/block.c M gdb/testsuite/gdb.dwarf2/varval.exp 2 files changed, 55 insertions(+), 3 deletions(-) git pull ssh://gnutoolchain-gerrit.osci.io:29418/binutils-gdb refs/changes/29/29/2 -- To view, visit https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/29 To unsubscribe, or for help writing mail filters, visit https://gnutoolchain-gerrit.osci.io/r/settings Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: Id92326cb8ef9903b121ef9e320658eb565d0f5a9 Gerrit-Change-Number: 29 Gerrit-PatchSet: 2 Gerrit-Owner: Tom de Vries Gerrit-Reviewer: Andrew Burgess Gerrit-MessageType: newpatchset