Re: [PATCH RFC 1/2] Remove "readnow" support

Jan Vrany
2026-02-12T21:33:24Z

On Thu, 2026-02-12 at 19:39 +0000, Simon Marchi wrote:
> https://inbox.sourceware.org/gdb-patches/945d83fc-5518-4e04-8fe8-ebcca0acf0bd@simark.ca/
>
> On 2/12/26 8:29 AM, Andrew Burgess wrote:
> > Eli Zaretskii <eliz@gnu.org> writes:
> >
> > > > From: Tom Tromey <tom@tromey.com>
> > > > Date: Wed, 11 Feb 2026 11:49:09 -0700
> > > > Cc: Tom Tromey <tom@tromey.com>
> > > >
> > > > I think the "readnow" feature should be removed.
> > > >
> > > > "readnow" exists basically to work around potential bugs in any
> > > > "partial" reader.  This used to work ok because gdb would scan all the
> > > > expanded symtabs in addition to using the "quick" functions.  This
> > > > changed with the "search via psyms" series.
> > > >
> > > > So now, "readnow" is basically its own separate implementation.  As
> > > > such, I don't think it carries its weight.  It is very slow and uses a
> > > > lot of memory, and can have its own bugs requiring extra work on our
> > > > part.
> > >
> > > Is there any other way for the user to force GDB to read all of the
> > > symbols from all of the object files?  If not, perhaps this
> > > functionality still has its value?  Maybe we should make it a "maint"
> > > command instead?
> >
> > I second this.  We do run into bugs with the indexes from time to time,
> > and it's good to have some way to tell GDB to go read the full debug
> > information so we can narrow the bug down.  Plus it offers a work around
> > in these cases.
> >
> > Is 'maint expand-symtabs' the equivalent?  When someone uses -readnow
> > should we maybe guide them towards the new way of doing things, even all
> > we do is point towards a particular entry in the manual maybe?
>
> From what I understand, "maint expand-symtabs" is not an exact
> replacement for readnow.  With the recent changes that Tom Tromey did
> (always search via the "quick" functions), this is how it works when
> searching for a symbol:
>
>  - the code invokes the quick_symbol_functions::search method
>    (cooked_index_functions::search for the DWARF index).
>  - if a compunit_symtab looks like it could contain said symbol, the
>    quick functions' search method calls a callback, passing the
>    compunit_symtab, and the core searches it
>  - if you "maint expand-symtabs" first, the search still goes through
>    cooked_index_functions::search.  So if there is a bug in
>    cooked_index_functions::search, it won't bypass it.  In other words,
>    which symtabs are currently expanded should not affect a search (this
>    was the point of the change, that was a source of bugs)
>
> With readnow, the cooked index is not built.  Instead, compunit_symtab
> are built from the start,

I'm not sure this is exactly how it works. My undestanding is that with -readnow,
index is not build, but all_units is build. compunit_symtabs are built later on
and lazily in dw2_instantiate_symtab. In another words, with -readnow all the work
is done except creation of compunit_symtabs.
See patch https://inbox.sourceware.org/gdb-patches/20251124195535.2116845-9-jan.vrany@labware.com/

> and readnow_functions is used instead of
> cooked_index_functions.  readnow_functions::search goes over the
> all_units vector and searches all of them (I wonder if it could use
> expanded_symbols_functions instead...).

It could - this is what I originally did in v1 and v2 of what then became
expanded_symbol_functions (https://inbox.sourceware.org/gdb-patches/20251124195535.2116845-1-jan.vrany@labware.com/)

Jan

> If there was a bug in
> cooked_index_functions::search, then this would by pass it.
>
> I don't know if it's really worth having a completely parallel code path
> just in case there is a bug in the main path.  That parallel code path
> is a source of headaches of its own.  That being said, if we could indeed
> use expanded_symbols_functions, then keeping readnow wouldn't represent
> much code I think.

> Simon