[PATCHv10,1/5] gdb: more 'const' in the multi-so-lib progspace code

Message ID d4d92f4d46ef96803006908849733143248e734a.1793268860.git.aburgess@redhat.com
State New
Headers
Series gdb: allow 'until' to work in outermost frame |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply

Commit Message

Andrew Burgess Oct. 29, 2026, 10:20 a.m. UTC
  This is a small tweak to some of the code added in commit:

  commit 822c4cd732ce0b6a76f5b4c3317f6aaa5dca09c6
  Date:   Fri Aug 7 09:52:28 2026 -0400

      gdb: multiple solib_ops per program space

that makes some of the new methods more 'const'.  There are two
methods that I change here program_space::solib_ops and
program_space::find_solib_ops.

A later commit in this series needs to call the solib_ops method from
a const member function.  I initially added a solib_ops overload that
was const, but then I realised none of the existing users actually
need the method to be non-const, so I figure lets just make the
existing method const, and we can add a non-const overload later, when
there's an actual need.

For find_solib_ops this was me just looking at the 822c4cd732ce0b6a
commit again and spotting that this method could also be const.  This
change isn't needed by any of my follow on commits, so this part could
be dropped if there's push back.

There should be no user visible changes after this commit.
---
 gdb/progspace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Simon Marchi Oct. 30, 2026, 3:28 p.m. UTC | #1
On 10/29/26 6:20 AM, Andrew Burgess wrote:
> This is a small tweak to some of the code added in commit:
> 
>   commit 822c4cd732ce0b6a76f5b4c3317f6aaa5dca09c6
>   Date:   Fri Aug 7 09:52:28 2026 -0400
> 
>       gdb: multiple solib_ops per program space
> 
> that makes some of the new methods more 'const'.  There are two
> methods that I change here program_space::solib_ops and
> program_space::find_solib_ops.
> 
> A later commit in this series needs to call the solib_ops method from
> a const member function.  I initially added a solib_ops overload that
> was const, but then I realised none of the existing users actually
> need the method to be non-const, so I figure lets just make the
> existing method const, and we can add a non-const overload later, when
> there's an actual need.
> 
> For find_solib_ops this was me just looking at the 822c4cd732ce0b6a
> commit again and spotting that this method could also be const.  This
> change isn't needed by any of my follow on commits, so this part could
> be dropped if there's push back.
> 
> There should be no user visible changes after this commit.

LGTM, I think this can be pushed right away regardless of the state of
the rest of the series.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  

Patch

diff --git a/gdb/progspace.h b/gdb/progspace.h
index a5ef3deb337..513f5c157b6 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -271,14 +271,14 @@  struct program_space
   void remove_solib_ops (const solib_ops &ops);
 
   /* Return a view of the solib providers for this program space.  */
-  std::vector<solib_ops_up> &solib_ops ()
+  const std::vector<solib_ops_up> &solib_ops () const
   { return m_solib_ops; }
 
   /* Find an solib_ops instance of type SOLIB_OPS_TYPE.
 
      Return nullptr if not found.  */
   template <typename solib_ops_type>
-  solib_ops_type *find_solib_ops ()
+  const solib_ops_type *find_solib_ops () const
   {
     for (auto &ops : this->solib_ops ())
       if (auto ret = dynamic_cast<solib_ops_type *> (ops.get ());