mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 04:24:43 +00:00
gdb/solib: pass lm_info, original_name and name to solib constructor
These values are always known at construction time, so pass them to the constructor. Add constructors to some lm_info_* types when it's easy and it makes things cleaner. Change-Id: Ie2d751be276470c10c81792a93bf3ddafbcd4c33 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -495,10 +495,8 @@ aix_solib_ops::current_sos () const
|
||||
}
|
||||
|
||||
/* Add it to the list. */
|
||||
auto &new_solib = sos.emplace_back (*this);
|
||||
new_solib.original_name = so_name;
|
||||
new_solib.name = so_name;
|
||||
new_solib.lm_info = std::make_unique<lm_info_aix> (info);
|
||||
sos.emplace_back (std::make_unique<lm_info_aix> (info), so_name, so_name,
|
||||
*this);
|
||||
}
|
||||
|
||||
return sos;
|
||||
|
||||
@@ -158,8 +158,12 @@ darwin_load_image_infos (struct darwin_info *info)
|
||||
|
||||
struct lm_info_darwin final : public lm_info
|
||||
{
|
||||
explicit lm_info_darwin (CORE_ADDR lm_addr)
|
||||
: lm_addr (lm_addr)
|
||||
{}
|
||||
|
||||
/* The target location of lm. */
|
||||
CORE_ADDR lm_addr = 0;
|
||||
CORE_ADDR lm_addr;
|
||||
};
|
||||
|
||||
/* Lookup the value for a specific symbol. */
|
||||
@@ -269,15 +273,8 @@ darwin_solib_ops::current_sos () const
|
||||
break;
|
||||
|
||||
/* Create and fill the new struct solib element. */
|
||||
auto &newobj = sos.emplace_back (*this);
|
||||
|
||||
auto li = std::make_unique<lm_info_darwin> ();
|
||||
|
||||
newobj.name = file_path.get ();
|
||||
newobj.original_name = newobj.name;
|
||||
li->lm_addr = load_addr;
|
||||
|
||||
newobj.lm_info = std::move (li);
|
||||
sos.emplace_back (std::make_unique<lm_info_darwin> (load_addr),
|
||||
file_path.get (), file_path.get (), *this);
|
||||
}
|
||||
|
||||
return sos;
|
||||
|
||||
@@ -144,13 +144,19 @@ make_dsbt_solib_ops (program_space *pspace)
|
||||
|
||||
struct lm_info_dsbt final : public lm_info
|
||||
{
|
||||
explicit lm_info_dsbt (int_elf32_dsbt_loadmap *map)
|
||||
: map (map)
|
||||
{}
|
||||
|
||||
DISABLE_COPY_AND_ASSIGN (lm_info_dsbt);
|
||||
|
||||
~lm_info_dsbt ()
|
||||
{
|
||||
xfree (this->map);
|
||||
}
|
||||
|
||||
/* The loadmap, digested into an easier to use form. */
|
||||
int_elf32_dsbt_loadmap *map = NULL;
|
||||
int_elf32_dsbt_loadmap *map;
|
||||
};
|
||||
|
||||
/* Per pspace dsbt specific data. */
|
||||
@@ -604,9 +610,6 @@ dsbt_solib_ops::current_sos () const
|
||||
break;
|
||||
}
|
||||
|
||||
auto &sop = sos.emplace_back (*this);
|
||||
auto li = std::make_unique<lm_info_dsbt> ();
|
||||
li->map = loadmap;
|
||||
/* Fetch the name. */
|
||||
addr = extract_unsigned_integer (lm_buf.l_name,
|
||||
sizeof (lm_buf.l_name),
|
||||
@@ -621,12 +624,12 @@ dsbt_solib_ops::current_sos () const
|
||||
if (solib_dsbt_debug)
|
||||
gdb_printf (gdb_stdlog, "current_sos: name = %s\n",
|
||||
name_buf.get ());
|
||||
|
||||
sop.name = name_buf.get ();
|
||||
sop.original_name = sop.name;
|
||||
}
|
||||
|
||||
sop.lm_info = std::move (li);
|
||||
sos.emplace_back (std::make_unique<lm_info_dsbt> (loadmap),
|
||||
name_buf != nullptr ? name_buf.get () : "",
|
||||
name_buf != nullptr ? name_buf.get () : "",
|
||||
*this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -809,8 +812,7 @@ dsbt_relocate_main_executable (void)
|
||||
ldm = info->exec_loadmap;
|
||||
|
||||
delete info->main_executable_lm_info;
|
||||
info->main_executable_lm_info = new lm_info_dsbt;
|
||||
info->main_executable_lm_info->map = ldm;
|
||||
info->main_executable_lm_info = new lm_info_dsbt (ldm);
|
||||
|
||||
objfile *objf = current_program_space->symfile_object_file;
|
||||
section_offsets new_offsets (objf->section_offsets.size ());
|
||||
|
||||
@@ -218,6 +218,13 @@ struct ext_link_map
|
||||
|
||||
struct lm_info_frv final : public lm_info
|
||||
{
|
||||
lm_info_frv (int_elf32_fdpic_loadmap *map, CORE_ADDR got_value,
|
||||
CORE_ADDR lm_addr)
|
||||
: map (map), got_value (got_value), lm_addr (lm_addr)
|
||||
{}
|
||||
|
||||
DISABLE_COPY_AND_ASSIGN (lm_info_frv);
|
||||
|
||||
~lm_info_frv ()
|
||||
{
|
||||
xfree (this->map);
|
||||
@@ -226,11 +233,11 @@ struct lm_info_frv final : public lm_info
|
||||
}
|
||||
|
||||
/* The loadmap, digested into an easier to use form. */
|
||||
int_elf32_fdpic_loadmap *map = NULL;
|
||||
int_elf32_fdpic_loadmap *map;
|
||||
/* The GOT address for this link map entry. */
|
||||
CORE_ADDR got_value = 0;
|
||||
CORE_ADDR got_value;
|
||||
/* The link map address, needed for frv_fetch_objfile_link_map(). */
|
||||
CORE_ADDR lm_addr = 0;
|
||||
CORE_ADDR lm_addr;
|
||||
|
||||
/* Cached dynamic symbol table and dynamic relocs initialized and
|
||||
used only by find_canonical_descriptor_in_load_object().
|
||||
@@ -385,13 +392,6 @@ frv_solib_ops::current_sos () const
|
||||
break;
|
||||
}
|
||||
|
||||
auto &sop = sos.emplace_back (*this);
|
||||
auto li = std::make_unique<lm_info_frv> ();
|
||||
li->map = loadmap;
|
||||
li->got_value = got_addr;
|
||||
li->lm_addr = lm_addr;
|
||||
sop.lm_info = std::move (li);
|
||||
|
||||
/* Fetch the name. */
|
||||
addr = extract_unsigned_integer (lm_buf.l_name,
|
||||
sizeof (lm_buf.l_name),
|
||||
@@ -403,11 +403,12 @@ frv_solib_ops::current_sos () const
|
||||
|
||||
if (name_buf == nullptr)
|
||||
warning (_("Can't read pathname for link map entry."));
|
||||
else
|
||||
{
|
||||
sop.name = name_buf.get ();
|
||||
sop.original_name = sop.name;
|
||||
}
|
||||
|
||||
sos.emplace_back (std::make_unique<lm_info_frv> (loadmap, got_addr,
|
||||
lm_addr),
|
||||
name_buf != nullptr ? name_buf.get () : "",
|
||||
name_buf != nullptr ? name_buf.get () : "",
|
||||
*this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -743,8 +744,7 @@ frv_relocate_main_executable (void)
|
||||
error (_("Unable to load the executable's loadmap."));
|
||||
|
||||
delete main_executable_lm_info;
|
||||
main_executable_lm_info = new lm_info_frv;
|
||||
main_executable_lm_info->map = ldm;
|
||||
main_executable_lm_info = new lm_info_frv (ldm, 0, 0);
|
||||
|
||||
objfile *objf = current_program_space->symfile_object_file;
|
||||
section_offsets new_offsets (objf->section_offsets.size ());
|
||||
|
||||
@@ -280,13 +280,8 @@ rocm_solib_ops::solibs_from_rocm_sos (const std::vector<rocm_so> &sos) const
|
||||
owning_intrusive_list<solib> dst;
|
||||
|
||||
for (const rocm_so &so : sos)
|
||||
{
|
||||
auto &newobj = dst.emplace_back (*this);
|
||||
|
||||
newobj.lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
|
||||
newobj.name = so.name;
|
||||
newobj.original_name = so.unique_name;
|
||||
}
|
||||
dst.emplace_back (std::make_unique<lm_info_svr4> (*so.lm_info),
|
||||
so.unique_name, so.name, *this);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
@@ -1069,13 +1069,8 @@ svr4_solib_ops::solibs_from_svr4_sos (const std::vector<svr4_so> &sos) const
|
||||
owning_intrusive_list<solib> dst;
|
||||
|
||||
for (const svr4_so &so : sos)
|
||||
{
|
||||
auto &newobj = dst.emplace_back (*this);
|
||||
|
||||
newobj.name = so.name;
|
||||
newobj.original_name = so.name;
|
||||
newobj.lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
|
||||
}
|
||||
dst.emplace_back (std::make_unique<lm_info_svr4> (*so.lm_info), so.name,
|
||||
so.name, *this);
|
||||
|
||||
return dst;
|
||||
}
|
||||
@@ -1275,11 +1270,8 @@ svr4_solib_ops::default_sos (svr4_info *info) const
|
||||
li->l_addr_p = 1;
|
||||
|
||||
owning_intrusive_list<solib> sos;
|
||||
auto &newobj = sos.emplace_back (*this);
|
||||
|
||||
newobj.lm_info = std::move (li);
|
||||
newobj.name = info->debug_loader_name;
|
||||
newobj.original_name = newobj.name;
|
||||
sos.emplace_back (std::move (li), info->debug_loader_name,
|
||||
info->debug_loader_name, *this);
|
||||
|
||||
return sos;
|
||||
}
|
||||
|
||||
@@ -249,14 +249,8 @@ target_solib_ops::current_sos () const
|
||||
|
||||
/* Build a struct solib for each entry on the list. */
|
||||
for (auto &library : library_list)
|
||||
{
|
||||
auto &new_solib = sos.emplace_back (*this);
|
||||
|
||||
/* We don't need a copy of the name in INFO anymore. */
|
||||
new_solib.name = std::move (library.name);
|
||||
new_solib.original_name = new_solib.name;
|
||||
new_solib.lm_info = std::move (library.info);
|
||||
}
|
||||
sos.emplace_back (std::move (library.info), library.name, library.name,
|
||||
*this);
|
||||
|
||||
return sos;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,13 @@ struct solib : intrusive_list_node<solib>
|
||||
/* Constructor
|
||||
|
||||
OPS is the solib_ops implementation providing this solib. */
|
||||
explicit solib (const solib_ops &ops) : m_ops (&ops) {}
|
||||
explicit solib (lm_info_up lm_info, std::string original_name,
|
||||
std::string name, const solib_ops &ops)
|
||||
: lm_info (std::move (lm_info)),
|
||||
original_name (std::move (original_name)),
|
||||
name (std::move (name)),
|
||||
m_ops (&ops)
|
||||
{}
|
||||
|
||||
/* Return the solib_ops implementation providing this solib. */
|
||||
const solib_ops &ops () const
|
||||
|
||||
Reference in New Issue
Block a user