gdb: remove free_so function

Remove this function, replace it with deleting the so_list in callers.

Change-Id: Idbd0cb84674ade1d8e17af471550dbd388264f60
Approved-By: Pedro Alves <pedro@palves.net>
Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
This commit is contained in:
Simon Marchi 2023-10-10 16:32:42 +00:00
parent 38dc8f35f9
commit 30932f4012
3 changed files with 5 additions and 35 deletions

View file

@ -1478,7 +1478,7 @@ svr4_current_sos ()
if (address_in_mem_range (li->l_ld, &vsyscall_range)) if (address_in_mem_range (li->l_ld, &vsyscall_range))
{ {
auto next = sos.erase (so); auto next = sos.erase (so);
free_so (*so); delete &*so;
so = next; so = next;
break; break;
} }

View file

@ -650,24 +650,6 @@ so_list::clear ()
lm_info::~lm_info () = default; lm_info::~lm_info () = default;
/* Free the storage associated with the `struct so_list' object SO.
If we have opened a BFD for SO, close it.
The caller is responsible for removing SO from whatever list it is
a member of. If we have placed SO's sections in some target's
section table, the caller is responsible for removing them.
This function doesn't mess with objfiles at all. If there is an
objfile associated with SO that needs to be removed, the caller is
responsible for taking care of that. */
void
free_so (so_list &so)
{
delete &so;
}
/* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS, /* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS,
be chatty about it. Return true if any symbols were actually loaded. */ be chatty about it. Return true if any symbols were actually loaded. */
@ -845,7 +827,7 @@ update_solib_list (int from_tty)
if (inferior_iter != inferior.end ()) if (inferior_iter != inferior.end ())
{ {
inferior.erase (inferior_iter); inferior.erase (inferior_iter);
free_so (*inferior_iter); delete &*inferior_iter;
++gdb_iter; ++gdb_iter;
} }
@ -871,7 +853,7 @@ update_solib_list (int from_tty)
sections from so.abfd; remove them. */ sections from so.abfd; remove them. */
current_program_space->remove_target_sections (&*gdb_iter); current_program_space->remove_target_sections (&*gdb_iter);
free_so (*gdb_iter); delete &*gdb_iter;
gdb_iter = gdb_iter_next; gdb_iter = gdb_iter_next;
} }
} }
@ -1215,7 +1197,7 @@ clear_solib (void)
{ {
notify_solib_unloaded (current_program_space, *so); notify_solib_unloaded (current_program_space, *so);
current_program_space->remove_target_sections (&so); current_program_space->remove_target_sections (&so);
free_so (*so); delete so;
}); });

View file

@ -169,20 +169,8 @@ struct target_so_ops
void (*handle_event) (void); void (*handle_event) (void);
}; };
/* Free the memory associated with a (so_list *). */
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);
}
};
/* A unique pointer to a so_list. */ /* A unique pointer to a so_list. */
typedef std::unique_ptr<so_list, so_deleter> so_list_up; using so_list_up = std::unique_ptr<so_list>;
/* Find main executable binary file. */ /* Find main executable binary file. */
extern gdb::unique_xmalloc_ptr<char> exec_file_find (const char *in_pathname, extern gdb::unique_xmalloc_ptr<char> exec_file_find (const char *in_pathname,