/* Definitions for BFD wrappers used by GDB.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
This file is part of GDB.
#include "ui-out.h"
#include "gdbcmd.h"
#include "hashtab.h"
-#include "filestuff.h"
-#include "vec.h"
+#include "common/filestuff.h"
+#include "common/vec.h"
#ifdef HAVE_MMAP
#include <sys/mman.h>
#ifndef MAP_FAILED
#include "gdb/fileio.h"
#include "inferior.h"
-typedef bfd *bfdp;
-DEF_VEC_P (bfdp);
-
/* An object of this type is stored in the section's user data when
mapping a section. */
~gdb_bfd_data ()
{
- int ix;
- bfd *included_bfd;
-
- for (ix = 0;
- VEC_iterate (bfdp, included_bfds, ix, included_bfd);
- ++ix)
- gdb_bfd_unref (included_bfd);
- VEC_free (bfdp, included_bfds);
}
/* The reference count. */
bfd *archive_bfd = nullptr;
/* Table of all the bfds this bfd has included. */
- VEC (bfdp) *included_bfds = nullptr;
+ std::vector<gdb_bfd_ref_ptr> included_bfds;
/* The registry. */
REGISTRY_FIELDS = {};
host_address_to_string (abfd),
bfd_get_filename (abfd));
close (fd);
- return new_bfd_ref (abfd);
+ return gdb_bfd_ref_ptr::new_reference (abfd);
}
abfd = bfd_fopen (name, target, FOPEN_RB, fd);
*slot = abfd;
}
- return new_bfd_ref (abfd);
+ return gdb_bfd_ref_ptr::new_reference (abfd);
}
/* A helper function that releases any section data attached to the
data = NULL;
if (!bfd_get_full_section_contents (abfd, sectp, &data))
- error (_("Can't read data for section '%s' in file '%s'"),
- bfd_get_section_name (abfd, sectp),
- bfd_get_filename (abfd));
+ {
+ warning (_("Can't read data for section '%s' in file '%s'"),
+ bfd_get_section_name (abfd, sectp),
+ bfd_get_filename (abfd));
+ /* Set size to 0 to prevent further attempts to read the invalid
+ section. */
+ *size = 0;
+ return (const gdb_byte *) NULL;
+ }
descriptor->data = data;
done:
{
bfd *result = bfd_fopen (filename, target, mode, fd);
- return new_bfd_ref (result);
+ return gdb_bfd_ref_ptr::new_reference (result);
}
/* See gdb_bfd.h. */
{
bfd *result = bfd_openr (filename, target);
- return new_bfd_ref (result);
+ return gdb_bfd_ref_ptr::new_reference (result);
}
/* See gdb_bfd.h. */
{
bfd *result = bfd_openw (filename, target);
- return new_bfd_ref (result);
+ return gdb_bfd_ref_ptr::new_reference (result);
}
/* See gdb_bfd.h. */
open_func, open_closure,
pread_func, close_func, stat_func);
- return new_bfd_ref (result);
+ return gdb_bfd_ref_ptr::new_reference (result);
}
/* See gdb_bfd.h. */
{
struct gdb_bfd_data *gdata;
- gdb_bfd_ref (includee);
gdata = (struct gdb_bfd_data *) bfd_usrdata (includer);
- VEC_safe_push (bfdp, gdata->included_bfds, includee);
-}
-
-/* See gdb_bfd.h. */
-
-gdb_bfd_ref_ptr
-gdb_bfd_fdopenr (const char *filename, const char *target, int fd)
-{
- bfd *result = bfd_fdopenr (filename, target, fd);
-
- return new_bfd_ref (result);
+ gdata->included_bfds.push_back (gdb_bfd_ref_ptr::new_reference (includee));
}
\f