]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: make objfile::pspace private
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 15 Jul 2024 13:54:45 +0000 (13:54 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 15 Jul 2024 13:55:00 +0000 (13:55 +0000)
Rename to m_pspace, add getter.  An objfile's pspace never changes, so
no setter is necessary.

Change-Id: If4dfb300cb90dc0fb9776ea704ff92baebb8f626

16 files changed:
gdb/ada-lang.c
gdb/ada-tasks.c
gdb/annotate.c
gdb/auto-load.c
gdb/breakpoint.c
gdb/guile/scm-objfile.c
gdb/linespec.c
gdb/objfiles.c
gdb/objfiles.h
gdb/printcmd.c
gdb/python/py-objfile.c
gdb/remote.c
gdb/solib-svr4.c
gdb/solib.c
gdb/symfile.c
gdb/symtab.c

index 46c20576cff8e295d5ea2892d00786108765a35d..e2be7f9722415f512ef85c28cdc6b3444c040d0e 100644 (file)
@@ -13884,7 +13884,7 @@ static struct cmd_list_element *show_ada_list;
 static void
 ada_new_objfile_observer (struct objfile *objfile)
 {
-  ada_clear_symbol_cache (objfile->pspace);
+  ada_clear_symbol_cache (objfile->pspace ());
 }
 
 /* This module's 'free_objfile' observer.  */
@@ -13892,7 +13892,7 @@ ada_new_objfile_observer (struct objfile *objfile)
 static void
 ada_free_objfile_observer (struct objfile *objfile)
 {
-  ada_clear_symbol_cache (objfile->pspace);
+  ada_clear_symbol_cache (objfile->pspace ());
 }
 
 /* Charsets known to GNAT.  */
index 83059d720709434f43e7417d524a54a567f7bfeb..119b223caa947c7826d99a6eba0c0e7380f746a1 100644 (file)
@@ -1495,7 +1495,7 @@ ada_tasks_clear_pspace_data (program_space *pspace)
 static void
 ada_tasks_new_objfile_observer (objfile *objfile)
 {
-  ada_tasks_clear_pspace_data (objfile->pspace);
+  ada_tasks_clear_pspace_data (objfile->pspace ());
 }
 
 /* The qcs command line flags for the "task apply" commands.  Keep
index 88180295d1d6752ae5256582c3f7fa007f494573..c1d4229e28cbd7c499ad91626190845f6c9d74aa 100644 (file)
@@ -457,7 +457,7 @@ annotate_source_line (struct symtab *s, int line, int mid_statement,
 
       /* Update the current symtab and line.  */
       symtab_and_line sal;
-      sal.pspace = s->compunit ()->objfile ()->pspace;
+      sal.pspace = s->compunit ()->objfile ()->pspace ();
       sal.symtab = s;
       sal.line = line;
       set_current_source_symtab_and_line (sal);
index afc98eb1f588a10ae7fa608b745c3e41f1dd79e1..839be081b3dab387d14c574c9168154bc7fd5c91 100644 (file)
@@ -783,7 +783,7 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
       /* Add this script to the hash table too so
         "info auto-load ${lang}-scripts" can print it.  */
       pspace_info
-       = get_auto_load_pspace_data_for_loading (objfile->pspace);
+       = get_auto_load_pspace_data_for_loading (objfile->pspace ());
       maybe_add_script_file (pspace_info, is_safe, debugfile, debugfile,
                             language);
 
@@ -1048,7 +1048,7 @@ source_section_scripts (struct objfile *objfile, const char *section_name,
                        const char *start, const char *end)
 {
   auto_load_pspace_info *pspace_info
-    = get_auto_load_pspace_data_for_loading (objfile->pspace);
+    = get_auto_load_pspace_data_for_loading (objfile->pspace ());
 
   for (const char *p = start; p < end; ++p)
     {
index a973518ac5f03b3e14eab8da3709317ecc9d4259..f32883eb3bc3911194867769568ce3f087136087 100644 (file)
@@ -8092,7 +8092,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
          if (loc.shlib_disabled != 0)
            continue;
 
-         if (objfile->pspace != loc.pspace)
+         if (objfile->pspace () != loc.pspace)
            continue;
 
          if (loc.loc_type != bp_loc_hardware_breakpoint
index bccf6ba156d71ec839801b31d0099c174fe8e277..d6c0559afd3cd364bc2d647a0c4def0d015e31f8 100644 (file)
@@ -250,7 +250,7 @@ gdbscm_objfile_progspace (SCM self)
   objfile_smob *o_smob
     = ofscm_get_valid_objfile_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  return psscm_scm_from_pspace (o_smob->objfile->pspace);
+  return psscm_scm_from_pspace (o_smob->objfile->pspace ());
 }
 
 /* (objfile-pretty-printers <gdb:objfile>) -> list
index 7a1fbc2ebec56c599dfc8a6d2470907992568c06..d24d6912e3472f0b0b8888fa1db7eeb156fac579 100644 (file)
@@ -2172,7 +2172,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
       for (const auto &sym : ls->labels.label_symbols)
        {
          struct program_space *pspace
-           = sym.symbol->symtab ()->compunit ()->objfile ()->pspace;
+           = sym.symbol->symtab ()->compunit ()->objfile ()->pspace ();
 
          if (symbol_to_sal (&sal, state->funfirstline, sym.symbol)
              && maybe_add_address (state->addr_set, pspace, sal.pc))
@@ -2194,7 +2194,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
          for (const auto &sym : ls->function_symbols)
            {
              program_space *pspace
-               = sym.symbol->symtab ()->compunit ()->objfile ()->pspace;
+               = sym.symbol->symtab ()->compunit ()->objfile ()->pspace ();
              set_current_program_space (pspace);
 
              /* Don't skip to the first line of the function if we
@@ -2256,7 +2256,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
 
          for (const auto &elem : ls->minimal_symbols)
            {
-             program_space *pspace = elem.objfile->pspace;
+             program_space *pspace = elem.objfile->pspace ();
              set_current_program_space (pspace);
              minsym_found (state, elem.objfile, elem.minsym, &sals);
            }
@@ -3437,7 +3437,7 @@ lookup_prefix_sym (struct linespec_state *state,
        {
          /* Program spaces that are executing startup should have
             been filtered out earlier.  */
-         program_space *pspace = elt->compunit ()->objfile ()->pspace;
+         program_space *pspace = elt->compunit ()->objfile ()->pspace ();
 
          gdb_assert (!pspace->executing_startup);
          set_current_program_space (pspace);
@@ -3459,8 +3459,8 @@ compare_symbols (const block_symbol &a, const block_symbol &b)
 {
   uintptr_t uia, uib;
 
-  uia = (uintptr_t) a.symbol->symtab ()->compunit ()->objfile ()->pspace;
-  uib = (uintptr_t) b.symbol->symtab ()->compunit ()->objfile ()->pspace;
+  uia = (uintptr_t) a.symbol->symtab ()->compunit ()->objfile ()->pspace ();
+  uib = (uintptr_t) b.symbol->symtab ()->compunit ()->objfile ()->pspace ();
 
   if (uia < uib)
     return true;
@@ -3483,8 +3483,8 @@ compare_msymbols (const bound_minimal_symbol &a, const bound_minimal_symbol &b)
 {
   uintptr_t uia, uib;
 
-  uia = (uintptr_t) a.objfile->pspace;
-  uib = (uintptr_t) a.objfile->pspace;
+  uia = (uintptr_t) a.objfile->pspace ();
+  uib = (uintptr_t) a.objfile->pspace ();
 
   if (uia < uib)
     return true;
@@ -3584,7 +3584,7 @@ find_method (struct linespec_state *self,
 
       /* Program spaces that are executing startup should have
         been filtered out earlier.  */
-      pspace = sym->symtab ()->compunit ()->objfile ()->pspace;
+      pspace = sym->symtab ()->compunit ()->objfile ()->pspace ();
       gdb_assert (!pspace->executing_startup);
       set_current_program_space (pspace);
       t = check_typedef (sym->type ());
@@ -3596,7 +3596,7 @@ find_method (struct linespec_state *self,
       if (ix == sym_classes->size () - 1
          || (pspace
              != (sym_classes->at (ix + 1).symbol->symtab ()
-                 ->compunit ()->objfile ()->pspace)))
+                 ->compunit ()->objfile ()->pspace ())))
        {
          /* If we did not find a direct implementation anywhere in
             this program space, consider superclasses.  */
@@ -3963,7 +3963,7 @@ find_label_symbols (struct linespec_state *self,
        {
          fn_sym = elt.symbol;
          set_current_program_space
-           (fn_sym->symtab ()->compunit ()->objfile ()->pspace);
+           (fn_sym->symtab ()->compunit ()->objfile ()->pspace ());
          block = fn_sym->value_block ();
 
          find_label_symbols_in_block (block, name, fn_sym, completion_mode,
@@ -3992,7 +3992,7 @@ decode_digits_list_mode (struct linespec_state *self,
       /* The logic above should ensure this.  */
       gdb_assert (elt != NULL);
 
-      program_space *pspace = elt->compunit ()->objfile ()->pspace;
+      program_space *pspace = elt->compunit ()->objfile ()->pspace ();
       set_current_program_space (pspace);
 
       /* Simplistic search just for the list command.  */
@@ -4027,7 +4027,7 @@ decode_digits_ordinary (struct linespec_state *self,
       /* The logic above should ensure this.  */
       gdb_assert (elt != NULL);
 
-      program_space *pspace = elt->compunit ()->objfile ()->pspace;
+      program_space *pspace = elt->compunit ()->objfile ()->pspace ();
       set_current_program_space (pspace);
 
       pcs = find_pcs_for_symtab_line (elt, line, best_entry);
@@ -4153,7 +4153,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
 
   sal.section = msymbol->obj_section (objfile);
 
-  if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc))
+  if (maybe_add_address (self->addr_set, objfile->pspace (), sal.pc))
     add_sal_to_sals (self, result, &sal, msymbol->natural_name (), 0);
 }
 
@@ -4228,7 +4228,7 @@ search_minsyms_for_name (struct collect_info *info,
     }
   else
     {
-      program_space *pspace = symtab->compunit ()->objfile ()->pspace;
+      program_space *pspace = symtab->compunit ()->objfile ()->pspace ();
 
       if (search_pspace == NULL || pspace == search_pspace)
        {
@@ -4322,13 +4322,13 @@ add_matching_symbols_to_info (const char *name,
            { return info->add_symbol (bsym); });
          search_minsyms_for_name (info, lookup_name, pspace, NULL);
        }
-      else if (pspace == NULL || pspace == elt->compunit ()->objfile ()->pspace)
+      else if (pspace == NULL || pspace == elt->compunit ()->objfile ()->pspace ())
        {
          int prev_len = info->result.symbols->size ();
 
          /* Program spaces that are executing startup should have
             been filtered out earlier.  */
-         program_space *elt_pspace = elt->compunit ()->objfile ()->pspace;
+         program_space *elt_pspace = elt->compunit ()->objfile ()->pspace ();
          gdb_assert (!elt_pspace->executing_startup);
          set_current_program_space (elt_pspace);
          iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT,
@@ -4369,7 +4369,7 @@ symbol_to_sal (struct symtab_and_line *result,
          result->symbol = sym;
          result->line = sym->line ();
          result->pc = sym->value_address ();
-         result->pspace = result->symtab->compunit ()->objfile ()->pspace;
+         result->pspace = result->symtab->compunit ()->objfile ()->pspace ();
          result->explicit_pc = 1;
          return 1;
        }
@@ -4385,7 +4385,7 @@ symbol_to_sal (struct symtab_and_line *result,
          result->symbol = sym;
          result->line = sym->line ();
          result->pc = sym->value_address ();
-         result->pspace = result->symtab->compunit ()->objfile ()->pspace;
+         result->pspace = result->symtab->compunit ()->objfile ()->pspace ();
          return 1;
        }
     }
index 368e129b49d3c4fd9700b145e5fba8714438515d..3d50db40241282a68838396ba54669c314d77fab 100644 (file)
@@ -308,7 +308,7 @@ build_objfile_section_table (struct objfile *objfile)
 
 objfile::objfile (gdb_bfd_ref_ptr bfd_, const char *name, objfile_flags flags_)
   : flags (flags_),
-    pspace (current_program_space),
+    m_pspace (current_program_space),
     obfd (std::move (bfd_))
 {
   const char *expanded_name;
@@ -568,7 +568,7 @@ objfile::~objfile ()
   }
 
   /* Rebuild section map next time we need it.  */
-  get_objfile_pspace_data (pspace)->section_map_dirty = 1;
+  get_objfile_pspace_data (m_pspace)->section_map_dirty = 1;
 }
 
 \f
@@ -646,7 +646,7 @@ objfile_relocate1 (struct objfile *objfile,
     objfile->section_offsets[i] = new_offsets[i];
 
   /* Rebuild section map next time we need it.  */
-  get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1;
+  get_objfile_pspace_data (objfile->pspace ())->section_map_dirty = 1;
 
   /* Update the table in exec_ops, used to read memory.  */
   for (obj_section *s : objfile->sections ())
index 88dfb33e45c95c162db2d634d408d8b5918955e6..320e8099c91a9b5b4a72e6867f6f34f9fff50394 100644 (file)
@@ -445,6 +445,9 @@ public:
 
   DISABLE_COPY_AND_ASSIGN (objfile);
 
+  /* Return the program space associated with this objfile.  */
+  program_space *pspace () { return m_pspace; }
+
   /* A range adapter that makes it possible to iterate over all
      compunits in one objfile.  */
 
@@ -716,10 +719,12 @@ public:
 
   objfile_flags flags;
 
+private:
   /* The program space associated with this objfile.  */
 
-  struct program_space *pspace;
+  program_space *m_pspace;
 
+public:
   /* List of compunits.
      These are used to do symbol lookups and file/line-number lookups.  */
 
index 1d6a4922b8e795e902fd8740f04301a1fe7afbb0..e37e30edb87b67917136040f8600a9b17c76d475 100644 (file)
@@ -2294,11 +2294,11 @@ disable_display_command (const char *args, int from_tty)
 static void
 clear_dangling_display_expressions (struct objfile *objfile)
 {
-  program_space *pspace = objfile->pspace;
+  program_space *pspace = objfile->pspace ();
   if (objfile->separate_debug_objfile_backlink)
     {
       objfile = objfile->separate_debug_objfile_backlink;
-      gdb_assert (objfile->pspace == pspace);
+      gdb_assert (objfile->pspace () == pspace);
     }
 
   for (auto &d : all_displays)
index 60a14833b9578e47d0c271d05456238635995d9d..6e8d5b57692a0a07decac3632dd3f367f4e0c6c5 100644 (file)
@@ -183,7 +183,7 @@ objfpy_get_progspace (PyObject *self, void *closure)
   objfile_object *obj = (objfile_object *) self;
 
   if (obj->objfile)
-    return pspace_to_pspace_object (obj->objfile->pspace).release ();
+    return pspace_to_pspace_object (obj->objfile->pspace ()).release ();
 
   Py_RETURN_NONE;
 }
index 90a4bd57a82865e4bb2e0d6d048c4c23ec005306..15c3eea6f79ba42379ab191f5c7eff6ee2ce1b62 100644 (file)
@@ -15444,7 +15444,7 @@ remote_objfile_changed_check_symbols (program_space *pspace)
 static void
 remote_new_objfile (struct objfile *objfile)
 {
-  remote_objfile_changed_check_symbols (objfile->pspace);
+  remote_objfile_changed_check_symbols (objfile->pspace ());
 }
 
 /* Pull all the tracepoints defined on the target and create local
index 5c8557e9377a3e9d5ca19e8ef455159b3bc53b52..9f377f427c878883488a57a9adfdabc4eb02e7be 100644 (file)
@@ -1496,7 +1496,7 @@ svr4_current_sos ()
 CORE_ADDR
 svr4_fetch_objfile_link_map (struct objfile *objfile)
 {
-  struct svr4_info *info = get_svr4_info (objfile->pspace);
+  struct svr4_info *info = get_svr4_info (objfile->pspace ());
 
   /* Cause svr4_current_sos() to be run if it hasn't been already.  */
   if (info->main_lm_addr == 0)
@@ -1625,7 +1625,7 @@ probes_table_htab_remove_objfile_probes (void **slot, void *info)
   struct objfile *objfile = (struct objfile *) info;
 
   if (pa->objfile == objfile)
-    htab_clear_slot (get_svr4_info (objfile->pspace)->probes_table.get (),
+    htab_clear_slot (get_svr4_info (objfile->pspace ())->probes_table.get (),
                     slot);
 
   return 1;
@@ -1636,7 +1636,7 @@ probes_table_htab_remove_objfile_probes (void **slot, void *info)
 static void
 probes_table_remove_objfile_probes (struct objfile *objfile)
 {
-  svr4_info *info = get_svr4_info (objfile->pspace);
+  svr4_info *info = get_svr4_info (objfile->pspace ());
   if (info->probes_table != nullptr)
     htab_traverse_noresize (info->probes_table.get (),
                            probes_table_htab_remove_objfile_probes, objfile);
index 881f0d965027e18c7cbf7baf4ea0faac4096d6a8..55f1c53b99bed44fa5f6473b1882af0887609a8c 100644 (file)
@@ -1700,7 +1700,7 @@ remove_user_added_objfile (struct objfile *objfile)
 {
   if (objfile->flags & OBJF_USERLOADED)
     {
-      for (solib &so : objfile->pspace->solibs ())
+      for (solib &so : objfile->pspace ()->solibs ())
        if (so.objfile == objfile)
          so.objfile = nullptr;
     }
index b0510b4b4090e211ebca6615939958a894d7887e..fc86841b52d5d03b4330639e6cf8169d1048b3a9 100644 (file)
@@ -2387,7 +2387,7 @@ remove_symbol_file_command (const char *args, int from_tty)
        {
          if ((objfile->flags & OBJF_USERLOADED) != 0
              && (objfile->flags & OBJF_SHARED) != 0
-             && objfile->pspace == pspace
+             && objfile->pspace () == pspace
              && is_addr_in_objfile (addr, objfile))
            {
              objf = objfile;
@@ -2408,7 +2408,7 @@ remove_symbol_file_command (const char *args, int from_tty)
        {
          if ((objfile->flags & OBJF_USERLOADED) != 0
              && (objfile->flags & OBJF_SHARED) != 0
-             && objfile->pspace == pspace
+             && objfile->pspace () == pspace
              && filename_cmp (filename.get (), objfile_name (objfile)) == 0)
            {
              objf = objfile;
@@ -3722,7 +3722,7 @@ static void
 symfile_free_objfile (struct objfile *objfile)
 {
   /* Remove the target sections owned by this objfile.  */
-  objfile->pspace->remove_target_sections (objfile);
+  objfile->pspace ()->remove_target_sections (objfile);
 }
 
 /* Wrapper around the quick_symbol_functions expand_symtabs_matching "method".
index 41d71beec2ac165e424aa6d89eec0d4b6c591fc6..9ffc1e0b26b063f94258076747f8d4277ef3ac3f 100644 (file)
@@ -1755,7 +1755,7 @@ maintenance_print_symbol_cache_statistics (const char *args, int from_tty)
 static void
 symtab_new_objfile_observer (struct objfile *objfile)
 {
-  symbol_cache_flush (objfile->pspace);
+  symbol_cache_flush (objfile->pspace ());
 }
 
 /* This module's 'all_objfiles_removed' observer.  */
@@ -1774,7 +1774,7 @@ symtab_all_objfiles_removed (program_space *pspace)
 static void
 symtab_free_objfile_observer (struct objfile *objfile)
 {
-  symbol_cache_flush (objfile->pspace);
+  symbol_cache_flush (objfile->pspace ());
 }
 \f
 /* See symtab.h.  */