Re: [PATCH v3 08/10] gdb: add objfile -> solib backlink
Simon Marchi <[email protected]> Tue, 4 Aug 2026 11:47:16 -0400
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
On 7/21/26 1:31 PM, Tom Tromey wrote: >>>>>> "Simon" == simon marchi <[email protected]> writes: > > Simon> + /* Return the list of struct solib associated to this objfile. */ > Simon> + std::vector<solib *> &solibs () { return m_solibs; } > > It's kind of bad to expose this as a non-const vector, since it means > that unscrupulous code can just modify it. I could change it to `const std::vector<solib *> &` or `gdb::array_view<solib *>`. The latter sounds better, since callers don't need to know they are stored in a vector (we could also return an even more generic "range" type, but I guess that would require more boilerplate (unless we already have a class to accomplish this easily that I forgot about?). > Simon> + if (const auto &solibs = objfile->solibs (); > Simon> + !solibs.empty ()) > Simon> + return solibs.front (); > > I wonder if instead you would consider exposing something like this as a > method on objfile. Like a "first_solib ()" method? I certainly can do that. Simon