aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2024-07-15 13:54:45 +0000
committerSimon Marchi <simon.marchi@efficios.com>2024-07-15 13:55:00 +0000
commit134a0a106c944234e9e4f0dd95af96986117d7d9 (patch)
tree4e6f91d3cea33a40d9e941739a5b2b8ba14d4a15
parentd21176c014a4696e667b8567df90364939269170 (diff)
downloadgdb-134a0a106c944234e9e4f0dd95af96986117d7d9.zip
gdb-134a0a106c944234e9e4f0dd95af96986117d7d9.tar.gz
gdb-134a0a106c944234e9e4f0dd95af96986117d7d9.tar.bz2
gdb: make objfile::pspace private
Rename to m_pspace, add getter. An objfile's pspace never changes, so no setter is necessary. Change-Id: If4dfb300cb90dc0fb9776ea704ff92baebb8f626
-rw-r--r--gdb/ada-lang.c4
-rw-r--r--gdb/ada-tasks.c2
-rw-r--r--gdb/annotate.c2
-rw-r--r--gdb/auto-load.c4
-rw-r--r--gdb/breakpoint.c2
-rw-r--r--gdb/guile/scm-objfile.c2
-rw-r--r--gdb/linespec.c38
-rw-r--r--gdb/objfiles.c6
-rw-r--r--gdb/objfiles.h7
-rw-r--r--gdb/printcmd.c4
-rw-r--r--gdb/python/py-objfile.c2
-rw-r--r--gdb/remote.c2
-rw-r--r--gdb/solib-svr4.c6
-rw-r--r--gdb/solib.c2
-rw-r--r--gdb/symfile.c6
-rw-r--r--gdb/symtab.c4
16 files changed, 49 insertions, 44 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 46c2057..e2be7f9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -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. */
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 83059d7..119b223 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -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
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 8818029..c1d4229 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -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);
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index afc98eb..839be08 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -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)
{
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index a973518..f32883e 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -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
diff --git a/gdb/guile/scm-objfile.c b/gdb/guile/scm-objfile.c
index bccf6ba..d6c0559 100644
--- a/gdb/guile/scm-objfile.c
+++ b/gdb/guile/scm-objfile.c
@@ -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
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 7a1fbc2..d24d691 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -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;
}
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 368e129..3d50db4 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -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;
}
@@ -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 ())
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 88dfb33..320e809 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -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. */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 1d6a492..e37e30e 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -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)
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 60a1483..6e8d5b5 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -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;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 90a4bd5..15c3eea 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -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
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 5c8557e..9f377f4 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -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);
diff --git a/gdb/solib.c b/gdb/solib.c
index 881f0d9..55f1c53 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -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;
}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b0510b4..fc86841 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -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".
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 41d71be..9ffc1e0 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -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 ());
}
/* See symtab.h. */