diff options
author | Andy Wingo <wingo@igalia.com> | 2015-03-26 19:41:15 +0100 |
---|---|---|
committer | Andy Wingo <wingo@igalia.com> | 2015-03-26 19:41:54 +0100 |
commit | ff908ebf8612a737d9e168eca0604ff6c97556bc (patch) | |
tree | 5decbc2e9890ad4b60c7d8e7b940fef9ba29e4ef /gdb/dwarf2read.c | |
parent | f30d5c78faa5979fb933038923e5270b7728f96f (diff) | |
download | gdb-ff908ebf8612a737d9e168eca0604ff6c97556bc.zip gdb-ff908ebf8612a737d9e168eca0604ff6c97556bc.tar.gz gdb-ff908ebf8612a737d9e168eca0604ff6c97556bc.tar.bz2 |
Properly intern constants into psymtab
Variables with a DW_AT_const_value but without a DW_AT_location were not
getting added to the partial symbol table. They are added to the full
symbol table, however, when the compilation unit's psymtabs are
expanded.
Before:
(gdb) p one
No symbol "one" in current context.
(gdb) mt flush-symbol-cache
(gdb) mt expand one.c
(gdb) p one
$1 = 1
After:
(gdb) p one
$1 = 1
To the user it's pretty strange, as depending on whether tab completion
has forced expansion of all CUs or not the lookup might succeed, or not
if the failure was already added to the symbol cache.
This commit simply makes sure to add constants to the partial symbol
tables.
gdb/testsuite/ChangeLog:
PR symtab/18148
* gdb.dwarf2/dw2-intercu.S (one, two): Add variables that have a
const_value but not a location.
* gdb.dwarf2/dw2-intercu.exp: Add tests that constants without
location defined in non-main CUs are visible.
gdb/ChangeLog:
PR symtab/18148
* dwarf2read.c (struct partial_die_info): Add has_const_value
member.
(add_partial_symbol): Don't punt on symbols that have const_value
attributes.
(read_partial_die): Detect DW_AT_const_value.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 96c5a33..f6b0c016 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1105,6 +1105,9 @@ struct partial_die_info /* Flag set if the DIE has a byte_size attribute. */ unsigned int has_byte_size : 1; + /* Flag set if the DIE has a DW_AT_const_value attribute. */ + unsigned int has_const_value : 1; + /* Flag set if any of the DIE's children are template arguments. */ unsigned int has_template_arguments : 1; @@ -6956,19 +6959,24 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) } else { - /* Static Variable. Skip symbols without location descriptors. */ - if (pdi->d.locdesc == NULL) + int has_loc = pdi->d.locdesc != NULL; + + /* Static Variable. Skip symbols whose value we cannot know (those + without location descriptors or constant values). */ + if (!has_loc && !pdi->has_const_value) { xfree (built_actual_name); return; } + /* prim_record_minimal_symbol (actual_name, addr + baseaddr, mst_file_data, objfile); */ add_psymbol_to_list (actual_name, strlen (actual_name), built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC, &objfile->static_psymbols, - 0, addr + baseaddr, + 0, + has_loc ? addr + baseaddr : (CORE_ADDR) 0, cu->language, objfile); } break; @@ -15851,6 +15859,9 @@ read_partial_die (const struct die_reader_specs *reader, case DW_AT_byte_size: part_die->has_byte_size = 1; break; + case DW_AT_const_value: + part_die->has_const_value = 1; + break; case DW_AT_calling_convention: /* DWARF doesn't provide a way to identify a program's source-level entry point. DW_AT_calling_convention attributes are only meant |