aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2013-01-23 18:47:51 +0000
committerDoug Evans <dje@google.com>2013-01-23 18:47:51 +0000
commit796a7ff8234cfaa8ad1ab884c1c8dafe29b18d42 (patch)
tree3791b7ddb4f6e56494b844dab9b24bce0c30c2c1 /gdb
parentf5c66ab0f8a76861a46ba52e232524ae52251efc (diff)
downloadgdb-796a7ff8234cfaa8ad1ab884c1c8dafe29b18d42.zip
gdb-796a7ff8234cfaa8ad1ab884c1c8dafe29b18d42.tar.gz
gdb-796a7ff8234cfaa8ad1ab884c1c8dafe29b18d42.tar.bz2
Work around binutils/15021.
* dwarf2read.c (dwarf2_per_cu_data): Split imported_symtabs and type_unit_group out of union s. All uses updated. (read_index_from_section): Watch for index version 8. (follow_die_sig): If using .gdb_index version <= 7, record the TU as an imported symtab. (write_psymtabs_to_index): Increment version number to 8. doc/ * gdb.texinfo (Index Section Format): Document .gdb_index version 8.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/gdb.texinfo10
-rw-r--r--gdb/dwarf2read.c106
4 files changed, 90 insertions, 40 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 94325d4..c00bb3b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-23 Doug Evans <dje@google.com>
+
+ Work around binutils/15021.
+ * dwarf2read.c (dwarf2_per_cu_data): Split imported_symtabs and
+ type_unit_group out of union s. All uses updated.
+ (read_index_from_section): Watch for index version 8.
+ (follow_die_sig): If using .gdb_index version <= 7, record the TU as
+ an imported symtab.
+ (write_psymtabs_to_index): Increment version number to 8.
+
2013-01-22 Pedro Alves <palves@redhat.com>
* annotate.c (breakpoint_changed): Skip if breakpoint is not
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 662ec6d..c09e2ff 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-23 Doug Evans <dje@google.com>
+
+ * gdb.texinfo (Index Section Format): Document .gdb_index version 8.
+
2013-01-21 Marc Khouzam <marc.khouzam@ericsson.com>
* gdb.texinfo (GDB/MI Breakpoint Commands): Document new
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index ba25aac..61e9190 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41050,12 +41050,18 @@ unless otherwise noted:
@enumerate
@item
-The version number, currently 7. Versions 1, 2 and 3 are obsolete.
+The version number, currently 8. Versions 1, 2 and 3 are obsolete.
Version 4 uses a different hashing function from versions 5 and 6.
Version 6 includes symbols for inlined functions, whereas versions 4
and 5 do not. Version 7 adds attributes to the CU indices in the
-symbol table. @value{GDBN} will only read version 4, 5, or 6 indices
+symbol table. Version 8 specifies that symbols from DWARF type units
+(@samp{DW_TAG_type_unit}) refer to the type unit's symbol table and not the
+compilation unit (@samp{DW_TAG_comp_unit}) using the type.
+
+@value{GDBN} will only read version 4, 5, or 6 indices
by specifying @code{set use-deprecated-index-sections on}.
+GDB has a workaround for potentially broken version 7 indices so it is
+currently not flagged as deprecated.
@item
The offset, from the start of the file, of the CU list.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0c25726..8ac062a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -566,19 +566,29 @@ struct dwarf2_per_cu_data
struct dwarf2_per_cu_quick_data *quick;
} v;
- union
- {
- /* The CUs we import using DW_TAG_imported_unit. This is filled in
- while reading psymtabs, used to compute the psymtab dependencies,
- and then cleared. Then it is filled in again while reading full
- symbols, and only deleted when the objfile is destroyed. */
- VEC (dwarf2_per_cu_ptr) *imported_symtabs;
-
- /* Type units are grouped by their DW_AT_stmt_list entry so that they
- can share them. If this is a TU, this points to the containing
- symtab. */
- struct type_unit_group *type_unit_group;
- } s;
+ /* The CUs we import using DW_TAG_imported_unit. This is filled in
+ while reading psymtabs, used to compute the psymtab dependencies,
+ and then cleared. Then it is filled in again while reading full
+ symbols, and only deleted when the objfile is destroyed.
+
+ This is also used to work around a difference between the way gold
+ generates .gdb_index version <=7 and the way gdb does. Arguably this
+ is a gold bug. For symbols coming from TUs, gold records in the index
+ the CU that includes the TU instead of the TU itself. This breaks
+ dw2_lookup_symbol: It assumes that if the index says symbol X lives
+ in CU/TU Y, then one need only expand Y and a subsequent lookup in Y
+ will find X. Alas TUs live in their own symtab, so after expanding CU Y
+ we need to look in TU Z to find X. Fortunately, this is akin to
+ DW_TAG_imported_unit, so we just use the same mechanism: For
+ .gdb_index version <=7 this also records the TUs that the CU referred
+ to. Concurrently with this change gdb was modified to emit version 8
+ indices so we only pay a price for gold generated indices. */
+ VEC (dwarf2_per_cu_ptr) *imported_symtabs;
+
+ /* Type units are grouped by their DW_AT_stmt_list entry so that they
+ can share them. If this is a TU, this points to the containing
+ symtab. */
+ struct type_unit_group *type_unit_group;
};
/* Entry in the signatured_types hash table. */
@@ -2690,9 +2700,14 @@ to use the section anyway."),
}
return 0;
}
+ /* Version 7 indices generated by gold refer to the CU for a symbol instead
+ of the TU (for symbols coming from TUs). It's just a performance bug, and
+ we can't distinguish gdb-generated indices from gold-generated ones, so
+ nothing to do here. */
+
/* Indexes with higher version than the one supported by GDB may be no
longer backward compatible. */
- if (version > 7)
+ if (version > 8)
return 0;
map->version = version;
@@ -2929,7 +2944,7 @@ dw2_get_file_names (struct objfile *objfile,
DWO file. */
if (this_cu->is_debug_types)
{
- struct type_unit_group *tu_group = this_cu->s.type_unit_group;
+ struct type_unit_group *tu_group = this_cu->type_unit_group;
init_cutu_and_read_dies (tu_group->t.first_tu, NULL, 0, 0,
dw2_get_file_names_reader, tu_group);
@@ -4959,10 +4974,10 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
(objfile->static_psymbols.list + pst->statics_offset);
sort_pst_symbols (objfile, pst);
- if (!VEC_empty (dwarf2_per_cu_ptr, cu->per_cu->s.imported_symtabs))
+ if (!VEC_empty (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs))
{
int i;
- int len = VEC_length (dwarf2_per_cu_ptr, cu->per_cu->s.imported_symtabs);
+ int len = VEC_length (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs);
struct dwarf2_per_cu_data *iter;
/* Fill in 'dependencies' here; we fill in 'users' in a
@@ -4971,12 +4986,12 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
pst->dependencies = obstack_alloc (&objfile->objfile_obstack,
len * sizeof (struct symtab *));
for (i = 0;
- VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->s.imported_symtabs,
+ VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
i, iter);
++i)
pst->dependencies[i] = iter->v.psymtab;
- VEC_free (dwarf2_per_cu_ptr, cu->per_cu->s.imported_symtabs);
+ VEC_free (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs);
}
/* Get the list of files included in the current compilation unit,
@@ -5074,7 +5089,7 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
per_cu = &tu_group->per_cu;
per_cu->objfile = objfile;
per_cu->is_debug_types = 1;
- per_cu->s.type_unit_group = tu_group;
+ per_cu->type_unit_group = tu_group;
if (dwarf2_per_objfile->using_index)
{
@@ -5411,7 +5426,7 @@ build_type_psymtab_dependencies (void **slot, void *info)
++i)
{
pst->dependencies[i] = iter->v.psymtab;
- iter->s.type_unit_group = tu_group;
+ iter->type_unit_group = tu_group;
}
VEC_free (dwarf2_per_cu_ptr, tu_group->t.tus);
@@ -5732,7 +5747,7 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
process_psymtab_comp_unit (per_cu, 1);
VEC_safe_push (dwarf2_per_cu_ptr,
- cu->per_cu->s.imported_symtabs, per_cu);
+ cu->per_cu->imported_symtabs, per_cu);
}
break;
default:
@@ -6866,7 +6881,7 @@ recursively_compute_inclusions (VEC (dwarf2_per_cu_ptr) **result,
VEC_safe_push (dwarf2_per_cu_ptr, *result, per_cu);
for (ix = 0;
- VEC_iterate (dwarf2_per_cu_ptr, per_cu->s.imported_symtabs, ix, iter);
+ VEC_iterate (dwarf2_per_cu_ptr, per_cu->imported_symtabs, ix, iter);
++ix)
recursively_compute_inclusions (result, all_children, iter);
}
@@ -6879,7 +6894,7 @@ compute_symtab_includes (struct dwarf2_per_cu_data *per_cu)
{
gdb_assert (! per_cu->is_debug_types);
- if (!VEC_empty (dwarf2_per_cu_ptr, per_cu->s.imported_symtabs))
+ if (!VEC_empty (dwarf2_per_cu_ptr, per_cu->imported_symtabs))
{
int ix, len;
struct dwarf2_per_cu_data *iter;
@@ -6895,13 +6910,14 @@ compute_symtab_includes (struct dwarf2_per_cu_data *per_cu)
NULL, xcalloc, xfree);
for (ix = 0;
- VEC_iterate (dwarf2_per_cu_ptr, per_cu->s.imported_symtabs,
+ VEC_iterate (dwarf2_per_cu_ptr, per_cu->imported_symtabs,
ix, iter);
++ix)
recursively_compute_inclusions (&result_children, all_children, iter);
- /* Now we have a transitive closure of all the included CUs, so
- we can convert it to a list of symtabs. */
+ /* Now we have a transitive closure of all the included CUs, and
+ for .gdb_index version 7 the included TUs, so we can convert it
+ to a list of symtabs. */
len = VEC_length (dwarf2_per_cu_ptr, result_children);
symtab->includes
= obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
@@ -6984,7 +7000,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
static_block
= end_symtab_get_static_block (highpc + baseaddr, objfile, 0,
- per_cu->s.imported_symtabs != NULL);
+ per_cu->imported_symtabs != NULL);
/* If the comp unit has DW_AT_ranges, it may have discontiguous ranges.
Also, DW_AT_ranges may record ranges not belonging to any child DIEs
@@ -7080,10 +7096,10 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
If this is the first TU to use this symtab, complete the construction
of it with end_expandable_symtab. Otherwise, complete the addition of
this TU's symbols to the existing symtab. */
- if (per_cu->s.type_unit_group->primary_symtab == NULL)
+ if (per_cu->type_unit_group->primary_symtab == NULL)
{
symtab = end_expandable_symtab (0, objfile, SECT_OFF_TEXT (objfile));
- per_cu->s.type_unit_group->primary_symtab = symtab;
+ per_cu->type_unit_group->primary_symtab = symtab;
if (symtab != NULL)
{
@@ -7098,8 +7114,8 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
else
{
augment_type_symtab (objfile,
- per_cu->s.type_unit_group->primary_symtab);
- symtab = per_cu->s.type_unit_group->primary_symtab;
+ per_cu->type_unit_group->primary_symtab);
+ symtab = per_cu->type_unit_group->primary_symtab;
}
if (dwarf2_per_objfile->using_index)
@@ -7145,7 +7161,7 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu)
if (maybe_queue_comp_unit (cu, per_cu, cu->language))
load_full_comp_unit (per_cu, cu->language);
- VEC_safe_push (dwarf2_per_cu_ptr, cu->per_cu->s.imported_symtabs,
+ VEC_safe_push (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
per_cu);
}
}
@@ -8036,9 +8052,9 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
/* If we're using .gdb_index (includes -readnow) then
per_cu->s.type_unit_group may not have been set up yet. */
- if (per_cu->s.type_unit_group == NULL)
- per_cu->s.type_unit_group = get_type_unit_group (cu, attr);
- tu_group = per_cu->s.type_unit_group;
+ if (per_cu->type_unit_group == NULL)
+ per_cu->type_unit_group = get_type_unit_group (cu, attr);
+ tu_group = per_cu->type_unit_group;
/* If we've already processed this stmt_list there's no real need to
do it again, we could fake it and just recreate the part we need
@@ -17588,6 +17604,16 @@ follow_die_sig (struct die_info *src_die, struct attribute *attr,
temp_die.offset.sect_off);
if (die)
{
+ /* For .gdb_index version 7 keep track of included TUs.
+ http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */
+ if (dwarf2_per_objfile->index_table != NULL
+ && dwarf2_per_objfile->index_table->version <= 7)
+ {
+ VEC_safe_push (dwarf2_per_cu_ptr,
+ (*ref_cu)->per_cu->imported_symtabs,
+ sig_cu->per_cu);
+ }
+
*ref_cu = sig_cu;
return die;
}
@@ -19638,7 +19664,11 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d)
for (ix = 0; ix < dwarf2_per_objfile->n_comp_units; ++ix)
VEC_free (dwarf2_per_cu_ptr,
- dwarf2_per_objfile->all_comp_units[ix]->s.imported_symtabs);
+ dwarf2_per_objfile->all_comp_units[ix]->imported_symtabs);
+
+ for (ix = 0; ix < dwarf2_per_objfile->n_type_units; ++ix)
+ VEC_free (dwarf2_per_cu_ptr,
+ dwarf2_per_objfile->all_type_units[ix]->per_cu.imported_symtabs);
VEC_free (dwarf2_section_info_def, data->types);
@@ -20460,7 +20490,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
total_len = size_of_contents;
/* The version number. */
- val = MAYBE_SWAP (7);
+ val = MAYBE_SWAP (8);
obstack_grow (&contents, &val, sizeof (val));
/* The offset of the CU list from the start of the file. */