+2013-08-05 Tom Tromey <tromey@redhat.com>
+
+ * 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) <msymbol>: 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 <jan.kratochvil@redhat.com>
Code cleanup.
}
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? */
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
{
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
(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 *);
{
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,
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."));
}
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."));
}
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."));
}
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 ())
}
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"));
}
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."));
}
}
-/* 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
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;
}
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)
{
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)
else
msymbol = objfile->msymbol_demangled_hash[dem_hash];
- while (msymbol != NULL && found_symbol == NULL)
+ while (msymbol != NULL && found_symbol.minsym == NULL)
{
int match;
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:
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;
}
}
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. */
\f
-/* 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);
-
-\f
-
/* 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
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. */
{
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,
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 ())
}
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 ())
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);
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)
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;
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);
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;
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,
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);
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;
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"
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);
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);
const char *name,
const domain_enum domain);
-static void print_msymbol_info (struct minimal_symbol *);
-
void _initialize_symtab (void);
/* */
}
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);
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;
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;
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
{
QUIT;
- if (p->msymbol != NULL)
+ if (p->msymbol.minsym != NULL)
{
if (first)
{
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);
}
else
{
- int newlen = (strlen (SYMBOL_LINKAGE_NAME (p->msymbol)) + 3);
+ int newlen = (strlen (SYMBOL_LINKAGE_NAME (p->msymbol.minsym)) + 3);
if (newlen > len)
{
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 ("<function, no debug info> %s;\n",
- SYMBOL_PRINT_NAME (p->msymbol));
+ SYMBOL_PRINT_NAME (p->msymbol.minsym));
}
}
/* 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;
}
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;
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;
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;
}
{
/* 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)