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.
This commit is contained in:
parent
ccdac490bb
commit
8419ee5331
@ -1,3 +1,12 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2018-07-16 Tom Tromey <tom@tromey.com>
|
2018-07-16 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* buildsym.c (push_subfile): Use gdb_assert.
|
* buildsym.c (push_subfile): Use gdb_assert.
|
||||||
|
@ -201,6 +201,9 @@ struct buildsym_compunit
|
|||||||
comes from the N_SO symbol. For Dwarf it typically comes from the
|
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. */
|
DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE. */
|
||||||
CORE_ADDR m_last_source_start_addr;
|
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.
|
/* The work-in-progress of the compunit we are building.
|
||||||
@ -248,14 +251,6 @@ struct pending_block
|
|||||||
|
|
||||||
static struct pending_block *pending_blocks;
|
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. */
|
/* Currently allocated size of context stack. */
|
||||||
|
|
||||||
static int context_stack_size;
|
static int context_stack_size;
|
||||||
@ -885,27 +880,21 @@ patch_subfile_names (struct subfile *subfile, const char *name)
|
|||||||
order. */
|
order. */
|
||||||
|
|
||||||
void
|
void
|
||||||
push_subfile (void)
|
push_subfile ()
|
||||||
{
|
{
|
||||||
struct subfile_stack *tem = XNEW (struct subfile_stack);
|
gdb_assert (buildsym_compunit != nullptr);
|
||||||
|
|
||||||
tem->next = subfile_stack;
|
|
||||||
subfile_stack = tem;
|
|
||||||
gdb_assert (current_subfile != NULL && current_subfile->name != NULL);
|
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 *
|
const char *
|
||||||
pop_subfile (void)
|
pop_subfile ()
|
||||||
{
|
{
|
||||||
char *name;
|
gdb_assert (buildsym_compunit != nullptr);
|
||||||
struct subfile_stack *link = subfile_stack;
|
gdb_assert (!buildsym_compunit->m_subfile_stack.empty ());
|
||||||
|
const char *name = buildsym_compunit->m_subfile_stack.back ();
|
||||||
gdb_assert (link != NULL);
|
buildsym_compunit->m_subfile_stack.pop_back ();
|
||||||
name = link->name;
|
return name;
|
||||||
subfile_stack = link->next;
|
|
||||||
xfree ((void *) link);
|
|
||||||
return (name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a linetable entry for line number LINE and address PC to the
|
/* Add a linetable entry for line number LINE and address PC to the
|
||||||
@ -1718,8 +1707,6 @@ get_last_source_start_addr ()
|
|||||||
void
|
void
|
||||||
buildsym_init ()
|
buildsym_init ()
|
||||||
{
|
{
|
||||||
subfile_stack = NULL;
|
|
||||||
|
|
||||||
pending_addrmap_interesting = 0;
|
pending_addrmap_interesting = 0;
|
||||||
|
|
||||||
/* Context stack is initially empty. Allocate first one with room
|
/* Context stack is initially empty. Allocate first one with room
|
||||||
|
@ -186,9 +186,9 @@ extern void start_subfile (const char *name);
|
|||||||
|
|
||||||
extern void patch_subfile_names (struct subfile *subfile, const char *name);
|
extern void patch_subfile_names (struct subfile *subfile, const char *name);
|
||||||
|
|
||||||
extern void push_subfile (void);
|
extern void push_subfile ();
|
||||||
|
|
||||||
extern char *pop_subfile (void);
|
extern const char *pop_subfile ();
|
||||||
|
|
||||||
extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
|
extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
|
||||||
int expandable,
|
int expandable,
|
||||||
|
Loading…
Reference in New Issue
Block a user