This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Use gdb_bfd_ref_ptr in target_bfd


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ade72a3453670d518ba14fe47bc7a64df81ce766

commit ade72a3453670d518ba14fe47bc7a64df81ce766
Author: Tom Tromey <tom@tromey.com>
Date:   Fri May 4 10:17:52 2018 -0600

    Use gdb_bfd_ref_ptr in target_bfd
    
    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.

Diff:
---
 gdb/ChangeLog    | 5 +++++
 gdb/bfd-target.c | 6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6005f54..7f7c547 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
 2018-05-04  Ulrich Weigand  <uweigand@de.ibm.com>
 
 	* spu-linux-nat.c (spu_linux_nat_target::wait): Fix syntax error.
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index ba194d7..6138d45 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);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]