[RFA 29/42] Move the symbol lists to buildsym_compunit

Tom Tromey
2018-05-23T04:59:29Z

This moves the global symbol lists into buildsym_compunit, adds
accessors, and updates all the users.

gdb/ChangeLog
2018-05-22 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.
---
gdb/ChangeLog | 27 ++++++++++++++
gdb/buildsym.c | 112 ++++++++++++++++++++++++++++++++++---------------------
gdb/buildsym.h | 26 ++++++-------
gdb/coffread.c | 30 +++++++--------
gdb/dbxread.c | 6 +--
gdb/dwarf2read.c | 38 +++++++++----------
gdb/mdebugread.c | 2 +-
gdb/stabsread.c | 65 ++++++++++++++++----------------
gdb/xcoffread.c | 8 ++--
9 files changed, 184 insertions(+), 130 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 40176298a2..0e21cfd83a 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)
@@ -251,6 +265,20 @@ struct buildsym_compunit
are just waiting to be built into a blockvector when finalizing the
associated symtab. */
struct pending_block *m_pending_blocks = nullptr;
+
+ /* Here are the three lists that symbols are put on. */
+
+ /* static at top level, and types */
+
+ struct pending *m_file_symbols = nullptr;
+
+ /* global functions and variables */
+
+ struct pending *m_global_symbols = nullptr;
+
+ /* everything local to lexical context */
+
+ struct pending *m_local_symbols = nullptr;
};

/* The work-in-progress of the compunit we are building.
@@ -345,22 +373,6 @@ scoped_free_pendings::scoped_free_pendings ()

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 ();
}

@@ -569,7 +581,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);
}

@@ -995,12 +1008,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);
}

@@ -1150,10 +1159,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 ();
}

@@ -1241,8 +1246,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 == 0
&& buildsym_compunit->m_pending_macros == NULL
&& buildsym_compunit->m_global_using_directives == NULL)
@@ -1253,7 +1258,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);
}
@@ -1281,7 +1286,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 ();
@@ -1551,26 +1556,27 @@ augment_type_symtab (void)
complaint (&symfile_complaints,
_("Line numbers recorded in a type symtab"));

- if (file_symbols != NULL)
+ if (*get_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 (*get_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 ();
@@ -1589,14 +1595,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;
@@ -1735,6 +1741,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;
+}
+
\f

/* Initialize anything that needs initializing when starting to read a
@@ -1744,9 +1777,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);
}
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 969afbc828..71d133e6ad 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -77,20 +77,6 @@ struct pending
struct symbol *symbol[PENDINGSIZE];
};

-/* Here are the three lists that symbols are put on. */
-
-/* static at top level, and types */
-
-EXTERN struct pending *file_symbols;
-
-/* global functions and variables */
-
-EXTERN struct pending *global_symbols;
-
-/* everything local to lexical context */
-
-EXTERN struct pending *local_symbols;
-
/* Stack representing unclosed lexical contexts (that will become
blocks, eventually). */

@@ -275,6 +261,18 @@ extern int get_context_stack_depth ();

extern struct subfile *get_current_subfile ();

+/* Return the local symbol list. */
+
+extern struct pending **get_local_symbols ();
+
+/* Return the file symbol list. */
+
+extern struct pending **get_file_symbols ();
+
+/* Return the global symbol list. */
+
+extern struct pending **get_global_symbols ();
+
#undef EXTERN

#endif /* defined (BUILDSYM_H) */
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 71b6ed9995..3bb6639914 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1177,7 +1177,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
symnum);
break;
}
- if (local_symbols && !outermost_context_p ())
+ if (*get_local_symbols () && !outermost_context_p ())
{
tmpaddr =
cs->c_value + ANOFFSET (objfile->section_offsets,
@@ -1187,7 +1187,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
newobj->start_addr, tmpaddr);
}
/* Now pop locals of block just finished. */
- local_symbols = newobj->locals;
+ *get_local_symbols () = newobj->locals;
}
break;

@@ -1654,10 +1654,10 @@ process_coff_symbol (struct coff_symbol *cs,
SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
|| cs->c_sclass == C_THUMBSTATFUNC)
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
else if (cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT
|| cs->c_sclass == C_THUMBEXTFUNC)
- add_symbol_to_list (sym, &global_symbols);
+ add_symbol_to_list (sym, get_global_symbols ());
}
else
{
@@ -1669,7 +1669,7 @@ process_coff_symbol (struct coff_symbol *cs,

case C_AUTO:
SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case C_THUMBEXT:
@@ -1679,7 +1679,7 @@ process_coff_symbol (struct coff_symbol *cs,
SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value;
SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets,
SECT_OFF_TEXT (objfile));
- add_symbol_to_list (sym, &global_symbols);
+ add_symbol_to_list (sym, get_global_symbols ());
break;

case C_THUMBSTAT:
@@ -1692,12 +1692,12 @@ process_coff_symbol (struct coff_symbol *cs,
if (within_function)
{
/* Static symbol of local scope. */
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
}
else
{
/* Static symbol at top level of file. */
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
}
break;

@@ -1707,7 +1707,7 @@ process_coff_symbol (struct coff_symbol *cs,
case C_REG:
SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
SYMBOL_VALUE (sym) = cs->c_value;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case C_THUMBLABEL:
@@ -1717,14 +1717,14 @@ process_coff_symbol (struct coff_symbol *cs,
case C_ARG:
SYMBOL_ACLASS_INDEX (sym) = LOC_ARG;
SYMBOL_IS_ARGUMENT (sym) = 1;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case C_REGPARM:
SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = cs->c_value;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case C_TPDEF:
@@ -1778,7 +1778,7 @@ process_coff_symbol (struct coff_symbol *cs,
SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i];
opaque_type_chain[i] = sym;
}
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
break;

case C_STRTAG:
@@ -1797,7 +1797,7 @@ process_coff_symbol (struct coff_symbol *cs,
TYPE_TAG_NAME (SYMBOL_TYPE (sym)) =
concat (SYMBOL_LINKAGE_NAME (sym), (char *)NULL);

- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
break;

default:
@@ -2175,9 +2175,9 @@ coff_read_enum_type (int index, int length, int lastsym,

type = coff_alloc_type (index);
if (within_function)
- symlist = &local_symbols;
+ symlist = get_local_symbols ();
else
- symlist = &file_symbols;
+ symlist = get_file_symbols ();
osyms = *symlist;
o_nsyms = osyms ? osyms->nsyms : 0;

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index b6a44e245e..989ce77be2 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2636,7 +2636,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
if (desc != newobj->depth)
lbrac_mismatch_complaint (symnum);

- if (local_symbols != NULL)
+ if (*get_local_symbols () != NULL)
{
/* GCC development snapshots from March to December of
2000 would output N_LSYM entries after N_LBRAC
@@ -2646,7 +2646,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
_("misplaced N_LBRAC entry; discarding local "
"symbols which have no enclosing block"));
}
- local_symbols = newobj->locals;
+ *get_local_symbols () = newobj->locals;

if (get_context_stack_depth () > 1)
{
@@ -2656,7 +2656,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
for them (but don't bother if the block contains no
symbols. Should we complain on blocks without symbols?
I can't think of any useful purpose for them). */
- if (local_symbols != NULL)
+ if (*get_local_symbols () != NULL)
{
/* Muzzle a compiler bug that makes end < start.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f7cca01445..b73f13bb19 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9739,7 +9739,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
struct pending *list;
int i;

- for (list = global_symbols; list != NULL; list = list->next)
+ for (list = *get_global_symbols (); list != NULL; list = list->next)
{
for (i = 0; i < list->nsyms; ++i)
{
@@ -9795,7 +9795,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
SYMBOL_TYPE (sym) = type;

- add_symbol_to_list (sym, &global_symbols);
+ add_symbol_to_list (sym, get_global_symbols ());

xfree (package_name);
}
@@ -13677,7 +13677,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
attr_to_dynamic_prop (attr, die, cu, newobj->static_link);
}

- cu->list_in_scope = &local_symbols;
+ cu->list_in_scope = get_local_symbols ();

if (die->child != NULL)
{
@@ -13762,13 +13762,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
a function declares a class that has methods). This means that
when we finish processing a function scope, we may need to go
back to building a containing block's symbol lists. */
- local_symbols = newobj->locals;
+ *get_local_symbols () = newobj->locals;
set_local_using_directives (newobj->local_using_directives);

/* If we've finished processing a top-level function, subsequent
symbols go in the file symbol list. */
if (outermost_context_p ())
- cu->list_in_scope = &file_symbols;
+ cu->list_in_scope = get_file_symbols ();
}

/* Process all the DIES contained within a lexical block scope. Start
@@ -13821,7 +13821,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
inherit_abstract_dies (die, cu);
newobj = pop_context ();

- if (local_symbols != NULL || (*get_local_using_directives ()) != NULL)
+ if (*get_local_symbols () != NULL || (*get_local_using_directives ()) != NULL)
{
struct block *block
= finish_block (0, newobj->old_blocks, NULL,
@@ -13839,7 +13839,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
to do. */
dwarf2_record_block_ranges (die, block, baseaddr, cu);
}
- local_symbols = newobj->locals;
+ *get_local_symbols () = newobj->locals;
set_local_using_directives (newobj->local_using_directives);
}

@@ -21328,7 +21328,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
access them globally. For instance, we want to be able
to break on a nested subprogram without having to
specify the context. */
- list_to_add = &global_symbols;
+ list_to_add = get_global_symbols ();
}
else
{
@@ -21371,7 +21371,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
if (!suppress_add)
{
if (attr2 && (DW_UNSND (attr2) != 0))
- list_to_add = &global_symbols;
+ list_to_add = get_global_symbols ();
else
list_to_add = cu->list_in_scope;
}
@@ -21416,8 +21416,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,

/* A variable with DW_AT_external is never static,
but it may be block-scoped. */
- list_to_add = (cu->list_in_scope == &file_symbols
- ? &global_symbols : cu->list_in_scope);
+ list_to_add = (cu->list_in_scope == get_file_symbols ()
+ ? get_global_symbols () : cu->list_in_scope);
}
else
list_to_add = cu->list_in_scope;
@@ -21447,8 +21447,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
{
/* A variable with DW_AT_external is never static, but it
may be block-scoped. */
- list_to_add = (cu->list_in_scope == &file_symbols
- ? &global_symbols : cu->list_in_scope);
+ list_to_add = (cu->list_in_scope == get_file_symbols ()
+ ? get_global_symbols () : cu->list_in_scope);

SYMBOL_ACLASS_INDEX (sym) = LOC_UNRESOLVED;
}
@@ -21513,9 +21513,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,

if (!suppress_add)
{
- list_to_add = (cu->list_in_scope == &file_symbols
+ list_to_add = (cu->list_in_scope == get_file_symbols ()
&& cu->language == language_cplus
- ? &global_symbols : cu->list_in_scope);
+ ? get_global_symbols () : cu->list_in_scope);

/* The semantics of C++ state that "struct foo {
... }" also defines a typedef for "foo". */
@@ -21554,20 +21554,20 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* NOTE: carlton/2003-11-10: See comment above in the
DW_TAG_class_type, etc. block. */

- list_to_add = (cu->list_in_scope == &file_symbols
+ list_to_add = (cu->list_in_scope == get_file_symbols ()
&& cu->language == language_cplus
- ? &global_symbols : cu->list_in_scope);
+ ? get_global_symbols () : cu->list_in_scope);
}
break;
case DW_TAG_imported_declaration:
case DW_TAG_namespace:
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
- list_to_add = &global_symbols;
+ list_to_add = get_global_symbols ();
break;
case DW_TAG_module:
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = MODULE_DOMAIN;
- list_to_add = &global_symbols;
+ list_to_add = get_global_symbols ();
break;
case DW_TAG_common_block:
SYMBOL_ACLASS_INDEX (sym) = LOC_COMMON_BLOCK;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 704c064fd8..1045426c67 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4059,7 +4059,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_void;
SYMBOL_VALUE_BYTES (s) = (gdb_byte *) e;
e->pdr.framereg = -1;
- add_symbol_to_list (s, &local_symbols);
+ add_symbol_to_list (s, get_local_symbols ());
}
}
else if (sh.st == stLabel)
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 8c90241165..ebb844d2c5 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -434,7 +434,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
{
SYMBOL_TYPE (sym) = read_type (&pp, objfile);
}
- add_symbol_to_list (sym, &global_symbols);
+ add_symbol_to_list (sym, get_global_symbols ());
}
else
{
@@ -791,7 +791,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
return sym;
}
++p;
@@ -850,7 +850,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
return sym;
}

@@ -875,7 +875,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
return sym;
}

@@ -930,7 +930,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
}
}
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
return sym;

case 'C':
@@ -939,7 +939,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_VALUE_ADDRESS (sym) = valu;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case 'f':
@@ -947,7 +947,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
/* fall into process_function_types. */

process_function_types:
@@ -1018,7 +1018,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &global_symbols);
+ add_symbol_to_list (sym, get_global_symbols ());
goto process_function_types;

case 'G':
@@ -1039,7 +1039,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
global_sym_chain[i] = sym;
}
- add_symbol_to_list (sym, &global_symbols);
+ add_symbol_to_list (sym, get_global_symbols ());
break;

/* This case is faked by a conditional above,
@@ -1051,7 +1051,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case 'p':
@@ -1072,7 +1072,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_IS_ARGUMENT (sym) = 1;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());

if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_BIG)
{
@@ -1121,7 +1121,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case 'r':
@@ -1152,6 +1152,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
but this case is considered pathological and causes a warning
from a decent compiler. */

+ struct pending *local_symbols = *get_local_symbols ();
if (local_symbols
&& local_symbols->nsyms > 0
&& gdbarch_stabs_argument_has_addr (gdbarch, SYMBOL_TYPE (sym)))
@@ -1173,10 +1174,10 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
break;
}
}
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
}
else
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
break;

case 'S':
@@ -1203,7 +1204,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
}
}
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
break;

case 't':
@@ -1307,7 +1308,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_LINKAGE_NAME (sym);
}

- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());

if (synonym)
{
@@ -1323,7 +1324,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
= obconcat (&objfile->objfile_obstack,
SYMBOL_LINKAGE_NAME (sym),
(char *) NULL);
- add_symbol_to_list (struct_sym, &file_symbols);
+ add_symbol_to_list (struct_sym, get_file_symbols ());
}

break;
@@ -1351,7 +1352,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
= obconcat (&objfile->objfile_obstack,
SYMBOL_LINKAGE_NAME (sym),
(char *) NULL);
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());

if (synonym)
{
@@ -1367,7 +1368,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
= obconcat (&objfile->objfile_obstack,
SYMBOL_LINKAGE_NAME (sym),
(char *) NULL);
- add_symbol_to_list (typedef_sym, &file_symbols);
+ add_symbol_to_list (typedef_sym, get_file_symbols ());
}
break;

@@ -1395,7 +1396,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
}
}
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case 'v':
@@ -1405,7 +1406,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case 'a':
@@ -1415,7 +1416,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

case 'X':
@@ -1427,7 +1428,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &local_symbols);
+ add_symbol_to_list (sym, get_local_symbols ());
break;

default:
@@ -1435,7 +1436,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_VALUE (sym) = 0;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- add_symbol_to_list (sym, &file_symbols);
+ add_symbol_to_list (sym, get_file_symbols ());
break;
}

@@ -1679,7 +1680,7 @@ again:
type, rather than allocating a new one. This saves some
memory. */

- for (ppt = file_symbols; ppt; ppt = ppt->next)
+ for (ppt = *get_file_symbols (); ppt; ppt = ppt->next)
for (i = 0; i < ppt->nsyms; i++)
{
struct symbol *sym = ppt->symbol[i];
@@ -3663,10 +3664,10 @@ read_enum_type (const char **pp, struct type *type,
to be file-scope, between N_FN entries, using N_LSYM. What's a mother
to do? For now, force all enum values to file scope. */
if (within_function)
- symlist = &local_symbols;
+ symlist = get_local_symbols ();
else
#endif
- symlist = &file_symbols;
+ symlist = get_file_symbols ();
osyms = *symlist;
o_nsyms = osyms ? osyms->nsyms : 0;

@@ -4339,8 +4340,8 @@ common_block_start (const char *name, struct objfile *objfile)
complaint (&symfile_complaints,
_("Invalid symbol data: common block within common block"));
}
- common_block = local_symbols;
- common_block_i = local_symbols ? local_symbols->nsyms : 0;
+ common_block = *get_local_symbols ();
+ common_block_i = common_block ? common_block->nsyms : 0;
common_block_name = (char *) obstack_copy0 (&objfile->objfile_obstack, name,
strlen (name));
}
@@ -4375,7 +4376,7 @@ common_block_end (struct objfile *objfile)
/* Now we copy all the symbols which have been defined since the BCOMM. */

/* Copy all the struct pendings before common_block. */
- for (next = local_symbols;
+ for (next = *get_local_symbols ();
next != NULL && next != common_block;
next = next->next)
{
@@ -4568,7 +4569,7 @@ cleanup_undefined_types_1 (void)
complaint (&symfile_complaints, _("need a type name"));
break;
}
- for (ppt = file_symbols; ppt; ppt = ppt->next)
+ for (ppt = *get_file_symbols (); ppt; ppt = ppt->next)
{
for (i = 0; i < ppt->nsyms; i++)
{
@@ -4808,7 +4809,7 @@ finish_global_stabs (struct objfile *objfile)
{
if (global_stabs)
{
- patch_block_stabs (global_symbols, global_stabs, objfile);
+ patch_block_stabs (*get_global_symbols (), global_stabs, objfile);
xfree (global_stabs);
global_stabs = NULL;
}
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 73e0638412..4ccc5bf7fc 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1501,7 +1501,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
eb_complaint (cs->c_symnum);
break;
}
- if (local_symbols && !outermost_context_p ())
+ if (*get_local_symbols () && !outermost_context_p ())
{
/* Make a block for the local symbols within. */
finish_block (newobj->name,
@@ -1511,7 +1511,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
+ ANOFFSET (objfile->section_offsets,
SECT_OFF_TEXT (objfile))));
}
- local_symbols = newobj->locals;
+ *get_local_symbols () = newobj->locals;
}
break;

@@ -1599,9 +1599,9 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
SYMBOL_DUP (sym, sym2);

if (cs->c_sclass == C_EXT || C_WEAKEXT)
- add_symbol_to_list (sym2, &global_symbols);
+ add_symbol_to_list (sym2, get_global_symbols ());
else if (cs->c_sclass == C_HIDEXT || cs->c_sclass == C_STAT)
- add_symbol_to_list (sym2, &file_symbols);
+ add_symbol_to_list (sym2, get_file_symbols ());
}
else
{
--
2.13.6