disabled ones can just stay disabled. */
static void
-disable_breakpoints_in_unloaded_shlib (program_space *pspace, so_list *solib)
+disable_breakpoints_in_unloaded_shlib (program_space *pspace,
+ const so_list &solib)
{
bool disabled_shlib_breaks = false;
target_terminal::ours_for_output ();
warning (_("Temporarily disabling breakpoints "
"for unloaded shared library \"%s\""),
- solib->so_name);
+ solib.so_name);
}
disabled_shlib_breaks = true;
}
};
static void
-bsd_uthread_solib_loaded (struct so_list *so)
+bsd_uthread_solib_loaded (so_list &so)
{
const char * const *names = bsd_uthread_solib_names;
for (names = bsd_uthread_solib_names; *names; names++)
{
- if (startswith (so->so_original_name, *names))
+ if (startswith (so.so_original_name, *names))
{
solib_read_symbols (so, 0);
- if (bsd_uthread_activate (so->objfile))
+ if (bsd_uthread_activate (so.objfile))
{
- bsd_uthread_solib_name = so->so_original_name;
+ bsd_uthread_solib_name = so.so_original_name;
return;
}
}
}
static void
-bsd_uthread_solib_unloaded (program_space *pspace, so_list *so)
+bsd_uthread_solib_unloaded (program_space *pspace, const so_list &so)
{
if (!bsd_uthread_solib_name)
return;
- if (strcmp (so->so_original_name, bsd_uthread_solib_name) == 0)
+ if (strcmp (so.so_original_name, bsd_uthread_solib_name) == 0)
bsd_uthread_deactivate ();
}
current set of target sections. */
void
-program_space::add_target_sections (void *owner,
+program_space::add_target_sections (const void *owner,
const target_section_table §ions)
{
if (!sections.empty ())
OWNER must be the same value passed to add_target_sections. */
void
-program_space::remove_target_sections (void *owner)
+program_space::remove_target_sections (const void *owner)
{
gdb_assert (owner != NULL);
/* See interps.h. */
void
-interps_notify_solib_loaded (so_list *so)
+interps_notify_solib_loaded (const so_list &so)
{
interps_notify (&interp::on_solib_loaded, so);
}
/* See interps.h. */
void
-interps_notify_solib_unloaded (so_list *so)
+interps_notify_solib_unloaded (const so_list &so)
{
interps_notify (&interp::on_solib_unloaded, so);
}
virtual void on_target_resumed (ptid_t ptid) {}
/* Notify the interpreter that solib SO has been loaded. */
- virtual void on_solib_loaded (so_list *so) {}
+ virtual void on_solib_loaded (const so_list &so) {}
/* Notify the interpreter that solib SO has been unloaded. */
- virtual void on_solib_unloaded (so_list *so) {}
+ virtual void on_solib_unloaded (const so_list &so) {}
/* Notify the interpreter that a command it is executing is about to cause
the inferior to proceed. */
extern void interps_notify_target_resumed (ptid_t ptid);
/* Notify all interpreters that solib SO has been loaded. */
-extern void interps_notify_solib_loaded (so_list *so);
+extern void interps_notify_solib_loaded (const so_list &so);
/* Notify all interpreters that solib SO has been unloaded. */
-extern void interps_notify_solib_unloaded (so_list *so);
+extern void interps_notify_solib_unloaded (const so_list &so);
/* Notify all interpreters that the selected traceframe changed.
continue;
ui_out_emit_tuple tuple_emitter (uiout, NULL);
- mi_output_solib_attribs (uiout, so);
+ mi_output_solib_attribs (uiout, *so);
}
}
/* See mi-interp.h. */
void
-mi_output_solib_attribs (ui_out *uiout, struct so_list *solib)
+mi_output_solib_attribs (ui_out *uiout, const so_list &solib)
{
gdbarch *gdbarch = current_inferior ()->arch ();
- uiout->field_string ("id", solib->so_original_name);
- uiout->field_string ("target-name", solib->so_original_name);
- uiout->field_string ("host-name", solib->so_name);
- uiout->field_signed ("symbols-loaded", solib->symbols_loaded);
+ uiout->field_string ("id", solib.so_original_name);
+ uiout->field_string ("target-name", solib.so_original_name);
+ uiout->field_string ("host-name", solib.so_name);
+ uiout->field_signed ("symbols-loaded", solib.symbols_loaded);
if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num);
ui_out_emit_list list_emitter (uiout, "ranges");
ui_out_emit_tuple tuple_emitter (uiout, NULL);
- if (solib->addr_high != 0)
+ if (solib.addr_high != 0)
{
- uiout->field_core_addr ("from", gdbarch, solib->addr_low);
- uiout->field_core_addr ("to", gdbarch, solib->addr_high);
+ uiout->field_core_addr ("from", gdbarch, solib.addr_low);
+ uiout->field_core_addr ("to", gdbarch, solib.addr_high);
}
}
void
-mi_interp::on_solib_loaded (so_list *solib)
+mi_interp::on_solib_loaded (const so_list &solib)
{
ui_out *uiout = this->interp_ui_out ();
}
void
-mi_interp::on_solib_unloaded (so_list *solib)
+mi_interp::on_solib_unloaded (const so_list &solib)
{
ui_out *uiout = this->interp_ui_out ();
ui_out_redirect_pop redir (uiout, this->event_channel);
- uiout->field_string ("id", solib->so_original_name);
- uiout->field_string ("target-name", solib->so_original_name);
- uiout->field_string ("host-name", solib->so_name);
+ uiout->field_string ("id", solib.so_original_name);
+ uiout->field_string ("target-name", solib.so_original_name);
+ uiout->field_string ("host-name", solib.so_name);
if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num);
void on_record_changed (inferior *inf, int started, const char *method,
const char *format) override;
void on_target_resumed (ptid_t ptid) override;
- void on_solib_loaded (so_list *so) override;
- void on_solib_unloaded (so_list *so) override;
+ void on_solib_loaded (const so_list &so) override;
+ void on_solib_unloaded (const so_list &so) override;
void on_about_to_proceed () override;
void on_traceframe_changed (int tfnum, int tpnum) override;
void on_tsv_created (const trace_state_variable *tsv) override;
/* Output the shared object attributes to UIOUT. */
-void mi_output_solib_attribs (ui_out *uiout, struct so_list *solib);
+void mi_output_solib_attribs (ui_out *uiout, const so_list &solib);
/* Returns the INTERP's data cast as mi_interp if INTERP is an MI, and
returns NULL otherwise. */
}
static CORE_ADDR
-lm_addr (struct so_list *so)
+lm_addr (const so_list &so)
{
- lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info;
+ const lm_info_svr4 *li = (const lm_info_svr4 *) so.lm_info;
return li->l_addr;
}
}
void
-nto_relocate_section_addresses (struct so_list *so, struct target_section *sec)
+nto_relocate_section_addresses (so_list &so, target_section *sec)
{
/* Neutrino treats the l_addr base address field in link.h as different than
the base address in the System V ABI and so the offset needs to be
char **nto_parse_redirection (char *start_argv[], const char **in,
const char **out, const char **err);
-void nto_relocate_section_addresses (struct so_list *,
- struct target_section *);
+void nto_relocate_section_addresses (so_list &, target_section *);
int nto_map_arch_to_cputype (const char *);
/* The shared library specified by SOLIB has been loaded. Note that
when gdb calls this observer, the library's symbols probably
haven't been loaded yet. */
-extern observable<struct so_list */* solib */> solib_loaded;
+extern observable<so_list &/* solib */> solib_loaded;
/* The shared library SOLIB has been unloaded from program space PSPACE.
Note when gdb calls this observer, the library's symbols have not
been unloaded yet, and thus are still available. */
-extern observable<struct program_space */* pspace */, struct so_list */* solib */>
- solib_unloaded;
+extern observable<program_space *, const so_list &/* solib */> solib_unloaded;
/* The symbol file specified by OBJFILE has been loaded. */
extern observable<struct objfile */* objfile */> new_objfile;
bool empty ();
/* Remove all target sections owned by OWNER. */
- void remove_target_sections (void *owner);
+ void remove_target_sections (const void *owner);
/* Add the sections array defined by SECTIONS to the
current set of target sections. */
- void add_target_sections (void *owner,
+ void add_target_sections (const void *owner,
const target_section_table §ions);
/* Add the sections of OBJFILE to the current set of target
/* Implement the "relocate_section_addresses" target_so_ops method. */
static void
-solib_aix_relocate_section_addresses (struct so_list *so,
- struct target_section *sec)
+solib_aix_relocate_section_addresses (so_list &so, target_section *sec)
{
struct bfd_section *bfd_sect = sec->the_bfd_section;
bfd *abfd = bfd_sect->owner;
const char *section_name = bfd_section_name (bfd_sect);
- lm_info_aix *info = (lm_info_aix *) so->lm_info;
+ lm_info_aix *info = (lm_info_aix *) so.lm_info;
if (strcmp (section_name, ".text") == 0)
{
/* Implement the "free_so" target_so_ops method. */
static void
-solib_aix_free_so (struct so_list *so)
+solib_aix_free_so (so_list &so)
{
- lm_info_aix *li = (lm_info_aix *) so->lm_info;
+ lm_info_aix *li = (lm_info_aix *) so.lm_info;
- solib_debug_printf ("%s", so->so_name);
+ solib_debug_printf ("%s", so.so_name);
delete li;
}
}
static void
-darwin_free_so (struct so_list *so)
+darwin_free_so (so_list &so)
{
- lm_info_darwin *li = (lm_info_darwin *) so->lm_info;
+ lm_info_darwin *li = (lm_info_darwin *) so.lm_info;
delete li;
}
Relocate these VMAs according to solib info. */
static void
-darwin_relocate_section_addresses (struct so_list *so,
- struct target_section *sec)
+darwin_relocate_section_addresses (so_list &so, target_section *sec)
{
- lm_info_darwin *li = (lm_info_darwin *) so->lm_info;
+ lm_info_darwin *li = (lm_info_darwin *) so.lm_info;
sec->addr += li->lm_addr;
sec->endaddr += li->lm_addr;
/* Best effort to set addr_high/addr_low. This is used only by
'info sharedlibary'. */
- if (so->addr_high == 0)
+ if (so.addr_high == 0)
{
- so->addr_low = sec->addr;
- so->addr_high = sec->endaddr;
+ so.addr_low = sec->addr;
+ so.addr_high = sec->endaddr;
}
- if (sec->endaddr > so->addr_high)
- so->addr_high = sec->endaddr;
- if (sec->addr < so->addr_low)
- so->addr_low = sec->addr;
+ if (sec->endaddr > so.addr_high)
+ so.addr_high = sec->endaddr;
+ if (sec->addr < so.addr_low)
+ so.addr_low = sec->addr;
}
\f
static gdb_bfd_ref_ptr
}
static void
-dsbt_free_so (struct so_list *so)
+dsbt_free_so (so_list &so)
{
- lm_info_dsbt *li = (lm_info_dsbt *) so->lm_info;
+ lm_info_dsbt *li = (lm_info_dsbt *) so.lm_info;
delete li;
}
static void
-dsbt_relocate_section_addresses (struct so_list *so,
- struct target_section *sec)
+dsbt_relocate_section_addresses (so_list &so, target_section *sec)
{
int seg;
- lm_info_dsbt *li = (lm_info_dsbt *) so->lm_info;
+ lm_info_dsbt *li = (lm_info_dsbt *) so.lm_info;
int_elf32_dsbt_loadmap *map = li->map;
for (seg = 0; seg < map->nsegs; seg++)
}
static void
-frv_free_so (struct so_list *so)
+frv_free_so (so_list &so)
{
- lm_info_frv *li = (lm_info_frv *) so->lm_info;
+ lm_info_frv *li = (lm_info_frv *) so.lm_info;
delete li;
}
static void
-frv_relocate_section_addresses (struct so_list *so,
- struct target_section *sec)
+frv_relocate_section_addresses (so_list &so, target_section *sec)
{
int seg;
- lm_info_frv *li = (lm_info_frv *) so->lm_info;
+ lm_info_frv *li = (lm_info_frv *) so.lm_info;
int_elf32_fdpic_loadmap *map = li->map;
for (seg = 0; seg < map->nsegs; seg++)
{
struct so_list *next = info->solib_list->next;
- free_so (info->solib_list);
+ free_so (*info->solib_list);
info->solib_list = next;
}
/* Relocate section addresses. */
static void
-rocm_solib_relocate_section_addresses (struct so_list *so,
+rocm_solib_relocate_section_addresses (so_list &so,
struct target_section *sec)
{
- if (!is_amdgpu_arch (gdbarch_from_bfd (so->abfd)))
+ if (!is_amdgpu_arch (gdbarch_from_bfd (so.abfd)))
{
svr4_so_ops.relocate_section_addresses (so, sec);
return;
}
- lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info;
+ lm_info_svr4 *li = (lm_info_svr4 *) so.lm_info;
sec->addr = sec->addr + li->l_addr;
sec->endaddr = sec->endaddr + li->l_addr;
}
}
static int
-svr4_same (struct so_list *gdb, struct so_list *inferior)
+svr4_same (const so_list &gdb, const so_list &inferior)
{
- if (!svr4_same_1 (gdb->so_original_name, inferior->so_original_name))
+ if (!svr4_same_1 (gdb.so_original_name, inferior.so_original_name))
return false;
/* There may be different instances of the same library, in different
namespaces. Each instance, however, must have been loaded at a
different address so its relocation offset would be different. */
- const lm_info_svr4 *lmg = (const lm_info_svr4 *) gdb->lm_info;
- const lm_info_svr4 *lmi = (const lm_info_svr4 *) inferior->lm_info;
+ const lm_info_svr4 *lmg = (const lm_info_svr4 *) gdb.lm_info;
+ const lm_info_svr4 *lmi = (const lm_info_svr4 *) inferior.lm_info;
return (lmg->l_addr_inferior == lmi->l_addr_inferior);
}
}
static CORE_ADDR
-lm_addr_check (const struct so_list *so, bfd *abfd)
+lm_addr_check (const so_list &so, bfd *abfd)
{
- lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info;
+ lm_info_svr4 *li = (lm_info_svr4 *) so.lm_info;
if (!li->l_addr_p)
{
gdb_printf (_("Using PIC (Position Independent Code) "
"prelink displacement %s for \"%s\".\n"),
paddress (current_inferior ()->arch (), l_addr),
- so->so_name);
+ so.so_name);
}
else
{
warning (_(".dynamic section for \"%s\" "
"is not at the expected address "
- "(wrong library or version mismatch?)"), so->so_name);
+ "(wrong library or version mismatch?)"), so.so_name);
}
}
/* Implementation for target_so_ops.free_so. */
static void
-svr4_free_so (struct so_list *so)
+svr4_free_so (so_list &so)
{
- lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info;
+ lm_info_svr4 *li = (lm_info_svr4 *) so.lm_info;
delete li;
}
/* Implement target_so_ops.clear_so. */
static void
-svr4_clear_so (struct so_list *so)
+svr4_clear_so (const so_list &so)
{
- lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info;
+ lm_info_svr4 *li = (lm_info_svr4 *) so.lm_info;
if (li != NULL)
li->l_addr_p = 0;
{
struct so_list *next = list->next;
- free_so (list);
+ free_so (*list);
list = next;
}
}
if (address_in_mem_range (li->l_ld, &vsyscall_range))
{
*sop = so->next;
- free_so (so);
+ free_so (*so);
break;
}
{
load_addr_found = 1;
loader_found_in_list = 1;
- load_addr = lm_addr_check (so, tmp_bfd.get ());
+ load_addr = lm_addr_check (*so, tmp_bfd.get ());
break;
}
}
static void
-svr4_relocate_section_addresses (struct so_list *so,
- struct target_section *sec)
+svr4_relocate_section_addresses (so_list &so, target_section *sec)
{
bfd *abfd = sec->the_bfd_section->owner;
so_list *solist = tuple.second;
for (; solist != nullptr; solist = solist->next)
- if (svr4_same (solib, solist))
+ if (svr4_same (*solib, *solist))
return debug_base;
}
}
static void
-solib_target_free_so (struct so_list *so)
+solib_target_free_so (so_list &so)
{
- lm_info_target *li = (lm_info_target *) so->lm_info;
+ lm_info_target *li = (lm_info_target *) so.lm_info;
gdb_assert (li->name.empty ());
}
static void
-solib_target_relocate_section_addresses (struct so_list *so,
- struct target_section *sec)
+solib_target_relocate_section_addresses (so_list &so, target_section *sec)
{
CORE_ADDR offset;
- lm_info_target *li = (lm_info_target *) so->lm_info;
+ lm_info_target *li = (lm_info_target *) so.lm_info;
/* Build the offset table only once per object file. We can not do
it any earlier, since we need to open the file first. */
if (li->offsets.empty ())
{
- int num_sections = gdb_bfd_count_sections (so->abfd);
+ int num_sections = gdb_bfd_count_sections (so.abfd);
li->offsets.assign (num_sections, 0);
asection *sect;
int num_alloc_sections = 0;
- for (i = 0, sect = so->abfd->sections;
+ for (i = 0, sect = so.abfd->sections;
sect != NULL;
i++, sect = sect->next)
if ((bfd_section_flags (sect) & SEC_ALLOC))
if (num_alloc_sections != li->section_bases.size ())
warning (_("\
Could not relocate shared library \"%s\": wrong number of ALLOC sections"),
- so->so_name);
+ so.so_name);
else
{
int bases_index = 0;
int found_range = 0;
- so->addr_low = ~(CORE_ADDR) 0;
- so->addr_high = 0;
- for (i = 0, sect = so->abfd->sections;
+ so.addr_low = ~(CORE_ADDR) 0;
+ so.addr_high = 0;
+ for (i = 0, sect = so.abfd->sections;
sect != NULL;
i++, sect = sect->next)
{
low = li->section_bases[i];
high = low + bfd_section_size (sect) - 1;
- if (low < so->addr_low)
- so->addr_low = low;
- if (high > so->addr_high)
- so->addr_high = high;
- gdb_assert (so->addr_low <= so->addr_high);
+ if (low < so.addr_low)
+ so.addr_low = low;
+ if (high > so.addr_high)
+ so.addr_high = high;
+ gdb_assert (so.addr_low <= so.addr_high);
found_range = 1;
}
li->offsets[i] = li->section_bases[bases_index];
bases_index++;
}
if (!found_range)
- so->addr_low = so->addr_high = 0;
- gdb_assert (so->addr_low <= so->addr_high);
+ so.addr_low = so.addr_high = 0;
+ gdb_assert (so.addr_low <= so.addr_high);
}
}
else if (!li->segment_bases.empty ())
{
symfile_segment_data_up data
- = get_symfile_segment_data (so->abfd);
+ = get_symfile_segment_data (so.abfd);
if (data == NULL)
warning (_("\
-Could not relocate shared library \"%s\": no segments"), so->so_name);
+Could not relocate shared library \"%s\": no segments"), so.so_name);
else
{
ULONGEST orig_delta;
int i;
- if (!symfile_map_offsets_to_segments (so->abfd, data.get (),
+ if (!symfile_map_offsets_to_segments (so.abfd, data.get (),
li->offsets,
li->segment_bases.size (),
li->segment_bases.data ()))
warning (_("\
-Could not relocate shared library \"%s\": bad offsets"), so->so_name);
+Could not relocate shared library \"%s\": bad offsets"), so.so_name);
/* Find the range of addresses to report for this library in
"info sharedlibrary". Report any consecutive segments
break;
}
- so->addr_low = li->segment_bases[0];
- so->addr_high = (data->segments[i - 1].base
+ so.addr_low = li->segment_bases[0];
+ so.addr_high = (data->segments[i - 1].base
+ data->segments[i - 1].size
+ orig_delta);
- gdb_assert (so->addr_low <= so->addr_high);
+ gdb_assert (so.addr_low <= so.addr_high);
}
}
}
expansion stuff?). */
static int
-solib_map_sections (struct so_list *so)
+solib_map_sections (so_list &so)
{
const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
- gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so->so_name));
+ gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so.so_name));
gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
gdb::unique_xmalloc_ptr<char> build_id_hexstr
- = get_cbfd_soname_build_id (current_program_space->cbfd, so->so_name);
+ = get_cbfd_soname_build_id (current_program_space->cbfd, so.so_name);
/* If we already know the build-id of this solib from a core file, verify
it matches ABFD's build-id. If there is a mismatch or the solib wasn't
{
scoped_fd fd = debuginfod_exec_query ((const unsigned char*)
build_id_hexstr.get (),
- 0, so->so_name, &filename);
+ 0, so.so_name, &filename);
if (fd.get () >= 0)
abfd = ops->bfd_open (filename.get ());
return 0;
/* Leave bfd open, core_xfer_memory and "info files" need it. */
- so->abfd = abfd.release ();
+ so.abfd = abfd.release ();
/* Copy the full path name into so_name, allowing symbol_file_add
to find it later. This also affects the =library-loaded GDB/MI
the library's host-side path. If we let the target dictate
that objfile's path, and the target is different from the host,
GDB/MI will not provide the correct host-side path. */
- if (strlen (bfd_get_filename (so->abfd)) >= SO_NAME_MAX_PATH_SIZE)
+ if (strlen (bfd_get_filename (so.abfd)) >= SO_NAME_MAX_PATH_SIZE)
error (_("Shared library file name is too long."));
- strcpy (so->so_name, bfd_get_filename (so->abfd));
+ strcpy (so.so_name, bfd_get_filename (so.abfd));
- if (so->sections == nullptr)
- so->sections = new target_section_table;
- *so->sections = build_section_table (so->abfd);
+ if (so.sections == nullptr)
+ so.sections = new target_section_table;
+ *so.sections = build_section_table (so.abfd);
- for (target_section &p : *so->sections)
+ for (target_section &p : *so.sections)
{
/* Relocate the section binding addresses as recorded in the shared
object's file by the base address to which the object was actually
/* If the target didn't provide information about the address
range of the shared object, assume we want the location of
the .text section. */
- if (so->addr_low == 0 && so->addr_high == 0
+ if (so.addr_low == 0 && so.addr_high == 0
&& strcmp (p.the_bfd_section->name, ".text") == 0)
{
- so->addr_low = p.addr;
- so->addr_high = p.endaddr;
+ so.addr_low = p.addr;
+ so.addr_high = p.endaddr;
}
}
section tables. Do this immediately after mapping the object so
that later nodes in the list can query this object, as is needed
in solib-osf.c. */
- current_program_space->add_target_sections (so, *so->sections);
+ current_program_space->add_target_sections (&so, *so.sections);
return 1;
}
responsible for taking care of that. */
static void
-clear_so (struct so_list *so)
+clear_so (so_list &so)
{
const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
- delete so->sections;
- so->sections = NULL;
+ delete so.sections;
+ so.sections = NULL;
- gdb_bfd_unref (so->abfd);
- so->abfd = NULL;
+ gdb_bfd_unref (so.abfd);
+ so.abfd = NULL;
/* Our caller closed the objfile, possibly via objfile_purge_solibs. */
- so->symbols_loaded = 0;
- so->objfile = NULL;
+ so.symbols_loaded = 0;
+ so.objfile = NULL;
- so->addr_low = so->addr_high = 0;
+ so.addr_low = so.addr_high = 0;
/* Restore the target-supplied file name. SO_NAME may be the path
of the symbol file. */
- strcpy (so->so_name, so->so_original_name);
+ strcpy (so.so_name, so.so_original_name);
/* Do the same for target-specific data. */
if (ops->clear_so != NULL)
responsible for taking care of that. */
void
-free_so (struct so_list *so)
+free_so (so_list &so)
{
const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
clear_so (so);
ops->free_so (so);
- xfree (so);
+ xfree (&so);
}
be chatty about it. Return true if any symbols were actually loaded. */
bool
-solib_read_symbols (struct so_list *so, symfile_add_flags flags)
+solib_read_symbols (so_list &so, symfile_add_flags flags)
{
- if (so->symbols_loaded)
+ if (so.symbols_loaded)
{
/* If needed, we've already warned in our caller. */
}
- else if (so->abfd == NULL)
+ else if (so.abfd == NULL)
{
/* We've already warned about this library, when trying to open
it. */
try
{
/* Have we already loaded this shared object? */
- so->objfile = nullptr;
+ so.objfile = nullptr;
for (objfile *objfile : current_program_space->objfiles ())
{
- if (filename_cmp (objfile_name (objfile), so->so_name) == 0
- && objfile->addr_low == so->addr_low)
+ if (filename_cmp (objfile_name (objfile), so.so_name) == 0
+ && objfile->addr_low == so.addr_low)
{
- so->objfile = objfile;
+ so.objfile = objfile;
break;
}
}
- if (so->objfile == NULL)
+ if (so.objfile == NULL)
{
section_addr_info sap
- = build_section_addr_info_from_section_table (*so->sections);
+ = build_section_addr_info_from_section_table (*so.sections);
gdb_bfd_ref_ptr tmp_bfd
- (gdb_bfd_ref_ptr::new_reference (so->abfd));
- so->objfile = symbol_file_add_from_bfd (tmp_bfd, so->so_name,
+ (gdb_bfd_ref_ptr::new_reference (so.abfd));
+ so.objfile = symbol_file_add_from_bfd (tmp_bfd, so.so_name,
flags, &sap,
OBJF_SHARED, NULL);
- so->objfile->addr_low = so->addr_low;
+ so.objfile->addr_low = so.addr_low;
}
- so->symbols_loaded = 1;
+ so.symbols_loaded = 1;
}
catch (const gdb_exception_error &e)
{
exception_fprintf (gdb_stderr, e, _("Error while reading shared"
" library symbols for %s:\n"),
- so->so_name);
+ so.so_name);
}
return true;
/* Notify interpreters and observers that solib SO has been loaded. */
static void
-notify_solib_loaded (so_list *so)
+notify_solib_loaded (so_list &so)
{
interps_notify_solib_loaded (so);
gdb::observers::solib_loaded.notify (so);
/* Notify interpreters and observers that solib SO has been unloaded. */
static void
-notify_solib_unloaded (program_space *pspace, so_list *so)
+notify_solib_unloaded (program_space *pspace, const so_list &so)
{
interps_notify_solib_unloaded (so);
gdb::observers::solib_unloaded.notify (pspace, so);
{
if (ops->same)
{
- if (ops->same (gdb, i))
+ if (ops->same (*gdb, *i))
break;
}
else
if (i)
{
*i_link = i->next;
- free_so (i);
+ free_so (*i);
gdb_link = &gdb->next;
gdb = *gdb_link;
}
{
/* Notify any observer that the shared object has been
unloaded before we remove it from GDB's tables. */
- notify_solib_unloaded (current_program_space, gdb);
+ notify_solib_unloaded (current_program_space, *gdb);
current_program_space->deleted_solibs.push_back (gdb->so_name);
gdb->objfile->unlink ();
/* Some targets' section tables might be referring to
- sections from so->abfd; remove them. */
+ sections from so.abfd; remove them. */
current_program_space->remove_target_sections (gdb);
- free_so (gdb);
+ free_so (*gdb);
gdb = *gdb_link;
}
}
try
{
/* Fill in the rest of the `struct so_list' node. */
- if (!solib_map_sections (i))
+ if (!solib_map_sections (*i))
{
not_found++;
if (not_found_filename == NULL)
/* Notify any observer that the shared object has been
loaded now that we've added it to GDB's tables. */
- notify_solib_loaded (i);
+ notify_solib_loaded (*i);
}
/* If a library was not found, issue an appropriate warning
/* Return non-zero if SO is the libpthread shared library. */
static bool
-libpthread_solib_p (struct so_list *so)
+libpthread_solib_p (const so_list &so)
{
- return libpthread_name_p (so->so_name);
+ return libpthread_name_p (so.so_name);
}
/* Read in symbolic information for any shared objects whose names
need the library symbols to be loaded in order to provide
thread support (x86-linux for instance). */
const int add_this_solib =
- (readsyms || libpthread_solib_p (gdb));
+ (readsyms || libpthread_solib_p (*gdb));
any_matches = true;
if (add_this_solib)
gdb_printf (_("Symbols already loaded for %s\n"),
gdb->so_name);
}
- else if (solib_read_symbols (gdb, add_flags))
+ else if (solib_read_symbols (*gdb, add_flags))
loaded_any_symbols = true;
}
}
/* See solib.h. */
bool
-solib_contains_address_p (const struct so_list *const solib,
+solib_contains_address_p (const so_list &solib,
CORE_ADDR address)
{
- if (solib->sections == nullptr)
+ if (solib.sections == nullptr)
return false;
- for (target_section &p : *solib->sections)
+ for (target_section &p : *solib.sections)
if (p.addr <= address && address < p.endaddr)
return true;
struct so_list *so = NULL;
for (so = pspace->so_list; so; so = so->next)
- if (solib_contains_address_p (so, address))
+ if (solib_contains_address_p (*so, address))
return (so->so_name);
return (0);
struct so_list *so = current_program_space->so_list;
current_program_space->so_list = so->next;
- notify_solib_unloaded (current_program_space, so);
+ notify_solib_unloaded (current_program_space, *so);
current_program_space->remove_target_sections (so);
- free_so (so);
+ free_so (*so);
}
if (ops->clear_solib != nullptr)
&& !solib_used (so))
so->objfile->unlink ();
current_program_space->remove_target_sections (so);
- clear_so (so);
+ clear_so (*so);
}
/* If this shared library is now associated with a new symbol
try
{
- solib_map_sections (so);
+ solib_map_sections (*so);
}
catch (const gdb_exception_error &e)
}
if (!got_error
- && (auto_solib_add || was_loaded || libpthread_solib_p (so)))
- solib_read_symbols (so, add_flags);
+ && (auto_solib_add || was_loaded || libpthread_solib_p (*so)))
+ solib_read_symbols (*so, add_flags);
}
}
}
/* Called to add symbols from a shared library to gdb's symbol table. */
extern void solib_add (const char *, int, int);
-extern bool solib_read_symbols (struct so_list *, symfile_add_flags);
+extern bool solib_read_symbols (so_list &, symfile_add_flags);
/* Function to be called when the inferior starts up, to discover the
names of shared libraries that are dynamically linked, the base
/* Return true if ADDR lies within SOLIB. */
-extern bool solib_contains_address_p (const struct so_list *, CORE_ADDR);
+extern bool solib_contains_address_p (const so_list &, CORE_ADDR);
/* Return whether the data starting at VADDR, size SIZE, must be kept
in a core file for shared libraries loaded before "gcore" is used
{
/* Adjust the section binding addresses by the base address at
which the object was actually mapped. */
- void (*relocate_section_addresses) (struct so_list *so,
- struct target_section *);
+ void (*relocate_section_addresses) (so_list &so, target_section *);
/* Free the link map info and any other private data structures
associated with a so_list entry. */
- void (*free_so) (struct so_list *so);
+ void (*free_so) (so_list &so);
/* Reset private data structures associated with SO.
This is called when SO is about to be reloaded.
It is also called before free_so when SO is about to be freed. */
- void (*clear_so) (struct so_list *so);
+ void (*clear_so) (const so_list &so);
/* Free private data structures associated to PSPACE. This method
should not free resources associated to individual so_list entries,
if they represent the same library.
Falls back to using strcmp on so_original_name field when set
to NULL. */
- int (*same) (struct so_list *gdb, struct so_list *inferior);
+ int (*same) (const so_list &gdb, const so_list &inferior);
/* Return whether a region of memory must be kept in a core file
for shared libraries loaded before "gcore" is used to be
using so_list_range = next_range<so_list>;
/* Free the memory associated with a (so_list *). */
-void free_so (struct so_list *so);
+void free_so (so_list &so);
/* A deleter that calls free_so. */
struct so_deleter
{
void operator() (struct so_list *so) const
{
- free_so (so);
+ free_so (*so);
}
};
and used by remove_target_sections.
For example, for executables it is a pointer to exec_bfd and
for shlibs it is the so_list pointer. */
- void *owner;
+ const void *owner;
};
/* Holds an array of target sections. */