]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make "cbfd" a gdb_bfd_ref_ptr
authorTom Tromey <tom@tromey.com>
Fri, 11 May 2018 18:36:19 +0000 (12:36 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 16 May 2018 17:45:03 +0000 (11:45 -0600)
This changes program_space::cbfd to be a gdb_bfd_ref_ptr.  This makes
it somewhat less error-prone to use, because now it manages the
reference counting automatically.

Tested by the buildbot.

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

* gdbcore.h (core_bfd): Redefine.
* corelow.c (core_target::close): Update.
(core_target_open): Update.
* progspace.h (struct program_space) <cbfd>: Now a
gdb_bfd_ref_ptr.

gdb/ChangeLog
gdb/corelow.c
gdb/gdbcore.h
gdb/progspace.h

index 65b9098bd303fbf80ed1d9fc3d002c04b3b511c1..b8d8fe641061f8fcab1b2fc29b52bc72960c4b6a 100644 (file)
@@ -1,3 +1,11 @@
+2018-05-16  Tom Tromey  <tom@tromey.com>
+
+       * gdbcore.h (core_bfd): Redefine.
+       * corelow.c (core_target::close): Update.
+       (core_target_open): Update.
+       * progspace.h (struct program_space) <cbfd>: Now a
+       gdb_bfd_ref_ptr.
+
 2018-05-16  Tom Tromey  <tom@tromey.com>
 
        PR cli/19551:
index 439fe1338a735d1ee252baa311eb81533b58767e..c6175279da9b5df4a006adff63b2251c240cf885 100644 (file)
@@ -270,8 +270,7 @@ core_target::close ()
          comments in clear_solib in solib.c.  */
       clear_solib ();
 
-      gdb_bfd_unref (core_bfd);
-      core_bfd = NULL;
+      current_program_space->cbfd.reset (nullptr);
     }
 
   /* Core targets are heap-allocated (see core_target_open), so here
@@ -406,7 +405,7 @@ core_target_open (const char *arg, int from_tty)
             filename.get (), bfd_errmsg (bfd_get_error ()));
     }
 
-  core_bfd = temp_bfd.release ();
+  current_program_space->cbfd = std::move (temp_bfd);
 
   core_target *target = new core_target ();
 
index 04a4b4767a0d3bdfbe83afffc5287c16054205f2..18ba0d72267e56763c9f8146f74d6888d95b74dc 100644 (file)
@@ -133,7 +133,7 @@ extern void specify_exec_file_hook (void (*hook) (const char *filename));
 
 /* Binary File Diddler for the core file.  */
 
-#define core_bfd (current_program_space->cbfd)
+#define core_bfd (current_program_space->cbfd.get ())
 
 /* Whether to open exec and core files read-only or read-write.  */
 
index 835fcfdd5d553504fb2fdccdd22662e03e637d8d..456911b29b1070893bed56b3ee64f1cd408e8274 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "target.h"
 #include "vec.h"
+#include "gdb_bfd.h"
 #include "gdb_vecs.h"
 #include "registry.h"
 
@@ -158,7 +159,7 @@ struct program_space
   char *pspace_exec_filename = NULL;
 
   /* Binary file diddling handle for the core file.  */
-  bfd *cbfd = NULL;
+  gdb_bfd_ref_ptr cbfd;
 
   /* The address space attached to this program space.  More than one
      program space may be bound to the same address space.  In the