+/* An iterator for minimal symbols. */
+
+struct minimal_symbol_iterator
+{
+ typedef minimal_symbol_iterator self_type;
+ typedef struct minimal_symbol *value_type;
+ typedef struct minimal_symbol *&reference;
+ typedef struct minimal_symbol **pointer;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef int difference_type;
+
+ explicit minimal_symbol_iterator (struct minimal_symbol *msym)
+ : m_msym (msym)
+ {
+ }
+
+ value_type operator* () const
+ {
+ return m_msym;
+ }
+
+ bool operator== (const self_type &other) const
+ {
+ return m_msym == other.m_msym;
+ }
+
+ bool operator!= (const self_type &other) const
+ {
+ return m_msym != other.m_msym;
+ }
+
+ self_type &operator++ ()
+ {
+ ++m_msym;
+ return *this;
+ }
+
+private:
+ struct minimal_symbol *m_msym;
+};
+
+/* Some objfile data is hung off the BFD. This enables sharing of the
+ data across all objfiles using the BFD. The data is stored in an
+ instance of this structure, and associated with the BFD using the
+ registry system. */
+
+struct objfile_per_bfd_storage
+{
+ objfile_per_bfd_storage ()
+ : minsyms_read (false)
+ {}
+
+ ~objfile_per_bfd_storage ();
+
+ /* The storage has an obstack of its own. */
+
+ auto_obstack storage_obstack;
+
+ /* Byte cache for file names. */
+
+ gdb::bcache filename_cache;
+
+ /* Byte cache for macros. */
+
+ gdb::bcache macro_cache;
+
+ /* The gdbarch associated with the BFD. Note that this gdbarch is
+ determined solely from BFD information, without looking at target
+ information. The gdbarch determined from a running target may
+ differ from this e.g. with respect to register types and names. */
+
+ struct gdbarch *gdbarch = NULL;
+
+ /* Hash table for mapping symbol names to demangled names. Each
+ entry in the hash table is a demangled_name_entry struct, storing the
+ language and two consecutive strings, both null-terminated; the first one
+ is a mangled or linkage name, and the second is the demangled name or just
+ a zero byte if the name doesn't demangle. */
+
+ 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. */
+
+ entry_info ei {};
+
+ /* The name and language of any "main" found in this objfile. The
+ name can be NULL, which means that the information was not
+ recorded. */
+
+ const char *name_of_main = NULL;
+ enum language language_of_main = language_unknown;
+
+ /* Each file contains a pointer to an array of minimal symbols for all
+ global symbols that are defined within the file. The array is
+ terminated by a "null symbol", one that has a NULL pointer for the
+ 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. */
+
+ gdb::unique_xmalloc_ptr<minimal_symbol> msymbols;
+ int minimal_symbol_count = 0;
+
+ /* The number of minimal symbols read, before any minimal symbol
+ de-duplication is applied. Note in particular that this has only
+ a passing relationship with the actual size of the table above;
+ use minimal_symbol_count if you need the true size. */
+
+ int n_minsyms = 0;
+
+ /* This is true if minimal symbols have already been read. Symbol
+ readers can use this to bypass minimal symbol reading. Also, the
+ minimal symbol table management code in minsyms.c uses this to
+ suppress new minimal symbols. You might think that MSYMBOLS or
+ MINIMAL_SYMBOL_COUNT could be used for this, but it is possible
+ for multiple readers to install minimal symbols into a given
+ per-BFD. */
+
+ bool minsyms_read : 1;
+
+ /* This is a hash table used to index the minimal symbols by (mangled)
+ name. */
+
+ minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE] {};
+
+ /* This hash table is used to index the minimal symbols by their
+ demangled names. Uses a language-specific hash function via
+ search_name_hash. */
+
+ minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE] {};
+
+ /* All the different languages of symbols found in the demangled
+ 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;
+};
+