]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gdb_bfd.h: Include registry.h. Use DECLARE_REGISTRY.
authorTom Tromey <tromey@redhat.com>
Wed, 22 Aug 2012 15:50:38 +0000 (15:50 +0000)
committerTom Tromey <tromey@redhat.com>
Wed, 22 Aug 2012 15:50:38 +0000 (15:50 +0000)
* gdb_bfd.c: Use DEFINE_REGISTRY.
(struct gdb_bfd_data): Add REGISTRY_FIELDS.
(gdb_bfd_ref): Call bfd_alloc_data.
(gdb_bfd_unref): Call bfd_free_data.

gdb/ChangeLog
gdb/gdb_bfd.c
gdb/gdb_bfd.h

index f274c4301f028722e9b4fe73c272de45ad05dba4..4cf150c268c860c8cc02926378f04a9839a6e0bc 100644 (file)
@@ -1,3 +1,11 @@
+2012-08-22  Tom Tromey  <tromey@redhat.com>
+
+       * gdb_bfd.h: Include registry.h.  Use DECLARE_REGISTRY.
+       * gdb_bfd.c: Use DEFINE_REGISTRY.
+       (struct gdb_bfd_data): Add REGISTRY_FIELDS.
+       (gdb_bfd_ref): Call bfd_alloc_data.
+       (gdb_bfd_unref): Call bfd_free_data.
+
 2012-08-22  Tom Tromey  <tromey@redhat.com>
 
        * registry.h (struct registry_fields): New.
index 5781d57070877fc759315c44c8a12785ef079b7e..a346cfbefa913812f7b98ade5613f39ae0b9f044 100644 (file)
@@ -85,8 +85,16 @@ struct gdb_bfd_data
   /* If the BFD comes from an archive, this points to the archive's
      BFD.  Otherwise, this is NULL.  */
   bfd *archive_bfd;
+
+  /* The registry.  */
+  REGISTRY_FIELDS;
 };
 
+#define GDB_BFD_DATA_ACCESSOR(ABFD) \
+  ((struct gdb_bfd_data *) bfd_usrdata (ABFD))
+
+DEFINE_REGISTRY (bfd, GDB_BFD_DATA_ACCESSOR)
+
 /* A hash table storing all the BFDs maintained in the cache.  */
 
 static htab_t gdb_bfd_cache;
@@ -256,6 +264,8 @@ gdb_bfd_ref (struct bfd *abfd)
   gdata->archive_bfd = NULL;
   bfd_usrdata (abfd) = gdata;
 
+  bfd_alloc_data (abfd);
+
   /* This is the first we've seen it, so add it to the hash table.  */
   slot = htab_find_slot (all_bfds, abfd, INSERT);
   gdb_assert (slot && !*slot);
@@ -297,6 +307,7 @@ gdb_bfd_unref (struct bfd *abfd)
        htab_clear_slot (gdb_bfd_cache, slot);
     }
 
+  bfd_free_data (abfd);
   bfd_usrdata (abfd) = NULL;  /* Paranoia.  */
 
   htab_remove_elt (all_bfds, abfd);
index f131ba777192427ad8cef9a33ad6d412e60aed45..5fd361cf8994de61a76aad5c351ed20b55ea6b07 100644 (file)
 #ifndef GDB_BFD_H
 #define GDB_BFD_H
 
+#include "registry.h"
+
+DECLARE_REGISTRY (bfd);
+
 /* Make a copy ABFD's filename using bfd_alloc, and reassign it to the
    BFD.  This ensures that the BFD's filename has the same lifetime as
    the BFD itself.  */