From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 19/24] gdb: make so_list::abfd a gdb_bfd_ref_ptr
Date: Tue, 10 Oct 2023 16:40:14 -0400 [thread overview]
Message-ID: <20231010204213.111285-20-simon.marchi@efficios.com> (raw)
In-Reply-To: <20231010204213.111285-1-simon.marchi@efficios.com>
Change the field from a `bfd *` to a gdb_bfd_ref_ptr to automatically
manage the reference.
Change-Id: I3ace18bea985bc194c5e67bb559eec567e258950
---
gdb/solib-frv.c | 2 +-
gdb/solib-rocm.c | 2 +-
gdb/solib-target.c | 6 +++---
gdb/solib.c | 15 ++++++---------
gdb/solist.h | 2 +-
5 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 5cbab1493128..2ed6280b5879 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -920,7 +920,7 @@ frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point)
auto *li = gdb::checked_static_cast<lm_info_frv *> (so->lm_info.get ());
addr = find_canonical_descriptor_in_load_object
- (entry_point, got_value, name, so->abfd, li);
+ (entry_point, got_value, name, so->abfd.get (), li);
if (addr != 0)
break;
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 3bd5dec6d052..9a9bfa36fddb 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -175,7 +175,7 @@ static void
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.get ())))
{
svr4_so_ops.relocate_section_addresses (so, sec);
return;
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 3743c77e9c76..cccdfa83c9c5 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -291,7 +291,7 @@ solib_target_relocate_section_addresses (so_list &so, target_section *sec)
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.get ());
li->offsets.assign (num_sections, 0);
@@ -349,7 +349,7 @@ Could not relocate shared library \"%s\": wrong number of ALLOC sections"),
else if (!li->segment_bases.empty ())
{
symfile_segment_data_up data
- = get_symfile_segment_data (so.abfd);
+ = get_symfile_segment_data (so.abfd.get ());
if (data == NULL)
warning (_("\
@@ -359,7 +359,7 @@ Could not relocate shared library \"%s\": no segments"), so.so_name);
ULONGEST orig_delta;
int i;
- if (!symfile_map_offsets_to_segments (so.abfd, data.get (),
+ if (!symfile_map_offsets_to_segments (so.abfd.get (), data.get (),
li->offsets,
li->segment_bases.size (),
li->segment_bases.data ()))
diff --git a/gdb/solib.c b/gdb/solib.c
index fabb6e1d938b..6b7f0da0498d 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -580,7 +580,7 @@ solib_map_sections (so_list &so)
return 0;
/* Leave bfd open, core_xfer_memory and "info files" need it. */
- so.abfd = abfd.release ();
+ so.abfd = std::move (abfd);
/* Copy the full path name into so_name, allowing symbol_file_add
to find it later. This also affects the =library-loaded GDB/MI
@@ -588,11 +588,11 @@ solib_map_sections (so_list &so)
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.get ())) >= 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.get ()));
- so.sections = build_section_table (so.abfd);
+ so.sections = build_section_table (so.abfd.get ());
for (target_section &p : so.sections)
{
@@ -629,9 +629,7 @@ so_list::clear ()
const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
this->sections.clear ();
-
- gdb_bfd_unref (this->abfd);
- this->abfd = NULL;
+ this->abfd = nullptr;
/* Our caller closed the objfile, possibly via objfile_purge_solibs. */
this->symbols_loaded = 0;
@@ -706,8 +704,7 @@ solib_read_symbols (so_list &so, symfile_add_flags flags)
{
section_addr_info sap
= build_section_addr_info_from_section_table (so.sections);
- gdb_bfd_ref_ptr tmp_bfd
- (gdb_bfd_ref_ptr::new_reference (so.abfd));
+ gdb_bfd_ref_ptr tmp_bfd = so.abfd;
so.objfile = symbol_file_add_from_bfd (tmp_bfd, so.so_name,
flags, &sap,
OBJF_SHARED, NULL);
diff --git a/gdb/solist.h b/gdb/solist.h
index 51b985d53247..671f8812916c 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -76,7 +76,7 @@ struct so_list
current_sos must initialize these fields to 0. */
- bfd *abfd = nullptr;
+ gdb_bfd_ref_ptr abfd;
char symbols_loaded = 0; /* flag: symbols read in yet? */
/* objfile with symbols for a loaded library. Target memory is read from
--
2.42.0
next prev parent reply other threads:[~2023-10-10 20:46 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 20:39 [PATCH 00/24] C++ification of struct so_list Simon Marchi
2023-10-10 20:39 ` [PATCH 01/24] gdb: remove empty clear_solib functions Simon Marchi
2023-10-10 20:39 ` [PATCH 02/24] gdb: add program_space parameter to target_so_ops::clear_solib Simon Marchi
2023-10-17 14:57 ` Pedro Alves
2023-10-17 15:19 ` Simon Marchi
2023-10-10 20:39 ` [PATCH 03/24] gdb: make interps_notify work with references Simon Marchi
2023-10-11 8:48 ` Lancelot SIX
2023-10-11 14:18 ` Simon Marchi
2023-10-10 20:39 ` [PATCH 04/24] gdb: replace some so_list parameters to use references Simon Marchi
2023-10-19 11:07 ` [PATCH 4/24] " Lancelot SIX
2023-10-19 14:49 ` Simon Marchi
2023-10-19 15:20 ` Lancelot SIX
2023-10-19 16:07 ` Simon Marchi
2023-10-10 20:40 ` [PATCH 05/24] gdbsupport: use "reference" and "pointer" type aliases in intrusive_list Simon Marchi
2023-10-10 20:40 ` [PATCH 06/24] gdbsupport: make intrusive_list's disposer accept a reference Simon Marchi
2023-10-12 19:05 ` Pedro Alves
2023-10-14 20:12 ` Simon Marchi
2023-10-10 20:40 ` [PATCH 07/24] gdb: make get_cbfd_soname_build_id static Simon Marchi
2023-10-10 20:40 ` [PATCH 08/24] gdb: allocate so_list with new, deallocate with delete Simon Marchi
2023-10-10 20:40 ` [PATCH 09/24] gdb: rename lm_info_base to lm_info Simon Marchi
2023-10-10 20:40 ` [PATCH 10/24] gdb: remove target_so_ops::free_so Simon Marchi
2023-10-10 20:40 ` [PATCH 11/24] gdb: use gdb::checked_static_cast when casting lm_info Simon Marchi
2023-10-10 20:40 ` [PATCH 12/24] gdb: make solib-svr4 not use so_list internally Simon Marchi
2023-10-13 17:52 ` Lancelot SIX
2023-10-14 19:59 ` Simon Marchi
2023-10-19 11:08 ` Lancelot SIX
2023-10-19 14:50 ` Simon Marchi
2023-10-10 20:40 ` [PATCH 13/24] gdb: make solib-rocm " Simon Marchi
2023-10-13 18:35 ` Lancelot SIX
2023-10-14 20:00 ` Simon Marchi
2023-10-17 15:23 ` Pedro Alves
2023-10-17 15:32 ` Simon Marchi
2023-10-10 20:40 ` [PATCH 14/24] gdb: remove lm_info_vector typedef Simon Marchi
2023-10-10 20:40 ` [PATCH 15/24] gdb: make so_list::lm_info a unique_ptr Simon Marchi
2023-10-10 20:40 ` [PATCH 16/24] gdb: make clear_so a method of struct so_list Simon Marchi
2023-10-19 11:08 ` Lancelot SIX
2023-10-19 14:52 ` Simon Marchi
2023-10-10 20:40 ` [PATCH 17/24] gdb: remove target_section_table typedef Simon Marchi
2023-10-10 20:40 ` [PATCH 18/24] gdb: make so_list::sections not a pointer Simon Marchi
2023-10-10 20:40 ` Simon Marchi [this message]
2023-10-10 20:40 ` [PATCH 20/24] gdb: make so_list::{so_original_name,so_name} std::strings Simon Marchi
2023-10-13 22:28 ` [PATCH 20/24] gdb: make so_list::{so_original_name, so_name} std::strings Lancelot SIX
2023-10-14 20:01 ` Simon Marchi
2023-10-19 11:08 ` [PATCH 20/24] gdb: make so_list::{so_original_name,so_name} std::strings Lancelot SIX
2023-10-19 14:55 ` Simon Marchi
2023-10-10 20:40 ` [PATCH 21/24] gdb: link so_list using intrusive_list Simon Marchi
2023-10-17 19:14 ` Pedro Alves
2023-10-17 19:38 ` Simon Marchi
2023-10-10 20:40 ` [PATCH 22/24] gdb: don't call so_list::clear in free_so Simon Marchi
2023-10-10 20:40 ` [PATCH 23/24] gdb: remove free_so function Simon Marchi
2023-10-10 20:49 ` [PATCH 24/24] gdb: rename struct so_list to so Simon Marchi
2023-10-17 19:20 ` [PATCH 00/24] C++ification of struct so_list Pedro Alves
2023-10-17 19:53 ` Simon Marchi
2023-10-20 14:40 ` Pedro Alves
2023-10-19 11:09 ` [PATCH 0/24] " Lancelot SIX
2023-10-19 14:57 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231010204213.111285-20-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).