[PATCH v4 04/10] gdb: de-constify some methods of solib_ops

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
From: Simon Marchi <[email protected]>

The following commit moves the ROCm solib data from a registry to the
rocm_solib_ops object itself.  This requires making some methods
non-const, and it then cascades to a bunch of things.  This will have to
be done one day or another, when (I suspect) we'll move more solib_ops
data out of registries and into the solib_ops objects themselves.  Do it
in this separate patch to avoid polluting that patch.

No behavior change expected.

Change-Id: Icb5e921a82e235817f8817a3aa3c20b2c9dc959f
Approved-by: Lancelot Six <[email protected]>
---
 gdb/progspace.h    |  2 +-
 gdb/solib-aix.c    | 12 ++++++------
 gdb/solib-darwin.c | 12 ++++++------
 gdb/solib-dsbt.c   |  8 ++++----
 gdb/solib-frv.c    |  8 ++++----
 gdb/solib-rocm.c   | 20 ++++++++++----------
 gdb/solib-svr4.c   | 14 +++++++-------
 gdb/solib-svr4.h   | 14 +++++++-------
 gdb/solib-target.c |  2 +-
 gdb/solib-target.h |  2 +-
 gdb/solib.c        | 10 +++++-----
 gdb/solib.h        | 14 +++++++-------
 gdb/windows-tdep.c |  4 ++--
 13 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/gdb/progspace.h b/gdb/progspace.h
index e9261ff8590d..21977747cb94 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -260,7 +260,7 @@ struct program_space
   { return std::move (m_solib_ops); }
 
   /* Get this program space's solib provider.  */
-  const struct solib_ops *solib_ops () const
+  struct solib_ops *solib_ops () const
   { return m_solib_ops.get (); }
 
   /* Return the list of all the solibs in this program space.  */
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 705760651217..28f69ed9cbb4 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -32,9 +32,9 @@ struct aix_solib_ops : public solib_ops
   using solib_ops::solib_ops;
 
   void relocate_section_addresses (solib &so, target_section *) const override;
-  void create_inferior_hook (int from_tty) const override;
-  owning_intrusive_list<solib> current_sos () const override;
-  gdb_bfd_ref_ptr bfd_open (const char *pathname) const override;
+  void create_inferior_hook (int from_tty) override;
+  owning_intrusive_list<solib> current_sos () override;
+  gdb_bfd_ref_ptr bfd_open (const char *pathname) override;
 };
 
 /* See solib-aix.h.  */
@@ -425,7 +425,7 @@ solib_aix_get_section_offsets (struct objfile *objfile,
 }
 
 void
-aix_solib_ops::create_inferior_hook (int from_tty) const
+aix_solib_ops::create_inferior_hook (int from_tty)
 {
   const char *warning_msg = "unable to relocate main executable";
 
@@ -454,7 +454,7 @@ aix_solib_ops::create_inferior_hook (int from_tty) const
 }
 
 owning_intrusive_list<solib>
-aix_solib_ops::current_sos () const
+aix_solib_ops::current_sos ()
 {
   std::optional<std::vector<lm_info_aix>> &library_list
     = solib_aix_get_library_list (current_inferior (), NULL);
@@ -498,7 +498,7 @@ aix_solib_ops::current_sos () const
 }
 
 gdb_bfd_ref_ptr
-aix_solib_ops::bfd_open (const char *pathname) const
+aix_solib_ops::bfd_open (const char *pathname)
 {
   /* The pathname is actually a synthetic filename with the following
      form: "/path/to/sharedlib(member.o)" (double-quotes excluded).
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 6e2535ca427f..07cd88d0e0c6 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -42,9 +42,9 @@ struct darwin_solib_ops : public solib_ops
 
   void relocate_section_addresses (solib &so, target_section *) const override;
   void clear_solib (program_space *pspace) const override;
-  void create_inferior_hook (int from_tty) const override;
-  owning_intrusive_list<solib> current_sos () const override;
-  gdb_bfd_ref_ptr bfd_open (const char *pathname) const override;
+  void create_inferior_hook (int from_tty) override;
+  owning_intrusive_list<solib> current_sos () override;
+  gdb_bfd_ref_ptr bfd_open (const char *pathname) override;
 };
 
 /* See solib-darwin.h.  */
@@ -211,7 +211,7 @@ find_program_interpreter (void)
 }
 
 owning_intrusive_list<solib>
-darwin_solib_ops::current_sos () const
+darwin_solib_ops::current_sos ()
 {
   type *ptr_type
     = builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
@@ -471,7 +471,7 @@ darwin_solib_read_all_image_info_addr (struct darwin_info *info)
 }
 
 void
-darwin_solib_ops::create_inferior_hook (int from_tty) const
+darwin_solib_ops::create_inferior_hook (int from_tty)
 {
   /* Everything below only makes sense if we have a running inferior.  */
   if (!target_has_execution ())
@@ -606,7 +606,7 @@ darwin_solib_ops::relocate_section_addresses (solib &so,
 }
 
 gdb_bfd_ref_ptr
-darwin_solib_ops::bfd_open (const char *pathname) const
+darwin_solib_ops::bfd_open (const char *pathname)
 {
   int found_file;
 
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index d3a0cca5cb78..76fadfc9b692 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -128,8 +128,8 @@ struct dsbt_solib_ops : public solib_ops
 
   void relocate_section_addresses (solib &so, target_section *) const override;
   void clear_solib (program_space *pspace) const override;
-  void create_inferior_hook (int from_tty) const override;
-  owning_intrusive_list<solib> current_sos () const override;
+  void create_inferior_hook (int from_tty) override;
+  owning_intrusive_list<solib> current_sos () override;
   bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
 };
 
@@ -526,7 +526,7 @@ lm_base (void)
    we provide values for.  */
 
 owning_intrusive_list<solib>
-dsbt_solib_ops::current_sos () const
+dsbt_solib_ops::current_sos ()
 {
   bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
   CORE_ADDR lm_addr;
@@ -860,7 +860,7 @@ dsbt_relocate_main_executable (void)
    The shared library breakpoints also need to be enabled.  */
 
 void
-dsbt_solib_ops::create_inferior_hook (int from_tty) const
+dsbt_solib_ops::create_inferior_hook (int from_tty)
 {
   /* Relocate main executable.  */
   dsbt_relocate_main_executable ();
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 08ee0a9578fc..de2791d7262a 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -36,8 +36,8 @@ struct frv_solib_ops : public solib_ops
 
   void relocate_section_addresses (solib &so, target_section *) const override;
   void clear_solib (program_space *pspace) const override;
-  void create_inferior_hook (int from_tty) const override;
-  owning_intrusive_list<solib> current_sos () const override;
+  void create_inferior_hook (int from_tty) override;
+  owning_intrusive_list<solib> current_sos () override;
   bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
 };
 
@@ -321,7 +321,7 @@ lm_base (void)
 }
 
 owning_intrusive_list<solib>
-frv_solib_ops::current_sos () const
+frv_solib_ops::current_sos ()
 {
   bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
   CORE_ADDR lm_addr, mgot;
@@ -789,7 +789,7 @@ frv_relocate_main_executable (void)
    enabled.  */
 
 void
-frv_solib_ops::create_inferior_hook (int from_tty) const
+frv_solib_ops::create_inferior_hook (int from_tty)
 {
   /* Relocate main executable.  */
   frv_relocate_main_executable ();
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index a54e3a5a400b..9f2fc915b12b 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -215,11 +215,11 @@ struct rocm_solib_ops : public solib_ops
   { return std::move (m_host_ops); }
 
   /* The methods implemented by rocm_solib_ops.  */
-  owning_intrusive_list<solib> current_sos () const override;
-  void create_inferior_hook (int from_tty) const override;
-  gdb_bfd_ref_ptr bfd_open (const char *pathname) const override;
+  owning_intrusive_list<solib> current_sos () override;
+  void create_inferior_hook (int from_tty) override;
+  gdb_bfd_ref_ptr bfd_open (const char *pathname) override;
   void relocate_section_addresses (solib &so, target_section *) const override;
-  void handle_event () const override;
+  void handle_event () override;
 
   /* Implement the following methods just to forward the calls to the host
      solib_ops.  We currently need to implement all the methods that
@@ -270,7 +270,7 @@ struct rocm_solib_ops : public solib_ops
 
 private:
   owning_intrusive_list<solib>
-  solibs_from_rocm_sos (const std::vector<rocm_so> &sos) const;
+  solibs_from_rocm_sos (const std::vector<rocm_so> &sos);
 
   solib_ops_up m_host_ops;
 };
@@ -303,7 +303,7 @@ rocm_solib_ops::relocate_section_addresses (solib &so,
 static void rocm_update_solib_list ();
 
 void
-rocm_solib_ops::handle_event () const
+rocm_solib_ops::handle_event ()
 {
   /* Since we sit on top of a host solib_ops, we might get called following an
      event concerning host libraries.  We must therefore forward the call.  If
@@ -319,7 +319,7 @@ rocm_solib_ops::handle_event () const
 /* Create solib objects from rocm_so objects in SOS.  */
 
 owning_intrusive_list<solib>
-rocm_solib_ops::solibs_from_rocm_sos (const std::vector<rocm_so> &sos) const
+rocm_solib_ops::solibs_from_rocm_sos (const std::vector<rocm_so> &sos)
 {
   owning_intrusive_list<solib> dst;
 
@@ -334,7 +334,7 @@ rocm_solib_ops::solibs_from_rocm_sos (const std::vector<rocm_so> &sos) const
    objects currently loaded in the inferior.  */
 
 owning_intrusive_list<solib>
-rocm_solib_ops::current_sos () const
+rocm_solib_ops::current_sos ()
 {
   /* First, retrieve the host-side shared library list.  */
   owning_intrusive_list<solib> sos = m_host_ops->current_sos ();
@@ -692,7 +692,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 }
 
 gdb_bfd_ref_ptr
-rocm_solib_ops::bfd_open (const char *pathname) const
+rocm_solib_ops::bfd_open (const char *pathname)
 {
   /* Handle regular files with SVR4 open.  */
   if (strstr (pathname, "://") == nullptr)
@@ -780,7 +780,7 @@ rocm_solib_ops::bfd_open (const char *pathname) const
 }
 
 void
-rocm_solib_ops::create_inferior_hook (int from_tty) const
+rocm_solib_ops::create_inferior_hook (int from_tty)
 {
   get_solib_info (current_inferior ())->solib_list.clear ();
 
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 8e3de4d3ea1a..35c81000b10a 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1059,7 +1059,7 @@ svr4_solib_ops::clear_so (const solib &so) const
 /* Create the solib objects equivalent to the svr4_sos in SOS.  */
 
 owning_intrusive_list<solib>
-svr4_solib_ops::solibs_from_svr4_sos (const std::vector<svr4_so> &sos) const
+svr4_solib_ops::solibs_from_svr4_sos (const std::vector<svr4_so> &sos)
 {
   owning_intrusive_list<solib> dst;
 
@@ -1253,7 +1253,7 @@ svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list,
    linker, build a fallback list from other sources.  */
 
 owning_intrusive_list<solib>
-svr4_solib_ops::default_sos (svr4_info *info) const
+svr4_solib_ops::default_sos (svr4_info *info)
 {
   if (!info->debug_loader_offset_p)
     return {};
@@ -1452,7 +1452,7 @@ svr4_solib_ops::current_sos_direct (svr4_info *info) const
 /* Collect sos read and stored by the probes interface.  */
 
 owning_intrusive_list<solib>
-svr4_solib_ops::collect_probes_sos (svr4_info *info) const
+svr4_solib_ops::collect_probes_sos (svr4_info *info)
 {
   owning_intrusive_list<solib> res;
 
@@ -1469,7 +1469,7 @@ svr4_solib_ops::collect_probes_sos (svr4_info *info) const
    method.  */
 
 owning_intrusive_list<solib>
-svr4_solib_ops::current_sos_1 (svr4_info *info) const
+svr4_solib_ops::current_sos_1 (svr4_info *info)
 {
   owning_intrusive_list<solib> sos;
 
@@ -1496,7 +1496,7 @@ svr4_solib_ops::current_sos_1 (svr4_info *info) const
 /* Implement the "current_sos" solib_ops method.  */
 
 owning_intrusive_list<solib>
-svr4_solib_ops::current_sos () const
+svr4_solib_ops::current_sos ()
 {
   svr4_info *info = get_svr4_info (current_program_space);
 
@@ -2143,7 +2143,7 @@ svr4_solib_ops::disable_probes_interface (svr4_info *info) const
    standard interface.  */
 
 void
-svr4_solib_ops::handle_event () const
+svr4_solib_ops::handle_event ()
 {
   struct svr4_info *info = get_svr4_info (current_program_space);
   struct probe_and_action *pa;
@@ -3318,7 +3318,7 @@ svr4_relocate_main_executable (void)
    their symbols to be read at a later time.  */
 
 void
-svr4_solib_ops::create_inferior_hook (int from_tty) const
+svr4_solib_ops::create_inferior_hook (int from_tty)
 {
   struct svr4_info *info;
 
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 3078a092778c..d7f58a76224d 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -99,14 +99,14 @@ struct svr4_solib_ops : public solib_ops
   void relocate_section_addresses (solib &so, target_section *) const override;
   void clear_so (const solib &so) const override;
   void clear_solib (program_space *pspace) const override;
-  void create_inferior_hook (int from_tty) const override;
-  owning_intrusive_list<solib> current_sos () const override;
+  void create_inferior_hook (int from_tty) override;
+  owning_intrusive_list<solib> current_sos () override;
   bool open_symbol_file_object (int from_tty) const override;
   bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
   bool same (const solib &gdb, const solib &inferior) const override;
   bool keep_data_in_core (CORE_ADDR vaddr, unsigned long size) const override;
   void update_breakpoints () const override;
-  void handle_event () const override;
+  void handle_event () override;
   std::optional<CORE_ADDR> find_solib_addr (solib &so) const override;
   bool supports_namespaces () const override { return true; }
   int find_solib_ns (const solib &so) const override;
@@ -135,7 +135,7 @@ struct svr4_solib_ops : public solib_ops
   void free_probes_table (svr4_info *info) const;
   CORE_ADDR find_r_brk (svr4_info *info) const;
   CORE_ADDR find_r_ldsomap (svr4_info *info) const;
-  owning_intrusive_list<solib> default_sos (svr4_info *info) const;
+  owning_intrusive_list<solib> default_sos (svr4_info *info);
   int read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
 		    CORE_ADDR debug_base, std::vector<svr4_so> &sos,
 		    int ignore_first) const;
@@ -144,10 +144,10 @@ struct svr4_solib_ops : public solib_ops
   CORE_ADDR lm_addr_check (const solib &so, bfd *abfd) const;
   CORE_ADDR read_r_next (CORE_ADDR debug_base) const;
   CORE_ADDR read_r_map (CORE_ADDR debug_base) const;
-  owning_intrusive_list<solib> collect_probes_sos (svr4_info *info) const;
-  owning_intrusive_list<solib> current_sos_1 (svr4_info *info) const;
+  owning_intrusive_list<solib> collect_probes_sos (svr4_info *info);
+  owning_intrusive_list<solib> current_sos_1 (svr4_info *info);
   owning_intrusive_list<solib> solibs_from_svr4_sos
-    (const std::vector<svr4_so> &sos) const;
+    (const std::vector<svr4_so> &sos);
   void disable_probes_interface (svr4_info *info) const;
   void update_full (svr4_info *info) const;
   int update_incremental (svr4_info *info, CORE_ADDR debug_base,
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index ac965df20e94..0df8c6048aef 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -232,7 +232,7 @@ solib_target_parse_libraries (const char *library)
 #endif
 
 owning_intrusive_list<solib>
-target_solib_ops::current_sos () const
+target_solib_ops::current_sos ()
 {
   owning_intrusive_list<solib> sos;
 
diff --git a/gdb/solib-target.h b/gdb/solib-target.h
index 0d2f0840aa63..abfa0b513742 100644
--- a/gdb/solib-target.h
+++ b/gdb/solib-target.h
@@ -29,7 +29,7 @@ struct target_solib_ops : solib_ops
   using solib_ops::solib_ops;
 
   void relocate_section_addresses (solib &so, target_section *) const override;
-  owning_intrusive_list<solib> current_sos () const override;
+  owning_intrusive_list<solib> current_sos () override;
   bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
 };
 
diff --git a/gdb/solib.c b/gdb/solib.c
index 869b769d0439..561a1448cfe6 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -439,7 +439,7 @@ solib_bfd_open (const char *pathname)
 }
 
 gdb_bfd_ref_ptr
-solib_ops::bfd_open (const char *pathname) const
+solib_ops::bfd_open (const char *pathname)
 {
   return solib_bfd_open (pathname);
 }
@@ -572,7 +572,7 @@ solib_map_sections (solib &so)
 /* See solib.h.  */
 
 solib::solib (lm_info_up lm_info, std::string original_name_,
-	      std::string name_, const solib_ops &ops)
+	      std::string name_, solib_ops &ops)
   : lm_info (std::move (lm_info)),
     original_name (std::move (original_name_)),
     name (std::move (name_)),
@@ -706,7 +706,7 @@ notify_solib_unloaded (program_space *pspace, const solib &so,
 void
 update_solib_list (int from_tty)
 {
-  const solib_ops *ops = current_program_space->solib_ops ();
+  solib_ops *ops = current_program_space->solib_ops ();
 
   if (ops == nullptr)
     return;
@@ -1306,7 +1306,7 @@ clear_solib (program_space *pspace)
 void
 solib_create_inferior_hook (int from_tty)
 {
-  if (const solib_ops *ops = current_program_space->solib_ops ();
+  if (solib_ops *ops = current_program_space->solib_ops ();
       ops != nullptr)
     ops->create_inferior_hook (from_tty);
 }
@@ -1371,7 +1371,7 @@ update_solib_breakpoints (void)
 void
 handle_solib_event (void)
 {
-  if (const solib_ops *ops = current_program_space->solib_ops ();
+  if (solib_ops *ops = current_program_space->solib_ops ();
       ops != nullptr)
     ops->handle_event ();
 
diff --git a/gdb/solib.h b/gdb/solib.h
index 662d467b0cca..b2523906596a 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -62,10 +62,10 @@ struct solib : intrusive_list_node<solib>
 
      OPS is the solib_ops implementation providing this solib.  */
   explicit solib (lm_info_up lm_info, std::string original_name,
-		  std::string name, const solib_ops &ops);
+		  std::string name, solib_ops &ops);
 
   /* Return the solib_ops implementation providing this solib.  */
-  const solib_ops &ops () const
+  solib_ops &ops () const
   { return *m_ops; }
 
   /* Free symbol-file related contents of SO and reset for possible reloading
@@ -126,7 +126,7 @@ struct solib : intrusive_list_node<solib>
 
 private:
   /* The solib_ops responsible for this solib.  */
-  const solib_ops *m_ops;
+  solib_ops *m_ops;
 };
 
 /* A unique pointer to an solib.  */
@@ -168,7 +168,7 @@ struct solib_ops
   /* Target dependent code to run after child process fork.
 
      Defaults to no-op.  */
-  virtual void create_inferior_hook (int from_tty) const {};
+  virtual void create_inferior_hook (int from_tty) {};
 
   /* Construct a list of the currently loaded shared objects.  This
      list does not include an entry for the main executable file.
@@ -177,7 +177,7 @@ struct solib_ops
      inferior --- we don't examine any of the shared library files
      themselves.  The declaration of `struct solib' says which fields
      we provide values for.  */
-  virtual owning_intrusive_list<solib> current_sos () const = 0;
+  virtual owning_intrusive_list<solib> current_sos () = 0;
 
   /* Find, open, and read the symbols for the main executable.  If
      FROM_TTY is non-zero, allow messages to be printed.
@@ -193,7 +193,7 @@ struct solib_ops
   { return false; };
 
   /* Find and open shared library binary file.  */
-  virtual gdb_bfd_ref_ptr bfd_open (const char *pathname) const;
+  virtual gdb_bfd_ref_ptr bfd_open (const char *pathname);
 
   /* Given two solib objects, GDB from the GDB thread list and INFERIOR from the
      list returned by current_sos, return true if they represent the same library.
@@ -221,7 +221,7 @@ struct solib_ops
      solib_add is called.
 
      Defaults to no-op.  */
-  virtual void handle_event () const {};
+  virtual void handle_event () {};
 
   /* Return an address within the inferior's address space which is known
      to be part of SO.  If there is no such address, or GDB doesn't know
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index c0a743914b1c..36ab10e0abf8 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -826,7 +826,7 @@ struct windows_solib_ops : target_solib_ops
 {
   using target_solib_ops::target_solib_ops;
 
-  void create_inferior_hook (int from_tty) const override;
+  void create_inferior_hook (int from_tty) override;
   void iterate_over_objfiles_in_search_order
     (iterate_over_objfiles_in_search_order_cb_ftype cb,
      objfile *current_objfile) const override;
@@ -843,7 +843,7 @@ make_windows_solib_ops (program_space *pspace)
 /* Implement the "solib_create_inferior_hook" solib_ops method.  */
 
 void
-windows_solib_ops::create_inferior_hook (int from_tty) const
+windows_solib_ops::create_inferior_hook (int from_tty)
 {
   CORE_ADDR exec_base = 0;
 
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.