-/* Buildsym's counterpart to struct compunit_symtab.
- TODO(dje): Move all related global state into here. */
-
-struct buildsym_compunit
-{
- /* Start recording information about a primary source file (IOW, not an
- included source file).
- COMP_DIR is the directory in which the compilation unit was compiled
- (or NULL if not known). */
-
- buildsym_compunit (struct objfile *objfile_, const char *name,
- const char *comp_dir_, enum language language_,
- CORE_ADDR last_addr)
- : objfile (objfile_),
- m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
- comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
- language (language_),
- m_last_source_start_addr (last_addr)
- {
- }
-
- ~buildsym_compunit ()
- {
- struct subfile *subfile, *nextsub;
-
- if (m_pending_macros != nullptr)
- free_macro_table (m_pending_macros);
-
- for (subfile = subfiles;
- subfile != NULL;
- subfile = nextsub)
- {
- nextsub = subfile->next;
- xfree (subfile->name);
- xfree (subfile->line_vector);
- xfree (subfile);
- }
- }
-
- void set_last_source_file (const char *name)
- {
- char *new_name = name == NULL ? NULL : xstrdup (name);
- m_last_source_file.reset (new_name);
- }
-
- struct macro_table *get_macro_table ()
- {
- if (m_pending_macros == nullptr)
- m_pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
- objfile->per_bfd->macro_cache,
- compunit_symtab);
- return m_pending_macros;
- }
-
- struct macro_table *release_macros ()
- {
- struct macro_table *result = m_pending_macros;
- m_pending_macros = nullptr;
- return result;
- }
-
- /* The objfile we're reading debug info from. */
- struct objfile *objfile;
-
- /* List of subfiles (source files).
- Files are added to the front of the list.
- This is important mostly for the language determination hacks we use,
- which iterate over previously added files. */
- struct subfile *subfiles = nullptr;
-
- /* The subfile of the main source file. */
- struct subfile *main_subfile = nullptr;
-
- /* Name of source file whose symbol data we are now processing. This
- comes from a symbol of type N_SO for stabs. For DWARF it comes
- from the DW_AT_name attribute of a DW_TAG_compile_unit DIE. */
- gdb::unique_xmalloc_ptr<char> m_last_source_file;
-
- /* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */
- gdb::unique_xmalloc_ptr<char> comp_dir;
-
- /* Space for this is not malloc'd, and is assumed to have at least
- the same lifetime as objfile. */
- const char *producer = nullptr;
-
- /* Space for this is not malloc'd, and is assumed to have at least
- the same lifetime as objfile. */
- const char *debugformat = nullptr;
-
- /* The compunit we are building. */
- struct compunit_symtab *compunit_symtab = nullptr;
-
- /* Language of this compunit_symtab. */
- enum language language;
-
- /* The macro table for the compilation unit whose symbols we're
- currently reading. */
- struct macro_table *m_pending_macros = nullptr;
-
- /* True if symtab has line number info. This prevents an otherwise
- empty symtab from being tossed. */
- bool m_have_line_numbers = false;
-
- /* Core address of start of text of current source file. This too
- comes from the N_SO symbol. For Dwarf it typically comes from the
- DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE. */
- CORE_ADDR m_last_source_start_addr;
-
- /* Stack of subfile names. */
- std::vector<const char *> m_subfile_stack;
-};
-
-/* The work-in-progress of the compunit we are building.
- This is created first, before any subfiles by start_symtab. */
-
-static struct buildsym_compunit *buildsym_compunit;
-
-/* List of free `struct pending' structures for reuse. */
-
-static struct pending *free_pendings;
-
-/* The mutable address map for the compilation unit whose symbols
- we're currently reading. The symtabs' shared blockvector will
- point to a fixed copy of this. */
-static struct addrmap *pending_addrmap;
-
-/* The obstack on which we allocate pending_addrmap.
- If pending_addrmap is NULL, this is uninitialized; otherwise, it is
- initialized (and holds pending_addrmap). */
-static struct obstack pending_addrmap_obstack;
-
-/* Non-zero if we recorded any ranges in the addrmap that are
- different from those in the blockvector already. We set this to
- zero when we start processing a symfile, and if it's still zero at
- the end, then we just toss the addrmap. */
-static int pending_addrmap_interesting;
-
-/* An obstack used for allocating pending blocks. */
-
-static struct obstack pending_block_obstack;
-