diff options
author | Tom Tromey <tromey@redhat.com> | 2012-08-22 15:50:38 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-08-22 15:50:38 +0000 |
commit | e992eda4f6cece4cccbad807b1307168de924174 (patch) | |
tree | 807d0bed9e385f52d9a1e2a37e2d9749db76f5bc | |
parent | 6b81941e358ef95a24d90b971dd05f6c30dfa9a7 (diff) | |
download | gdb-e992eda4f6cece4cccbad807b1307168de924174.zip gdb-e992eda4f6cece4cccbad807b1307168de924174.tar.gz gdb-e992eda4f6cece4cccbad807b1307168de924174.tar.bz2 |
* 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.
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/gdb_bfd.c | 11 | ||||
-rw-r--r-- | gdb/gdb_bfd.h | 4 |
3 files changed, 23 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f274c43..4cf150c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 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. (REGISTRY_FIELDS): Redefine. (REGISTRY_ACCESS_FIELD): New macro. diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 5781d57..a346cfb 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -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); diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h index f131ba7..5fd361c 100644 --- a/gdb/gdb_bfd.h +++ b/gdb/gdb_bfd.h @@ -21,6 +21,10 @@ #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. */ |