Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 11/28] Rewrite the .gdb_index reader
Date: Wed, 23 Apr 2025 13:22:37 -0400	[thread overview]
Message-ID: <6785bbf8-4a37-454a-abcb-747f27b8e153@simark.ca> (raw)
In-Reply-To: <20250402-search-in-psyms-v2-11-ea91704487cb@tromey.com>



On 2025-04-02 19:45, Tom Tromey wrote:
> 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.
> 
> * Support for older versions of .gdb_index is removed entirely.
> 
> * 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.

I'm not knowledgeable enough with the .gdb_index quirks to have an
informed opinion about this.  I am happy with this change because it
brings it in line with the other two we already have (.debug_info and
.debug_names).

I noted some random comments below.

> diff --git a/gdb/dwarf2/cooked-index-shard.c b/gdb/dwarf2/cooked-index-shard.c
> index 29a8aea513786e4c1c1ed77dee8610fc329d1c8a..888a0fa345b9124e2814aa722e71a9d2fd5adf8e 100644
> --- a/gdb/dwarf2/cooked-index-shard.c
> +++ b/gdb/dwarf2/cooked-index-shard.c
> @@ -86,7 +86,16 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag,
>       implicit "main" discovery.  */
>    if ((flags & IS_MAIN) != 0)
>      m_main = result;
> -  else if ((flags & IS_PARENT_DEFERRED) == 0
> +  /* The language check here is subtle: it exists solely to work
> +     around a bug in .gdb_index.  That index does not record
> +     languages, but it might emit an entry for "main".  However,
> +     recognizing this "main" as being the main program would be wrong
> +     -- for example, an Ada program has a C "main" but this is not the
> +     desired target of the "start" command.  Requiring the language to
> +     be set here avoids over-eagerly setting the "main" when using
> +     .gdb_index.  Should .gdb_index ever be removed (PR symtab/31363),
> +     the language_unknown check here could also be removed.  */
> +  else if (lang != language_unknown

Did you remove the IS_PARENT_DEFERRED check on purpose?

> @@ -203,10 +209,10 @@ enum class cooked_state
>  /* An object of this type controls the scanning of the DWARF.  It
>     schedules the worker tasks and tracks the current state.  Once
>     scanning is done, this object is discarded.
> -
> +   

Trailing spaces ^.

> +/* This is like a cooked index, but as it has been ingested from
> +   .gdb_index, it can't be used to write out an index.  */
> +
> +class cooked_gdb_index : public cooked_index

Technically, I think it should be "This is a cooked index as ingested
from .gdb_index".  You know, the "is-a" relationship.  Currently, the
base class is the "from .debug_info" case and we have some derived
classes for the indexes.  I feel like we should (eventually) move to
having an abstract base class and add a derived class for the "from
.debug_info" case.

> +	  /* Note that this assumes the final component ends in \0.  */
> +	  cooked_index_entry *entry = result.add (per_cu->sect_off, tag,
> +						  flags, this_lang,
> +						  components.back ().data (),
> +						  nullptr, per_cu);
> +	  /* Don't bother pushing if we do not need a panrent.  */

panrent -> parent

Simon

  reply	other threads:[~2025-04-23 17:23 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02 23:44 [PATCH v2 00/28] Search symbols via quick API Tom Tromey
2025-04-02 23:45 ` [PATCH v2 01/28] Add another minor hack to cooked_index_entry::full_name Tom Tromey
2025-04-02 23:45 ` [PATCH v2 02/28] Change ada_decode to preserve upper-case in some situations Tom Tromey
2025-04-02 23:45 ` [PATCH v2 03/28] Emit some type declarations in .gdb_index Tom Tromey
2025-04-21  2:50   ` Simon Marchi
2025-04-21 14:50     ` Tom Tromey
2025-04-23  4:11       ` Simon Marchi
2025-04-23 20:54         ` Tom Tromey
2025-04-02 23:45 ` [PATCH v2 04/28] Ada import functions not in index Tom Tromey
2025-04-02 23:45 ` [PATCH v2 05/28] Fix index's handling of DW_TAG_imported_declaration Tom Tromey
2025-04-02 23:45 ` [PATCH v2 06/28] Put all CTF symbols in global scope Tom Tromey
2025-04-02 23:45 ` [PATCH v2 07/28] Restore "ingestion" of .debug_str when writing .debug_names Tom Tromey
2025-04-02 23:45 ` [PATCH v2 08/28] Entries from anon-struct.exp not in cooked index Tom Tromey
2025-04-02 23:45 ` [PATCH v2 09/28] Remove dwarf2_per_cu_data::mark Tom Tromey
2025-04-21  3:09   ` Simon Marchi
2025-04-21 15:38     ` Tom Tromey
2025-04-23  4:12       ` Simon Marchi
2025-04-02 23:45 ` [PATCH v2 10/28] Have expand_symtabs_matching work for already-expanded CUs Tom Tromey
2025-04-23 15:53   ` Simon Marchi
2025-04-23 20:39     ` Tom Tromey
2025-04-23 20:57       ` Tom Tromey
2025-04-02 23:45 ` [PATCH v2 11/28] Rewrite the .gdb_index reader Tom Tromey
2025-04-23 17:22   ` Simon Marchi [this message]
2025-04-23 20:50     ` Tom Tromey
2025-04-24 14:37   ` Pedro Alves
2025-04-02 23:45 ` [PATCH v2 12/28] Convert default_collect_symbol_completion_matches_break_on Tom Tromey
2025-04-02 23:45 ` [PATCH v2 13/28] Convert gdbpy_lookup_static_symbols Tom Tromey
2025-04-02 23:45 ` [PATCH v2 14/28] Convert ada_add_global_exceptions Tom Tromey
2025-04-02 23:45 ` [PATCH v2 15/28] Convert ada_language_defn::collect_symbol_completion_matches Tom Tromey
2025-04-02 23:45 ` [PATCH v2 16/28] Convert ada-lang.c:map_matching_symbols Tom Tromey
2025-04-02 23:45 ` [PATCH v2 17/28] Remove expand_symtabs_matching Tom Tromey
2025-04-02 23:45 ` [PATCH v2 18/28] Simplify basic_lookup_transparent_type Tom Tromey
2025-04-02 23:45 ` [PATCH v2 19/28] Remove objfile::expand_symtabs_for_function Tom Tromey
2025-04-02 23:45 ` [PATCH v2 20/28] Convert linespec.c:iterate_over_all_matching_symtabs Tom Tromey
2025-04-02 23:45 ` [PATCH v2 21/28] Simplify block_lookup_symbol_primary Tom Tromey
2025-04-02 23:45 ` [PATCH v2 22/28] Pass lookup_name_info to block_lookup_symbol_primary Tom Tromey
2025-04-02 23:45 ` [PATCH v2 23/28] Simplify block_lookup_symbol Tom Tromey
2025-04-02 23:45 ` [PATCH v2 24/28] Add best_symbol_tracker Tom Tromey
2025-04-02 23:45 ` [PATCH v2 25/28] Convert lookup_symbol_via_quick_fns Tom Tromey
2025-04-02 23:45 ` [PATCH v2 26/28] Convert lookup_symbol_in_objfile Tom Tromey
2025-04-02 23:45 ` [PATCH v2 27/28] Make dw_expand_symtabs_matching_file_matcher static Tom Tromey
2025-04-23 20:00   ` Simon Marchi
2025-04-23 20:09     ` Tom Tromey
2025-04-23 20:44       ` Tom Tromey
2025-04-02 23:45 ` [PATCH v2 28/28] Remove enter_symbol_lookup Tom Tromey
2025-04-23 20:09 ` [PATCH v2 00/28] Search symbols via quick API Simon Marchi
2025-04-24 21:09   ` Tom Tromey
2025-04-28 14:07 ` Guinevere Larsen
2025-04-28 22:06   ` Tom Tromey
2025-04-29 19:31     ` Guinevere Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6785bbf8-4a37-454a-abcb-747f27b8e153@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox