[binutils-gdb] Rename context_stack and make it private
Tom Tromey via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=45ae1b13a444e56fb7a068ed46839989a648b421 commit 45ae1b13a444e56fb7a068ed46839989a648b421 Author: Tom Tromey <[email protected]> Date: Wed Apr 15 13:22:52 2026 -0600 Rename context_stack and make it private "context_stack" has been misnamed at least since the storage was changed to a std::vector, and arguably even since the very beginning. This patch renames it to "lexical_context", which is a bit closer to what is is for. This type is also no longer used outside of buildsym itself -- callers can now push and pop contexts, but they don't act on the context object itself. So, the type is made private. One benefit of this approach is that callers no longer need to be quite as careful -- previously there was at least a possibility that a context object pointer would be invalidated when pushing and popping the stack. Approved-By: Simon Marchi <[email protected]> Diff: --- gdb/buildsym.c | 2 +- gdb/buildsym.h | 60 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 0ef1ea1cc2e..9799af17f32 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -944,7 +944,7 @@ buildsym_compunit::pop_context (CORE_ADDR end_addr, bool required) { gdb_assert (!m_context_stack.empty ()); - context_stack cstk = std::move (m_context_stack.back ()); + lexical_context cstk = std::move (m_context_stack.back ()); m_context_stack.pop_back (); block *result = nullptr; diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 02c411b053d..c9010665bce 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -68,35 +68,6 @@ struct subfile using subfile_up = std::unique_ptr<subfile>; -/* Stack representing unclosed lexical contexts (that will become - blocks, eventually). */ - -struct context_stack -{ - context_stack (std::vector<symbol *> locals, using_direct *local_using_directives, - pending_block *old_blocks, CORE_ADDR start_addr) - : locals (std::move (locals)), - local_using_directives (local_using_directives), - old_blocks (old_blocks), - start_addr (start_addr) - {} - - /* Outer locals at the time we entered. */ - std::vector<symbol *> locals; - - /* Pending using directives at the time we entered. */ - using_direct *local_using_directives; - - /* Pointer into blocklist as of entry. */ - pending_block *old_blocks; - - /* Name of function, if any, defining context. */ - symbol *name = nullptr; - - /* PC where this context starts. */ - CORE_ADDR start_addr; -}; - /* Flags associated with a linetable entry. */ enum linetable_entry_flag : unsigned @@ -340,9 +311,38 @@ private: /* Global "using" directives. */ struct using_direct *m_global_using_directives = nullptr; + /* Unclosed lexical contexts (that will become blocks, + eventually). */ + struct lexical_context + { + lexical_context (std::vector<symbol *> locals, + using_direct *local_using_directives, + pending_block *old_blocks, CORE_ADDR start_addr) + : locals (std::move (locals)), + local_using_directives (local_using_directives), + old_blocks (old_blocks), + start_addr (start_addr) + {} + + /* Outer locals at the time we entered. */ + std::vector<symbol *> locals; + + /* Pending using directives at the time we entered. */ + using_direct *local_using_directives; + + /* Pointer into blocklist as of entry. */ + pending_block *old_blocks; + + /* Name of function, if any, defining context. */ + symbol *name = nullptr; + + /* PC where this context starts. */ + CORE_ADDR start_addr; + }; + /* The stack of contexts that are pushed by push_context and popped by pop_context. */ - std::vector<struct context_stack> m_context_stack; + std::vector<lexical_context> m_context_stack; struct subfile *m_current_subfile = nullptr;