aboutsummaryrefslogtreecommitdiff
path: root/gdb/buildsym.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-05-21 09:12:54 -0600
committerTom Tromey <tom@tromey.com>2018-07-20 09:42:46 -0600
commite148f09d75af9e5c6af5136fee3a5a298114d41f (patch)
tree0f9ca53921bd325bae5d3cd079cead946204ac60 /gdb/buildsym.c
parent93b8bea4143cafae79076076c64aaa4c46a9b73c (diff)
downloadgdb-e148f09d75af9e5c6af5136fee3a5a298114d41f.zip
gdb-e148f09d75af9e5c6af5136fee3a5a298114d41f.tar.gz
gdb-e148f09d75af9e5c6af5136fee3a5a298114d41f.tar.bz2
Move the symbol lists to buildsym_compunit
This moves the global symbol lists into buildsym_compunit, adds accessors, and updates all the users. gdb/ChangeLog 2018-07-20 Tom Tromey <tom@tromey.com> * xcoffread.c (read_xcoff_symtab, process_xcoff_symbol): Update. * stabsread.c (patch_block_stabs, define_symbol, read_type) (read_enum_type, common_block_start, common_block_end) (cleanup_undefined_types_1, finish_global_stabs): Update. * mdebugread.c (psymtab_to_symtab_1): Update. * dwarf2read.c (fixup_go_packaging, read_func_scope) (read_lexical_block_scope, new_symbol): Update. * dbxread.c (process_one_symbol): Update. * coffread.c (coff_symtab_read, process_coff_symbol) (coff_read_enum_type): Update. * buildsym.h (file_symbols, global_symbols, local_symbols): Don't declare. (get_local_symbols, get_file_symbols, get_global_symbols): New functions. * buildsym.c (~buildsym_compunit): Clean up m_file_symbols and m_global_symbols. <m_file_symbols, m_local_symbols, m_global_symbols>: New members. (~scoped_free_pendings): Update. (finish_block, prepare_for_building, reset_symtab_globals) (end_symtab_get_static_block, end_symtab_with_blockvector) (augment_type_symtab, push_context): Update. (get_local_symbols, get_file_symbols, get_global_symbols): New functions. (buildsym_init): Update.
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r--gdb/buildsym.c107
1 files changed, 65 insertions, 42 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 59b08f0..5503132 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -131,6 +131,20 @@ struct buildsym_compunit
xfree (subfile->line_vector);
xfree (subfile);
}
+
+ struct pending *next, *next1;
+
+ for (next = m_file_symbols; next != NULL; next = next1)
+ {
+ next1 = next->next;
+ xfree ((void *) next);
+ }
+
+ for (next = m_global_symbols; next != NULL; next = next1)
+ {
+ next1 = next->next;
+ xfree ((void *) next);
+ }
}
void set_last_source_file (const char *name)
@@ -249,6 +263,15 @@ struct buildsym_compunit
are just waiting to be built into a blockvector when finalizing the
associated symtab. */
struct pending_block *m_pending_blocks = nullptr;
+
+ /* Pending static symbols and types at the top level. */
+ struct pending *m_file_symbols = nullptr;
+
+ /* Pending global functions and variables. */
+ struct pending *m_global_symbols = nullptr;
+
+ /* Pending symbols that are local to the lexical context. */
+ struct pending *m_local_symbols = nullptr;
};
/* The work-in-progress of the compunit we are building.
@@ -339,22 +362,6 @@ find_symbol_in_list (struct pending *list, char *name, int length)
scoped_free_pendings::~scoped_free_pendings ()
{
- struct pending *next, *next1;
-
- for (next = file_symbols; next != NULL; next = next1)
- {
- next1 = next->next;
- xfree ((void *) next);
- }
- file_symbols = NULL;
-
- for (next = global_symbols; next != NULL; next = next1)
- {
- next1 = next->next;
- xfree ((void *) next);
- }
- global_symbols = NULL;
-
free_buildsym_compunit ();
}
@@ -559,7 +566,8 @@ finish_block (struct symbol *symbol,
const struct dynamic_prop *static_link,
CORE_ADDR start, CORE_ADDR end)
{
- return finish_block_internal (symbol, &local_symbols, old_blocks, static_link,
+ return finish_block_internal (symbol, &buildsym_compunit->m_local_symbols,
+ old_blocks, static_link,
start, end, 0, 0);
}
@@ -985,12 +993,8 @@ get_macro_table (void)
static void
prepare_for_building ()
{
- local_symbols = NULL;
-
/* These should have been reset either by successful completion of building
a symtab, or by the scoped_free_pendings destructor. */
- gdb_assert (file_symbols == NULL);
- gdb_assert (global_symbols == NULL);
gdb_assert (buildsym_compunit == nullptr);
}
@@ -1140,10 +1144,6 @@ watch_main_source_file_lossage (void)
static void
reset_symtab_globals (void)
{
- local_symbols = NULL;
- file_symbols = NULL;
- global_symbols = NULL;
-
free_buildsym_compunit ();
}
@@ -1230,8 +1230,8 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
if (!required
&& buildsym_compunit->m_pending_blocks == NULL
- && file_symbols == NULL
- && global_symbols == NULL
+ && buildsym_compunit->m_file_symbols == NULL
+ && buildsym_compunit->m_global_symbols == NULL
&& !buildsym_compunit->m_have_line_numbers
&& buildsym_compunit->m_pending_macros == NULL
&& buildsym_compunit->m_global_using_directives == NULL)
@@ -1242,7 +1242,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
else
{
/* Define the STATIC_BLOCK. */
- return finish_block_internal (NULL, &file_symbols, NULL, NULL,
+ return finish_block_internal (NULL, get_file_symbols (), NULL, NULL,
buildsym_compunit->m_last_source_start_addr,
end_addr, 0, expandable);
}
@@ -1270,7 +1270,7 @@ end_symtab_with_blockvector (struct block *static_block,
end_addr = BLOCK_END (static_block);
/* Create the GLOBAL_BLOCK and build the blockvector. */
- finish_block_internal (NULL, &global_symbols, NULL, NULL,
+ finish_block_internal (NULL, get_global_symbols (), NULL, NULL,
buildsym_compunit->m_last_source_start_addr, end_addr,
1, expandable);
blockvector = make_blockvector ();
@@ -1538,26 +1538,27 @@ augment_type_symtab (void)
if (buildsym_compunit->m_have_line_numbers)
complaint (_("Line numbers recorded in a type symtab"));
- if (file_symbols != NULL)
+ if (buildsym_compunit->m_file_symbols != NULL)
{
struct block *block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
- set_missing_symtab (file_symbols, cust);
+ set_missing_symtab (buildsym_compunit->m_file_symbols, cust);
- dict_add_pending (BLOCK_DICT (block), file_symbols);
+ dict_add_pending (BLOCK_DICT (block), buildsym_compunit->m_file_symbols);
}
- if (global_symbols != NULL)
+ if (buildsym_compunit->m_global_symbols != NULL)
{
struct block *block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
- set_missing_symtab (global_symbols, cust);
+ set_missing_symtab (buildsym_compunit->m_global_symbols, cust);
- dict_add_pending (BLOCK_DICT (block), global_symbols);
+ dict_add_pending (BLOCK_DICT (block),
+ buildsym_compunit->m_global_symbols);
}
reset_symtab_globals ();
@@ -1576,14 +1577,14 @@ push_context (int desc, CORE_ADDR valu)
struct context_stack *newobj = &buildsym_compunit->m_context_stack.back ();
newobj->depth = desc;
- newobj->locals = local_symbols;
+ newobj->locals = buildsym_compunit->m_local_symbols;
newobj->old_blocks = buildsym_compunit->m_pending_blocks;
newobj->start_addr = valu;
newobj->local_using_directives
= buildsym_compunit->m_local_using_directives;
newobj->name = NULL;
- local_symbols = NULL;
+ buildsym_compunit->m_local_symbols = NULL;
buildsym_compunit->m_local_using_directives = NULL;
return newobj;
@@ -1721,6 +1722,33 @@ get_current_subfile ()
return buildsym_compunit->m_current_subfile;
}
+/* See buildsym.h. */
+
+struct pending **
+get_local_symbols ()
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return &buildsym_compunit->m_local_symbols;
+}
+
+/* See buildsym.h. */
+
+struct pending **
+get_file_symbols ()
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return &buildsym_compunit->m_file_symbols;
+}
+
+/* See buildsym.h. */
+
+struct pending **
+get_global_symbols ()
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return &buildsym_compunit->m_global_symbols;
+}
+
/* Initialize anything that needs initializing when starting to read a
@@ -1730,9 +1758,4 @@ get_current_subfile ()
void
buildsym_init ()
{
- /* Ensure the scoped_free_pendings destructor was called after
- the last time. */
- gdb_assert (file_symbols == NULL);
- gdb_assert (global_symbols == NULL);
- gdb_assert (buildsym_compunit == NULL);
}