Internals of -readnow implementation
Jan Vrany
jan@vrany.io
Tue Nov 11 21:44:34 GMT 2025
On Tue, 2025-11-11 at 14:18 -0700, Tom Tromey wrote:
> Jan> looking at how -readnow is implemented, I'm puzzled
> Jan> why implementation of readnow_functions inherits/user
> Jan> dwarf2_base_index_functions?
>
> It's mostly a convenience, because that class implements some methods.
I see, thanks.
>
> Jan> My understanding is that if -readnow is specified, then
> Jan> all compunit symbtabs in that objfile are fully read.
> Jan> It seems to me that in theory one can implement it "directly"
> Jan> by traversing compunit symtabs, its blockvector and symbols
> Jan> (rather than using dwarf2_per_objfile and alike).
>
> Jan> Is that because it was just easier to implement it this way
> Jan> or is there a reason why it has to go through DWARF reader
> Jan> structures?
>
> There's no deep reason.
>
> For this bug:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=33554
>
> ... I am planning to reimplement it as you say: just search things
> directly without regard to the DWARF data structures.
Yes! I encountered the same issue when working on Python JIT API
and came to the same realization.
In fact, I already started working on it and got relatively far
in replacing current implementation of readnow_functions but still
have loose ends especially in ::search method. It seems to me that the
implementations not always match its comment.
Jan
>
> -readnow is weird because it's mostly there as a debugging aid, and
> sometimes a workaround for other bugs. While I have recommended it to
> users, I don't really like doing so. Occasionally I think about
> removing it.
>
> Tom
More information about the Gdb
mailing list