#include "registry.h"
#include "gdb_bfd.h"
#include "psymtab.h"
+#include <bitset>
#include <vector>
#include "common/next-iterator.h"
#include "common/safe-iterator.h"
+#include "bcache.h"
-struct bcache;
struct htab;
struct objfile_data;
struct partial_symbol;
: minsyms_read (false)
{}
+ ~objfile_per_bfd_storage ();
+
/* The storage has an obstack of its own. */
auto_obstack storage_obstack;
/* Byte cache for file names. */
- struct bcache *filename_cache = NULL;
+ struct bcache filename_cache;
/* Byte cache for macros. */
- struct bcache *macro_cache = NULL;
+ struct bcache macro_cache;
/* The gdbarch associated with the BFD. Note that this gdbarch is
determined solely from BFD information, without looking at target
name, and the second is the demangled name or just a zero byte
if the name doesn't demangle. */
- htab *demangled_names_hash = NULL;
+ htab_up demangled_names_hash;
/* The per-objfile information about the entry point, the scope (file/func)
containing the entry point, and the scope of the user's main() func. */
name and a zero value for the address. This makes it easy to walk
through the array when passed a pointer to somewhere in the middle
of it. There is also a count of the number of symbols, which does
- not include the terminating null symbol. The array itself, as well
- as all the data that it points to, should be allocated on the
- objfile_obstack for this file. */
+ not include the terminating null symbol. */
- minimal_symbol *msymbols = NULL;
+ gdb::unique_xmalloc_ptr<minimal_symbol> msymbols;
int minimal_symbol_count = 0;
/* The number of minimal symbols read, before any minimal symbol
minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE] {};
/* All the different languages of symbols found in the demangled
- hash table. A flat/vector-based map is more efficient than a map
- or hash table here, since this will only usually contain zero or
- one entries. */
- std::vector<enum language> demangled_hash_languages;
+ hash table. */
+ std::bitset<nr_languages> demangled_hash_languages;
+};
+
+/* An iterator that first returns a parent objfile, and then each
+ separate debug objfile. */
+
+class separate_debug_iterator
+{
+public:
+
+ explicit separate_debug_iterator (struct objfile *objfile)
+ : m_objfile (objfile),
+ m_parent (objfile)
+ {
+ }
+
+ bool operator!= (const separate_debug_iterator &other)
+ {
+ return m_objfile != other.m_objfile;
+ }
+
+ separate_debug_iterator &operator++ ();
+
+ struct objfile *operator* ()
+ {
+ return m_objfile;
+ }
+
+private:
+
+ struct objfile *m_objfile;
+ struct objfile *m_parent;
+};
+
+/* A range adapter wrapping separate_debug_iterator. */
+
+class separate_debug_range
+{
+public:
+
+ explicit separate_debug_range (struct objfile *objfile)
+ : m_objfile (objfile)
+ {
+ }
+
+ separate_debug_iterator begin ()
+ {
+ return separate_debug_iterator (m_objfile);
+ }
+
+ separate_debug_iterator end ()
+ {
+ return separate_debug_iterator (nullptr);
+ }
+
+private:
+
+ struct objfile *m_objfile;
};
/* Master structure for keeping track of each file from which
minimal_symbol_iterator begin () const
{
- return minimal_symbol_iterator (m_objfile->per_bfd->msymbols);
+ return minimal_symbol_iterator (m_objfile->per_bfd->msymbols.get ());
}
minimal_symbol_iterator end () const
{
return minimal_symbol_iterator
- (m_objfile->per_bfd->msymbols
+ (m_objfile->per_bfd->msymbols.get ()
+ m_objfile->per_bfd->minimal_symbol_count);
}
return msymbols_range (this);
}
+ /* Return a range adapter for iterating over all the separate debug
+ objfiles of this objfile. */
+
+ separate_debug_range separate_debug_objfiles ()
+ {
+ return separate_debug_range (this);
+ }
+
/* All struct objfile's are chained together by their next pointers.
The program space field "objfiles" (frequently referenced via
Very few blocks have a static link, so it's more memory efficient to
store these here rather than in struct block. Static links must be
allocated on the objfile's obstack. */
- htab_t static_links {};
+ htab_up static_links;
};
/* Declarations for functions defined in objfiles.c */
extern void build_objfile_section_table (struct objfile *);
-extern struct objfile *objfile_separate_debug_iterate (const struct objfile *,
- const struct objfile *);
-
extern void put_objfile_before (struct objfile *, struct objfile *);
extern void add_separate_debug_objfile (struct objfile *, struct objfile *);