[5/6] gdb/buildsym: add constructor to context_stack
Commit Message
This makes it clearer what is set up front vs what is set later by
callers.
Change-Id: I2ee8d053c068f2b9ca37d48834aa688aeb6c0560
---
gdb/buildsym.c | 15 +++++----------
gdb/buildsym.h | 13 +++++++++++--
2 files changed, 16 insertions(+), 12 deletions(-)
Comments
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> This makes it clearer what is set up front vs what is set later by
Simon> callers.
Looks great, thank you.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
@@ -1064,17 +1064,12 @@ buildsym_compunit::augment_type_symtab ()
context_stack &
buildsym_compunit::push_context (int desc, CORE_ADDR valu)
{
- context_stack &ctx = m_context_stack.emplace_back ();
+ context_stack &ctx
+ = m_context_stack.emplace_back (m_local_symbols, m_local_using_directives,
+ m_pending_blocks, valu, desc);
- ctx.depth = desc;
- ctx.locals = m_local_symbols;
- ctx.old_blocks = m_pending_blocks;
- ctx.start_addr = valu;
- ctx.local_using_directives = m_local_using_directives;
- ctx.name = NULL;
-
- m_local_symbols = NULL;
- m_local_using_directives = NULL;
+ m_local_symbols = nullptr;
+ m_local_using_directives = nullptr;
return ctx;
}
@@ -86,6 +86,15 @@ struct pending
struct context_stack
{
+ context_stack (pending *locals, using_direct *local_using_directives,
+ pending_block *old_blocks, CORE_ADDR start_addr, int depth)
+ : locals (locals),
+ local_using_directives (local_using_directives),
+ old_blocks (old_blocks),
+ start_addr (start_addr),
+ depth (depth)
+ {}
+
/* Outer locals at the time we entered. */
pending *locals;
@@ -96,11 +105,11 @@ struct context_stack
pending_block *old_blocks;
/* Name of function, if any, defining context. */
- symbol *name;
+ symbol *name = nullptr;
/* Expression that computes the frame base of the lexically enclosing
function, if any. NULL otherwise. */
- dynamic_prop *static_link;
+ dynamic_prop *static_link = nullptr;
/* PC where this context starts. */
CORE_ADDR start_addr;