From 7c7b66552d1cca8a2d2519232f26643dbcb6300a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 5 Aug 2013 15:51:02 +0000 Subject: [PATCH] remove msymbol_objfile This is another patch in my ongoing series to "split" objfile to share more read-only data across inferiors. See http://sourceware.org/gdb/wiki/ObjfileSplitting When symbols are finally shared, there will be no back-link from the symbol to its containing objfile, because there may be more than one such objfile. So, all such back-links must be removed. One hidden back-link is the msymbol_objfile function. Since (eventually) a symbol may appear in more than one objfile, trying to look up the objfile given just a symbol cannot work. This patch removes msymbol_objfile in favor of using a bound minimal symbol. It introduces a new function to make this conversion simpler in some spots. The bonus of this patch is that using msymbol_objfile is slower than simply looking up the owning objfile in the first place. Built and regtested on x86-64 Fedora 18. * ada-exp.y (write_var_or_type): Use bound_minimal_symbol. * ada-lang.c (ada_lookup_simple_minsym): Return bound_minimal_symbol. * ada-lang.h (ada_lookup_simple_minsym): Update. * c-exp.y (variable): Use lookup_bound_minimal_symbol. * f-exp.y (variable): Use lookup_bound_minimal_symbol. * go-exp.y (variable): Use lookup_bound_minimal_symbol. * jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol. * m2-exp.y (variable): Use lookup_bound_minimal_symbol. * minsyms.c (msymbol_objfile): Remove. (lookup_minimal_symbol_internal): New function, from lookup_minimal_symbol. (lookup_minimal_symbol): Rewrite using lookup_minimal_symbol_internal. (lookup_bound_minimal_symbol): New function. * minsyms.h (msymbol_objfile): Remove. (lookup_bound_minimal_symbol): Declare. * p-exp.y (variable): Use lookup_bound_minimal_symbol. * parse.c (write_exp_msymbol): Change parameter to a bound_minimal_symbol. (write_dollar_variable): Use lookup_bound_minimal_symbol. * parser-defs.h (write_exp_msymbol): Update. * printcmd.c (address_info): Use lookup_bound_minimal_symbol. * symfile.c (simple_read_overlay_table): Use lookup_bound_minimal_symbol. * symtab.c (skip_prologue_sal): Don't use msymbol_objfile. (search_symbols): Likewise. (print_msymbol_info): Take a bound_minimal_symbol argument. (symtab_symbol_info, rbreak_command): Update. * symtab.h (struct symbol_search) : Change type to bound_minimal_symbol. * valops.c (find_function_in_inferior): Use lookup_bound_minimal_symbol. * value.c (value_fn_field): Use lookup_bound_minimal_symbol. --- gdb/ChangeLog | 37 +++++++++++++++++++++ gdb/ada-exp.y | 4 +-- gdb/ada-lang.c | 22 ++++++++---- gdb/ada-lang.h | 2 +- gdb/c-exp.y | 12 +++---- gdb/f-exp.y | 6 ++-- gdb/go-exp.y | 6 ++-- gdb/jv-exp.y | 6 ++-- gdb/m2-exp.y | 6 ++-- gdb/minsyms.c | 85 +++++++++++++++++++++++++---------------------- gdb/minsyms.h | 13 +++----- gdb/p-exp.y | 12 +++---- gdb/parse.c | 11 +++--- gdb/parser-defs.h | 2 +- gdb/printcmd.c | 12 +++---- gdb/symfile.c | 11 +++--- gdb/symtab.c | 41 +++++++++++------------ gdb/symtab.h | 2 +- gdb/valops.c | 10 +++--- gdb/value.c | 12 +++---- 20 files changed, 180 insertions(+), 132 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2a7773c25f..5da081f25c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,40 @@ +2013-08-05 Tom Tromey + + * ada-exp.y (write_var_or_type): Use bound_minimal_symbol. + * ada-lang.c (ada_lookup_simple_minsym): Return + bound_minimal_symbol. + * ada-lang.h (ada_lookup_simple_minsym): Update. + * c-exp.y (variable): Use lookup_bound_minimal_symbol. + * f-exp.y (variable): Use lookup_bound_minimal_symbol. + * go-exp.y (variable): Use lookup_bound_minimal_symbol. + * jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol. + * m2-exp.y (variable): Use lookup_bound_minimal_symbol. + * minsyms.c (msymbol_objfile): Remove. + (lookup_minimal_symbol_internal): New function, from + lookup_minimal_symbol. + (lookup_minimal_symbol): Rewrite using + lookup_minimal_symbol_internal. + (lookup_bound_minimal_symbol): New function. + * minsyms.h (msymbol_objfile): Remove. + (lookup_bound_minimal_symbol): Declare. + * p-exp.y (variable): Use lookup_bound_minimal_symbol. + * parse.c (write_exp_msymbol): Change parameter to a + bound_minimal_symbol. + (write_dollar_variable): Use lookup_bound_minimal_symbol. + * parser-defs.h (write_exp_msymbol): Update. + * printcmd.c (address_info): Use lookup_bound_minimal_symbol. + * symfile.c (simple_read_overlay_table): Use + lookup_bound_minimal_symbol. + * symtab.c (skip_prologue_sal): Don't use msymbol_objfile. + (search_symbols): Likewise. + (print_msymbol_info): Take a bound_minimal_symbol argument. + (symtab_symbol_info, rbreak_command): Update. + * symtab.h (struct symbol_search) : Change type + to bound_minimal_symbol. + * valops.c (find_function_in_inferior): Use + lookup_bound_minimal_symbol. + * value.c (value_fn_field): Use lookup_bound_minimal_symbol. + 2013-08-05 Jan Kratochvil Code cleanup. diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index d9fa9acd0c..702a32e83e 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1369,9 +1369,9 @@ write_var_or_type (const struct block *block, struct stoken name0) } else if (nsyms == 0) { - struct minimal_symbol *msym + struct bound_minimal_symbol msym = ada_lookup_simple_minsym (encoded_name); - if (msym != NULL) + if (msym.minsym != NULL) { write_exp_msymbol (msym); /* Maybe cause error here rather than later? FIXME? */ diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index dc5f2b6e3b..ba59913b38 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4405,18 +4405,22 @@ defns_collected (struct obstack *obstackp, int finish) return (struct ada_symbol_info *) obstack_base (obstackp); } -/* Return a minimal symbol matching NAME according to Ada decoding - rules. Returns NULL if there is no such minimal symbol. Names - prefixed with "standard__" are handled specially: "standard__" is - first stripped off, and only static and global symbols are searched. */ +/* Return a bound minimal symbol matching NAME according to Ada + decoding rules. Returns an invalid symbol if there is no such + minimal symbol. Names prefixed with "standard__" are handled + specially: "standard__" is first stripped off, and only static and + global symbols are searched. */ -struct minimal_symbol * +struct bound_minimal_symbol ada_lookup_simple_minsym (const char *name) { + struct bound_minimal_symbol result; struct objfile *objfile; struct minimal_symbol *msymbol; const int wild_match_p = should_use_wild_match (name); + memset (&result, 0, sizeof (result)); + /* Special case: If the user specifies a symbol name inside package Standard, do a non-wild matching of the symbol name without the "standard__" prefix. This was primarily introduced in order @@ -4431,10 +4435,14 @@ ada_lookup_simple_minsym (const char *name) { if (match_name (SYMBOL_LINKAGE_NAME (msymbol), name, wild_match_p) && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) - return msymbol; + { + result.minsym = msymbol; + result.objfile = objfile; + break; + } } - return NULL; + return result; } /* For all subprograms that statically enclose the subprogram of the diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 55c0a8192a..4ea25b80ba 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -239,7 +239,7 @@ extern void ada_lookup_encoded_symbol (const char *name, const struct block *block, domain_enum namespace, struct ada_symbol_info *symbol_info); -extern struct minimal_symbol *ada_lookup_simple_minsym (const char *); +extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *); extern void ada_fill_in_ada_prototype (struct symbol *); diff --git a/gdb/c-exp.y b/gdb/c-exp.y index dd032d2ead..3a51878da5 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1004,7 +1004,7 @@ variable: qualified_name { char *name = copy_name ($2.stoken); struct symbol *sym; - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; sym = lookup_symbol (name, (const struct block *) NULL, @@ -1018,8 +1018,8 @@ variable: qualified_name break; } - msymbol = lookup_minimal_symbol (name, NULL, NULL); - if (msymbol != NULL) + msymbol = lookup_bound_minimal_symbol (name); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); @@ -1066,12 +1066,12 @@ variable: name_not_typename } else { - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; char *arg = copy_name ($1.stoken); msymbol = - lookup_minimal_symbol (arg, NULL, NULL); - if (msymbol != NULL) + lookup_bound_minimal_symbol (arg); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 846cc02b3b..296a7fe1c7 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -513,12 +513,12 @@ variable: name_not_typename } else { - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; char *arg = copy_name ($1.stoken); msymbol = - lookup_minimal_symbol (arg, NULL, NULL); - if (msymbol != NULL) + lookup_bound_minimal_symbol (arg); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); diff --git a/gdb/go-exp.y b/gdb/go-exp.y index 66d9149d94..2ccb394dce 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -616,12 +616,12 @@ variable: name_not_typename } else { - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; char *arg = copy_name ($1.stoken); msymbol = - lookup_minimal_symbol (arg, NULL, NULL); - if (msymbol != NULL) + lookup_bound_minimal_symbol (arg); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y index ea562965c0..a4e1253e34 100644 --- a/gdb/jv-exp.y +++ b/gdb/jv-exp.y @@ -1391,10 +1391,10 @@ push_expression_name (struct stoken name) } else { - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; - msymbol = lookup_minimal_symbol (tmp, NULL, NULL); - if (msymbol != NULL) + msymbol = lookup_bound_minimal_symbol (tmp); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command")); diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 69e17d84d0..eaa5a23ac8 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -627,12 +627,12 @@ variable: NAME } else { - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; char *arg = copy_name ($1); msymbol = - lookup_minimal_symbol (arg, NULL, NULL); - if (msymbol != NULL) + lookup_bound_minimal_symbol (arg); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. Use the \"symbol-file\" command.")); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 89e538af0e..e2079301fa 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -139,27 +139,6 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, } } -/* See minsyms.h. */ - -struct objfile * -msymbol_objfile (struct minimal_symbol *sym) -{ - struct objfile *objf; - struct minimal_symbol *tsym; - - unsigned int hash - = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE; - - for (objf = object_files; objf; objf = objf->next) - for (tsym = objf->msymbol_hash[hash]; tsym; tsym = tsym->hash_next) - if (tsym == sym) - return objf; - - /* We should always be able to find the objfile ... */ - internal_error (__FILE__, __LINE__, _("failed internal consistency check")); -} - - /* Look through all the current minimal symbol tables and find the first minimal symbol that matches NAME. If OBJF is non-NULL, limit the search to that objfile. If SFILE is non-NULL, the only file-scope @@ -180,15 +159,14 @@ msymbol_objfile (struct minimal_symbol *sym) Obviously, there must be distinct mangled names for each of these, but the demangled names are all the same: S::S or S::~S. */ -struct minimal_symbol * -lookup_minimal_symbol (const char *name, const char *sfile, - struct objfile *objf) +static struct bound_minimal_symbol +lookup_minimal_symbol_internal (const char *name, const char *sfile, + struct objfile *objf) { struct objfile *objfile; - struct minimal_symbol *msymbol; - struct minimal_symbol *found_symbol = NULL; - struct minimal_symbol *found_file_symbol = NULL; - struct minimal_symbol *trampoline_symbol = NULL; + struct bound_minimal_symbol found_symbol = { NULL, NULL }; + struct bound_minimal_symbol found_file_symbol = { NULL, NULL }; + struct bound_minimal_symbol trampoline_symbol = { NULL, NULL }; unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE; @@ -213,9 +191,11 @@ lookup_minimal_symbol (const char *name, const char *sfile, } for (objfile = object_files; - objfile != NULL && found_symbol == NULL; + objfile != NULL && found_symbol.minsym == NULL; objfile = objfile->next) { + struct minimal_symbol *msymbol; + if (objf == NULL || objf == objfile || objf == objfile->separate_debug_objfile_backlink) { @@ -223,7 +203,7 @@ lookup_minimal_symbol (const char *name, const char *sfile, and the second over the demangled hash table. */ int pass; - for (pass = 1; pass <= 2 && found_symbol == NULL; pass++) + for (pass = 1; pass <= 2 && found_symbol.minsym == NULL; pass++) { /* Select hash list according to pass. */ if (pass == 1) @@ -231,7 +211,7 @@ lookup_minimal_symbol (const char *name, const char *sfile, else msymbol = objfile->msymbol_demangled_hash[dem_hash]; - while (msymbol != NULL && found_symbol == NULL) + while (msymbol != NULL && found_symbol.minsym == NULL) { int match; @@ -260,7 +240,10 @@ lookup_minimal_symbol (const char *name, const char *sfile, case mst_file_bss: if (sfile == NULL || filename_cmp (msymbol->filename, sfile) == 0) - found_file_symbol = msymbol; + { + found_file_symbol.minsym = msymbol; + found_file_symbol.objfile = objfile; + } break; case mst_solib_trampoline: @@ -269,13 +252,17 @@ lookup_minimal_symbol (const char *name, const char *sfile, keep looking for the *real* symbol. If the actual symbol is not found, then we'll use the trampoline entry. */ - if (trampoline_symbol == NULL) - trampoline_symbol = msymbol; + if (trampoline_symbol.minsym == NULL) + { + trampoline_symbol.minsym = msymbol; + trampoline_symbol.objfile = objfile; + } break; case mst_unknown: default: - found_symbol = msymbol; + found_symbol.minsym = msymbol; + found_symbol.objfile = objfile; break; } } @@ -294,18 +281,36 @@ lookup_minimal_symbol (const char *name, const char *sfile, xfree ((void *) modified_name); /* External symbols are best. */ - if (found_symbol) + if (found_symbol.minsym != NULL) return found_symbol; /* File-local symbols are next best. */ - if (found_file_symbol) + if (found_file_symbol.minsym != NULL) return found_file_symbol; /* Symbols for shared library trampolines are next best. */ - if (trampoline_symbol) - return trampoline_symbol; + return trampoline_symbol; +} - return NULL; +/* See minsyms.h. */ + +struct minimal_symbol * +lookup_minimal_symbol (const char *name, const char *sfile, + struct objfile *objf) +{ + struct bound_minimal_symbol bms = lookup_minimal_symbol_internal (name, + sfile, + objf); + + return bms.minsym; +} + +/* See minsyms.h. */ + +struct bound_minimal_symbol +lookup_bound_minimal_symbol (const char *name) +{ + return lookup_minimal_symbol_internal (name, NULL, NULL); } /* See minsyms.h. */ diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 4d484771f8..95bbdc51f2 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -162,14 +162,6 @@ unsigned int msymbol_hash_iw (const char *); -/* Return the objfile that holds the minimal symbol SYM. Every - minimal symbols is held by some objfile; this will never return - NULL. */ - -struct objfile *msymbol_objfile (struct minimal_symbol *sym); - - - /* Look through all the current minimal symbol tables and find the first minimal symbol that matches NAME. If OBJF is non-NULL, limit the search to that objfile. If SFILE is non-NULL, the only file-scope @@ -181,6 +173,11 @@ struct minimal_symbol *lookup_minimal_symbol (const char *, const char *, struct objfile *); +/* Like lookup_minimal_symbol, but searches all files and objfiles + and returns a bound minimal symbol. */ + +struct bound_minimal_symbol lookup_bound_minimal_symbol (const char *); + /* Find the minimal symbol named NAME, and return both the minsym struct and its objfile. This only checks the linkage name. */ diff --git a/gdb/p-exp.y b/gdb/p-exp.y index a989ac4ca5..da8d5f7471 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -700,7 +700,7 @@ variable: qualified_name { char *name = copy_name ($2); struct symbol *sym; - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; sym = lookup_symbol (name, (const struct block *) NULL, @@ -714,8 +714,8 @@ variable: qualified_name break; } - msymbol = lookup_minimal_symbol (name, NULL, NULL); - if (msymbol != NULL) + msymbol = lookup_bound_minimal_symbol (name); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) @@ -779,12 +779,12 @@ variable: name_not_typename } else { - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; char *arg = copy_name ($1.stoken); msymbol = - lookup_minimal_symbol (arg, NULL, NULL); - if (msymbol != NULL) + lookup_bound_minimal_symbol (arg); + if (msymbol.minsym != NULL) write_exp_msymbol (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) diff --git a/gdb/parse.c b/gdb/parse.c index 13699a85e6..674342bd3a 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -496,9 +496,10 @@ write_exp_bitstring (struct stoken str) the expression. */ void -write_exp_msymbol (struct minimal_symbol *msymbol) +write_exp_msymbol (struct bound_minimal_symbol bound_msym) { - struct objfile *objfile = msymbol_objfile (msymbol); + struct minimal_symbol *msymbol = bound_msym.minsym; + struct objfile *objfile = bound_msym.objfile; struct gdbarch *gdbarch = get_objfile_arch (objfile); CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (msymbol); @@ -640,7 +641,7 @@ void write_dollar_variable (struct stoken str) { struct symbol *sym = NULL; - struct minimal_symbol *msym = NULL; + struct bound_minimal_symbol msym; struct internalvar *isym = NULL; /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) @@ -704,8 +705,8 @@ write_dollar_variable (struct stoken str) write_exp_elt_opcode (OP_VAR_VALUE); return; } - msym = lookup_minimal_symbol (copy_name (str), NULL, NULL); - if (msym) + msym = lookup_bound_minimal_symbol (copy_name (str)); + if (msym.minsym) { write_exp_msymbol (msym); return; diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 5fbae0db59..92daca9919 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -195,7 +195,7 @@ extern void write_exp_elt_block (const struct block *); extern void write_exp_elt_objfile (struct objfile *objfile); -extern void write_exp_msymbol (struct minimal_symbol *); +extern void write_exp_msymbol (struct bound_minimal_symbol); extern void write_dollar_variable (struct stoken str); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 1cc248d70f..68921b05df 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1201,7 +1201,7 @@ address_info (char *exp, int from_tty) struct gdbarch *gdbarch; int regno; struct symbol *sym; - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; long val; struct obj_section *section; CORE_ADDR load_addr, context_pc = 0; @@ -1227,14 +1227,14 @@ address_info (char *exp, int from_tty) return; } - msymbol = lookup_minimal_symbol (exp, NULL, NULL); + msymbol = lookup_bound_minimal_symbol (exp); - if (msymbol != NULL) + if (msymbol.minsym != NULL) { - struct objfile *objfile = msymbol_objfile (msymbol); + struct objfile *objfile = msymbol.objfile; gdbarch = get_objfile_arch (objfile); - load_addr = SYMBOL_VALUE_ADDRESS (msymbol); + load_addr = SYMBOL_VALUE_ADDRESS (msymbol.minsym); printf_filtered ("Symbol \""); fprintf_symbol_filtered (gdb_stdout, exp, @@ -1242,7 +1242,7 @@ address_info (char *exp, int from_tty) printf_filtered ("\" is at "); fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); printf_filtered (" in a file compiled without debugging"); - section = SYMBOL_OBJ_SECTION (objfile, msymbol); + section = SYMBOL_OBJ_SECTION (objfile, msymbol.minsym); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); diff --git a/gdb/symfile.c b/gdb/symfile.c index 51291054a7..3328648755 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3399,7 +3399,8 @@ read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr, static int simple_read_overlay_table (void) { - struct minimal_symbol *novlys_msym, *ovly_table_msym; + struct minimal_symbol *novlys_msym; + struct bound_minimal_symbol ovly_table_msym; struct gdbarch *gdbarch; int word_size; enum bfd_endian byte_order; @@ -3414,8 +3415,8 @@ simple_read_overlay_table (void) return 0; } - ovly_table_msym = lookup_minimal_symbol ("_ovly_table", NULL, NULL); - if (! ovly_table_msym) + ovly_table_msym = lookup_bound_minimal_symbol ("_ovly_table"); + if (! ovly_table_msym.minsym) { error (_("Error reading inferior's overlay table: couldn't find " "`_ovly_table' array\n" @@ -3423,7 +3424,7 @@ simple_read_overlay_table (void) return 0; } - gdbarch = get_objfile_arch (msymbol_objfile (ovly_table_msym)); + gdbarch = get_objfile_arch (ovly_table_msym.objfile); word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT; byte_order = gdbarch_byte_order (gdbarch); @@ -3431,7 +3432,7 @@ simple_read_overlay_table (void) 4, byte_order); cache_ovly_table = (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table)); - cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym); + cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym.minsym); read_target_long_array (cache_ovly_table_base, (unsigned int *) cache_ovly_table, cache_novlys * 4, word_size, byte_order); diff --git a/gdb/symtab.c b/gdb/symtab.c index 237b2582e9..8076fe5bb3 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -101,8 +101,6 @@ struct symbol *lookup_symbol_aux_quick (struct objfile *objfile, const char *name, const domain_enum domain); -static void print_msymbol_info (struct minimal_symbol *); - void _initialize_symtab (void); /* */ @@ -2832,19 +2830,19 @@ skip_prologue_sal (struct symtab_and_line *sal) } else { - struct minimal_symbol *msymbol - = lookup_minimal_symbol_by_pc_section (sal->pc, sal->section).minsym; + struct bound_minimal_symbol msymbol + = lookup_minimal_symbol_by_pc_section (sal->pc, sal->section); - if (msymbol == NULL) + if (msymbol.minsym == NULL) { do_cleanups (old_chain); return; } - objfile = msymbol_objfile (msymbol); - pc = SYMBOL_VALUE_ADDRESS (msymbol); - section = SYMBOL_OBJ_SECTION (objfile, msymbol); - name = SYMBOL_LINKAGE_NAME (msymbol); + objfile = msymbol.objfile; + pc = SYMBOL_VALUE_ADDRESS (msymbol.minsym); + section = SYMBOL_OBJ_SECTION (objfile, msymbol.minsym); + name = SYMBOL_LINKAGE_NAME (msymbol.minsym); } gdbarch = get_objfile_arch (objfile); @@ -3666,7 +3664,7 @@ search_symbols (char *regexp, enum search_domain kind, psr->block = i; psr->symtab = real_symtab; psr->symbol = sym; - psr->msymbol = NULL; + memset (&psr->msymbol, 0, sizeof (psr->msymbol)); psr->next = NULL; if (tail == NULL) found = psr; @@ -3719,7 +3717,8 @@ search_symbols (char *regexp, enum search_domain kind, struct symbol_search *psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search)); psr->block = i; - psr->msymbol = msymbol; + psr->msymbol.minsym = msymbol; + psr->msymbol.objfile = objfile; psr->symtab = NULL; psr->symbol = NULL; psr->next = NULL; @@ -3783,20 +3782,20 @@ print_symbol_info (enum search_domain kind, for non-debugging symbols to gdb_stdout. */ static void -print_msymbol_info (struct minimal_symbol *msymbol) +print_msymbol_info (struct bound_minimal_symbol msymbol) { - struct gdbarch *gdbarch = get_objfile_arch (msymbol_objfile (msymbol)); + struct gdbarch *gdbarch = get_objfile_arch (msymbol.objfile); char *tmp; if (gdbarch_addr_bit (gdbarch) <= 32) - tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol) + tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol.minsym) & (CORE_ADDR) 0xffffffff, 8); else - tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol), + tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol.minsym), 16); printf_filtered ("%s %s\n", - tmp, SYMBOL_PRINT_NAME (msymbol)); + tmp, SYMBOL_PRINT_NAME (msymbol.minsym)); } /* This is the guts of the commands "info functions", "info types", and @@ -3831,7 +3830,7 @@ symtab_symbol_info (char *regexp, enum search_domain kind, int from_tty) { QUIT; - if (p->msymbol != NULL) + if (p->msymbol.minsym != NULL) { if (first) { @@ -3928,7 +3927,7 @@ rbreak_command (char *regexp, int from_tty) make_cleanup (do_end_rbreak_breakpoints, NULL); for (p = ss; p != NULL; p = p->next) { - if (p->msymbol == NULL) + if (p->msymbol.minsym == NULL) { const char *fullname = symtab_to_fullname (p->symtab); @@ -3954,7 +3953,7 @@ rbreak_command (char *regexp, int from_tty) } else { - int newlen = (strlen (SYMBOL_LINKAGE_NAME (p->msymbol)) + 3); + int newlen = (strlen (SYMBOL_LINKAGE_NAME (p->msymbol.minsym)) + 3); if (newlen > len) { @@ -3962,12 +3961,12 @@ rbreak_command (char *regexp, int from_tty) len = newlen; } strcpy (string, "'"); - strcat (string, SYMBOL_LINKAGE_NAME (p->msymbol)); + strcat (string, SYMBOL_LINKAGE_NAME (p->msymbol.minsym)); strcat (string, "'"); break_command (string, from_tty); printf_filtered (" %s;\n", - SYMBOL_PRINT_NAME (p->msymbol)); + SYMBOL_PRINT_NAME (p->msymbol.minsym)); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index 32897aabb7..6d81507f57 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1299,7 +1299,7 @@ struct symbol_search /* If msymbol is non-null, then a match was made on something for which only minimal_symbols exist. */ - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; /* A link to the next match, or NULL for the end. */ struct symbol_search *next; diff --git a/gdb/valops.c b/gdb/valops.c index f527550f37..f86b2835d5 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -149,12 +149,12 @@ find_function_in_inferior (const char *name, struct objfile **objf_p) } else { - struct minimal_symbol *msymbol = - lookup_minimal_symbol (name, NULL, NULL); + struct bound_minimal_symbol msymbol = + lookup_bound_minimal_symbol (name); - if (msymbol != NULL) + if (msymbol.minsym != NULL) { - struct objfile *objfile = msymbol_objfile (msymbol); + struct objfile *objfile = msymbol.objfile; struct gdbarch *gdbarch = get_objfile_arch (objfile); struct type *type; @@ -162,7 +162,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p) type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char); type = lookup_function_type (type); type = lookup_pointer_type (type); - maddr = SYMBOL_VALUE_ADDRESS (msymbol); + maddr = SYMBOL_VALUE_ADDRESS (msymbol.minsym); if (objf_p) *objf_p = objfile; diff --git a/gdb/value.c b/gdb/value.c index 8d635c7bc2..09ab1bb4e2 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2773,18 +2773,18 @@ value_fn_field (struct value **arg1p, struct fn_field *f, struct type *ftype = TYPE_FN_FIELD_TYPE (f, j); const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); struct symbol *sym; - struct minimal_symbol *msym; + struct bound_minimal_symbol msym; sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0); if (sym != NULL) { - msym = NULL; + memset (&msym, 0, sizeof (msym)); } else { gdb_assert (sym == NULL); - msym = lookup_minimal_symbol (physname, NULL, NULL); - if (msym == NULL) + msym = lookup_bound_minimal_symbol (physname); + if (msym.minsym == NULL) return NULL; } @@ -2797,12 +2797,12 @@ value_fn_field (struct value **arg1p, struct fn_field *f, { /* The minimal symbol might point to a function descriptor; resolve it to the actual code address instead. */ - struct objfile *objfile = msymbol_objfile (msym); + struct objfile *objfile = msym.objfile; struct gdbarch *gdbarch = get_objfile_arch (objfile); set_value_address (v, gdbarch_convert_from_func_ptr_addr - (gdbarch, SYMBOL_VALUE_ADDRESS (msym), ¤t_target)); + (gdbarch, SYMBOL_VALUE_ADDRESS (msym.minsym), ¤t_target)); } if (arg1p) -- 2.34.1