Remove MULTI_OBJFILE_P
[deliverable/binutils-gdb.git] / gdb / objfiles.h
index dbd06c01e26448dd64d3dfc3aae176a746ed5ba5..0656cfe4a12f1f6e0280b804a49573e18c48c41c 100644 (file)
@@ -69,8 +69,8 @@ struct partial_symbol;
    testcase are broken for some targets.  In this test the functions
    are all implemented as part of one file and the testcase is not
    necessarily linked with a start file (depending on the target).
-   What happens is, that the first frame is printed normaly and
-   following frames are treated as being inside the enttry file then.
+   What happens is, that the first frame is printed normally and
+   following frames are treated as being inside the entry file then.
    This way, only the #0 frame is printed in the backtrace output.''
    Ref "frame.c" "NOTE: vinschen/2003-04-01".
 
@@ -244,11 +244,11 @@ struct objfile_per_bfd_storage
 
   /* Byte cache for file names.  */
 
-  struct bcache filename_cache;
+  gdb::bcache filename_cache;
 
   /* Byte cache for macros.  */
 
-  struct bcache macro_cache;
+  gdb::bcache macro_cache;
 
   /* The gdbarch associated with the BFD.  Note that this gdbarch is
      determined solely from BFD information, without looking at target
@@ -394,9 +394,24 @@ private:
 
 struct objfile
 {
+private:
+
+  /* The only way to create an objfile is to call objfile::make.  */
   objfile (bfd *, const char *, objfile_flags);
+
+  /* The only way to free an objfile is via 'unlink'.  */
   ~objfile ();
 
+public:
+
+  /* Create an objfile.  */
+  static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_,
+                       objfile *parent = nullptr);
+
+  /* Remove an objfile from the current program space, and free
+     it.  */
+  void unlink ();
+
   DISABLE_COPY_AND_ASSIGN (objfile);
 
   /* A range adapter that makes it possible to iterate over all
@@ -483,7 +498,7 @@ struct objfile
      This pointer is never NULL.  This does not have to be freed; it is
      guaranteed to have a lifetime at least as long as the objfile.  */
 
-  char *original_name = nullptr;
+  const char *original_name = nullptr;
 
   CORE_ADDR addr_low = 0;
 
@@ -627,6 +642,20 @@ struct objfile
   htab_up static_links;
 };
 
+/* A deleter for objfile.  */
+
+struct objfile_deleter
+{
+  void operator() (objfile *ptr) const
+  {
+    ptr->unlink ();
+  }
+};
+
+/* A unique pointer that holds an objfile.  */
+
+typedef std::unique_ptr<objfile, objfile_deleter> objfile_up;
+
 /* Declarations for functions defined in objfiles.c */
 
 extern struct gdbarch *get_objfile_arch (const struct objfile *);
@@ -637,12 +666,6 @@ extern CORE_ADDR entry_point_address (void);
 
 extern void build_objfile_section_table (struct objfile *);
 
-extern void put_objfile_before (struct objfile *, struct objfile *);
-
-extern void add_separate_debug_objfile (struct objfile *, struct objfile *);
-
-extern void unlink_objfile (struct objfile *);
-
 extern void free_objfile_separate_debug (struct objfile *);
 
 extern void free_all_objfiles (void);
@@ -750,10 +773,6 @@ extern void default_iterate_over_objfiles_in_search_order
    uninitialized section index.  */
 #define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
 
-/* Answer whether there is more than one object file loaded.  */
-
-#define MULTI_OBJFILE_P() (object_files && object_files->next)
-
 /* Reset the per-BFD storage area on OBJ.  */
 
 void set_objfile_per_bfd (struct objfile *obj);
This page took 0.025429 seconds and 4 git commands to generate.