+2003-03-07 David Carlton <carlton@math.stanford.edu>
+
+ * symtab.c (lookup_partial_symbol): Replace uses of
+ SYMBOL_MATCHES_NATURAL_NAME by equivalent uses of
+ SYMBOL_NATURAL_NAME, strcmp_iw.
+ * symtab.h (SYMBOL_MATCHES_NATURAL_NAME): Delete.
+ * minsyms.c (lookup_minimal_symbol_linkage): Make static.
+ (lookup_minimal_symbol_natural): Ditto.
+ (lookup_minimal_symbol): Only search on linkage names; rename
+ first argument to 'linkage_name'.
+ (lookup_minimal_symbol_linkage): Delete.
+ (lookup_minimal_symbol_natural): Delete.
+ (add_minsym_to_demangled_hash_table): Go back to using
+ SYMBOL_DEMANGLED_NAME instead of SYMBOL_NATURAL_NAME.
+ (lookup_minimal_symbol_aux): Don't use
+ SYMBOL_MATCHES_NATURAL_NAME: do a strcmp_iw on
+ SYMBOL_DEMANGLED_NAME instead. Add comment.
+ (build_minimal_symbol_hash_tables): Go back to only adding to
+ demangled has table if SYMBOL_DEMANGLED_NAME is non-NULL.
+ * symtab.h: Delete declarations for lookup_minimal_symbol_linkage
+ and lookup_minimal_symbol_natural.
+ * valops.c (find_function_in_inferior): Use lookup_symbol_linkage
+ instead of lookup_symbol. Change comment.
+ * remote.c (remote_check_symbols): Use
+ lookup_minimal_symbol_linkage_or_natural instead of
+ lookup_minimal_symbol, but add FIXME comment as well.
+ * objc-lang.c: Ditto.
+ * c-exp.y: Use lookup_minimal_symbol_linkage_or_natural instead of
+ lookup_minimal_symbol.
+ * p-exp.y: Ditto.
+ * objc-exp.y: Ditto.
+ * m2-exp.y: Ditto.
+ * jv-exp.y (push_expression_name): Ditto.
+ * f-exp.y: Ditto.
+ * printcmd.c (address_info): Ditto.
+ * symtab.h: Declare lookup_minimal_symbol_linkage_or_natural.
+ * minsyms.c (lookup_minimal_symbol_linkage_or_natural): New.
+ * ax-gdb.c (gen_var_ref): Use SYMBOL_LINKAGE_NAME instead of
+ DEPRECATED_SYMBOL_NAME.
+ * tracepoint.c (scope_info): Ditto.
+ * symtab.c (find_pc_sect_line): Ditto.
+ * stabsread.c (define_symbol): Ditto.
+ * sol-thread.c (info_cb): Ditto.
+ * printcmd.c (address_info): Ditto.
+ * hppa-tdep.c (hppa_fix_call_dummy): Ditto.
+ (hppa_in_solib_call_trampoline): Ditto.
+ * findvar.c (read_var_value): Ditto.
+
2003-03-06 David Carlton <carlton@math.stanford.edu>
* minsyms.c (add_minsym_to_hash_table): Use SYMBOL_LINKAGE_NAME.
case LOC_UNRESOLVED:
{
struct minimal_symbol *msym
- = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (var), NULL, NULL);
+ = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
if (!msym)
error ("Couldn't resolve symbol `%s'.", SYMBOL_PRINT_NAME (var));
break;
}
- msymbol = lookup_minimal_symbol (name, NULL, NULL);
+ msymbol
+ = lookup_minimal_symbol_linkage_or_natural (name);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
register char *arg = copy_name ($1.stoken);
msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
+ lookup_minimal_symbol_linkage_or_natural (arg);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
register char *arg = copy_name ($1.stoken);
msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
+ lookup_minimal_symbol_linkage_or_natural (arg);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
{
struct minimal_symbol *msym;
- msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (var), NULL, NULL);
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
if (msym == NULL)
return 0;
if (overlay_debugging)
{
stub_symbol
= lookup_minimal_symbol_solib_trampoline
- (DEPRECATED_SYMBOL_NAME (funsymbol), NULL, objfile);
+ (SYMBOL_LINKAGE_NAME (funsymbol), NULL, objfile);
if (!stub_symbol)
- stub_symbol = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (funsymbol),
+ stub_symbol = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (funsymbol),
NULL, objfile);
/* Found a symbol with the right name. */
return 1;
minsym = lookup_minimal_symbol_by_pc (pc);
- if (minsym && strcmp (DEPRECATED_SYMBOL_NAME (minsym), ".stub") == 0)
+ if (minsym && strcmp (SYMBOL_LINKAGE_NAME (minsym), ".stub") == 0)
return 1;
/* Get the unwind descriptor corresponding to PC, return zero
return orig_pc == pc ? 0 : pc & ~0x3;
}
- libsym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (stubsym), NULL, NULL);
+ libsym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (stubsym), NULL, NULL);
if (libsym == NULL)
{
warning ("Unable to find library symbol for %s\n",
{
struct minimal_symbol *msymbol;
- msymbol = lookup_minimal_symbol (tmp, NULL, NULL);
+ msymbol = lookup_minimal_symbol_linkage_or_natural (tmp);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
register char *arg = copy_name ($1);
msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
+ lookup_minimal_symbol_linkage_or_natural (arg);
if (msymbol != NULL)
{
write_exp_msymbol
static int msym_count;
+static struct minimal_symbol *lookup_minimal_symbol_linkage (const char *name,
+ const char *sfile,
+ struct objfile
+ *objf);
+
+static struct minimal_symbol *lookup_minimal_symbol_natural (const char *name,
+ const char *sfile,
+ struct objfile
+ *objf);
+
static struct minimal_symbol *lookup_minimal_symbol_aux (const char *name,
int linkage,
const char *sfile,
if (sym->demangled_hash_next == NULL)
{
unsigned int hash
- = (msymbol_hash_iw (SYMBOL_NATURAL_NAME (sym))
+ = (msymbol_hash_iw (SYMBOL_DEMANGLED_NAME (sym))
% MINIMAL_SYMBOL_HASH_SIZE);
sym->demangled_hash_next = table[hash];
table[hash] = 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
- symbols considered will be from that source file (global symbols are
- still preferred). Returns a pointer to the minimal symbol that
- matches, or NULL if no match is found.
+ first minimal symbol whose linkage name is LINKAGE_NAME. If OBJF
+ is non-NULL, limit the search to that objfile. If SFILE is
+ non-NULL, the only file-scope symbols considered will be from that
+ source file (global symbols are still preferred). Returns a
+ pointer to the minimal symbol that matches, or NULL if no match is
+ found.
Note: One instance where there may be duplicate minimal symbols with
the same name is when the symbol tables for a shared library and the
symbol tables for an executable contain global symbols with the same
- names (the dynamic linker deals with the duplication).
+ names (the dynamic linker deals with the duplication). */
- This function first searches for matches via linkage names; if it
- doesn't find a match there, it then searches via natural names. */
+/* NOTE: carlton/2003-03-07: This function used to match on natural
+ names as well; if you want that behavior, call
+ lookup_minimal_symbol_linkage_or_natural. */
struct minimal_symbol *
-lookup_minimal_symbol (register const char *name, const char *sfile,
+lookup_minimal_symbol (register const char *linkage_name, const char *sfile,
struct objfile *objf)
{
- struct minimal_symbol *msymbol;
+ return lookup_minimal_symbol_aux (linkage_name, 1, sfile, objf);
+}
- msymbol = lookup_minimal_symbol_linkage (name, sfile, objf);
+/* Search for a minimal symbol named NAME. Search for that name as
+ either a linkage name or a natural name. */
- if (msymbol != NULL)
- return msymbol;
- else
- return lookup_minimal_symbol_natural (name, sfile, objf);
-}
+/* NOTE: carlton/2003-03-07: I normally strongly dislike functions
+ that accept either linkage names or natural names, but I'm making
+ an exception here: callers of this function derive NAME from user
+ input, and do so in situations where using a linkage name might be
+ necessary as a workaround for some of GDB's C++ bugs. */
-/* Search for a minimal symbol via linkage names; args are as in
- lookup_minimal_symbol. */
+/* NOTE: carlton/2003-03-07: This never searches on all natural names
+ at once: it searches on linkage names via strcmp, and on demangled
+ names via strcmp_iw. However, for natural names that turn out to
+ be linkage names of minimal symbols, using strcmp in place of
+ strcmp_iw is safe. (You have to be more careful if the name isn't
+ associated to a minimal symbol: see PR gdb/33.) */
struct minimal_symbol *
-lookup_minimal_symbol_linkage (const char *name, const char *sfile,
- struct objfile *objf)
+lookup_minimal_symbol_linkage_or_natural (const char *name)
{
- return lookup_minimal_symbol_aux (name, 1, sfile, objf);
-}
+ struct minimal_symbol *msymbol;
-/* Search for a minimal symbol via natural names; args are as in
- lookup_minimal_symbol. */
+ msymbol = lookup_minimal_symbol_aux (name, 1, NULL, NULL);
-struct minimal_symbol *
-lookup_minimal_symbol_natural (const char *name, const char *sfile,
- struct objfile *objf)
-{
- return lookup_minimal_symbol_aux (name, 0, sfile, objf);
+ if (msymbol != NULL)
+ return msymbol;
+ else
+ return lookup_minimal_symbol_aux (name, 0, NULL, NULL);
}
/* Helper function for lookup_minimal_symbol and friends, which only
searches for matches via linkage names or natural names but not
both. Args are in lookup_minimal_symbol; if LINKAGE is non-zero,
- search in linkage names, if zero, search in natural names. */
+ search in linkage names via strcmp, and if zero, search in
+ demangled names via strcmp_iw. */
+
+/* NOTE: carlton/2003-03-07: If non-zero, it really only searches in
+ demangled names, not in all natural names. Be careful. */
static struct minimal_symbol *
lookup_minimal_symbol_aux (const char *name, int linkage,
{
if (linkage
? strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0
- : SYMBOL_MATCHES_NATURAL_NAME (msymbol, name))
+ : strcmp_iw (SYMBOL_DEMANGLED_NAME (msymbol), name) == 0)
{
switch (MSYMBOL_TYPE (msymbol))
{
add_minsym_to_hash_table (msym, objfile->msymbol_hash);
msym->demangled_hash_next = 0;
- add_minsym_to_demangled_hash_table (msym,
- objfile->msymbol_demangled_hash);
+ if (SYMBOL_DEMANGLED_NAME (msym) != NULL)
+ add_minsym_to_demangled_hash_table (msym,
+ objfile->msymbol_demangled_hash);
}
}
break;
}
- msymbol = lookup_minimal_symbol (name, NULL, NULL);
+ msymbol
+ = lookup_minimal_symbol_linkage_or_natural (name);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
register char *arg = copy_name ($1.stoken);
msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
+ lookup_minimal_symbol_linkage_or_natural (arg);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
}
if (sym == NULL)
- msym = lookup_minimal_symbol (selector, 0, 0);
+ {
+ /* FIXME: carlton/2003-03-07: I don't know what SELECTOR looks
+ like: is it a linkage name or a natural name? I'll accept
+ natural names for now, to be on the safe side. */
+ msym = lookup_minimal_symbol_linkage_or_natural (selector);
if (msym != NULL)
{
break;
}
- msymbol = lookup_minimal_symbol (name, NULL, NULL);
+ msymbol
+ = lookup_minimal_symbol_linkage_or_natural (name);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
register char *arg = copy_name ($1.stoken);
msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
+ lookup_minimal_symbol_linkage_or_natural (arg);
if (msymbol != NULL)
{
write_exp_msymbol (msymbol,
return;
}
- msymbol = lookup_minimal_symbol (exp, NULL, NULL);
+ msymbol = lookup_minimal_symbol_linkage_or_natural (exp);
if (msymbol != NULL)
{
{
struct minimal_symbol *msym;
- msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, NULL);
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, NULL);
if (msym == NULL)
printf_filtered ("unresolved");
else
tmp = &reply[8];
end = hex2bin (tmp, msg, strlen (tmp) / 2);
msg[end] = '\0';
- sym = lookup_minimal_symbol (msg, NULL, NULL);
+ /* FIXME: carlton/2003-03-07: I have no idea if natural names
+ are allowed here; allowing them is safest. Somebody else
+ should look at this. */
+ sym = lookup_minimal_symbol_linkage_or_natural (msg);
if (sym == NULL)
sprintf (msg, "qSymbol::%s", &reply[8]);
else
struct minimal_symbol *msym;
msym = lookup_minimal_symbol_by_pc (ti.ti_startfunc);
if (msym)
- printf_filtered (" startfunc: %s\n", DEPRECATED_SYMBOL_NAME (msym));
+ printf_filtered (" startfunc: %s\n", SYMBOL_LINKAGE_NAME (msym));
else
printf_filtered (" startfunc: 0x%s\n", paddr (ti.ti_startfunc));
}
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
#ifdef STATIC_TRANSFORM_NAME
- if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym)))
+ if (IS_STATIC_TRANSFORM_NAME (SYMBOL_LINKAGE_NAME (sym)))
{
struct minimal_symbol *msym;
- msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, objfile);
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, objfile);
if (msym != NULL)
{
- DEPRECATED_SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym));
+ SYMBOL_LINKAGE_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_LINKAGE_NAME (sym));
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
}
}
if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym)))
{
struct minimal_symbol *msym;
- msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, objfile);
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, objfile);
if (msym != NULL)
{
- DEPRECATED_SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym));
+ SYMBOL_LINKAGE_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_LINKAGE_NAME (sym));
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
}
}
while (top <= real_top
&& (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0
- : SYMBOL_MATCHES_NATURAL_NAME (*top,name)))
+ : strcmp_iw (SYMBOL_NATURAL_NAME (*top), name) == 0))
{
if (SYMBOL_NAMESPACE (*top) == namespace)
{
{
if (linkage_name != NULL
? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0
- : SYMBOL_MATCHES_NATURAL_NAME (*psym, name))
+ : strcmp_iw (SYMBOL_NATURAL_NAME (*psym), name) == 0)
{
return (*psym);
}
if (msymbol != NULL)
if (MSYMBOL_TYPE (msymbol) == mst_solib_trampoline)
{
- mfunsym = lookup_minimal_symbol_text (DEPRECATED_SYMBOL_NAME (msymbol), NULL, NULL);
+ mfunsym = lookup_minimal_symbol_text (SYMBOL_LINKAGE_NAME (msymbol), NULL, NULL);
if (mfunsym == NULL)
/* I eliminated this warning since it is coming out
* in the following situation:
#define SYMBOL_PRINT_NAME(symbol) \
(demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol))
-/* Macro that tests a symbol for a match against a specified name
- string. It tests against SYMBOL_NATURAL_NAME, and it ignores
- whitespace and trailing parentheses. (See strcmp_iw for details
- about its behavior.) */
-
-#define SYMBOL_MATCHES_NATURAL_NAME(symbol, name) \
- (strcmp_iw (SYMBOL_NATURAL_NAME (symbol), (name)) == 0)
-
/* Define a simple structure used to hold some very basic information about
all defined global symbols (text, data, bss, abs, etc). The only required
information is the general_symbol_info.
const char *,
struct objfile *);
-extern struct minimal_symbol *lookup_minimal_symbol_linkage (const char *,
- const char *,
- struct objfile *);
-
-extern struct minimal_symbol *lookup_minimal_symbol_natural (const char *,
- const char *,
- struct objfile *);
+extern struct
+minimal_symbol *lookup_minimal_symbol_linkage_or_natural (const char *);
extern struct minimal_symbol *lookup_minimal_symbol_text (const char *,
const char *,
REGISTER_NAME (SYMBOL_BASEREG (sym)));
break;
case LOC_UNRESOLVED:
- msym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym), NULL, NULL);
+ msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, NULL);
if (msym == NULL)
printf_filtered ("Unresolved Static");
else
static int coerce_float_to_double;
\f
-/* Find the address of function name NAME in the inferior. */
+/* Find the address of function whose linkage name is NAME in the
+ inferior. */
struct value *
find_function_in_inferior (const char *name)
{
register struct symbol *sym;
- sym = lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL);
+ sym = lookup_symbol_linkage (name);
if (sym != NULL)
{
if (SYMBOL_CLASS (sym) != LOC_BLOCK)