Add new_inferior, inferior_deleted, and new_thread events
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index 6e66a8e51fe97176f57fd0f9a8f68837cc332e9a..e743834df19149048acc4c2b01827f900bfcb8d4 100644 (file)
@@ -1,6 +1,6 @@
 /* GDB routines for manipulating objfiles.
 
-   Copyright (C) 1992-2016 Free Software Foundation, Inc.
+   Copyright (C) 1992-2017 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
@@ -142,18 +142,24 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
        {
          storage
            = ((struct objfile_per_bfd_storage *)
-              bfd_zalloc (abfd, sizeof (struct objfile_per_bfd_storage)));
+              bfd_alloc (abfd, sizeof (struct objfile_per_bfd_storage)));
          set_bfd_data (abfd, objfiles_bfd_data, storage);
        }
       else
-       storage = OBSTACK_ZALLOC (&objfile->objfile_obstack,
-                                 struct objfile_per_bfd_storage);
+       {
+         storage = (objfile_per_bfd_storage *)
+           obstack_alloc (&objfile->objfile_obstack,
+                          sizeof (objfile_per_bfd_storage));
+       }
+
+      /* objfile_per_bfd_storage is not trivially constructible, must
+        call the ctor manually.  */
+      storage = new (storage) objfile_per_bfd_storage ();
 
       /* Look up the gdbarch associated with the BFD.  */
       if (abfd != NULL)
        storage->gdbarch = gdbarch_from_bfd (abfd);
 
-      obstack_init (&storage->storage_obstack);
       storage->filename_cache = bcache_xmalloc (NULL, NULL);
       storage->macro_cache = bcache_xmalloc (NULL, NULL);
       storage->language_of_main = language_unknown;
@@ -171,7 +177,7 @@ free_objfile_per_bfd_storage (struct objfile_per_bfd_storage *storage)
   bcache_xfree (storage->macro_cache);
   if (storage->demangled_names_hash)
     htab_delete (storage->demangled_names_hash);
-  obstack_free (&storage->storage_obstack, 0);
+  storage->~objfile_per_bfd_storage ();
 }
 
 /* A wrapper for free_objfile_per_bfd_storage that can be passed as a
@@ -366,10 +372,10 @@ build_objfile_section_table (struct objfile *objfile)
    simply copied through to the new objfile flags member.  */
 
 struct objfile *
-allocate_objfile (bfd *abfd, const char *name, int flags)
+allocate_objfile (bfd *abfd, const char *name, objfile_flags flags)
 {
   struct objfile *objfile;
-  char *expanded_name;
+  const char *expanded_name;
 
   objfile = XCNEW (struct objfile);
   objfile->psymbol_cache = psymbol_bcache_init ();
@@ -379,22 +385,25 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
 
   objfile_alloc_data (objfile);
 
+  gdb::unique_xmalloc_ptr<char> name_holder;
   if (name == NULL)
     {
       gdb_assert (abfd == NULL);
       gdb_assert ((flags & OBJF_NOT_FILENAME) != 0);
-      expanded_name = xstrdup ("<<anonymous objfile>>");
+      expanded_name = "<<anonymous objfile>>";
     }
   else if ((flags & OBJF_NOT_FILENAME) != 0
           || is_target_filename (name))
-    expanded_name = xstrdup (name);
+    expanded_name = name;
   else
-    expanded_name = gdb_abspath (name);
+    {
+      name_holder = gdb_abspath (name);
+      expanded_name = name_holder.get ();
+    }
   objfile->original_name
     = (char *) obstack_copy0 (&objfile->objfile_obstack,
                              expanded_name,
                              strlen (expanded_name));
-  xfree (expanded_name);
 
   /* Update the per-objfile information that comes from the bfd, ensuring
      that any data that is reference is saved in the per-objfile data
@@ -1469,7 +1478,7 @@ find_pc_section (CORE_ADDR pc)
 /* Return non-zero if PC is in a section called NAME.  */
 
 int
-pc_in_section (CORE_ADDR pc, char *name)
+pc_in_section (CORE_ADDR pc, const char *name)
 {
   struct obj_section *s;
   int retval = 0;
@@ -1621,9 +1630,6 @@ objfile_flavour_name (struct objfile *objfile)
   return NULL;
 }
 
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-extern initialize_file_ftype _initialize_objfiles;
-
 void
 _initialize_objfiles (void)
 {
This page took 0.024584 seconds and 4 git commands to generate.