Move the context stack to buildsym_compunit

This moves the context stack globals to be members of
buildsym_compunit, changing the type to a std::vector in the process.

Because the callers expect the context stack object to be valid after
being popped, at Simon's suggestion I've changed pop_context to return
the object rather than the pointer.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* coffread.c (coff_symtab_read): Update.
	* xcoffread.c (read_xcoff_symtab): Update.
	* dwarf2read.c (new_symbol): Update.
	(read_func_scope, read_lexical_block_scope): Update.
	* dbxread.c (process_one_symbol): Update.
	* buildsym.h (context_stack, context_stack_depth): Don't declare.
	(outermost_context_p): Remove macro.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): Declare.
	(pop_context): Return struct context_stack.
	* buildsym.c (struct buildsym_compunit) <m_context_stack: New
	member.
	(context_stack_size): Remove.
	(INITIAL_CONTEXT_STACK_SIZE): Remove.
	(prepare_for_building, end_symtab_get_static_block)
	(augment_type_symtab, push_context): Update.
	(pop_context): Return struct context_stack.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): New functions.
	(buildsym_init): Update.
This commit is contained in:
Tom Tromey 2018-05-20 23:58:35 -06:00
parent 56ba65a047
commit a60f3166aa
7 changed files with 160 additions and 119 deletions

View file

@ -1100,7 +1100,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
break;
}
newobj = pop_context ();
struct context_stack cstk = pop_context ();
/* Stack must be empty now. */
if (!outermost_context_p () || newobj == NULL)
{
@ -1135,8 +1135,8 @@ coff_symtab_read (minimal_symbol_reader &reader,
enter_linenos (fcn_line_ptr, fcn_first_line,
fcn_last_line, objfile);
finish_block (newobj->name, &local_symbols, newobj->old_blocks,
NULL, newobj->start_addr,
finish_block (cstk.name, &local_symbols, cstk.old_blocks,
NULL, cstk.start_addr,
fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize
+ ANOFFSET (objfile->section_offsets,
@ -1163,8 +1163,8 @@ coff_symtab_read (minimal_symbol_reader &reader,
break;
}
newobj = pop_context ();
if (depth-- != newobj->depth)
struct context_stack cstk = pop_context ();
if (depth-- != cstk.depth)
{
complaint (_("Mismatched .eb symbol ignored "
"starting at symnum %d"),
@ -1177,11 +1177,11 @@ coff_symtab_read (minimal_symbol_reader &reader,
cs->c_value + ANOFFSET (objfile->section_offsets,
SECT_OFF_TEXT (objfile));
/* Make a block for the local symbols within. */
finish_block (0, &local_symbols, newobj->old_blocks, NULL,
newobj->start_addr, tmpaddr);
finish_block (0, &local_symbols, cstk.old_blocks, NULL,
cstk.start_addr, tmpaddr);
}
/* Now pop locals of block just finished. */
local_symbols = newobj->locals;
local_symbols = cstk.locals;
}
break;