Re: [PATCH] gdb: replace msym_bunch with deque

Tom Tromey
2025-12-17T16:01:51Z

>>>>> "Simon" == simon marchi <simon.marchi@polymtl.ca> writes:

Simon> An std::deque implementation typically uses a sequence of fixed-sized
Simon> arrays, much like our current msym_bunch implementation. So adding an
Simon> item at the end will not invalidate existing references. But unlike our
Simon> msym_bunch, we don't have to worry about memory management.

FWIW we have another instance of this idiom in buildsym.

Simon> I am a bit puzzled about this code in
Simon> minimal_symbol_reader::record_full:

Simon> I am not sure when minsyms_read would already be true when reading
Simon> minimal symbols, and if we should do anything differently here.

It's been a long time since I worked on this, but IIRC there were
readers where minimal symbol reading was mixed with partial symbol reading.
In these cases we could reuse the already-read minimal symbols but not
the partial symbols. This code, and the check in
minimal_symbol_reader::install, were there to allow the reuse without
creating new symbols.

The particular check you highlighted is just based on the idea that the
code is still trying to create a minimal symbol, but since it won't ever
be installed, there's no point to allocating more memory, we can just
reuse the same one over and over.

It's possible all this is obsolete given the stabs removal. You'd have
to investigate. But anyway all of this was a hack to avoid doing work
on these ancient / obsolete readers.

Simon> + /* The minimal symbols recorded so far. This uses a deque instead of e.g. a
Simon> + vector, because references to minimal symbols need to stay valid across
Simon> + calls to recod_full. */

Typo, "record_full"

Tom