This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA, doc RFA] work around gold/15646
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 19 Jun 2013 14:42:13 -0700
- Subject: [RFA, doc RFA] work around gold/15646
Hi.
This patch works around gold/15646.
Basically, gold can add multiple copies of global syms to the index
whereas gdb only adds one. The workaround is easy enough,
just ignore global instances of a sym after the first one.
I've also updated the docs on .gdb_index to list the problem's with
gold version 7 generated indices.
I wanted to document the Gold issues in the manual so that there's a
more complete description of the differences between version 7 and 8.
In doing so I found all the text regarding version differences to reduce
the S/N ratio of the description of the format of the index.
So I moved the version descriptions into a separate part.
Regression tested on amd64-linux with gold and gdb-generated .gdb_index.
Ok to commit?
2013-06-19 Doug Evans <dje@google.com>
Work around gold/15646.
* dwarf2read.c (read_index_from_section): Update comment.
(struct dw2_symtab_iterator): New member global_seen.
(dw2_symtab_iter_init): Initialize it.
(dw2_symtab_iter_next): Skip duplicate global symbols.
(dw2_expand_symtabs_matching): Ditto.
doc/
* gdb.texinfo (Index Section Format): Move version descriptions
to separate section. Give symbol attribute description a subheading.
Document Gold issues.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.807
diff -u -p -r1.807 dwarf2read.c
--- dwarf2read.c 19 Jun 2013 04:38:51 -0000 1.807
+++ dwarf2read.c 19 Jun 2013 18:54:04 -0000
@@ -2747,9 +2747,12 @@ 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. */
+ of the TU (for symbols coming from TUs),
+ http://sourceware.org/bugzilla/show_bug.cgi?id=15021.
+ Plus gold-generated indices can have duplicate entries for global symbols,
+ http://sourceware.org/bugzilla/show_bug.cgi?id=15646.
+ These are just performance bugs, and we can't distinguish gdb-generated
+ indices from gold-generated ones, so issue no warning here. */
/* Indexes with higher version than the one supported by GDB may be no
longer backward compatible. */
@@ -3160,6 +3163,11 @@ struct dw2_symtab_iterator
int next;
/* The number of elements in VEC, or zero if there is no match. */
int length;
+ /* Have we seen a global version of the symbol?
+ If so we can ignore all further global instances.
+ This is to work around gold/15646, inefficient gold-generated
+ indices. */
+ int global_seen;
};
/* Initialize the index symtab iterator ITER.
@@ -3179,6 +3187,7 @@ dw2_symtab_iter_init (struct dw2_symtab_
iter->block_index = block_index;
iter->domain = domain;
iter->next = 0;
+ iter->global_seen = 0;
if (find_slot_in_mapped_hash (index, name, &iter->vec))
iter->length = MAYBE_SWAP (*iter->vec);
@@ -3229,10 +3238,18 @@ dw2_symtab_iter_next (struct dw2_symtab_
if (per_cu->v.quick->symtab)
continue;
- if (attrs_valid
- && iter->want_specific_block
- && want_static != is_static)
- continue;
+ /* Check static vs global. */
+ if (attrs_valid)
+ {
+ if (iter->want_specific_block
+ && want_static != is_static)
+ continue;
+ /* Work around gold/15646. */
+ if (!is_static && iter->global_seen)
+ continue;
+ if (!is_static)
+ iter->global_seen = 1;
+ }
/* Only check the symbol's kind if it has one. */
if (attrs_valid)
@@ -3621,6 +3638,7 @@ dw2_expand_symtabs_matching
offset_type idx = 2 * iter;
const char *name;
offset_type *vec, vec_len, vec_idx;
+ int global_seen = 0;
if (index->symbol_table[idx] == 0 && index->symbol_table[idx + 1] == 0)
continue;
@@ -3639,6 +3657,8 @@ dw2_expand_symtabs_matching
{
struct dwarf2_per_cu_data *per_cu;
offset_type cu_index_and_attrs = MAYBE_SWAP (vec[vec_idx + 1]);
+ /* This value is only valid for index versions >= 7. */
+ int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
gdb_index_symbol_kind symbol_kind =
GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
@@ -3650,6 +3670,15 @@ dw2_expand_symtabs_matching
(index->version >= 7
&& symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
+ /* Work around gold/15646. */
+ if (attrs_valid)
+ {
+ if (!is_static && global_seen)
+ continue;
+ if (!is_static)
+ global_seen = 1;
+ }
+
/* Only check the symbol's kind if it has one. */
if (attrs_valid)
{
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.1096
diff -u -p -r1.1096 gdb.texinfo
--- doc/gdb.texinfo 7 Jun 2013 00:33:25 -0000 1.1096
+++ doc/gdb.texinfo 19 Jun 2013 21:38:51 -0000
@@ -42649,16 +42649,9 @@ unless otherwise noted:
@enumerate
@item
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. 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
+GDB has workarounds for potentially broken version 7 indices so it is
currently not flagged as deprecated.
@item
@@ -42766,6 +42759,8 @@ See below for the format of each CU inde
A string in the constant pool is zero-terminated.
@end enumerate
+@subheading Symbol Attributes
+
Attributes were added to CU index values in @code{.gdb_index} version 7.
If a symbol has multiple uses within a CU then there is one
CU index+attributes value for each use.
@@ -42855,6 +42850,37 @@ switch (die->tag)
@}
@end smallexample
+@subheading Version History
+
+Here is a brief history of @code{.gdb_index} versions.
+
+@itemize @bullet
+@item
+Versions 1, 2 and 3 are obsolete.
+@item
+Version 4 is the oldest supported version.
+@item
+Version 5 introduces a different hashing function to support
+case-insensitive systems.
+@item
+Version 6 adds symbols for inlined functions.
+@item
+Version 7 adds symbol attributes.
+@item
+Version 8 specifies that the performance issues in
+Gold generated version 7 indices are fixed.
+@end itemize
+
+Gold generated version 7 indices have the following problems:
+
+@itemize @bullet
+@item
+Symbols from DWARF type units refer to a compilation unit that uses
+the type, instead of the type unit itself.
+@item
+Global symbols appear multiple times, whereas only one is needed.
+@end itemize
+
@node Man Pages
@appendix Manual pages
@cindex Man pages