Manage objfiles with shared_ptr
[deliverable/binutils-gdb.git] / gdb / objfiles.h
index 34240558da3d8823fd6206c356f0b8652a2b0cc3..f0ee8037b6ddc374afef244479dafb71d57bdb15 100644 (file)
 #include "registry.h"
 #include "gdb_bfd.h"
 #include "psymtab.h"
+#include <atomic>
 #include <bitset>
 #include <vector>
 #include "gdbsupport/next-iterator.h"
 #include "gdbsupport/safe-iterator.h"
 #include "bcache.h"
 #include "gdbarch.h"
+#include "gdbsupport/refcounted-object.h"
 
 struct htab;
 struct objfile_data;
@@ -399,11 +401,16 @@ 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:
 
+  /* Normally you should not call delete.  Instead, call 'unlink' to
+     remove it from the program space's list.  In some cases, you may
+     need to hold a reference to an objfile that is independent of its
+     existence on the program space's list; for this case, the
+     destructor must be public so that shared_ptr can reference
+     it.  */
+  ~objfile ();
+
   /* Create an objfile.  */
   static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_,
                        objfile *parent = nullptr);
This page took 0.023964 seconds and 4 git commands to generate.