aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdb_bfd.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2014-01-13 17:15:42 -0800
committerDoug Evans <dje@google.com>2014-01-13 17:15:42 -0800
commit13aaf454542c1028a033ac836d7a0d47c63a7029 (patch)
treeef8e7526a16ef704d182a4bb80a30dae3f07e3dc /gdb/gdb_bfd.c
parent067c5c1de23cff42597ec35d4c2a0730d8c16fbe (diff)
downloadgdb-13aaf454542c1028a033ac836d7a0d47c63a7029.zip
gdb-13aaf454542c1028a033ac836d7a0d47c63a7029.tar.gz
gdb-13aaf454542c1028a033ac836d7a0d47c63a7029.tar.bz2
PR symtab/16426
* dwarf2read.c (dwarf2_get_dwz_file): Call gdb_bfd_record_inclusion. (try_open_dwop_file): Ditto. * gdb_bfd.c: #include "vec.h". (bfdp): New typedef. (struct gdb_bfd_data): New member included_bfds. (gdb_bfd_unref): Unref all included bfds. (gdb_bfd_record_inclusion): New function. * gdb_bfd.h (gdb_bfd_record_inclusion): Declare.
Diffstat (limited to 'gdb/gdb_bfd.c')
-rw-r--r--gdb/gdb_bfd.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 5230d21..4d4b0a5 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -25,6 +25,7 @@
#include "gdbcmd.h"
#include "hashtab.h"
#include "filestuff.h"
+#include "vec.h"
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
@@ -35,6 +36,9 @@
#endif
#endif
+typedef bfd *bfdp;
+DEF_VEC_P (bfdp);
+
/* An object of this type is stored in the section's user data when
mapping a section. */
@@ -84,6 +88,9 @@ struct gdb_bfd_data
BFD. Otherwise, this is NULL. */
bfd *archive_bfd;
+ /* Table of all the bfds this bfd has included. */
+ VEC (bfdp) *included_bfds;
+
/* The registry. */
REGISTRY_FIELDS;
};
@@ -277,9 +284,10 @@ gdb_bfd_ref (struct bfd *abfd)
void
gdb_bfd_unref (struct bfd *abfd)
{
+ int ix;
struct gdb_bfd_data *gdata;
struct gdb_bfd_cache_search search;
- bfd *archive_bfd;
+ bfd *archive_bfd, *included_bfd;
if (abfd == NULL)
return;
@@ -307,6 +315,12 @@ gdb_bfd_unref (struct bfd *abfd)
htab_clear_slot (gdb_bfd_cache, slot);
}
+ for (ix = 0;
+ VEC_iterate (bfdp, gdata->included_bfds, ix, included_bfd);
+ ++ix)
+ gdb_bfd_unref (included_bfd);
+ VEC_free (bfdp, gdata->included_bfds);
+
bfd_free_data (abfd);
bfd_usrdata (abfd) = NULL; /* Paranoia. */
@@ -569,6 +583,18 @@ gdb_bfd_openr_next_archived_file (bfd *archive, bfd *previous)
/* See gdb_bfd.h. */
+void
+gdb_bfd_record_inclusion (bfd *includer, bfd *includee)
+{
+ struct gdb_bfd_data *gdata;
+
+ gdb_bfd_ref (includee);
+ gdata = bfd_usrdata (includer);
+ VEC_safe_push (bfdp, gdata->included_bfds, includee);
+}
+
+/* See gdb_bfd.h. */
+
bfd *
gdb_bfd_fdopenr (const char *filename, const char *target, int fd)
{