From patchwork Fri Jul 20 04:27:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 28517 Received: (qmail 15039 invoked by alias); 20 Jul 2018 04:28:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14084 invoked by uid 89); 20 Jul 2018 04:28:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=mother, december, December, belonging X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.62.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Jul 2018 04:28:06 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway20.websitewelcome.com (Postfix) with ESMTP id BA34A400C3F7C for ; Thu, 19 Jul 2018 23:28:04 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id gN1EfPxUHbXuJgN1KfXPuE; Thu, 19 Jul 2018 23:28:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mmivxS98Hrfm1WvyNE5tsYytg9E3swXnoEfuoCH15jU=; b=oaQMClo0hZuEycb16ER4EYxgWf D37y0rEvTebmjX6XcJxl6IvG6BufbcW3fsNlfWjeQ7nD6lIBxayfgkykEgw28LxszK/l3D8v771WI 4o2eG0lxWj7QO9kqw7JLPWT6t; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:39336 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fgN1E-003pgz-FS; Thu, 19 Jul 2018 23:27:52 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 09/23] Move the symbol lists to buildsym_compunit Date: Thu, 19 Jul 2018 22:27:33 -0600 Message-Id: <20180720042747.18473-10-tom@tromey.com> In-Reply-To: <20180720042747.18473-1-tom@tromey.com> References: <20180720042747.18473-1-tom@tromey.com> This moves the global symbol lists into buildsym_compunit, adds accessors, and updates all the users. gdb/ChangeLog 2018-07-19 Tom Tromey * 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. : 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 | 107 +++++++++++++++++++++++++++++++++---------------------- gdb/buildsym.h | 26 +++++++------- gdb/coffread.c | 30 ++++++++-------- gdb/dbxread.c | 6 ++-- gdb/dwarf2read.c | 40 ++++++++++----------- gdb/mdebugread.c | 2 +- gdb/stabsread.c | 65 ++++++++++++++++----------------- gdb/xcoffread.c | 8 ++--- 9 files changed, 180 insertions(+), 131 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 59b08f0375c..5503132a729 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); } diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 10dce3edba8..bb4cef095e4 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 2d7859bd5d1..9649db4b9c5 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1171,7 +1171,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, @@ -1181,7 +1181,7 @@ coff_symtab_read (minimal_symbol_reader &reader, cstk.start_addr, tmpaddr); } /* Now pop locals of block just finished. */ - local_symbols = cstk.locals; + *get_local_symbols () = cstk.locals; } break; @@ -1647,10 +1647,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 { @@ -1662,7 +1662,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: @@ -1672,7 +1672,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: @@ -1685,12 +1685,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; @@ -1700,7 +1700,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: @@ -1710,14 +1710,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: @@ -1771,7 +1771,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: @@ -1790,7 +1790,7 @@ process_coff_symbol (struct coff_symbol *cs, TYPE_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: @@ -2154,9 +2154,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 e79d2a858af..df03df4d34b 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2573,7 +2573,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name, if (desc != cstk.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 @@ -2582,7 +2582,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name, complaint (_("misplaced N_LBRAC entry; discarding local " "symbols which have no enclosing block")); } - local_symbols = cstk.locals; + *get_local_symbols () = cstk.locals; if (get_context_stack_depth () > 1) { @@ -2592,7 +2592,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 b73c06e69c3..805eaf21575 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9715,7 +9715,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) { @@ -9768,7 +9768,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); } @@ -13628,7 +13628,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) { @@ -13713,13 +13713,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 = cstk.locals; + *get_local_symbols () = cstk.locals; set_local_using_directives (cstk.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 @@ -13771,7 +13771,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) inherit_abstract_dies (die, cu); struct context_stack cstk = 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, cstk.old_blocks, NULL, @@ -13789,7 +13789,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 = cstk.locals; + *get_local_symbols () = cstk.locals; set_local_using_directives (cstk.local_using_directives); } @@ -21015,7 +21015,7 @@ dwarf2_start_symtab (struct dwarf2_cu *cu, = start_symtab (cu->per_cu->dwarf2_per_objfile->objfile, name, comp_dir, low_pc, cu->language); - cu->list_in_scope = &file_symbols; + cu->list_in_scope = get_file_symbols (); record_debugformat ("DWARF 2"); record_producer (cu->producer); @@ -21208,7 +21208,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 { @@ -21251,7 +21251,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; } @@ -21296,8 +21296,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; @@ -21327,8 +21327,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; } @@ -21393,9 +21393,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". */ @@ -21434,20 +21434,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 a22cf84aa36..0bc7fa61074 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4040,7 +4040,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 ad7b459d722..e592edd4a33 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -432,7 +432,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 { @@ -789,7 +789,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; @@ -848,7 +848,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; } @@ -873,7 +873,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; } @@ -928,7 +928,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': @@ -937,7 +937,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': @@ -945,7 +945,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: @@ -1016,7 +1016,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': @@ -1037,7 +1037,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, @@ -1049,7 +1049,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': @@ -1070,7 +1070,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) { @@ -1119,7 +1119,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': @@ -1150,6 +1150,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))) @@ -1171,10 +1172,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': @@ -1201,7 +1202,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': @@ -1305,7 +1306,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) { @@ -1321,7 +1322,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; @@ -1349,7 +1350,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) { @@ -1365,7 +1366,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; @@ -1393,7 +1394,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': @@ -1403,7 +1404,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': @@ -1413,7 +1414,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': @@ -1425,7 +1426,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: @@ -1433,7 +1434,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; } @@ -1675,7 +1676,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]; @@ -3642,10 +3643,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; @@ -4316,8 +4317,8 @@ common_block_start (const char *name, struct objfile *objfile) { complaint (_("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)); } @@ -4352,7 +4353,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) { @@ -4545,7 +4546,7 @@ cleanup_undefined_types_1 (void) complaint (_("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++) { @@ -4781,7 +4782,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 f8dd3e9e0a2..9268a3f28f6 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1496,7 +1496,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 (cstk.name, @@ -1506,7 +1506,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst) + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))); } - local_symbols = cstk.locals; + *get_local_symbols () = cstk.locals; } break; @@ -1594,9 +1594,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 {