aboutsummaryrefslogtreecommitdiff
path: root/gdb/buildsym.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-05-20 20:48:44 -0600
committerTom Tromey <tom@tromey.com>2018-07-16 08:55:21 -0600
commit8419ee5331d5b3253d2bfe1a039f12a167292dfc (patch)
tree4189e39729bab4385610cf6e17bc5e9b1761feb7 /gdb/buildsym.c
parentccdac490bb3b568e88626afc84017c79e2d086e7 (diff)
downloadgdb-8419ee5331d5b3253d2bfe1a039f12a167292dfc.zip
gdb-8419ee5331d5b3253d2bfe1a039f12a167292dfc.tar.gz
gdb-8419ee5331d5b3253d2bfe1a039f12a167292dfc.tar.bz2
Move the subfile stack to buildsym_compunit
This moves the global subfile_stack to be a member of buildsym_compunit. It also change this to be a std::vector, which simplifies the code. gdb/ChangeLog 2018-07-16 Tom Tromey <tom@tromey.com> * buildsym.h (push_subfile, pop_subfile): Update declarations. * buildsym.c (struct buildsym_compunit) <m_subfile_stack>: New member. (struct subfile_stack): Remove. (subfile_stack): Remove. (push_subfile, pop_subfile, buildsym_init): Update.
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r--gdb/buildsym.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 6db07ce..8d06cec 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -201,6 +201,9 @@ struct buildsym_compunit
comes from the N_SO symbol. For Dwarf it typically comes from the
DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE. */
CORE_ADDR m_last_source_start_addr;
+
+ /* Stack of subfile names. */
+ std::vector<const char *> m_subfile_stack;
};
/* The work-in-progress of the compunit we are building.
@@ -248,14 +251,6 @@ struct pending_block
static struct pending_block *pending_blocks;
-struct subfile_stack
- {
- struct subfile_stack *next;
- char *name;
- };
-
-static struct subfile_stack *subfile_stack;
-
/* Currently allocated size of context stack. */
static int context_stack_size;
@@ -885,27 +880,21 @@ patch_subfile_names (struct subfile *subfile, const char *name)
order. */
void
-push_subfile (void)
+push_subfile ()
{
- struct subfile_stack *tem = XNEW (struct subfile_stack);
-
- tem->next = subfile_stack;
- subfile_stack = tem;
+ gdb_assert (buildsym_compunit != nullptr);
gdb_assert (current_subfile != NULL && current_subfile->name != NULL);
- tem->name = current_subfile->name;
+ buildsym_compunit->m_subfile_stack.push_back (current_subfile->name);
}
-char *
-pop_subfile (void)
+const char *
+pop_subfile ()
{
- char *name;
- struct subfile_stack *link = subfile_stack;
-
- gdb_assert (link != NULL);
- name = link->name;
- subfile_stack = link->next;
- xfree ((void *) link);
- return (name);
+ gdb_assert (buildsym_compunit != nullptr);
+ gdb_assert (!buildsym_compunit->m_subfile_stack.empty ());
+ const char *name = buildsym_compunit->m_subfile_stack.back ();
+ buildsym_compunit->m_subfile_stack.pop_back ();
+ return name;
}
/* Add a linetable entry for line number LINE and address PC to the
@@ -1718,8 +1707,6 @@ get_last_source_start_addr ()
void
buildsym_init ()
{
- subfile_stack = NULL;
-
pending_addrmap_interesting = 0;
/* Context stack is initially empty. Allocate first one with room