aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-aix.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2024-08-12 13:09:05 -0400
committerSimon Marchi <simon.marchi@efficios.com>2024-09-13 07:38:56 -0400
commitedb09798f2cd60b72591da9fe5f2e1bee50c5d83 (patch)
tree7206d3d1487dd5410317356f42fade2b9d76d29d /gdb/solib-aix.c
parent8b8f98ad2badcd859f429dd9c735671985aff762 (diff)
downloadbinutils-edb09798f2cd60b72591da9fe5f2e1bee50c5d83.zip
binutils-edb09798f2cd60b72591da9fe5f2e1bee50c5d83.tar.gz
binutils-edb09798f2cd60b72591da9fe5f2e1bee50c5d83.tar.bz2
gdb/solib: use owning_intrusive_list for solib list
Functions implementing `solib_ops::current_sos` return a list of solib object, transferring the ownership to their callers. However, the return type, `intrusive_list<solib>`, does not reflect that. Also, some of these functions build these lists incrementally, reading this from the target for each solib. If a target read were to throw, for instance, the already created solibs would just be leaked. Change `solib_ops::current_sos` to return an owning_intrusive_list to address that. Change `program_space::so_list` to be an owning_intrusive_list as well. This also saves us doing a few manual deletes. Change-Id: I6e4071d49744874491625075136c59cce8e608d4 Reviewed-by: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb/solib-aix.c')
-rw-r--r--gdb/solib-aix.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 1c319c2..926f1ed 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -444,7 +444,7 @@ solib_aix_solib_create_inferior_hook (int from_tty)
/* Implement the "current_sos" solib_ops method. */
-static intrusive_list<solib>
+static owning_intrusive_list<solib>
solib_aix_current_sos ()
{
std::optional<std::vector<lm_info_aix>> &library_list
@@ -452,14 +452,13 @@ solib_aix_current_sos ()
if (!library_list.has_value ())
return {};
- intrusive_list<solib> sos;
+ owning_intrusive_list<solib> sos;
/* Build a struct solib for each entry on the list.
We skip the first entry, since this is the entry corresponding
to the main executable, not a shared library. */
for (int ix = 1; ix < library_list->size (); ix++)
{
- solib *new_solib = new solib;
std::string so_name;
lm_info_aix &info = (*library_list)[ix];
@@ -481,12 +480,11 @@ solib_aix_current_sos ()
info.member_name.c_str ());
}
- new_solib->so_original_name = so_name;
- new_solib->so_name = so_name;
- new_solib->lm_info = std::make_unique<lm_info_aix> (info);
-
/* Add it to the list. */
- sos.push_back (*new_solib);
+ auto &new_solib = sos.emplace_back ();
+ new_solib.so_original_name = so_name;
+ new_solib.so_name = so_name;
+ new_solib.lm_info = std::make_unique<lm_info_aix> (info);
}
return sos;