return &m_local_using_directives;
}
- void set_local_using_directives (struct using_direct *new_local)
- {
- m_local_using_directives = new_local;
- }
-
struct using_direct **get_global_using_directives ()
{
return &m_global_using_directives;
context_stack &push_context (CORE_ADDR valu);
- context_stack pop_context ();
+ /* Pop a context and create the corresponding block. Returns the
+ block. END_ADDR is the final address of the block. STATIC_LINK,
+ if provided, is the static link. REQUIRED controls whether the
+ block is required. When false, if the block does not contain any
+ variables or 'using' directives, this method will return
+ nullptr. */
+ block *pop_context (CORE_ADDR end_addr,
+ const struct dynamic_prop *static_link = nullptr,
+ bool required = true);
struct block *end_compunit_symtab_get_static_block
(CORE_ADDR end_addr, bool expandable, bool required);
CORE_ADDR highpc;
struct attribute *attr, *call_line, *call_file;
const char *name;
- struct block *block;
int inlined_func = (die->tag == DW_TAG_inlined_subroutine);
std::vector<struct symbol *> template_args;
struct template_symbol *templ_func = NULL;
gdb_assert (cu->get_builder () != nullptr);
context_stack &ctx = cu->get_builder ()->push_context (lowpc);
- ctx.name = new_symbol (die, read_type_die (die, cu), cu, templ_func);
+ symbol *func_sym = new_symbol (die, read_type_die (die, cu), cu, templ_func);
+ ctx.name = func_sym;
if (dwarf2_func_is_main_p (die, cu))
- set_objfile_main_name (objfile, ctx.name->linkage_name (),
+ set_objfile_main_name (objfile, func_sym->linkage_name (),
cu->lang ());
/* If there is a location expression for DW_AT_frame_base, record
it. */
attr = dwarf2_attr (die, DW_AT_frame_base, cu);
if (attr != nullptr)
- dwarf2_symbol_mark_computed (attr, ctx.name, cu, 1);
+ dwarf2_symbol_mark_computed (attr, func_sym, cu, 1);
/* If there is a location for the static link, record it. */
dynamic_prop *static_link = nullptr;
}
}
- struct context_stack cstk = cu->get_builder ()->pop_context ();
-
- /* Make a block for the local symbols within. */
- block = cu->get_builder ()->finish_block (cstk.name, cstk.old_blocks,
- static_link, lowpc, highpc);
+ block *block = cu->get_builder ()->pop_context (highpc, static_link);
/* For C++, set the block's scope. */
if ((cu->lang () == language_cplus
/* If we have address ranges, record them. */
dwarf2_record_block_ranges (die, block, cu);
- gdbarch_make_symbol_special (gdbarch, cstk.name, objfile);
+ gdbarch_make_symbol_special (gdbarch, func_sym, objfile);
/* Attach template arguments to function. */
if (!template_args.empty ())
for (symbol *sym : template_args)
sym->set_symtab (templ_func->symtab ());
}
-
- /* In C++, we can have functions nested inside functions (e.g., when
- a function declares a class that has methods). This means that
- when we finish processing a function scope, we may need to go
- back to building a containing block's symbol lists. */
- cu->get_builder ()->get_local_symbols () = std::move (cstk.locals);
- cu->get_builder ()->set_local_using_directives (cstk.local_using_directives);
}
/* Process all the DIES contained within a lexical block scope. Start
process_die (child_die, cu);
inherit_abstract_dies (die, cu);
- struct context_stack cstk = cu->get_builder ()->pop_context ();
- if (!cu->get_builder ()->get_local_symbols ().empty ()
- || (*cu->get_builder ()->get_local_using_directives ()) != NULL)
- {
- struct block *block
- = cu->get_builder ()->finish_block (0, cstk.old_blocks, NULL,
- cstk.start_addr, highpc);
+ block *block = cu->get_builder ()->pop_context (highpc, nullptr, false);
- /* Note that recording ranges after traversing children, as we
- do here, means that recording a parent's ranges entails
- walking across all its children's ranges as they appear in
- the address map, which is quadratic behavior.
+ /* Note that recording ranges after traversing children, as we
+ do here, means that recording a parent's ranges entails
+ walking across all its children's ranges as they appear in
+ the address map, which is quadratic behavior.
- It would be nicer to record the parent's ranges before
- traversing its children, simply overriding whatever you find
- there. But since we don't even decide whether to create a
- block until after we've traversed its children, that's hard
- to do. */
- dwarf2_record_block_ranges (die, block, cu);
- }
- cu->get_builder ()->get_local_symbols () = std::move (cstk.locals);
- cu->get_builder ()->set_local_using_directives (cstk.local_using_directives);
+ It would be nicer to record the parent's ranges before
+ traversing its children, simply overriding whatever you find
+ there. But since we don't even decide whether to create a
+ block until after we've traversed its children, that's hard
+ to do. */
+ if (block != nullptr)
+ dwarf2_record_block_ranges (die, block, cu);
}
static void dwarf2_ranges_read_low_addrs