This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Change in binutils-gdb[master]: [gdb/symtab] Prefer var def over decl
- From: "Tom de Vries (Code Review)" <gerrit at gnutoolchain-gerrit dot osci dot io>
- To: Andrew Burgess <andrew dot burgess at embecosm dot com>, gdb-patches at sourceware dot org
- Date: Mon, 14 Oct 2019 12:35:14 -0400
- Subject: Change in binutils-gdb[master]: [gdb/symtab] Prefer var def over decl
- Auto-submitted: auto-generated
- References: <gerrit.1571043046000.Id92326cb8ef9903b121ef9e320658eb565d0f5a9@gnutoolchain-gerrit.osci.io>
- Reply-to: tdevries at suse dot de, sergiodj at sergiodj dot net, andrew dot burgess at embecosm dot com, gdb-patches at sourceware dot org
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><f4>: Abbrev Number: 2 (DW_TAG_array_type)
<f5> DW_AT_type : <0xff>
<f9> DW_AT_sibling : <0xff>
<2><fd>: Abbrev Number: 3 (DW_TAG_subrange_type)
<2><fe>: Abbrev Number: 0
<1><ff>: 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 <zzz>
...
[ 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 <tdevries@suse.de>
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 <tdevries@suse.de>
* 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 <tdevries@suse.de>
Gerrit-Reviewer: Andrew Burgess <andrew.burgess@embecosm.com>
Gerrit-MessageType: newpatchset