x86: also optimize KXOR{D,Q} and KANDN{D,Q}
[deliverable/binutils-gdb.git] / gdb / gdb_bfd.c
index b60d237635a124e5e5fd3bca112ec5b147f1181d..8fedeb438da633f13ca57c22d425bcda6ac33cab 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions for BFD wrappers used by GDB.
 
-   Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   Copyright (C) 2011-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -34,9 +34,6 @@
 #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.  */
 
@@ -87,14 +84,6 @@ struct gdb_bfd_data
 
   ~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.  */
@@ -130,7 +119,7 @@ struct gdb_bfd_data
   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 = {};
@@ -461,7 +450,7 @@ gdb_bfd_open (const char *name, const char *target, int fd)
                            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);
@@ -481,7 +470,7 @@ gdb_bfd_open (const char *name, const char *target, int 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
@@ -713,9 +702,15 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
 
   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:
@@ -786,7 +781,7 @@ gdb_bfd_fopen (const char *filename, const char *target, const char *mode,
 {
   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.  */
@@ -796,7 +791,7 @@ gdb_bfd_openr (const char *filename, const char *target)
 {
   bfd *result = bfd_openr (filename, target);
 
-  return new_bfd_ref (result);
+  return gdb_bfd_ref_ptr::new_reference (result);
 }
 
 /* See gdb_bfd.h.  */
@@ -806,7 +801,7 @@ gdb_bfd_openw (const char *filename, const char *target)
 {
   bfd *result = bfd_openw (filename, target);
 
-  return new_bfd_ref (result);
+  return gdb_bfd_ref_ptr::new_reference (result);
 }
 
 /* See gdb_bfd.h.  */
@@ -831,7 +826,7 @@ gdb_bfd_openr_iovec (const char *filename, const char *target,
                                 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.  */
@@ -875,9 +870,8 @@ gdb_bfd_record_inclusion (bfd *includer, bfd *includee)
 {
   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);
+  gdata->included_bfds.push_back (gdb_bfd_ref_ptr::new_reference (includee));
 }
 
 /* See gdb_bfd.h.  */
@@ -887,7 +881,7 @@ gdb_bfd_fdopenr (const char *filename, const char *target, int fd)
 {
   bfd *result = bfd_fdopenr (filename, target, fd);
 
-  return new_bfd_ref (result);
+  return gdb_bfd_ref_ptr::new_reference (result);
 }
 
 \f
This page took 0.026158 seconds and 4 git commands to generate.