public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] Use gdb_bfd_ref_ptr in target_bfd
@ 2018-05-04 17:34 Tom Tromey
  2018-05-04 17:52 ` Pedro Alves
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2018-05-04 17:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that target_bfd was using manual reference counting for the
BFD it held.  This patch changes it to use gdb_bfd_ref_ptr instead.

Tested by the buildbot.

ChangeLog
2018-05-04  Tom Tromey  <tom@tromey.com>

	* bfd-target.c (target_bfd::m_bfd): Now a gdb_bfd_ref_ptr.
	(target_bfd::target_bfd, target_bfd::~target_bfd): Update.
---
 gdb/ChangeLog    | 5 +++++
 gdb/bfd-target.c | 6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index ba194d7b04..6138d450d9 100644
--- a/gdb/bfd-target.c
+++ b/gdb/bfd-target.c
@@ -53,7 +53,7 @@ public:
 
 private:
   /* The BFD we're wrapping.  */
-  struct bfd *m_bfd;
+  gdb_bfd_ref_ptr m_bfd;
 
   /* The section table build from the ALLOC sections in BFD.  Note
      that we can't rely on extracting the BFD from a random section in
@@ -90,10 +90,9 @@ target_bfd::get_section_table ()
 }
 
 target_bfd::target_bfd (struct bfd *abfd)
+  : m_bfd (gdb_bfd_ref_ptr::new_reference (abfd))
 {
   this->to_stratum = file_stratum;
-  m_bfd = abfd;
-  gdb_bfd_ref (abfd);
   m_table.sections = NULL;
   m_table.sections_end = NULL;
   build_section_table (abfd, &m_table.sections, &m_table.sections_end);
@@ -101,7 +100,6 @@ target_bfd::target_bfd (struct bfd *abfd)
 
 target_bfd::~target_bfd ()
 {
-  gdb_bfd_unref (m_bfd);
   xfree (m_table.sections);
 }
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFA] Use gdb_bfd_ref_ptr in target_bfd
  2018-05-04 17:34 [RFA] Use gdb_bfd_ref_ptr in target_bfd Tom Tromey
@ 2018-05-04 17:52 ` Pedro Alves
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2018-05-04 17:52 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 05/04/2018 06:34 PM, Tom Tromey wrote:
> I noticed that target_bfd was using manual reference counting for the
> BFD it held.  This patch changes it to use gdb_bfd_ref_ptr instead.
> 
> Tested by the buildbot.
> 
> ChangeLog
> 2018-05-04  Tom Tromey  <tom@tromey.com>
> 
> 	* bfd-target.c (target_bfd::m_bfd): Now a gdb_bfd_ref_ptr.
> 	(target_bfd::target_bfd, target_bfd::~target_bfd): Update.

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-04 17:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 17:34 [RFA] Use gdb_bfd_ref_ptr in target_bfd Tom Tromey
2018-05-04 17:52 ` Pedro Alves

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).