]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/solib: save program space in solib_ops
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 21 Jul 2025 15:38:30 +0000 (11:38 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 22 Aug 2025 14:45:47 +0000 (10:45 -0400)
In some subsequent patches, solib_ops methods will need to access the
program space they were created for.  We currently access the program
space using "current_program_space", but it would better to remember the
program space at construction time instead.

Change-Id: Icf2809435a23c47ddeeb75e603863b201eff2e58
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
26 files changed:
gdb/gdbarch-gen.c
gdb/gdbarch-gen.h
gdb/gdbarch_components.py
gdb/infcmd.c
gdb/infrun.c
gdb/mips-fbsd-tdep.c
gdb/mips-linux-tdep.c
gdb/mips-netbsd-tdep.c
gdb/ppc-linux-tdep.c
gdb/solib-aix.c
gdb/solib-aix.h
gdb/solib-darwin.c
gdb/solib-darwin.h
gdb/solib-dsbt.c
gdb/solib-dsbt.h
gdb/solib-frv.c
gdb/solib-frv.h
gdb/solib-rocm.c
gdb/solib-svr4-linux.c
gdb/solib-svr4-linux.h
gdb/solib-svr4.c
gdb/solib-svr4.h
gdb/solib-target.c
gdb/solib-target.h
gdb/solib.h
gdb/windows-tdep.c

index 8f7d3596309b29abd11c8b21d27e892520193a0a..75956e206af4ab66956ef122d9e754ae84991816 100644 (file)
@@ -3470,13 +3470,13 @@ set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch,
 }
 
 solib_ops_up
-gdbarch_make_solib_ops (struct gdbarch *gdbarch)
+gdbarch_make_solib_ops (struct gdbarch *gdbarch, program_space *pspace)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->make_solib_ops != NULL);
   if (gdbarch_debug >= 2)
     gdb_printf (gdb_stdlog, "gdbarch_make_solib_ops called\n");
-  return gdbarch->make_solib_ops ();
+  return gdbarch->make_solib_ops (pspace);
 }
 
 void
index 148abfab2012a47490bf6c2024a7dbc3fcdd70ee..fba62e13a807f584e72112aaf5a5064b7adc594b 100644 (file)
@@ -820,8 +820,8 @@ extern void set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, gdbarch_s
 
 /* Return a newly-allocated solib_ops object capable of providing the solibs for this architecture. */
 
-typedef solib_ops_up (gdbarch_make_solib_ops_ftype) ();
-extern solib_ops_up gdbarch_make_solib_ops (struct gdbarch *gdbarch);
+typedef solib_ops_up (gdbarch_make_solib_ops_ftype) (program_space *pspace);
+extern solib_ops_up gdbarch_make_solib_ops (struct gdbarch *gdbarch, program_space *pspace);
 extern void set_gdbarch_make_solib_ops (struct gdbarch *gdbarch, gdbarch_make_solib_ops_ftype *make_solib_ops);
 
 /* If in_solib_dynsym_resolve_code() returns true, and SKIP_SOLIB_RESOLVER
index ae9e14a024f4d2b6d6a64201ac7484f672a0138f..dac3ce17a0edfb6c6f56984175806df635813d67 100644 (file)
@@ -1435,7 +1435,7 @@ Function(
     comment="Return a newly-allocated solib_ops object capable of providing the solibs for this architecture.",
     type="solib_ops_up",
     name="make_solib_ops",
-    params=[],
+    params=[("program_space *", "pspace")],
     predefault="make_target_solib_ops",
     invalid=False,
 )
index 89f9205c5bac0aa1c4642e6b43062c479bb462a6..a785ae37758660ff6457be90b8b048067cecfb1f 100644 (file)
@@ -261,7 +261,8 @@ post_create_inferior (int from_tty, bool set_pspace_solib_ops)
 
   if (set_pspace_solib_ops)
     current_program_space->set_solib_ops
-      (gdbarch_make_solib_ops (current_inferior ()->arch ()));
+      (gdbarch_make_solib_ops (current_inferior ()->arch (),
+                              current_program_space));
 
   if (current_program_space->exec_bfd ())
     {
index 051236e24e71aa7192b30c075a68a1a88091fa86..3b5cff71cc2f70d956195429539c9c1a9c498078 100644 (file)
@@ -1381,8 +1381,9 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
      registers.  */
   target_find_description ();
 
-  current_program_space->set_solib_ops
-    (gdbarch_make_solib_ops (following_inferior->arch ()));
+  following_inferior->pspace->set_solib_ops
+    (gdbarch_make_solib_ops (following_inferior->arch (),
+                            following_inferior->pspace));
   gdb::observers::inferior_execd.notify (execing_inferior, following_inferior);
 
   breakpoint_re_set ();
index 879058c0c8d33ce136ade200e390d23b21ae5ff5..dc549b591cf9230dac3c9f68a50e1fd358f7f376 100644 (file)
@@ -480,6 +480,8 @@ mips_fbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
 
 struct mips_fbsd_ilp32_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   /* FreeBSD/MIPS uses a slightly different `struct link_map' than the
      other FreeBSD platforms as it includes an additional `l_off' member.  */
 
@@ -489,9 +491,9 @@ struct mips_fbsd_ilp32_solib_ops : public svr4_solib_ops
 /* Return a new solib_ops for ILP32 FreeBSD/MIPS systems.  */
 
 static solib_ops_up
-make_mips_fbsd_ilp32_solib_ops ()
+make_mips_fbsd_ilp32_solib_ops (program_space *pspace)
 {
-  return std::make_unique<mips_fbsd_ilp32_solib_ops> ();
+  return std::make_unique<mips_fbsd_ilp32_solib_ops> (pspace);
 }
 
 /* See mips_fbsd_ilp32_solib_ops.  */
@@ -528,6 +530,8 @@ mips_fbsd_ilp32_solib_ops::fetch_link_map_offsets () const
 
 struct mips_fbsd_lp64_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   /* FreeBSD/MIPS uses a slightly different `struct link_map' than the
      other FreeBSD platforms as it includes an additional `l_off' member.  */
 
@@ -537,9 +541,9 @@ struct mips_fbsd_lp64_solib_ops : public svr4_solib_ops
 /* Return a new solib_ops for LP64 FreeBSD/MIPS systems.  */
 
 static solib_ops_up
-make_mips_fbsd_lp64_solib_ops ()
+make_mips_fbsd_lp64_solib_ops (program_space *pspace)
 {
-  return std::make_unique<mips_fbsd_lp64_solib_ops> ();
+  return std::make_unique<mips_fbsd_lp64_solib_ops> (pspace);
 }
 
 /* See mips_fbsd_lp64_solib_ops.  */
index 08dbd689090273ce2c14ac868d942b769dea2473..b668bcb357815d6a4fb443fc17a807f99e9cd783 100644 (file)
@@ -671,6 +671,8 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc)
 template <typename Base>
 struct mips_linux_svr4_solib_ops : public Base
 {
+  using Base::Base;
+
   bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
 };
 
@@ -700,9 +702,9 @@ using mips_linux_ilp32_svr4_solib_ops
 /* Return a new solib_ops for ILP32 Linux/MIPS systems.  */
 
 static solib_ops_up
-make_mips_linux_ilp32_svr4_solib_ops ()
+make_mips_linux_ilp32_svr4_solib_ops (program_space *pspace)
 {
-  return std::make_unique<mips_linux_ilp32_svr4_solib_ops> ();
+  return std::make_unique<mips_linux_ilp32_svr4_solib_ops> (pspace);
 }
 
 /* solib_ops for LP64 Linux/MIPS systems.  */
@@ -713,9 +715,9 @@ using mips_linux_lp64_svr4_solib_ops
 /* Return a new solib_ops for LP64 Linux/MIPS systems.  */
 
 static solib_ops_up
-make_mips_linux_lp64_svr4_solib_ops ()
+make_mips_linux_lp64_svr4_solib_ops (program_space *pspace)
 {
-  return std::make_unique<mips_linux_lp64_svr4_solib_ops> ();
+  return std::make_unique<mips_linux_lp64_svr4_solib_ops> (pspace);
 }
 
 /* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c,
index e72ed7b1f17eea0f5aade948f805bd2e27f7ff13..3c54c32d696d0b3536cbe140e2865d33e75a11a1 100644 (file)
@@ -292,6 +292,8 @@ mipsnbsd_cannot_store_register (struct gdbarch *gdbarch, int regno)
 
 struct mips_nbsd_ilp32_svr4_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   /* NetBSD/MIPS uses a slightly different `struct link_map' than the
      other NetBSD platforms.  */
   link_map_offsets *fetch_link_map_offsets () const override;
@@ -300,9 +302,9 @@ struct mips_nbsd_ilp32_svr4_solib_ops : public svr4_solib_ops
 /* Return a new solib_ops for ILP32 NetBSD/MIPS systems.  */
 
 static solib_ops_up
-make_mips_nbsd_ilp32_svr4_solib_ops ()
+make_mips_nbsd_ilp32_svr4_solib_ops (program_space *pspace)
 {
-  return std::make_unique<mips_nbsd_ilp32_svr4_solib_ops> ();
+  return std::make_unique<mips_nbsd_ilp32_svr4_solib_ops> (pspace);
 }
 
 /* See mips_nbsd_ilp32_svr4_solib_ops.  */
@@ -340,6 +342,8 @@ mips_nbsd_ilp32_svr4_solib_ops::fetch_link_map_offsets () const
 
 struct mips_nbsd_lp64_svr4_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   /* NetBSD/MIPS uses a slightly different `struct link_map' than the
      other NetBSD platforms.  */
   link_map_offsets *fetch_link_map_offsets () const override;
@@ -348,9 +352,9 @@ struct mips_nbsd_lp64_svr4_solib_ops : public svr4_solib_ops
 /* Return a new solib_ops for LP64 NetBSD/MIPS systems.  */
 
 static solib_ops_up
-make_mips_nbsd_lp64_svr4_solib_ops ()
+make_mips_nbsd_lp64_svr4_solib_ops (program_space *pspace)
 {
-  return std::make_unique<mips_nbsd_lp64_svr4_solib_ops> ();
+  return std::make_unique<mips_nbsd_lp64_svr4_solib_ops> (pspace);
 }
 
 /* See mips_nbsd_lp64_svr4_solib_ops.  */
index 5067b89cbe0ffb446681493c93eb333315b8a000..39566a48d291b6b8111a84359d763f1e6b043ffd 100644 (file)
@@ -309,6 +309,8 @@ static const struct ppc_insn_pattern powerpc32_plt_stub_so_2[] =
 
 struct ppc_linux_ilp32_svr4_solib_ops : public linux_ilp32_svr4_solib_ops
 {
+  using linux_ilp32_svr4_solib_ops::linux_ilp32_svr4_solib_ops;
+
   /* Check if PC is in PLT stub.  For non-secure PLT, stub is in .plt
      section.  For secure PLT, stub is in .text and we need to check
      instruction patterns.  */
@@ -319,9 +321,9 @@ struct ppc_linux_ilp32_svr4_solib_ops : public linux_ilp32_svr4_solib_ops
 /* Return a new solib_ops for ILP32 PowerPC/Linux systems.  */
 
 static solib_ops_up
-make_ppc_linux_ilp32_svr4_solib_ops ()
+make_ppc_linux_ilp32_svr4_solib_ops (program_space *pspace)
 {
-  return std::make_unique<ppc_linux_ilp32_svr4_solib_ops> ();
+  return std::make_unique<ppc_linux_ilp32_svr4_solib_ops> (pspace);
 }
 
 /* See ppc_linux_ilp32_svr4_solib_ops.  */
index b246df82561e17d5d028aa81730b9bf8aed85a52..fb81a56ca190c3d668716cd57b44e510487a290b 100644 (file)
@@ -28,6 +28,8 @@
 
 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;
@@ -37,9 +39,9 @@ struct aix_solib_ops : public solib_ops
 /* See solib-aix.h.  */
 
 solib_ops_up
-make_aix_solib_ops ()
+make_aix_solib_ops (program_space *pspace)
 {
-  return std::make_unique<aix_solib_ops> ();
+  return std::make_unique<aix_solib_ops> (pspace);
 }
 
 /* Our private data in struct solib.  */
index 628b7c8df474959c2418ef94905425e13d2f98f8..887487d3c6f099d14a727f8f7b3de2e2b41a2121 100644 (file)
@@ -24,6 +24,6 @@ extern CORE_ADDR solib_aix_get_toc_value (CORE_ADDR pc);
 
 /* Return a new solib_ops for AIX systems.  */
 
-solib_ops_up make_aix_solib_ops ();
+solib_ops_up make_aix_solib_ops (program_space *pspace);
 
 #endif /* GDB_SOLIB_AIX_H */
index aac8ab2942edd703fe35169ad56a654bcf684f05..62126974e012be9f5f1da352e45a72fde7bc756a 100644 (file)
@@ -37,6 +37,8 @@
 
 struct darwin_solib_ops : public solib_ops
 {
+  using solib_ops::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;
@@ -47,9 +49,9 @@ struct darwin_solib_ops : public solib_ops
 /* See solib-darwin.h.  */
 
 solib_ops_up
-make_darwin_solib_ops ()
+make_darwin_solib_ops (program_space *pspace)
 {
-  return std::make_unique<darwin_solib_ops> ();
+  return std::make_unique<darwin_solib_ops> (pspace);
 }
 
 struct gdb_dyld_image_info
index f5bcdd124551d75a1faf538f041d6427e74c4003..fc28b2c91c569a36b125ec6d14f5ba19c6910193 100644 (file)
@@ -24,6 +24,6 @@
 
 /* Return a new solib_ops for Darwin systems.  */
 
-extern solib_ops_up make_darwin_solib_ops ();
+extern solib_ops_up make_darwin_solib_ops (program_space *pspace);
 
 #endif /* GDB_SOLIB_DARWIN_H */
index 13623fcfe87cb136f2ba29917112d2cb2aa363ba..4f2c918c11b92cc15a3b4ec7b009624aefd4e565 100644 (file)
@@ -123,6 +123,8 @@ struct dbst_ext_link_map
 
 struct dsbt_solib_ops : public solib_ops
 {
+  using solib_ops::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;
@@ -133,9 +135,9 @@ struct dsbt_solib_ops : public solib_ops
 /* See solib-dsbt.h.  */
 
 solib_ops_up
-make_dsbt_solib_ops ()
+make_dsbt_solib_ops (program_space *pspace)
 {
-  return std::make_unique<dsbt_solib_ops> ();
+  return std::make_unique<dsbt_solib_ops> (pspace);
 }
 
 /* Link map info to include in an allocated solib entry */
index d44613c7b248208f4d7c2b18932e3d1d46d2baa5..00f77913cafb5ec514b6ac6dfa5e02f12ff0269e 100644 (file)
@@ -24,6 +24,6 @@
 
 /* Return a new solib_ops for DSBT systems.  */
 
-solib_ops_up make_dsbt_solib_ops ();
+solib_ops_up make_dsbt_solib_ops (program_space *pspace);
 
 #endif /* GDB_SOLIB_DSBT_H */
index b48efe56a4618f91dd92adf34d675eabc7305550..9a9b65d29646539fe552d3da0f06a0af7c7cf94a 100644 (file)
@@ -31,6 +31,8 @@
 
 struct frv_solib_ops : public solib_ops
 {
+  using solib_ops::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;
@@ -41,9 +43,9 @@ struct frv_solib_ops : public solib_ops
 /* See solib-frv.h.  */
 
 solib_ops_up
-make_frv_solib_ops ()
+make_frv_solib_ops (program_space *pspace)
 {
-  return std::make_unique<frv_solib_ops> ();
+  return std::make_unique<frv_solib_ops> (pspace);
 }
 
 /* FR-V pointers are four bytes wide.  */
index a2f3558021e7e3ba823339dd93242a7551f3fc51..33d156c7fc8d0baa2f5ae6d1be967966ab32ed19 100644 (file)
@@ -23,6 +23,6 @@
 
 /* Return a new solib_ops for FR-V systems.  */
 
-solib_ops_up make_frv_solib_ops ();
+solib_ops_up make_frv_solib_ops (program_space *pspace);
 
 #endif /* GDB_SOLIB_FRV_H */
index 2d26c3c1c6edabc4ca1f3002d6b2b9b3c8edff0d..7c60ebc072c21b22129ccc4b36f5d228bf9b48ac 100644 (file)
@@ -160,8 +160,8 @@ struct rocm_solib_ops : public solib_ops
 {
   /* HOST_OPS is the host solib_ops that rocm_solib_ops hijacks / wraps,
      in order to provide support for ROCm code objects.  */
-  explicit rocm_solib_ops (solib_ops_up host_ops)
-    : m_host_ops (std::move (host_ops))
+  explicit rocm_solib_ops (program_space *pspace, solib_ops_up host_ops)
+    : solib_ops (pspace), m_host_ops (std::move (host_ops))
   {
   }
 
@@ -807,7 +807,8 @@ rocm_solib_target_inferior_created (inferior *inf)
   get_solib_info (inf)->solib_list.clear ();
 
   auto prev_ops = inf->pspace->release_solib_ops ();
-  auto rocm_ops = std::make_unique<rocm_solib_ops> (std::move (prev_ops));
+  auto rocm_ops
+    = std::make_unique<rocm_solib_ops> (inf->pspace, std::move (prev_ops));
   inf->pspace->set_solib_ops (std::move (rocm_ops));
 
   rocm_update_solib_list ();
@@ -825,9 +826,11 @@ rocm_solib_target_inferior_execd (inferior *exec_inf, inferior *follow_inf)
   if (get_amd_dbgapi_process_id (follow_inf) == AMD_DBGAPI_PROCESS_NONE)
     return;
 
-  auto prev_ops = follow_inf->pspace->release_solib_ops ();
-  auto rocm_ops = std::make_unique<rocm_solib_ops> (std::move (prev_ops));
-  follow_inf->pspace->set_solib_ops (std::move (rocm_ops));
+  auto pspace = follow_inf->pspace;
+  auto prev_ops = pspace->release_solib_ops ();
+  auto rocm_ops
+    = std::make_unique<rocm_solib_ops> (pspace, std::move (prev_ops));
+  pspace->set_solib_ops (std::move (rocm_ops));
 
   get_solib_info (exec_inf)->solib_list.clear ();
 }
index fd86cf008b2963663619f238ffa5600831f2c60d..fe82e5d1e2e7e449a5d557e05d100c4d80bd2b97 100644 (file)
@@ -22,9 +22,9 @@
 /* See solib-svr4-linux.h.  */
 
 solib_ops_up
-make_linux_ilp32_svr4_solib_ops ()
+make_linux_ilp32_svr4_solib_ops (program_space *pspace)
 {
-  return std::make_unique<linux_ilp32_svr4_solib_ops> ();
+  return std::make_unique<linux_ilp32_svr4_solib_ops> (pspace);
 }
 
 /* See solib-svr4-linux.h.  */
@@ -61,9 +61,9 @@ linux_ilp32_svr4_solib_ops::fetch_link_map_offsets () const
 /* See solib-svr4-linux.h.  */
 
 solib_ops_up
-make_linux_lp64_svr4_solib_ops ()
+make_linux_lp64_svr4_solib_ops (program_space *pspace)
 {
-  return std::make_unique<linux_lp64_svr4_solib_ops> ();
+  return std::make_unique<linux_lp64_svr4_solib_ops> (pspace);
 }
 
 /* See linux-tdep.h.  */
index 623013c3dc2a3259850c1bbf89ffb0e6ad8640fd..af040ff43ed096b5134a43ef88115c76e18af01d 100644 (file)
@@ -26,6 +26,8 @@
 
 struct linux_ilp32_svr4_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   link_map_offsets *fetch_link_map_offsets () const override;
 };
 
@@ -33,15 +35,17 @@ struct linux_ilp32_svr4_solib_ops : public svr4_solib_ops
 
 struct linux_lp64_svr4_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   link_map_offsets *fetch_link_map_offsets () const override;
 };
 
 /* Return a new solib_ops for ILP32 Linux systems.  */
 
-extern solib_ops_up make_linux_ilp32_svr4_solib_ops ();
+extern solib_ops_up make_linux_ilp32_svr4_solib_ops (program_space *pspace);
 
 /* Return a new solib_ops for LP64 Linux systems.  */
 
-extern solib_ops_up make_linux_lp64_svr4_solib_ops ();
+extern solib_ops_up make_linux_lp64_svr4_solib_ops (program_space *pspace);
 
 #endif /* GDB_SOLIB_SVR4_LINUX_H */
index e61aeaa4879dd8b0f76fc22d68665678a52924fb..ddb9c918fda118ba20dd8a9ecbc9d323df3c5f29 100644 (file)
@@ -3454,9 +3454,9 @@ set_solib_svr4_ops (gdbarch *gdbarch, gdbarch_make_solib_ops_ftype make_solib_op
 /* See solib-svr4.h.  */
 
 solib_ops_up
-make_svr4_ilp32_solib_ops ()
+make_svr4_ilp32_solib_ops (program_space *pspace)
 {
-  return std::make_unique<ilp32_svr4_solib_ops> ();
+  return std::make_unique<ilp32_svr4_solib_ops> (pspace);
 }
 
 /* Most OS'es that have SVR4-style ELF dynamic libraries define a
@@ -3499,15 +3499,17 @@ ilp32_svr4_solib_ops::fetch_link_map_offsets () const
 
 struct lp64_svr4_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   link_map_offsets *fetch_link_map_offsets () const override;
 };
 
 /* See solib-svr4.h.  */
 
 solib_ops_up
-make_svr4_lp64_solib_ops ()
+make_svr4_lp64_solib_ops (program_space *pspace)
 {
-  return std::make_unique<lp64_svr4_solib_ops> ();
+  return std::make_unique<lp64_svr4_solib_ops> (pspace);
 }
 
 /* Fetch (and possibly build) an appropriate `struct link_map_offsets'
index 7235fd96a0c9ec88883b0a50a2f9b3a494a0a94f..70cb1d6374ade0e2e375bb3aaf1572c75997f8ba 100644 (file)
@@ -78,6 +78,8 @@ enum probe_action
 
 struct svr4_solib_ops : public solib_ops
 {
+  using solib_ops::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;
@@ -137,6 +139,8 @@ private:
 
 struct ilp32_svr4_solib_ops : public svr4_solib_ops
 {
+  using svr4_solib_ops::svr4_solib_ops;
+
   link_map_offsets *fetch_link_map_offsets () const override;
 };
 
@@ -192,11 +196,11 @@ extern CORE_ADDR svr4_fetch_objfile_link_map (struct objfile *objfile);
 
 /* Return a new solib_ops for ILP32 SVR4 systems.  */
 
-extern solib_ops_up make_svr4_ilp32_solib_ops ();
+extern solib_ops_up make_svr4_ilp32_solib_ops (program_space *pspace);
 
 /* Return a new solib_ops for LP64 SVR4 systems.  */
 
-extern solib_ops_up make_svr4_lp64_solib_ops ();
+extern solib_ops_up make_svr4_lp64_solib_ops (program_space *pspace);
 
 /* For the MUSL C library, given link map address LM_ADDR, return the
    corresponding TLS module id, or 0 if not found.  */
index 770028d9903953cb761c2901aae5a1f247aaa34b..f20332a022aad107411ff033a7354ebd657ef814 100644 (file)
@@ -389,7 +389,7 @@ target_solib_ops::in_dynsym_resolve_code (CORE_ADDR pc) const
 /* See solib-target.h.  */
 
 solib_ops_up
-make_target_solib_ops ()
+make_target_solib_ops (program_space *pspace)
 {
-  return std::make_unique<target_solib_ops> ();
+  return std::make_unique<target_solib_ops> (pspace);
 }
index 89ae2bc9b9e155b9cc31b7410a814e2340ab867a..4b8f2d6ad5cb5c32e347ff91bd96d8d7600aff84 100644 (file)
@@ -26,6 +26,8 @@
 
 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;
   bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
@@ -33,6 +35,6 @@ struct target_solib_ops : solib_ops
 
 /* Return a new solib_ops for systems fetching solibs from the target.  */
 
-solib_ops_up make_target_solib_ops ();
+solib_ops_up make_target_solib_ops (program_space *pspace);
 
 #endif /* GDB_SOLIB_TARGET_H */
index f6d6de92216908baa1bbcc2a77139355cb2f3998..a6e85ebeeaadeee69da29793c98db9518cb5f8b3 100644 (file)
@@ -133,6 +133,10 @@ using solib_up = std::unique_ptr<solib>;
 
 struct solib_ops
 {
+  explicit solib_ops (program_space *pspace)
+    : m_pspace (pspace)
+  {}
+
   virtual ~solib_ops () = default;
 
   /* Adjust the section binding addresses by the base address at
@@ -259,6 +263,10 @@ struct solib_ops
      The supports_namespaces method must return true for this to be called.  */
   virtual std::vector<const solib *> get_solibs_in_ns (int ns) const
   { gdb_assert_not_reached ("namespaces not supported"); }
+
+protected:
+  /* The program space for which this solib_ops was created.  */
+  program_space *m_pspace;
 };
 
 /* A unique pointer to an solib_ops.  */
index 05335d2958794175340bcd116163ef46822580cb..b71fad16f7962c0a161dfa8239adc11420167ba6 100644 (file)
@@ -866,15 +866,17 @@ windows_get_siginfo_type (struct gdbarch *gdbarch)
 
 struct windows_solib_ops : target_solib_ops
 {
+  using target_solib_ops::target_solib_ops;
+
   void create_inferior_hook (int from_tty) const override;
 };
 
 /* Return a new solib_ops for Windows systems.  */
 
 static solib_ops_up
-make_windows_solib_ops ()
+make_windows_solib_ops (program_space *pspace)
 {
-  return std::make_unique<windows_solib_ops> ();
+  return std::make_unique<windows_solib_ops> (pspace);
 }
 
 /* Implement the "solib_create_inferior_hook" solib_ops method.  */