This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[9/17] add a registry to BFD
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 14 Dec 2011 14:19:16 -0700
- Subject: [9/17] add a registry to BFD
This patch adds a registry to BFD.
We add the registry fields to the user-data we keep on the BFD and we
change the -ref and -unref functions to manage it.
This is where we will stick all the data we will share.
Tom
>From 1457686c30752300c65da41312ff5a5d4459bf94 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Mon, 5 Dec 2011 13:12:42 -0700
Subject: [PATCH 09/18] give a registry to BFD
* 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.
---
gdb/gdb_bfd.c | 11 +++++++++++
gdb/gdb_bfd.h | 4 ++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 84b612d..9d001f5 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -48,8 +48,16 @@ struct gdb_bfd_data
/* The mtime of the BFD at the point the cache entry was made. */
time_t mtime;
+
+ /* 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;
@@ -187,6 +195,8 @@ gdb_bfd_ref (struct bfd *abfd)
gdata->mtime = bfd_get_mtime (abfd);
bfd_usrdata (abfd) = gdata;
+ bfd_alloc_data (abfd);
+
return abfd;
}
@@ -223,6 +233,7 @@ gdb_bfd_unref (struct bfd *abfd)
htab_clear_slot (gdb_bfd_cache, slot);
}
+ bfd_free_data (abfd);
bfd_usrdata (abfd) = NULL; /* Paranoia. */
gdb_bfd_close_or_warn (abfd);
diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index 0f42c8f..a362c7f 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. */
--
1.7.6.4