2018-07-16 Tom Tromey <tom@tromey.com>
+ * buildsym.c (~buildsym_compunit): Free the macro table.
+ (struct buildsym_compunit) <get_macro_table, release_macros>: New
+ methods.
+ <m_pending_macros>: New member.
+ (pending_macros): Remove.
+ (~scoped_free_pendings, get_macro_table, prepare_for_building)
+ (reset_symtab_globals, end_symtab_get_static_block)
+ (end_symtab_with_blockvector, augment_type_symtab)
+ (buildsym_init): Update.
+
+2018-07-16 Tom Tromey <tom@tromey.com>
+
* buildsym.c (buildsym_compunit::buildsym_compunit): Add name
parameter.
(buildsym_compunit::set_last_source_file): New method.
{
struct subfile *subfile, *nextsub;
+ if (m_pending_macros != nullptr)
+ free_macro_table (m_pending_macros);
+
for (subfile = subfiles;
subfile != NULL;
subfile = nextsub)
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;
/* 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;
};
/* The work-in-progress of the compunit we are building.
static struct subfile_stack *subfile_stack;
-/* The macro table for the compilation unit whose symbols we're
- currently reading. */
-static struct macro_table *pending_macros;
-
static void free_buildsym_compunit (void);
static int compare_line_numbers (const void *ln1p, const void *ln2p);
}
global_symbols = NULL;
- if (pending_macros)
- free_macro_table (pending_macros);
- pending_macros = NULL;
-
if (pending_addrmap)
obstack_free (&pending_addrmap_obstack, NULL);
pending_addrmap = NULL;
struct objfile *objfile;
gdb_assert (buildsym_compunit != NULL);
-
- objfile = buildsym_compunit->objfile;
-
- if (! pending_macros)
- {
- pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
- objfile->per_bfd->macro_cache,
- buildsym_compunit->compunit_symtab);
- }
-
- return pending_macros;
+ return buildsym_compunit->get_macro_table ();
}
\f
/* Init state to prepare for building a symtab.
gdb_assert (file_symbols == NULL);
gdb_assert (global_symbols == NULL);
gdb_assert (global_using_directives == NULL);
- gdb_assert (pending_macros == NULL);
gdb_assert (pending_addrmap == NULL);
gdb_assert (current_subfile == NULL);
gdb_assert (buildsym_compunit == nullptr);
global_symbols = NULL;
global_using_directives = NULL;
- /* We don't free pending_macros here because if the symtab was successfully
- built then ownership was transferred to the symtab. */
- pending_macros = NULL;
-
if (pending_addrmap)
obstack_free (&pending_addrmap_obstack, NULL);
pending_addrmap = NULL;
&& file_symbols == NULL
&& global_symbols == NULL
&& have_line_numbers == 0
- && pending_macros == NULL
+ && buildsym_compunit->m_pending_macros == NULL
&& global_using_directives == NULL)
{
/* Ignore symtabs that have no functions with real debugging info. */
COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
- COMPUNIT_MACRO_TABLE (cu) = pending_macros;
+ COMPUNIT_MACRO_TABLE (cu) = buildsym_compunit->release_macros ();
/* Default any symbols without a specified symtab to the primary symtab. */
{
}
if (pending_blocks != NULL)
complaint (_("Blocks in a type symtab"));
- if (pending_macros != NULL)
+ if (buildsym_compunit->m_pending_macros != NULL)
complaint (_("Macro in a type symtab"));
if (have_line_numbers)
complaint (_("Line numbers recorded in a type symtab"));
gdb_assert (file_symbols == NULL);
gdb_assert (global_symbols == NULL);
gdb_assert (global_using_directives == NULL);
- gdb_assert (pending_macros == NULL);
gdb_assert (pending_addrmap == NULL);
gdb_assert (buildsym_compunit == NULL);
}