]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Rewrite the .gdb_index reader
authorTom Tromey <tom@tromey.com>
Fri, 7 Mar 2025 01:00:37 +0000 (18:00 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 10 Sep 2025 22:05:28 +0000 (16:05 -0600)
commit486bc5ac812f1d9d104df38c705828b46308e6b2
treeec7babd47dff5bbfc6bfad69c7c4f1fb831ff371
parentf88f9f42db8ff782758435214678ad87d3fc3a18
Rewrite the .gdb_index reader

This patch rewrites the .gdb_index reader to create the same data
structures that are created by the cooked indexer and the .debug_names
reader.

This is done in support of this series; but also because, from what I
can tell, the "templates.exp" change didn't really work properly with
this reader.

In addition to fixing that problem, this patch removes a lot of code.

Implementing this required a couple of hacks, as .gdb_index does not
contain all the information that's used by the cooked index
implementation.

* The index-searching code likes to differentiate between the various
  DWARF tags when matching, but .gdb_index lumps many things into a
  single "other" category.  To handle this, we introduce a phony tag
  that's used so that the match method can match on multiple domains.

* Similarly, .gdb_index doesn't distinguish between the type and
  struct domains, so another phony tag is used for this.

* The reader must attempt to guess the language of various symbols.
  This is somewhat finicky.  "Plain" (unqualified) symbols are marked
  as language_unknown and then a couple of hacks are used to handle
  these -- one in expand_symtabs_matching and another when recognizing
  "main".

For what it's worth, I consider .gdb_index to be near the end of its
life.  While .debug_names is not perfect -- we found a number of bugs
in the standard while implementing it -- it is better than .gdb_index
and also better documented.

After this patch, we could conceivably remove dwarf_scanner_base.
However, I have not done this.

Finally, this patch also changes this reader to dump the content of
the index, as the other DWARF readers do.  This can be handy when
debugging gdb.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33316
gdb/dwarf2/cooked-index-shard.c
gdb/dwarf2/cooked-index-worker.h
gdb/dwarf2/read-gdb-index.c
gdb/dwarf2/read-gdb-index.h
gdb/dwarf2/read.c
gdb/dwarf2/stringify.c
gdb/dwarf2/tag.h