From 7ad0a42e88c09b4046205316bd6352dfb31afd79 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 10 Oct 2023 14:47:13 -0400 Subject: gdb: make so_list::lm_info a unique_ptr Make it a unique_ptr, so it gets automatically deleted when the so_list is deleted. Change-Id: Ib62d60ae2a80656239860b80e4359121c93da13d Approved-By: Pedro Alves Reviewed-By: Reviewed-By: Lancelot Six --- gdb/solib-frv.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gdb/solib-frv.c') diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 47a81b8..5cbab14 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -378,8 +378,7 @@ frv_current_sos (void) } so_list *sop = new so_list; - lm_info_frv *li = new lm_info_frv; - sop->lm_info = li; + auto li = gdb::make_unique (); li->map = loadmap; li->got_value = got_addr; li->lm_addr = lm_addr; @@ -402,6 +401,8 @@ frv_current_sos (void) strcpy (sop->so_original_name, sop->so_name); } + sop->lm_info = std::move (li); + *sos_next_ptr = sop; sos_next_ptr = &sop->next; } @@ -819,7 +820,7 @@ static void frv_relocate_section_addresses (so_list &so, target_section *sec) { int seg; - auto *li = gdb::checked_static_cast (so.lm_info); + auto *li = gdb::checked_static_cast (so.lm_info.get ()); int_elf32_fdpic_loadmap *map = li->map; for (seg = 0; seg < map->nsegs; seg++) @@ -860,7 +861,7 @@ frv_fdpic_find_global_pointer (CORE_ADDR addr) for (struct so_list *so : current_program_space->solibs ()) { int seg; - auto *li = gdb::checked_static_cast (so->lm_info); + auto *li = gdb::checked_static_cast (so->lm_info.get ()); int_elf32_fdpic_loadmap *map = li->map; for (seg = 0; seg < map->nsegs; seg++) @@ -916,7 +917,7 @@ frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point) { for (struct so_list *so : current_program_space->solibs ()) { - auto *li = gdb::checked_static_cast (so->lm_info); + auto *li = gdb::checked_static_cast (so->lm_info.get ()); addr = find_canonical_descriptor_in_load_object (entry_point, got_value, name, so->abfd, li); @@ -1068,7 +1069,7 @@ frv_fetch_objfile_link_map (struct objfile *objfile) of shared libraries. */ for (struct so_list *so : current_program_space->solibs ()) { - auto *li = gdb::checked_static_cast (so->lm_info); + auto *li = gdb::checked_static_cast (so->lm_info.get ()); if (so->objfile == objfile) return li->lm_addr; -- cgit v1.1