#include "gdbcmd.h"
#include "hashtab.h"
#include "filestuff.h"
+#include "vec.h"
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#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. */
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;
};
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;
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. */
/* 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)
{