* defs.h (demangle_and_match): Remove prototype.
* dwarfread.c (STREQ, STREQN): Remove macros, replaced with STREQ
and STREQN defined in defs.h.
* dwarfread.c (set_cu_language): For completely unknown languages,
try to deduce the language from the filename. Retain behavior
that for known languages we don't know how to handle, we use
language_unknown.
* dwarfread.c (enum_type, symthesize_typedef): Initialize language
and demangled name fields in symbol.
* dwarfread.c, mipsread.c, partial-stab.h: For all usages of
ADD_PSYMBOL_TO_LIST, add language and objfile parameters.
* dwarfread.c (new_symbol): Attempt to demangle C++ symbol names
and cache the results in SYMBOL_DEMANGLED_NAME for the symbol.
* elfread.c (STREQ): Remove macro, use STREQ defined in defs.h.
Replace usages throughout.
* elfread.c (demangle.h): Include.
* elfread.c (record_minimal_symbol): Remove prototype and function.
* gdbtypes.h, symtab.h (B_SET, B_CLR, B_TST, B_TYPE, B_BYTES,
B_CLRALL): Moved from symtab.h to gdbtypes.h.
* infcmd.c (jump_command): Remove code to demangle name and add
it to a cleanup list. Now just use SYMBOL_DEMANGLED_NAME.
* minsyms.c (demangle.h): Include.
* minsyms.c (lookup_minimal_symbol): Indent comment to match code.
* minsyms.c (install_minimal_symbols): Attempt to demangle symbol
names as C++ names, and cache them in SYMBOL_DEMANGLED_NAME.
* mipsread.c (psymtab_language): Add static variable.
* stabsread.c (demangle.h): Include.
* stabsread.c (define_symbol): Attempt to demangle C++ symbol
names and cache them in the SYMBOL_DEMANGLED_NAME field.
* stack.c (return_command): Remove explicit demangling of name
and use of cleanups. Just use SYMBOL_DEMANGLED_NAME.
* symfile.c (demangle.h): Include.
* symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list): Fix
to match macros in symfile.h and allow them to be compiled
if INLINE_ADD_PSYMBOL is not true.
* symfile.h (INLINE_ADD_PSYMBOL): Default to true if not set.
* symfile.h (ADD_PSYMBOL_*): Add language and objfile parameters.
Add code to demangle and cache C++ symbol names. Use macro form
if INLINE_ADD_PSYMBOL is true, otherwise use C function form.
* symmisc.c (add_psymbol_to_list, add_psymbol_addr_to_list):
Remove, also defined in symfile.c, which we already fixed.
* symtab.c (expensive_mangler): Remove prototype and function.
* symtab.c (find_methods): Remove physnames parameter and fix
prototype to match.
* symtab.c (completion_list_add_symbol): Name changed to
completion_list_add_name.
* symtab.c (COMPLETION_LIST_ADD_SYMBOL): New macro, adds both
the normal symbol name and the cached C++ demangled name.
* symtab.c (lookup_demangled_partial_symbol,
lookup_demangled_block_symbol): Remove prototypes and functions.
* symtab.c (lookup_symbol): Remove use of expensive_mangler,
use lookup_block_symbol instead of lookup_demangled_block_symbol.
Remove code to try demangling names and matching them.
* symtab.c (lookup_partial_symbol, lookup_block_symbol):
Fix to try matching the cached demangled name if no match is
found using the regular symbol name.
* symtab.c (find_methods): Remove unused physnames array.
* symtab.c (name_match, NAME_MATCH): Remove function and macro,
replaced with SYMBOL_MATCHES_REGEXP from symtab.h.
* symtab.c (completion_list_add_symbol): Rewrite to use cached
C++ demangled symbol names.
* symtab.h: Much reformatting of structures and such to add
whitespace to make them more readable, and make them more
consistent with other gdb structure definitions.
* symtab.h (general_symbol_info): New struct containing fields
common to all symbols.
* symtab.h (SYMBOL_LANGUAGE, SYMBOL_DEMANGLED_NAME,
SYMBOL_SOURCE_NAME, SYMBOL_LINKAGE_NAME, SYMBOL_MATCHES_NAME,
SYMBOL_MATCHES_REGEXP, MSYMBOL_INFO, MSYMBOL_TYPE): New macros.
* symtab. (struct minimal_symbol, struct partial_symbol, struct
symbol): Use general_symbol_info struct.
* utils.c (demangle_and_match): Remove, no longer used.
* valops.c (demangle.h): Include.
* xcoffexec.c (eq): Remove macro, replace usages with STREQ.
* blockframe.c, breakpoint.c, c-exp.y, c-valprint.c, dbxread.c,
infcmd.c, m2-exp.y, minsyms.c, objfiles.h, solib.c, stack.c,
symmisc.c, symtab.c, valops.c: Replace references to minimal
symbol fields with appropriate macros.
* breakpoint.c, buildsym.c, c-exp.y, c-typeprint.c, c-valprint.c,
coffread.c, command.c, convex-tdep.c, cp-valprint.c, dbxread.c,
demangle.c, elfread.c, energize.c, environ.c, exec.c,
gdbtypes.c, i960-tdep.c, infrun.c, infrun-hacked.c, language.c,
main.c, minsyms.c, mipsread.c, partial-stab.h, remote-es1800.c,
remote-nindy.c, remote-udi.c, rs6000-tdep.c, solib.c, source.c,
sparc-pinsn.c, stabsread.c, standalone.c, state.c, stuff.c,
symfile.c, symmisc.c, symtab.c, symtab.h, tm-sysv4.h,
tm-ultra3.h, values.c, xcoffexec.c, xcoffread.c: Replace strcmp
and strncmp usages with STREQ, STREQN, or STRCMP as appropriate.
* breakpoint.c, buildsym.c, c-typeprint.c, expprint.c, findvar.c,
mipsread.c, printcmd.c, source.c, stabsread.c, stack.c,
symmisc.c, tm-29k.h, valops.c, values.c: Replace SYMBOL_NAME
references with SYMBOL_SOURCE_NAME or SYMBOL_LINKAGE_NAME as
appropriate.
* buildsym.c (start_subfile, patch_subfile_names): Default the
source language to what can be deduced from the filename.
* buildsym.c (end_symtab): Update the source language in the
allocated symtab to match what we have been using.
* buildsym.h (struct subfile): Add a language field.
* c-typeprint.c (c_print_type): Remove code to do explicit
demangling.
* dbxread.c (psymtab_language): Add static variable.
* dbxread.c (start_psymtab): Initialize psymtab_language using
deduce_language_from_filename.
+Tue Dec 22 20:33:38 1992 Fred Fish (fnf@cygnus.com)
+
+ * defs.h (STRCMP, STREQ, STREQN): New macros.
+ * defs.h (demangle_and_match): Remove prototype.
+ * dwarfread.c (STREQ, STREQN): Remove macros, replaced with STREQ
+ and STREQN defined in defs.h.
+ * dwarfread.c (set_cu_language): For completely unknown languages,
+ try to deduce the language from the filename. Retain behavior
+ that for known languages we don't know how to handle, we use
+ language_unknown.
+ * dwarfread.c (enum_type, symthesize_typedef): Initialize language
+ and demangled name fields in symbol.
+ * dwarfread.c, mipsread.c, partial-stab.h: For all usages of
+ ADD_PSYMBOL_TO_LIST, add language and objfile parameters.
+ * dwarfread.c (new_symbol): Attempt to demangle C++ symbol names
+ and cache the results in SYMBOL_DEMANGLED_NAME for the symbol.
+ * elfread.c (STREQ): Remove macro, use STREQ defined in defs.h.
+ Replace usages throughout.
+ * elfread.c (demangle.h): Include.
+ * elfread.c (record_minimal_symbol): Remove prototype and function.
+ * gdbtypes.h, symtab.h (B_SET, B_CLR, B_TST, B_TYPE, B_BYTES,
+ B_CLRALL): Moved from symtab.h to gdbtypes.h.
+ * infcmd.c (jump_command): Remove code to demangle name and add
+ it to a cleanup list. Now just use SYMBOL_DEMANGLED_NAME.
+ * minsyms.c (demangle.h): Include.
+ * minsyms.c (lookup_minimal_symbol): Indent comment to match code.
+ * minsyms.c (install_minimal_symbols): Attempt to demangle symbol
+ names as C++ names, and cache them in SYMBOL_DEMANGLED_NAME.
+ * mipsread.c (psymtab_language): Add static variable.
+ * stabsread.c (demangle.h): Include.
+ * stabsread.c (define_symbol): Attempt to demangle C++ symbol
+ names and cache them in the SYMBOL_DEMANGLED_NAME field.
+ * stack.c (return_command): Remove explicit demangling of name
+ and use of cleanups. Just use SYMBOL_DEMANGLED_NAME.
+ * symfile.c (demangle.h): Include.
+ * symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list): Fix
+ to match macros in symfile.h and allow them to be compiled
+ if INLINE_ADD_PSYMBOL is not true.
+ * symfile.h (INLINE_ADD_PSYMBOL): Default to true if not set.
+ * symfile.h (ADD_PSYMBOL_*): Add language and objfile parameters.
+ Add code to demangle and cache C++ symbol names. Use macro form
+ if INLINE_ADD_PSYMBOL is true, otherwise use C function form.
+ * symmisc.c (add_psymbol_to_list, add_psymbol_addr_to_list):
+ Remove, also defined in symfile.c, which we already fixed.
+ * symtab.c (expensive_mangler): Remove prototype and function.
+ * symtab.c (find_methods): Remove physnames parameter and fix
+ prototype to match.
+ * symtab.c (completion_list_add_symbol): Name changed to
+ completion_list_add_name.
+ * symtab.c (COMPLETION_LIST_ADD_SYMBOL): New macro, adds both
+ the normal symbol name and the cached C++ demangled name.
+ * symtab.c (lookup_demangled_partial_symbol,
+ lookup_demangled_block_symbol): Remove prototypes and functions.
+ * symtab.c (lookup_symbol): Remove use of expensive_mangler,
+ use lookup_block_symbol instead of lookup_demangled_block_symbol.
+ Remove code to try demangling names and matching them.
+ * symtab.c (lookup_partial_symbol, lookup_block_symbol):
+ Fix to try matching the cached demangled name if no match is
+ found using the regular symbol name.
+ * symtab.c (find_methods): Remove unused physnames array.
+ * symtab.c (name_match, NAME_MATCH): Remove function and macro,
+ replaced with SYMBOL_MATCHES_REGEXP from symtab.h.
+ * symtab.c (completion_list_add_symbol): Rewrite to use cached
+ C++ demangled symbol names.
+ * symtab.h: Much reformatting of structures and such to add
+ whitespace to make them more readable, and make them more
+ consistent with other gdb structure definitions.
+ * symtab.h (general_symbol_info): New struct containing fields
+ common to all symbols.
+ * symtab.h (SYMBOL_LANGUAGE, SYMBOL_DEMANGLED_NAME,
+ SYMBOL_SOURCE_NAME, SYMBOL_LINKAGE_NAME, SYMBOL_MATCHES_NAME,
+ SYMBOL_MATCHES_REGEXP, MSYMBOL_INFO, MSYMBOL_TYPE): New macros.
+ * symtab. (struct minimal_symbol, struct partial_symbol, struct
+ symbol): Use general_symbol_info struct.
+ * utils.c (demangle_and_match): Remove, no longer used.
+ * valops.c (demangle.h): Include.
+ * xcoffexec.c (eq): Remove macro, replace usages with STREQ.
+ * blockframe.c, breakpoint.c, c-exp.y, c-valprint.c, dbxread.c,
+ infcmd.c, m2-exp.y, minsyms.c, objfiles.h, solib.c, stack.c,
+ symmisc.c, symtab.c, valops.c: Replace references to minimal
+ symbol fields with appropriate macros.
+ * breakpoint.c, buildsym.c, c-exp.y, c-typeprint.c, c-valprint.c,
+ coffread.c, command.c, convex-tdep.c, cp-valprint.c, dbxread.c,
+ demangle.c, elfread.c, energize.c, environ.c, exec.c,
+ gdbtypes.c, i960-tdep.c, infrun.c, infrun-hacked.c, language.c,
+ main.c, minsyms.c, mipsread.c, partial-stab.h, remote-es1800.c,
+ remote-nindy.c, remote-udi.c, rs6000-tdep.c, solib.c, source.c,
+ sparc-pinsn.c, stabsread.c, standalone.c, state.c, stuff.c,
+ symfile.c, symmisc.c, symtab.c, symtab.h, tm-sysv4.h,
+ tm-ultra3.h, values.c, xcoffexec.c, xcoffread.c: Replace strcmp
+ and strncmp usages with STREQ, STREQN, or STRCMP as appropriate.
+ * breakpoint.c, buildsym.c, c-typeprint.c, expprint.c, findvar.c,
+ mipsread.c, printcmd.c, source.c, stabsread.c, stack.c,
+ symmisc.c, tm-29k.h, valops.c, values.c: Replace SYMBOL_NAME
+ references with SYMBOL_SOURCE_NAME or SYMBOL_LINKAGE_NAME as
+ appropriate.
+ * buildsym.c (start_subfile, patch_subfile_names): Default the
+ source language to what can be deduced from the filename.
+ * buildsym.c (end_symtab): Update the source language in the
+ allocated symtab to match what we have been using.
+ * buildsym.h (struct subfile): Add a language field.
+ * c-typeprint.c (c_print_type): Remove code to do explicit
+ demangling.
+ * dbxread.c (psymtab_language): Add static variable.
+ * dbxread.c (start_psymtab): Initialize psymtab_language using
+ deduce_language_from_filename.
+
Mon Dec 21 22:24:33 1992 Fred Fish (fnf@cygnus.com)
* valprint.c (val_print): Reorganize comment and add note
{
if (symbol)
{
- complain (&innerblock_complaint, SYMBOL_NAME (symbol));
+ complain (&innerblock_complaint,
+ SYMBOL_SOURCE_NAME (symbol));
}
else
{
for (subfile = subfiles; subfile; subfile = subfile->next)
{
- if (!strcmp (subfile->name, name))
+ if (STREQ (subfile->name, name))
{
current_subfile = subfile;
return;
/* Initialize line-number recording for this subfile. */
subfile->line_vector = NULL;
+
+ /* Default the source language to whatever can be deduced from
+ the filename. If nothing can be deduced (such as for a C/C++
+ include file with a ".h" extension), then inherit whatever
+ language the previous subfile had. This kludgery is necessary
+ because there is no standard way in some object formats to
+ record the source language. Also, when symtabs are allocated
+ we try to deduce a language then as well, but it is too late
+ for us to use that information while reading symbols, since
+ symtabs aren't allocated until after all the symbols have
+ been processed for a given source file. */
+
+ subfile->language = deduce_language_from_filename (subfile->name);
+ if (subfile->language == language_unknown &&
+ subfile->next != NULL)
+ {
+ subfile->language = subfile->next->language;
+ }
}
/* For stabs readers, the first N_SO symbol is assumed to be the source
{
subfile->dirname = subfile->name;
subfile->name = strdup (name);
+
+ /* Default the source language to whatever can be deduced from
+ the filename. If nothing can be deduced (such as for a C/C++
+ include file with a ".h" extension), then inherit whatever
+ language the previous subfile had. This kludgery is necessary
+ because there is no standard way in some object formats to
+ record the source language. Also, when symtabs are allocated
+ we try to deduce a language then as well, but it is too late
+ for us to use that information while reading symbols, since
+ symtabs aren't allocated until after all the symbols have
+ been processed for a given source file. */
+
+ subfile->language = deduce_language_from_filename (subfile->name);
+ if (subfile->language == language_unknown &&
+ subfile->next != NULL)
+ {
+ subfile->language = subfile->next->language;
+ }
}
}
symtab->free_code = free_linetable;
symtab->free_ptr = NULL;
+ /* Use whatever language we have been using for this subfile,
+ not the one that was deduced in allocate_symtab from the
+ filename. We already did our own deducing when we created
+ the subfile, and we may have altered our opinion of what
+ language it is from things we found in the symbols. */
+ symtab->language = subfile->language;
+
#ifdef IBM6000_TARGET
/* In case we need to duplicate symbol tables (to represent include
files), and in case our system needs relocation, we want to
char *dirname;
struct linetable *line_vector;
int line_vector_length;
+ enum language language;
};
EXTERN struct subfile *subfiles;
error ("`%s' is not defined as an aggregate type.",
TYPE_NAME (type));
- if (strcmp (type_name_no_tag (type), $4.ptr))
+ if (!STREQ (type_name_no_tag (type), $4.ptr))
error ("invalid destructor `%s::~%s'",
type_name_no_tag (type), $4.ptr);
{
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) msymbol -> address);
+ write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (UNOP_MEMVAL);
if (msymbol -> type == mst_data ||
{
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) msymbol -> address);
+ write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (UNOP_MEMVAL);
if (msymbol -> type == mst_data ||
fprintf_filtered(stream, "typedef ");
type_print(type,"",stream,0);
if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0
- || 0 != strcmp (TYPE_NAME ((SYMBOL_TYPE (new))),
- SYMBOL_NAME (new)))
- fprintf_filtered(stream, " %s", SYMBOL_NAME(new));
+ || !STREQ (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new)))
+ fprintf_filtered(stream, " %s", SYMBOL_SOURCE_NAME(new));
break;
#endif
#ifdef _LANG_m2
case language_m2:
fprintf_filtered(stream, "TYPE ");
if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
- strcmp (TYPE_NAME(SYMBOL_TYPE(new)),
- SYMBOL_NAME(new)))
- fprintf_filtered(stream, "%s = ", SYMBOL_NAME(new));
+ !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new)))
+ fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new));
else
fprintf_filtered(stream, "<builtin> = ");
type_print(type,"",stream,0);
int level;
{
register enum type_code code;
- char *demangled = NULL;
int demangled_args;
c_type_print_base (type, stream, show, level);
fputs_filtered (" ", stream);
c_type_print_varspec_prefix (type, stream, show, 0);
- /* See if the name has a C++ demangled equivalent, and if so, print that
- instead. */
-
- if (demangle)
- {
- demangled = cplus_demangle (varstring, DMGL_ANSI | DMGL_PARAMS);
- }
- fputs_filtered ((demangled != NULL) ? demangled : varstring, stream);
+ fputs_filtered (varstring, stream);
/* For demangled function names, we have the arglist as part of the name,
so don't print an additional pair of ()'s */
- demangled_args = (demangled != NULL) && (code == TYPE_CODE_FUNC);
+ demangled_args = varstring[strlen(varstring) - 1] == ')';
c_type_print_varspec_suffix (type, stream, show, 0, demangled_args);
- if (demangled != NULL)
- {
- free (demangled);
- }
}
/* Print the C++ method arguments ARGS to the file STREAM. */
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
- int is_constructor = name && strcmp(method_name, name) == 0;
+ int is_constructor = name && STREQ(method_name, name);
for (j = 0; j < len2; j++)
{
QUIT;
for (j = 0; j < len2; j++)
{
QUIT;
- if (!strcmp (SYMBOL_NAME (sym),
- TYPE_FN_FIELD_PHYSNAME (f, j)))
+ if (STREQ (SYMBOL_NAME (sym),
+ TYPE_FN_FIELD_PHYSNAME (f, j)))
{
goto common;
}
struct minimal_symbol *msymbol =
lookup_minimal_symbol_by_pc (vt_address);
- if ((msymbol != NULL) && (vt_address == msymbol -> address))
+ if ((msymbol != NULL) &&
+ (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
{
fputs_filtered (" <", stream);
- fputs_demangled (msymbol -> name, stream,
- DMGL_ANSI | DMGL_PARAMS);
+ fputs_filtered (SYMBOL_SOURCE_NAME (msymbol), stream);
fputs_filtered (">", stream);
}
if (vtblprint)
register struct cmd_list_element *c;
struct cmd_list_element *p;
- while (*list && !strcmp ((*list)->name, name))
+ while (*list && STREQ ((*list)->name, name))
{
if ((*list)->hookee)
(*list)->hookee->hook = 0; /* Hook slips out of its mouth */
if (*list)
for (c = *list; c->next;)
{
- if (!strcmp (c->next->name, name))
+ if (STREQ (c->next->name, name))
{
if (c->next->hookee)
c->next->hookee->hook = 0; /* hooked cmd gets away. */
if ((name[0] == 'v' || name[0] == 'V')
&& (((name[1] & -8) == '0' && name[2] == '\0')
- || !strcmp (name, "vl")
- || !strcmp (name, "vs")
- || !strcmp (name, "vm")))
+ || STREQ (name, "vl")
+ || STREQ (name, "vs")
+ || STREQ (name, "vm")))
return 1;
else return 0;
}
long len = *read_vector_register (VL_REGNUM);
if (len <= 0 || len > 128) len = 128;
- if (!strcmp (name, "vl"))
+ if (STREQ (name, "vl"))
{
val = value_from_longest (builtin_type_int,
(LONGEST) *read_vector_register_1 (VL_REGNUM));
}
- else if (!strcmp (name, "vs"))
+ else if (STREQ (name, "vs"))
{
val = value_from_longest (builtin_type_int,
(LONGEST) *read_vector_register_1 (VS_REGNUM));
}
- else if (!strcmp (name, "vm"))
+ else if (STREQ (name, "vm"))
{
long vm[4];
long i, *p;
char *name = var->name;
long long newval = value_as_long (val);
- if (!strcmp (name, "vl"))
+ if (STREQ (name, "vl"))
write_vector_register (VL_REGNUM, 0, newval);
- else if (!strcmp (name, "vs"))
+ else if (STREQ (name, "vs"))
write_vector_register (VS_REGNUM, 0, newval);
else if (name[0] == 'c' || name[0] == 'C')
write_comm_register (atoi (&name[1]), newval);
- else if (!strcmp (name, "vm"))
+ else if (STREQ (name, "vm"))
error ("can't assign to $vm");
else
{
sequential = !sequential;
printf_filtered ("%s\n", sequential ? "off" : "on");
}
- else if (!strcmp (arg, "on"))
+ else if (STREQ (arg, "on"))
sequential = 0;
- else if (!strcmp (arg, "off"))
+ else if (STREQ (arg, "off"))
sequential = 1;
else error ("valid args are `on', to allow instructions to overlap, or\n\
`off', to prevent it and thereby pinpoint exceptions.");
if (!strncmp (arg, "fixed", strlen (arg)))
parallel = 2;
- else if (!strcmp (arg, "on"))
+ else if (STREQ (arg, "on"))
parallel = 1;
- else if (!strcmp (arg, "off"))
+ else if (STREQ (arg, "off"))
parallel = 0;
else error ("valid args are `on', to allow multiple threads, or\n\
`fixed', to force multiple threads, or\n\
static const char vtbl_ptr_name[] =
{ CPLUS_MARKER,'v','t','b','l','_','p','t','r','_','t','y','p','e', 0 };
- return (typename != NULL && !strcmp(typename, vtbl_ptr_name));
+ return (typename != NULL && STREQ(typename, vtbl_ptr_name));
}
/* Return truth value for the assertion that TYPE is of the type
#define BELIEVE_PCC_PROMOTION 0
#endif
+/* Remember what we deduced to be the source language of this psymtab. */
+
+static enum language psymtab_language = language_unknown;
+
/* Nonzero means give verbose info on gdb action. From main.c. */
extern int info_verbose;
register int i;
for (i = 0; i < n_header_files; i++)
- if (!strcmp (p[i].name, name) && instance == p[i].instance)
+ if (STREQ (p[i].name, name) && instance == p[i].instance)
{
add_this_object_header_file (i);
return;
for (bincl = bincl_list; bincl < next_bincl; bincl++)
if (bincl->instance == instance
- && !strcmp (name, bincl->name))
+ && STREQ (name, bincl->name))
return bincl->pst;
return (struct partial_symtab *) 0;
/* Use the address of dbsubc to finish the last psymtab. */
if (hp_bufp->symbol_type == ST_CODE &&
HP_STRINGTAB (objfile)[hp_bufp->name.n_strx] == '_' &&
- !strcmp (HP_STRINGTAB (objfile) + hp_bufp->name.n_strx, "_dbsubc"))
+ STREQ (HP_STRINGTAB (objfile) + hp_bufp->name.n_strx, "_dbsubc"))
dbsubc_addr = hp_bufp->symbol_value;
if (hp_bufp->symbol_scope == SS_UNIVERSAL)
{
error ("Invalid symbol data; bad HP string table offset: %d",
hp_bufp->name.n_strx);
/* A hack, but gets the job done. */
- if (!strcmp (hp_bufp->name.n_strx + HP_STRINGTAB (objfile),
+ if (STREQ (hp_bufp->name.n_strx + HP_STRINGTAB (objfile),
"$START$"))
objfile -> ei.entry_file_lowpc = hp_bufp->symbol_value;
- if (!strcmp (hp_bufp->name.n_strx + HP_STRINGTAB (objfile),
+ if (STREQ (hp_bufp->name.n_strx + HP_STRINGTAB (objfile),
"_sr4export"))
objfile -> ei.entry_file_highpc = hp_bufp->symbol_value;
record_minimal_symbol (hp_bufp->name.n_strx + HP_STRINGTAB (objfile),
if successful. */
elfstab_offset_sections (objfile, result);
+ /* Deduce the source language from the filename for this psymtab. */
+ psymtab_language = deduce_language_from_filename (filename);
+
return result;
}
minsym = lookup_minimal_symbol (p, objfile);
if (minsym) {
- pst->texthigh = minsym->address + (int)minsym->info;
+ pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) +
+ (int) MSYMBOL_INFO (minsym);
} else {
/* This file ends with a static function, and it's
difficult to imagine how hard it would be to track down
processing_gcc_compilation = 0;
if (bufp->n_type == N_TEXT)
{
- if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
+ if (STREQ (namestring, GCC_COMPILED_FLAG_SYMBOL))
processing_gcc_compilation = 1;
- else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+ else if (STREQ (namestring, GCC2_COMPILED_FLAG_SYMBOL))
processing_gcc_compilation = 2;
}
However, there is no reason not to accept
the GCC_COMPILED_FLAG_SYMBOL anywhere. */
- if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
+ if (STREQ (namestring, GCC_COMPILED_FLAG_SYMBOL))
processing_gcc_compilation = 1;
- else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+ else if (STREQ (namestring, GCC2_COMPILED_FLAG_SYMBOL))
processing_gcc_compilation = 2;
#if 1 /* Works, but is experimental. -fnf */
case N_OPT: /* Solaris 2: Compiler options */
if (name)
{
- if (strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+ if (STREQ (name, GCC2_COMPILED_FLAG_SYMBOL))
{
processing_gcc_compilation = 2;
#if 1 /* Works, but is experimental. -fnf */
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
+/* Gdb does *lots* of string compares. Use macros to speed them up by
+ avoiding function calls if the first characters are not the same. */
+
+#define STRCMP(a,b) (*(a) == *(b) ? strcmp ((a), (b)) : *(a) - *(b))
+#define STREQ(a,b) (*(a) == *(b) ? !strcmp ((a), (b)) : 0)
+#define STREQN(a,b,c) (*(a) == *(b) ? !strncmp ((a), (b), (c)) : 0)
+
/* The character C++ uses to build identifiers that must be unique from
the program's identifiers (such as $this and $$vptr). */
#define CPLUS_MARKER '$' /* May be overridden to '.' for SysV */
extern int
inside_main_func PARAMS ((CORE_ADDR pc));
-/* From cplus-dem.c */
+/* From libiberty.a */
extern char *
cplus_demangle PARAMS ((const char *, int));
/* From utils.c */
-extern char *
-demangle_and_match PARAMS ((const char *, const char *, int));
-
extern int
strcmp_iw PARAMS ((const char *, const char *));
for (dem = demanglers; dem -> demangling_style_name != NULL; dem++)
{
- if (strcmp (current_demangling_style_string,
- dem -> demangling_style_name) == 0)
+ if (STREQ (current_demangling_style_string,
+ dem -> demangling_style_name))
{
current_demangling_style = dem -> demangling_style;
break;
#endif
/* end-sanitize-chill */
-#define STREQ(a,b) (strcmp(a,b)==0)
-#define STREQN(a,b,n) (strncmp(a,b,n)==0)
-
/* Flags to target_to_host() that tell whether or not the data object is
expected to be signed. Used, for example, when fetching a signed
integer in the target environment which is used as a signed integer
case LANG_FORTRAN77:
case LANG_FORTRAN90:
case LANG_PASCAL83:
- default:
+ /* We don't know anything special about these yet. */
cu_language = language_unknown;
break;
+ default:
+ /* If no at_language, try to deduce one from the filename */
+ cu_language = deduce_language_from_filename (dip -> at_name);
+ break;
}
cu_language_defn = language_def (cu_language);
}
memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = create_name (list -> field.name,
&objfile->symbol_obstack);
+ SYMBOL_LANGUAGE (sym) = cu_language;
+ SYMBOL_DEMANGLED_NAME (sym) = NULL;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = type;
{
scan += TARGET_FT_LONG_SIZE (objfile);
ADD_PSYMBOL_TO_LIST (scan, strlen (scan), VAR_NAMESPACE, LOC_CONST,
- objfile -> static_psymbols, 0);
+ objfile -> static_psymbols, 0, cu_language,
+ objfile);
scan += strlen (scan) + 1;
}
}
ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
VAR_NAMESPACE, LOC_BLOCK,
objfile -> global_psymbols,
- dip -> at_low_pc);
+ dip -> at_low_pc, cu_language, objfile);
break;
case TAG_global_variable:
record_minimal_symbol (dip -> at_name, locval (dip -> at_location),
ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
VAR_NAMESPACE, LOC_STATIC,
objfile -> global_psymbols,
- 0);
+ 0, cu_language, objfile);
break;
case TAG_subroutine:
ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
VAR_NAMESPACE, LOC_BLOCK,
objfile -> static_psymbols,
- dip -> at_low_pc);
+ dip -> at_low_pc, cu_language, objfile);
break;
case TAG_local_variable:
ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
VAR_NAMESPACE, LOC_STATIC,
objfile -> static_psymbols,
- 0);
+ 0, cu_language, objfile);
break;
case TAG_typedef:
ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
VAR_NAMESPACE, LOC_TYPEDEF,
objfile -> static_psymbols,
- 0);
+ 0, cu_language, objfile);
break;
case TAG_class_type:
case TAG_structure_type:
ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
STRUCT_NAMESPACE, LOC_TYPEDEF,
objfile -> static_psymbols,
- 0);
+ 0, cu_language, objfile);
if (cu_language == language_cplus)
{
/* For C++, these implicitly act as typedefs as well. */
ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
VAR_NAMESPACE, LOC_TYPEDEF,
objfile -> static_psymbols,
- 0);
+ 0, cu_language, objfile);
}
break;
}
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_TYPE (sym) = decode_die_type (dip);
+
+ /* If this symbol is from a C++ compilation, then attempt to cache the
+ demangled form for future reference. This is a typical time versus
+ space tradeoff, that was decided in favor of time because it sped up
+ C++ symbol lookups by a factor of about 20. */
+
+ SYMBOL_LANGUAGE (sym) = cu_language;
+ if (SYMBOL_LANGUAGE (sym) == language_cplus)
+ {
+ char *demangled =
+ cplus_demangle (SYMBOL_NAME (sym), DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ SYMBOL_DEMANGLED_NAME (sym) =
+ obsavestring (demangled, strlen (demangled),
+ &objfile -> symbol_obstack);
+ free (demangled);
+ }
+ }
+
switch (dip -> die_tag)
{
case TAG_label:
memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = create_name (dip -> at_name,
&objfile->symbol_obstack);
+ SYMBOL_LANGUAGE (sym) = cu_language;
+ SYMBOL_DEMANGLED_NAME (sym) = NULL;
SYMBOL_TYPE (sym) = type;
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
#include "gdb-stabs.h"
#include "complaints.h"
#include <string.h>
-
-#define STREQ(a,b) (strcmp((a),(b))==0)
+#include "demangle.h"
/* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the complation of psymtab-reading.
static struct section_offsets *
elf_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
-#if 0
-static void
-record_minimal_symbol PARAMS ((char *, CORE_ADDR, enum minimal_symbol_type,
- struct objfile *));
-#endif
-
static void
record_minimal_symbol_and_info PARAMS ((char *, CORE_ADDR,
enum minimal_symbol_type, char *,
#endif
-/*
-
-LOCAL FUNCTION
-
- record_minimal_symbol -- add entry to minimal symbol table
-
-SYNOPSIS
-
- static void record_minimal_symbol (char *name, CORE_ADDR address)
-
-DESCRIPTION
-
- Given a pointer to the name of a symbol that should be added to the
- minimal symbol table and the address associated with that symbol, records
- this information for later use in building the minimal symbol table.
-
- */
-
-#if 0 /* FIXME: Unused */
-
-static void
-record_minimal_symbol (name, address, ms_type, objfile)
- char *name;
- CORE_ADDR address;
- enum minimal_symbol_type ms_type;
- struct objfile *objfile;
-{
- name = obsavestring (name, strlen (name), &objfile -> symbol_obstack);
- prim_record_minimal_symbol (name, address, ms_type);
-}
-
-#endif
-
static void
record_minimal_symbol_and_info (name, address, ms_type, info, objfile)
char *name;
switch (sym->name[1])
{
case 'b':
- if (!strcmp ("Bbss.bss", sym->name))
+ if (STREQ ("Bbss.bss", sym->name))
index = SECT_OFF_BSS;
break;
case 'd':
- if (!strcmp ("Ddata.data", sym->name))
+ if (STREQ ("Ddata.data", sym->name))
index = SECT_OFF_DATA;
break;
case 'r':
- if (!strcmp ("Drodata.rodata", sym->name))
+ if (STREQ ("Drodata.rodata", sym->name))
index = SECT_OFF_RODATA;
break;
}
for (; maybe; maybe = maybe->next)
{
if (filename[0] == maybe->filename[0]
- && !strcmp (filename, maybe->filename))
+ && STREQ (filename, maybe->filename))
{
/* We found a match. But there might be several source files
(from different directories) with the same name. */
while (*text == ' ' || *text == '\t') text++;
- if (strcmp(text, "]*[") == 0) /* XXX - What does this mean??? */
+ if (STREQ(text, "]*[")) /* XXX - What does this mean??? */
break;
if (*text != '\000')
else
(*cmdblk->function.cfunc)(arg, from_tty);
- if (strcmp(cmdblk->name, "up") == 0
- || strcmp(cmdblk->name, "down") == 0
- || strcmp(cmdblk->name, "frame") == 0)
+ if (STREQ(cmdblk->name, "up")
+ || STREQ(cmdblk->name, "down")
+ || STREQ(cmdblk->name, "frame"))
send_location(get_frame_info(selected_frame)->pc,
selected_frame_level);
print_prompt();
case OP_VAR_VALUE:
(*pos) += 2;
- fputs_filtered (SYMBOL_NAME (exp->elts[pc + 1].symbol), stream);
+ fputs_filtered (SYMBOL_SOURCE_NAME (exp->elts[pc + 1].symbol), stream);
return;
case OP_LAST:
for (p = current_language -> la_builtin_type_vector; *p != NULL; p++)
{
- if (!strcmp ((**p) -> name, name))
+ if (STREQ ((**p) -> name, name))
{
return (**p);
}
{
char *t_field_name = TYPE_FIELD_NAME (type, i);
- if (t_field_name && !strcmp (t_field_name, name))
+ if (t_field_name && STREQ (t_field_name, name))
{
return TYPE_FIELD_TYPE (type, i);
}
#define FT_NUM_MEMBERS 28 /* Highest FT_* above, plus one. */
+/* Some macros for char-based bitfields. */
+
+#define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7)))
+#define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
+#define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7)))
+#define B_TYPE unsigned char
+#define B_BYTES(x) ( 1 + ((x)>>3) )
+#define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
+
/* Different kinds of data types are distinguished by the `code' field. */
enum type_code
if ((msymbol = lookup_minimal_symbol_by_pc (ip)) != NULL)
{
- if ((p = index (msymbol -> name, '.')) && !strcmp (p, ".lf"))
+ if ((p = index (msymbol -> name, '.')) && STREQ (p, ".lf"))
{
if (next_insn (msymbol -> address, &insn1, &insn2)
&& (insn1 & 0xff87ffff) == 0x5c80161e /* mov g14, gx */
fflush (stdout);
/* No info or after _etext ("Can't happen") */
- if (msymbol == NULL || (msymbol + 1) -> name == NULL)
+ if (msymbol == NULL || SYMBOL_NAME (msymbol + 1) == NULL)
error ("No data available on pc function.");
printf_filtered ("Single stepping until function exit.\n");
fflush (stdout);
- step_range_start = msymbol -> address;
- step_range_end = (msymbol + 1) -> address;
+ step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
+ step_range_end = SYMBOL_VALUE_ADDRESS (msymbol + 1);
}
}
else
struct symtab_and_line sal;
struct symbol *fn;
struct symbol *sfn;
- char *fname;
- struct cleanup *back_to;
ERROR_NO_INFERIOR;
sfn = find_pc_function (sal.pc);
if (fn != NULL && sfn != fn)
{
- fname = strdup_demangled (SYMBOL_NAME (fn));
- back_to = make_cleanup (free, fname);
- if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line, fname))
+ if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
+ SYMBOL_SOURCE_NAME (fn)))
{
error ("Not confirmed.");
/* NOTREACHED */
}
- do_cleanups (back_to);
}
addr = ADDR_BITS_SET (sal.pc);
if (msymbol == NULL)
error ("Execution is not within a known function.");
- step_range_start = msymbol -> address;
+ step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
step_range_end = pc;
}
else
no name, assume we are not in sigtramp). */
#if !defined (IN_SIGTRAMP)
#define IN_SIGTRAMP(pc, name) \
- name && !strcmp ("_sigtramp", name)
+ name && STREQ ("_sigtramp", name)
#endif
/* Tables of how to react to signals; the user sets them. */
/* Search the list of languages for a match. */
for (i = 0; i < languages_size; i++) {
- if (!strcmp (languages[i]->la_name, language)) {
+ if (STREQ (languages[i]->la_name, language)) {
/* Found it! Go into manual mode, and use this language. */
if (languages[i]->la_language == language_auto) {
/* Enter auto mode. Set to the current frame's language, if known. */
char *ignore;
int from_tty;
{
- if (!strcmp(type,"on"))
+ if (STREQ(type,"on"))
{
type_check = type_check_on;
type_mode = type_mode_manual;
}
- else if (!strcmp(type,"warn"))
+ else if (STREQ(type,"warn"))
{
type_check = type_check_warn;
type_mode = type_mode_manual;
}
- else if (!strcmp(type,"off"))
+ else if (STREQ(type,"off"))
{
type_check = type_check_off;
type_mode = type_mode_manual;
}
- else if (!strcmp(type,"auto"))
+ else if (STREQ(type,"auto"))
{
type_mode = type_mode_auto;
set_type_range();
char *ignore;
int from_tty;
{
- if (!strcmp(range,"on"))
+ if (STREQ(range,"on"))
{
range_check = range_check_on;
range_mode = range_mode_manual;
}
- else if (!strcmp(range,"warn"))
+ else if (STREQ(range,"warn"))
{
range_check = range_check_warn;
range_mode = range_mode_manual;
}
- else if (!strcmp(range,"off"))
+ else if (STREQ(range,"off"))
{
range_check = range_check_off;
range_mode = range_mode_manual;
}
- else if (!strcmp(range,"auto"))
+ else if (STREQ(range,"auto"))
{
range_mode = range_mode_auto;
set_type_range();
}
if (i >= len)
return 0; /* Not a valid BOOLEAN value */
- if (!strcmp ("TRUE", TYPE_FIELD_NAME(VALUE_TYPE(val), i)))
+ if (STREQ ("TRUE", TYPE_FIELD_NAME(VALUE_TYPE(val), i)))
return 1; /* BOOLEAN with value TRUE */
else
return 0; /* BOOLEAN with value FALSE */
{
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) msymbol -> address);
+ write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (UNOP_MEMVAL);
if (msymbol -> type == mst_data ||
if (execarg != NULL
&& symarg != NULL
- && strcmp (execarg, symarg) == 0)
+ && STREQ (execarg, symarg))
{
/* The exec file and the symbol-file are the same. If we can't open
it, better only print one error message. */
/* Look it up, and verify that we got an exact match. */
c = lookup_cmd (&tem, cmdlist, "", -1, 1);
- if (c && 0 != strcmp (comname, c->name))
+ if (c && !STREQ (comname, c->name))
c = 0;
if (c)
/* Look up cmd it hooks, and verify that we got an exact match. */
tem = comname+HOOK_LEN;
hookc = lookup_cmd (&tem, cmdlist, "", -1, 0);
- if (hookc && 0 != strcmp (comname+HOOK_LEN, hookc->name))
+ if (hookc && !STREQ (comname+HOOK_LEN, hookc->name))
hookc = 0;
if (!hookc)
{
if (args) error ("The \"pwd\" command does not take an argument: %s", args);
getcwd (dirbuf, sizeof (dirbuf));
- if (strcmp (dirbuf, current_directory))
+ if (!STREQ (dirbuf, current_directory))
printf ("Working directory %s\n (canonically %s).\n",
current_directory, dirbuf);
else
#include "bfd.h"
#include "symfile.h"
#include "objfiles.h"
+#include "demangle.h"
/* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE.
At the end, copy them all into one newly allocated location on an objfile's
if (objf == NULL || objf == objfile)
{
for (msymbol = objfile -> msymbols;
- msymbol != NULL && msymbol -> name != NULL &&
+ msymbol != NULL && SYMBOL_NAME (msymbol) != NULL &&
found_symbol == NULL;
msymbol++)
{
- if (strcmp (msymbol -> name, name) == 0)
+ if (SYMBOL_MATCHES_NAME (msymbol, name))
{
#ifdef IBM6000_TARGET
-/* I *think* all platforms using shared libraries (and trampoline code)
- * will suffer this problem. Consider a case where there are 5 shared
- * libraries, each referencing `foo' with a trampoline entry. When someone
- * wants to put a breakpoint on `foo' and the only info we have is minimal
- * symbol vector, we want to use the real `foo', rather than one of those
- * trampoline entries. MGO */
- /* If a trampoline symbol is found, we prefer to keep looking
- for the *real* symbol. If the actual symbol not found,
- then we'll use the trampoline entry. Sorry for the machine
- dependent code here, but I hope this will benefit other
- platforms as well. For trampoline entries, we used mst_unknown
- earlier. Perhaps we should define a `mst_trampoline' type?? */
-
- if (msymbol->type != mst_unknown)
+ /* I *think* all platforms using shared libraries (and
+ trampoline code) will suffer this problem. Consider a
+ case where there are 5 shared libraries, each referencing
+ `foo' with a trampoline entry. When someone wants to put
+ a breakpoint on `foo' and the only info we have is minimal
+ symbol vector, we want to use the real `foo', rather than
+ one of those trampoline entries. MGO */
+ /* If a trampoline symbol is found, we prefer to keep looking
+ for the *real* symbol. If the actual symbol not found,
+ then we'll use the trampoline entry. Sorry for the machine
+ dependent code here, but I hope this will benefit other
+ platforms as well. For trampoline entries, we used
+ mst_unknown earlier. Perhaps we should define a
+ `mst_trampoline' type?? */
+
+ if (MSYMBOL_TYPE (msymbol) != mst_unknown)
found_symbol = msymbol;
- else if (msymbol->type == mst_unknown && !trampoline_symbol)
+ else if (MSYMBOL_TYPE (msymbol) == mst_unknown &&
+ !trampoline_symbol)
trampoline_symbol = msymbol;
#else
Warning: this code is trickier than it would appear at first. */
/* Should also requires that pc is <= end of objfile. FIXME! */
- if (pc >= msymbol[lo].address)
+ if (pc >= SYMBOL_VALUE_ADDRESS (&msymbol[lo]))
{
- while (msymbol[hi].address > pc)
+ while (SYMBOL_VALUE_ADDRESS (&msymbol[hi]) > pc)
{
/* pc is still strictly less than highest address */
/* Note "new" will always be >= lo */
new = (lo + hi) / 2;
- if ((msymbol[new].address >= pc) || (lo == new))
+ if ((SYMBOL_VALUE_ADDRESS (&msymbol[new]) >= pc) ||
+ (lo == new))
{
hi = new;
}
overall. */
if ((best_symbol == NULL) ||
- (best_symbol -> address < msymbol[hi].address))
+ (SYMBOL_VALUE_ADDRESS (best_symbol) <
+ SYMBOL_VALUE_ADDRESS (&msymbol[hi])))
{
best_symbol = &msymbol[hi];
}
enum minimal_symbol_type ms_type;
{
register struct msym_bunch *new;
+ register struct minimal_symbol *msymbol;
if (msym_bunch_index == BUNCH_SIZE)
{
new -> next = msym_bunch;
msym_bunch = new;
}
- msym_bunch -> contents[msym_bunch_index].name = (char *) name;
- msym_bunch -> contents[msym_bunch_index].address = address;
- msym_bunch -> contents[msym_bunch_index].info = NULL;
- msym_bunch -> contents[msym_bunch_index].type = ms_type;
+ msymbol = &msym_bunch -> contents[msym_bunch_index];
+ SYMBOL_NAME (msymbol) = (char *) name;
+ /* Note that SYMBOL_LANGUAGE and SYMBOL_DEMANGLED_NAME are not initialized
+ to their final values until the minimal symbols are actually added to
+ the minimal symbol table. We just set them to a known state here so
+ random values won't confuse anyone debugging the debugger. */
+ SYMBOL_LANGUAGE (msymbol) = language_unknown;
+ SYMBOL_DEMANGLED_NAME (msymbol) = NULL;
+ SYMBOL_VALUE_ADDRESS (msymbol) = address;
+ MSYMBOL_TYPE (msymbol) = ms_type;
+ /* FIXME: This info, if it remains, needs its own field. */
+ MSYMBOL_INFO (msymbol) = NULL; /* FIXME! */
msym_bunch_index++;
msym_count++;
}
+/* FIXME: Why don't we just combine this function with the one above
+ and pass it a NULL info pointer value if info is not needed? */
+
void
prim_record_minimal_symbol_and_info (name, address, ms_type, info)
const char *name;
char *info;
{
register struct msym_bunch *new;
+ register struct minimal_symbol *msymbol;
if (msym_bunch_index == BUNCH_SIZE)
{
new -> next = msym_bunch;
msym_bunch = new;
}
- msym_bunch -> contents[msym_bunch_index].name = (char *) name;
- msym_bunch -> contents[msym_bunch_index].address = address;
- msym_bunch -> contents[msym_bunch_index].info = NULL;
- msym_bunch -> contents[msym_bunch_index].type = ms_type;
- /* FIXME: This info, if it remains, needs its own field. */
- msym_bunch -> contents[msym_bunch_index].info = info; /* FIXME! */
+ msymbol = &msym_bunch -> contents[msym_bunch_index];
+ SYMBOL_NAME (msymbol) = (char *) name;
+ /* Note that SYMBOL_LANGUAGE and SYMBOL_DEMANGLED_NAME are not initialized
+ to their final values until the minimal symbols are actually added to
+ the minimal symbol table. We just set them to a known state here so
+ random values won't confuse anyone debugging the debugger. */
+ SYMBOL_LANGUAGE (msymbol) = language_unknown;
+ SYMBOL_DEMANGLED_NAME (msymbol) = NULL;
+ SYMBOL_VALUE_ADDRESS (msymbol) = address;
+ MSYMBOL_TYPE (msymbol) = ms_type;
+ /* FIXME: This info, if it remains, needs its own field. */
+ MSYMBOL_INFO (msymbol) = info; /* FIXME! */
msym_bunch_index++;
msym_count++;
}
fn1 = (const struct minimal_symbol *) fn1p;
fn2 = (const struct minimal_symbol *) fn2p;
- if (fn1 -> address < fn2 -> address)
+ if (SYMBOL_VALUE_ADDRESS (fn1) < SYMBOL_VALUE_ADDRESS (fn2))
{
return (-1);
}
- else if (fn1 -> address > fn2 -> address)
+ else if (SYMBOL_VALUE_ADDRESS (fn1) > SYMBOL_VALUE_ADDRESS (fn2))
{
return (1);
}
copyfrom = copyto = msymbol;
while (copyfrom < msymbol + mcount - 1)
{
- if (copyfrom -> address == (copyfrom + 1) -> address
- && (strcmp (copyfrom -> name, (copyfrom + 1) -> name) == 0))
+ if (SYMBOL_VALUE_ADDRESS (copyfrom) ==
+ SYMBOL_VALUE_ADDRESS ((copyfrom + 1)) &&
+ (STREQ (SYMBOL_NAME (copyfrom), SYMBOL_NAME ((copyfrom + 1)))))
{
- if ((copyfrom + 1) -> type == mst_unknown)
+ if (MSYMBOL_TYPE((copyfrom + 1)) == mst_unknown)
{
- (copyfrom + 1) -> type = copyfrom -> type;
+ MSYMBOL_TYPE ((copyfrom + 1)) = MSYMBOL_TYPE (copyfrom);
}
copyfrom++;
}
return (mcount);
}
-/* Add the minimal symbols in the existing bunches to the objfile's
- official minimal symbol table. 99% of the time, this adds the
- bunches to NO existing symbols. Once in a while for shared
- libraries, we add symbols (e.g. common symbols) to an existing
- objfile. */
+/* Add the minimal symbols in the existing bunches to the objfile's official
+ minimal symbol table. In most cases there is no minimal symbol table yet
+ for this objfile, and the existing bunches are used to create one. Once
+ in a while (for shared libraries for example), we add symbols (e.g. common
+ symbols) to an existing objfile.
+
+ Because of the way minimal symbols are collected, we generally have no way
+ of knowing what source language applies to any particular minimal symbol.
+ Specifically, we have no way of knowing if the minimal symbol comes from a
+ C++ compilation unit or not. So for the sake of supporting cached
+ demangled C++ names, we have no choice but to try and demangle each new one
+ that comes in. If the demangling succeeds, then we assume it is a C++
+ symbol and set the symbol's language and demangled name fields
+ appropriately. Note that in order to avoid unnecessary demanglings, and
+ allocating obstack space that subsequently can't be freed for the demangled
+ names, we mark all newly added symbols with language_auto. After
+ compaction of the minimal symbols, we go back and scan the entire minimal
+ symbol table looking for these new symbols. For each new symbol we attempt
+ to demangle it, and if successful, record it as a language_cplus symbol
+ and cache the demangled form on the symbol obstack. Symbols which don't
+ demangle are marked as language_unknown symbols, which inhibits future
+ attempts to demangle them if we later add more minimal symbols. */
void
install_minimal_symbols (objfile)
register struct minimal_symbol *msymbols;
int alloc_count;
register char leading_char;
+ char *demangled_name;
if (msym_count > 0)
{
for (bindex = 0; bindex < msym_bunch_index; bindex++, mcount++)
{
msymbols[mcount] = bunch -> contents[bindex];
- if (msymbols[mcount].name[0] == leading_char)
+ SYMBOL_LANGUAGE (&msymbols[mcount]) = language_auto;
+ if (SYMBOL_NAME (&msymbols[mcount])[0] == leading_char)
{
- msymbols[mcount].name++;
+ SYMBOL_NAME(&msymbols[mcount])++;
}
}
msym_bunch_index = BUNCH_SIZE;
msymbols = (struct minimal_symbol *)
obstack_finish (&objfile->symbol_obstack);
- /* We also terminate the minimal symbol table
- with a "null symbol", which is *not* included in the size of
- the table. This makes it easier to find the end of the table
- when we are handed a pointer to some symbol in the middle of it.
- Zero out the fields in the "null symbol" allocated at the end
- of the array. Note that the symbol count does *not* include
- this null symbol, which is why it is indexed by mcount and not
- mcount-1. */
-
- msymbols[mcount].name = NULL;
- msymbols[mcount].address = 0;
- msymbols[mcount].info = NULL;
- msymbols[mcount].type = mst_unknown;
+ /* We also terminate the minimal symbol table with a "null symbol",
+ which is *not* included in the size of the table. This makes it
+ easier to find the end of the table when we are handed a pointer
+ to some symbol in the middle of it. Zero out the fields in the
+ "null symbol" allocated at the end of the array. Note that the
+ symbol count does *not* include this null symbol, which is why it
+ is indexed by mcount and not mcount-1. */
+
+ SYMBOL_NAME (&msymbols[mcount]) = NULL;
+ SYMBOL_VALUE_ADDRESS (&msymbols[mcount]) = 0;
+ MSYMBOL_INFO (&msymbols[mcount]) = NULL;
+ MSYMBOL_TYPE (&msymbols[mcount]) = mst_unknown;
+ SYMBOL_LANGUAGE (&msymbols[mcount]) = language_unknown;
+ SYMBOL_DEMANGLED_NAME (&msymbols[mcount]) = NULL;
/* Attach the minimal symbol table to the specified objfile.
The strings themselves are also located in the symbol_obstack
objfile -> minimal_symbol_count = mcount;
objfile -> msymbols = msymbols;
+
+ /* Now walk through all the minimal symbols, selecting the newly added
+ ones and attempting to cache their C++ demangled names. */
+
+ for ( ; mcount-- > 0 ; msymbols++)
+ {
+ if (SYMBOL_LANGUAGE (msymbols) == language_auto)
+ {
+ demangled_name = cplus_demangle (SYMBOL_NAME (msymbols),
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled_name == NULL)
+ {
+ SYMBOL_LANGUAGE (msymbols) = language_unknown;
+ }
+ else
+ {
+ SYMBOL_LANGUAGE (msymbols) = language_cplus;
+ SYMBOL_DEMANGLED_NAME (msymbols) =
+ obsavestring (demangled_name, strlen (demangled_name),
+ &objfile->symbol_obstack);
+
+ free (demangled_name);
+ }
+ }
+ }
}
}
/* Traverse all minimal symbols in one objfile. */
#define ALL_OBJFILE_MSYMBOLS(objfile, m) \
- for ((m) = (objfile) -> msymbols; (m)->name != NULL; (m)++)
+ for ((m) = (objfile) -> msymbols; SYMBOL_NAME(m) != NULL; (m)++)
/* Traverse all symtabs in all objfiles. */
&& namestring [nsl - 2] == '.')
#ifdef GDB_TARGET_IS_HPPA
/* some cooperation from gcc to get around ld stupidity */
- || (namestring[0] == 'e' && !strcmp (namestring, "end_file."))
+ || (namestring[0] == 'e' && STREQ (namestring, "end_file."))
#endif
)
{
Record it even if it's local, not global, so we can find it.
FIXME: this might want to check for _DYNAMIC and the current
symbol_leading_char. */
- if (namestring[8] == 'C' && !strcmp ("__DYNAMIC", namestring))
+ if (namestring[8] == 'C' && STREQ ("__DYNAMIC", namestring))
goto record_it;
/* Same with virtual function tables, both global and static. */
things like "break c-exp.y:435" need to work (I
suppose the psymtab_include_list could be hashed or put
in a binary tree, if profiling shows this is a major hog). */
- if (pst && !strcmp (namestring, pst->filename))
+ if (pst && STREQ (namestring, pst->filename))
continue;
{
register int i;
for (i = 0; i < includes_used; i++)
- if (!strcmp (namestring, psymtab_include_list[i]))
+ if (STREQ (namestring, psymtab_include_list[i]))
{
i = -1;
break;
{
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
STRUCT_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ objfile->static_psymbols,
+ CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
if (p[2] == 't')
{
/* Also a typedef with the same name. */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ objfile->static_psymbols,
+ CUR_SYMBOL_VALUE, psymtab_language,
+ objfile);
p += 1;
}
}
{
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ objfile->static_psymbols,
+ CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
}
check_enum:
/* If this is an enumerated type, we need to
enum constants in psymtabs, just in symtabs. */
ADD_PSYMBOL_TO_LIST (p, q - p,
VAR_NAMESPACE, LOC_CONST,
- objfile->static_psymbols, 0);
+ objfile->static_psymbols, 0,
+ psymtab_language, objfile);
/* Point past the name. */
p = q;
/* Skip over the value. */
/* Constant, e.g. from "const" in Pascal. */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_CONST,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ objfile->static_psymbols, CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
default:
/* Skip if the thing following the : is
case 'c':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_CONST,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ objfile->static_psymbols, CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
case 'S':
CUR_SYMBOL_VALUE += ANOFFSET (section_offsets, SECT_OFF_DATA);
ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_STATIC,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ VAR_NAMESPACE, LOC_STATIC,
+ objfile->static_psymbols,
+ CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
case 'G':
CUR_SYMBOL_VALUE += ANOFFSET (section_offsets, SECT_OFF_DATA);
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring,
- VAR_NAMESPACE, LOC_STATIC,
- objfile->global_psymbols, CUR_SYMBOL_VALUE);
+ VAR_NAMESPACE, LOC_STATIC,
+ objfile->global_psymbols,
+ CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
case 't':
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_TYPEDEF,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ objfile->static_psymbols, CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
case 'f':
#endif /* DBXREAD_ONLY */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
- objfile->static_psymbols, CUR_SYMBOL_VALUE);
+ objfile->static_psymbols, CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
/* Global functions were ignored here, but now they
#endif /* DBXREAD_ONLY */
ADD_PSYMBOL_TO_LIST (namestring, p - namestring,
VAR_NAMESPACE, LOC_BLOCK,
- objfile->global_psymbols, CUR_SYMBOL_VALUE);
+ objfile->global_psymbols, CUR_SYMBOL_VALUE,
+ psymtab_language, objfile);
continue;
/* Two things show up here (hopefully); static symbols of
after LEADIN. Print nothing if no symbolic name is found nearby.
DO_DEMANGLE controls whether to print a symbol in its native "raw" form,
or to interpret it as a possible C++ name and convert it back to source
- form. */
+ form. However note that DO_DEMANGLE can be overridden by the specific
+ settings of the demangle and asm_demangle variables. */
void
print_address_symbolic (addr, stream, do_demangle, leadin)
fputs_filtered (leadin, stream);
fputs_filtered ("<", stream);
if (do_demangle)
- fputs_demangled (msymbol -> name, stream, DMGL_ANSI | DMGL_PARAMS);
+ fputs_filtered (SYMBOL_SOURCE_NAME (msymbol), stream);
else
- fputs_filtered (msymbol -> name, stream);
- name_location = msymbol -> address;
+ fputs_filtered (SYMBOL_LINKAGE_NAME (msymbol), stream);
+ name_location = SYMBOL_VALUE_ADDRESS (msymbol);
if (addr - name_location)
fprintf_filtered (stream, "+%d>", addr - name_location);
else
sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE,
&is_a_field_of_this, (struct symtab **)NULL);
- if (sym == 0)
+ if (sym == NULL)
{
if (is_a_field_of_this)
{
if (msymbol != NULL)
printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n",
- exp, local_hex_string(msymbol -> address));
+ exp, local_hex_string(SYMBOL_VALUE_ADDRESS (msymbol)));
else
error ("No symbol \"%s\" in current context.", exp);
return;
if (! first)
fprintf_filtered (stream, ", ");
wrap_here (" ");
- fprint_symbol (stream, SYMBOL_NAME (sym));
+ fprint_symbol (stream, SYMBOL_SOURCE_NAME (sym));
fputs_filtered ("=", stream);
/* Avoid value_print because it will deref ref parameters. We just
for (i = 0; baudtab[i].rate != 0; i++)
{
- if (!strcmp (rate, baudtab[i].rate))
+ if (STREQ (rate, baudtab[i].rate))
{
return (baudtab[i].damn_b);
}
{
memory_error (status, memaddress);
}
- return (strcmp (instr, buf));
+ return (STRCMP (instr, buf));
}
return (-1);
}
;
}
*p2= '\0';
- if ( !strcmp("quit",p) ){
+ if ( STREQ("quit",p) ){
exit(1);
}
{
token++;
- if (strcmp (token, "ms") == 0)
+ if (STREQ (token, "ms"))
stack_sizes[1] = atol (strtok (NULL, " \t"));
- else if (strcmp (token, "rs") == 0)
+ else if (STREQ (token, "rs"))
stack_sizes[0] = atol (strtok (NULL, " \t"));
else
{
const char *section_name;
section_name = bfd_get_section_name (pbfd, section);
- if (strcmp (section_name, ".text") == 0 && !load_text)
+ if (STREQ (section_name, ".text") && !load_text)
continue;
- else if (strcmp (section_name, ".data") == 0 && !load_data)
+ else if (STREQ (section_name, ".data") && !load_data)
continue;
- else if (strcmp (section_name, ".bss") == 0 && !load_bss)
+ else if (STREQ (section_name, ".bss") && !load_bss)
continue;
- else if (strcmp (section_name, ".lit") == 0 && !load_lit)
+ else if (STREQ (section_name, ".lit") && !load_lit)
continue;
To.Offset = bfd_get_section_vma (pbfd, section);
function as well. */
tmp = find_pc_misc_function (pc);
- if (tmp >= 0 && !strcmp (misc_function_vector [tmp].name, "main"))
+ if (tmp >= 0 && STREQ (misc_function_vector [tmp].name, "main"))
return pc + 8;
}
}
p -> addr += (CORE_ADDR) LM_ADDR (so);
p -> endaddr += (CORE_ADDR) LM_ADDR (so);
so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend);
- if (strcmp (p -> sec_ptr -> name, ".text") == 0)
+ if (STREQ (p -> sec_ptr -> name, ".text"))
{
so -> textsection = p;
}
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
- if (strcmp (sym -> name, symname) == 0)
+ if (STREQ (sym -> name, symname))
{
symaddr = sym -> value;
break;
library. We don't want the shared library versions. */
msymbol = lookup_minimal_symbol (DEBUG_BASE, symfile_objfile);
- if ((msymbol != NULL) && (msymbol -> address != 0))
+ if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
- address = msymbol -> address;
+ address = SYMBOL_VALUE_ADDRESS (msymbol);
}
return (address);
struct minimal_symbol *msymbol;
msymbol = lookup_minimal_symbol ("main", symfile_objfile);
- if ((msymbol != NULL) && (msymbol -> address != 0))
+ if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
- breakpoint_addr = msymbol -> address;
+ breakpoint_addr = SYMBOL_VALUE_ADDRESS (msymbol);
}
else
{
{
char *name = s -> filename;
int len = strlen (name);
- if (! (len > 2 && (strcmp (&name[len - 2], ".h") == 0)))
+ if (! (len > 2 && (STREQ (&name[len - 2], ".h"))))
{
current_source_symtab = s;
}
{
char *name = ps -> filename;
int len = strlen (name);
- if (! (len > 2 && (strcmp (&name[len - 2], ".h") == 0)))
+ if (! (len > 2 && (STREQ (&name[len - 2], ".h"))))
{
cs_pst = ps;
}
/* "l" or "l +" lists next ten lines. */
- if (arg == 0 || !strcmp (arg, "+"))
+ if (arg == 0 || STREQ (arg, "+"))
{
if (current_source_symtab == 0)
error ("No default source file yet. Do \"help list\".");
}
/* "l -" lists previous ten lines, the ones before the ten just listed. */
- if (!strcmp (arg, "-"))
+ if (STREQ (arg, "-"))
{
if (current_source_symtab == 0)
error ("No default source file yet. Do \"help list\".");
if (sym)
{
printf_filtered ("%s is in ", local_hex_string(sal.pc));
- fprint_symbol (stdout, SYMBOL_NAME (sym));
+ fputs_filtered (SYMBOL_SOURCE_NAME (sym), stdout);
printf_filtered (" (%s:%d).\n", sal.symtab->filename, sal.line);
}
else
/* Except for aliases, two "identical" instructions had
better have the same opcode. This is a sanity check on the table. */
- i = strcmp (op0->name, op1->name);
+ i = STRCMP (op0->name, op1->name);
if (i)
if (op0->flags & F_ALIAS) /* If they're both aliases, be arbitrary. */
return i;
#include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
#include "buildsym.h"
#include "complaints.h"
+#include "demangle.h"
/* Ask stabsread.h to define the vars it normally declares `extern'. */
#define EXTERN /**/
else
{
normal:
+ SYMBOL_LANGUAGE (sym) = current_subfile -> language;
SYMBOL_NAME (sym) = (char *)
obstack_alloc (&objfile -> symbol_obstack, ((p - string) + 1));
/* Open-coded bcopy--saves function call time. */
+ /* FIXME: Does it really? Try replacing with simple strcpy and
+ try it on an executable with a large symbol table. */
{
register char *p1 = string;
register char *p2 = SYMBOL_NAME (sym);
}
*p2++ = '\0';
}
+
+ /* If this symbol is from a C++ compilation, then attempt to cache the
+ demangled form for future reference. This is a typical time versus
+ space tradeoff, that was decided in favor of time because it sped up
+ C++ symbol lookups by a factor of about 20. */
+
+ if (SYMBOL_LANGUAGE (sym) == language_cplus)
+ {
+ char *demangled =
+ cplus_demangle (SYMBOL_NAME (sym), DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ SYMBOL_DEMANGLED_NAME (sym) =
+ obsavestring (demangled, strlen (demangled),
+ &objfile -> symbol_obstack);
+ free (demangled);
+ }
+ }
}
p++;
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
if (SYMBOL_VALUE (sym) >= NUM_REGS)
{
- complain (®_value_complaint, SYMBOL_NAME (sym));
+ complain (®_value_complaint, SYMBOL_SOURCE_NAME (sym));
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
}
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
if (SYMBOL_VALUE (sym) >= NUM_REGS)
{
- complain (®_value_complaint, SYMBOL_NAME (sym));
+ complain (®_value_complaint, SYMBOL_SOURCE_NAME (sym));
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
}
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
if (synonym)
{
+ /* Clone the sym and then modify it. */
register struct symbol *typedef_sym = (struct symbol *)
obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
- memset (typedef_sym, 0, sizeof (struct symbol));
- SYMBOL_NAME (typedef_sym) = SYMBOL_NAME (sym);
- SYMBOL_TYPE (typedef_sym) = SYMBOL_TYPE (sym);
-
+ *typedef_sym = *sym;
SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
SYMBOL_VALUE (typedef_sym) = valu;
SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
&& SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
&& (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
- && !strcmp (SYMBOL_NAME (sym), type_name_only))
+ && STREQ (SYMBOL_NAME (sym), type_name_only))
{
obstack_free (&objfile -> type_obstack, type_name);
type = SYMBOL_TYPE (sym);
obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
SYMBOL_NAME (sym) = name;
+ SYMBOL_LANGUAGE (sym) = current_subfile -> language;
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_VALUE (sym) = n;
/* This screws up perfectly good C programs with enums. FIXME. */
/* Is this Modula-2's BOOLEAN type? Flag it as such if so. */
if(TYPE_NFIELDS(type) == 2 &&
- ((!strcmp(TYPE_FIELD_NAME(type,0),"TRUE") &&
- !strcmp(TYPE_FIELD_NAME(type,1),"FALSE")) ||
- (!strcmp(TYPE_FIELD_NAME(type,1),"TRUE") &&
- !strcmp(TYPE_FIELD_NAME(type,0),"FALSE"))))
+ ((STREQ(TYPE_FIELD_NAME(type,0),"TRUE") &&
+ STREQ(TYPE_FIELD_NAME(type,1),"FALSE")) ||
+ (STREQ(TYPE_FIELD_NAME(type,1),"TRUE") &&
+ STREQ(TYPE_FIELD_NAME(type,0),"FALSE"))))
TYPE_CODE(type) = TYPE_CODE_BOOL;
#endif
&& SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
&& (TYPE_CODE (SYMBOL_TYPE (sym)) ==
TYPE_CODE (*type))
- && !strcmp (SYMBOL_NAME (sym), typename))
+ && STREQ (SYMBOL_NAME (sym), typename))
{
memcpy (*type, SYMBOL_TYPE (sym),
sizeof (struct type));
if (objfile->msymbols == 0) /* Beware the null file. */
return;
- for (msymbol = objfile -> msymbols; msymbol -> name != NULL; msymbol++)
+ for (msymbol = objfile -> msymbols; SYMBOL_NAME (msymbol) != NULL; msymbol++)
{
QUIT;
/* Get the hash index and check all the symbols
under that hash index. */
- hash = hashname (msymbol -> name);
+ hash = hashname (SYMBOL_NAME (msymbol));
for (sym = global_sym_chain[hash]; sym;)
{
- if (*(msymbol -> name) == SYMBOL_NAME (sym)[0]
- && !strcmp(msymbol -> name + 1, SYMBOL_NAME (sym) + 1))
+ if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
+ STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
{
/* Splice this symbol out of the hash chain and
assign the value we have to it. */
if (SYMBOL_CLASS (sym) == LOC_BLOCK)
{
- fix_common_block (sym, msymbol -> address);
+ fix_common_block (sym, SYMBOL_VALUE_ADDRESS (msymbol));
}
else
{
- SYMBOL_VALUE_ADDRESS (sym) = msymbol -> address;
+ SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msymbol);
}
if (prev)
for (next - files_start; * (int *) next;
next += * (int *) next)
{
- if (!strcmp (next + 4, filename))
+ if (!STRCMP (next + 4, filename))
{
sourcebeg = next + 4 + strlen (next + 4) + 1;
sourcebeg = (char *) (((int) sourcebeg + 3) & (-4));
while (*++argv != NULL)
{
- if (strcmp (*argv, "symbols") == 0)
+ if (STREQ (*argv, "symbols"))
{
if (from_tty
&& !query ("load symbol table state from file \"%s\"? ",
fseek (asfd -> fp, sizeof (sf_hdr), SEEK_SET);
while (*++argv != NULL)
{
- if (strcmp (*argv, "objfile") == 0)
+ if (STREQ (*argv, "objfile"))
{
write_objfile_state (asfd);
}
outfile = 0;
for (i = 1; i < argc; i++)
{
- if (strcmp (argv[i], "-o") == 0)
+ if (STREQ (argv[i], "-o"))
outfile = argv[++i];
}
if (outfile == 0)
* that name the output file. */
for (i = 1; i < argc; i++)
{
- if (strcmp (argv[i], "-o") == 0)
+ if (STREQ (argv[i], "-o"))
continue;
if ((in_fd = open (argv[i], O_RDONLY)) < 0)
err ("Error opening %s for read: %s\n", argv[i],
{
if ((sym->n_type & N_TYPE) != N_DATA) continue;
if (sym->n_un.n_strx == 0) continue;
- if (strcmp (sym_name, strings + sym->n_un.n_strx - 4) == 0)
+ if (STREQ (sym_name, strings + sym->n_un.n_strx - 4))
return sym->n_value;
}
err ("Data symbol %s not found in %s\n", sym_name, file);
#include "breakpoint.h"
#include "language.h"
#include "complaints.h"
+#include "demangle.h"
#include <obstack.h>
#include <assert.h>
if (namediff != 0) return namediff;
/* If they match, compare the rest of the names. */
- namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2));
+ namediff = STRCMP (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2));
if (namediff != 0) return namediff;
/* For symbols of the same name, registers should come first. */
}
else
{
- return (strcmp (st1 + 2, st2 + 2));
+ return (STRCMP (st1 + 2, st2 + 2));
}
}
warning ("no loadable sections found in added symbol-file %s",
objfile->name);
else if (0 == bfd_get_section_name (objfile->obfd, lowest_sect)
- || 0 != strcmp(".text",
+ || !STREQ (".text",
bfd_get_section_name (objfile->obfd, lowest_sect)))
warning ("Lowest section in %s is %s at 0x%x",
objfile->name,
cleanups = make_cleanup (freeargv, (char *) argv);
while (*argv != NULL)
{
- if (strcmp (*argv, "-mapped") == 0)
+ if (STREQ (*argv, "-mapped"))
{
mapped = 1;
}
- else if (strcmp (*argv, "-readnow") == 0)
+ else if (STREQ (*argv, "-readnow"))
{
readnow = 1;
}
{
name = arg;
}
- else if (strcmp (arg, "-mapped") == 0)
+ else if (STREQ (arg, "-mapped"))
{
mapped = 1;
}
- else if (strcmp (arg, "-readnow") == 0)
+ else if (STREQ (arg, "-readnow"))
{
readnow = 1;
}
char *c = strrchr (filename, '.');
if (!c) ; /* Get default. */
- else if(!strcmp(c,".mod"))
+ else if(STREQ(c,".mod"))
return language_m2;
- else if(!strcmp(c,".c"))
+ else if(STREQ(c,".c"))
return language_c;
- else if(!strcmp(c,".cc") || !strcmp(c,".C"))
+ else if(STREQ(c,".cc") || STREQ(c,".C"))
return language_cplus;
/* start-sanitize-chill */
- else if(!strcmp(c,".chill") || !strcmp(c,".c186") || !strcmp(c,".c286"))
+ else if(STREQ(c,".ch") || STREQ(c,".c186") || STREQ(c,".c286"))
return language_chill;
/* end-sanitize-chill */
again2:
for (ps = partial_symtab_list; ps; ps = ps->next) {
- if (!strcmp (name, ps->filename)) {
+ if (STREQ (name, ps->filename)) {
cashier_psymtab (ps); /* Blow it away...and its little dog, too. */
goto again2; /* Must restart, chain has been munged */
}
for (s = symtab_list; s; s = s->next)
{
- if (!strcmp (name, s->filename))
+ if (STREQ (name, s->filename))
break;
prev = s;
}
/* Debugging versions of functions that are usually inline macros
(see symfile.h). */
-#if 0 /* Don't quite work nowadays... */
+#if !INLINE_ADD_PSYMBOL
/* Add a symbol with a long value to a psymtab.
Since one arg is a struct, we pass in a ptr and deref it (sigh). */
void
-add_psymbol_to_list (name, namelength, namespace, class, list, val)
+add_psymbol_to_list (name, namelength, namespace, class, list, val, language,
+ objfile)
char *name;
int namelength;
enum namespace namespace;
enum address_class class;
struct psymbol_allocation_list *list;
long val;
+ enum language language;
+ struct objfile *objfile;
{
- ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, (*list), val,
- SYMBOL_VALUE);
+ register struct partial_symbol *psym;
+ register char *demangled_name;
+
+ if (list->next >= list->list + list->size)
+ {
+ extend_psymbol_list (list,objfile);
+ }
+ psym = list->next++;
+
+ SYMBOL_NAME (psym) =
+ (char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1);
+ memcpy (SYMBOL_NAME (psym), name, namelength);
+ SYMBOL_NAME (psym)[namelength] = '\0';
+ SYMBOL_VALUE (psym) = val;
+ SYMBOL_LANGUAGE (psym) = language;
+ PSYMBOL_NAMESPACE (psym) = namespace;
+ PSYMBOL_CLASS (psym) = class;
+ if (language == language_cplus)
+ {
+ demangled_name =
+ cplus_demangle (SYMBOL_NAME (psym), DMGL_PARAMS | DMGL_ANSI);
+ if (demangled_name == NULL)
+ {
+ SYMBOL_DEMANGLED_NAME (psym) = NULL;
+ }
+ else
+ {
+ SYMBOL_DEMANGLED_NAME (psym) =
+ obsavestring (demangled_name, strlen (demangled_name),
+ &objfile->psymbol_obstack);
+ free (demangled_name);
+ }
+ }
}
/* Add a symbol with a CORE_ADDR value to a psymtab. */
void
-add_psymbol_addr_to_list (name, namelength, namespace, class, list, val)
+add_psymbol_addr_to_list (name, namelength, namespace, class, list, val,
+ language, objfile)
char *name;
int namelength;
enum namespace namespace;
enum address_class class;
struct psymbol_allocation_list *list;
CORE_ADDR val;
+ enum language language;
+ struct objfile *objfile;
{
- ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, (*list), val,
- SYMBOL_VALUE_ADDRESS);
+ register struct partial_symbol *psym;
+ register char *demangled_name;
+
+ if (list->next >= list->list + list->size)
+ {
+ extend_psymbol_list (list,objfile);
+ }
+ psym = list->next++;
+
+ SYMBOL_NAME (psym) =
+ (char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1);
+ memcpy (SYMBOL_NAME (psym), name, namelength);
+ SYMBOL_NAME (psym)[namelength] = '\0';
+ SYMBOL_VALUE_ADDRESS (psym) = val;
+ SYMBOL_LANGUAGE (psym) = language;
+ PSYMBOL_NAMESPACE (psym) = namespace;
+ PSYMBOL_CLASS (psym) = class;
+ if (language == language_cplus)
+ {
+ demangled_name =
+ cplus_demangle (SYMBOL_NAME (psym), DMGL_PARAMS | DMGL_ANSI);
+ if (demangled_name == NULL)
+ {
+ SYMBOL_DEMANGLED_NAME (psym) = NULL;
+ }
+ else
+ {
+ SYMBOL_DEMANGLED_NAME (psym) =
+ obsavestring (demangled_name, strlen (demangled_name),
+ &objfile->psymbol_obstack);
+ free (demangled_name);
+ }
+ }
}
-#endif /* 0 */
+#endif /* !INLINE_ADD_PSYMBOL */
+
\f
void
_initialize_symfile ()
/* Add any kind of symbol to a psymbol_allocation_list. */
-#define ADD_PSYMBOL_VT_TO_LIST(NAME,NAMELENGTH,NAMESPACE,CLASS,LIST,VALUE,VT) \
+#ifndef INLINE_ADD_PSYMBOL
+#define INLINE_ADD_PSYMBOL 1
+#endif
+
+#if !INLINE_ADD_PSYMBOL
+
+/* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */
+
+#define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value, language, objfile) \
+ add_psymbol_to_list (name, namelength, namespace, class, &list, value, language, objfile)
+
+#define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value, language, objfile) \
+ add_psymbol_addr_to_list (name, namelength, namespace, class, &list, value, language, objfile)
+
+#else /* !INLINE_ADD_PSYMBOL */
+
+#include "demangle.h"
+
+#define ADD_PSYMBOL_VT_TO_LIST(NAME,NAMELENGTH,NAMESPACE,CLASS,LIST,VALUE,VT,LANGUAGE, OBJFILE) \
do { \
register struct partial_symbol *psym; \
+ register char *demangled_name; \
if ((LIST).next >= (LIST).list + (LIST).size) \
- extend_psymbol_list (&(LIST),objfile); \
+ extend_psymbol_list (&(LIST),(OBJFILE)); \
psym = (LIST).next++; \
- \
- SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack, \
- (NAMELENGTH) + 1); \
+ SYMBOL_NAME (psym) = \
+ (char *) obstack_alloc (&objfile->psymbol_obstack, \
+ (NAMELENGTH) + 1); \
memcpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \
SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \
SYMBOL_NAMESPACE (psym) = (NAMESPACE); \
- SYMBOL_CLASS (psym) = (CLASS); \
+ PSYMBOL_CLASS (psym) = (CLASS); \
VT (psym) = (VALUE); \
+ SYMBOL_LANGUAGE (psym) = (LANGUAGE); \
+ if ((LANGUAGE) == language_cplus) \
+ { \
+ demangled_name = \
+ cplus_demangle (SYMBOL_NAME (psym), DMGL_PARAMS | DMGL_ANSI); \
+ if (demangled_name == NULL) \
+ { \
+ SYMBOL_DEMANGLED_NAME (psym) = NULL; \
+ } \
+ else \
+ { \
+ SYMBOL_DEMANGLED_NAME (psym) = \
+ obsavestring (demangled_name, strlen (demangled_name), \
+ &objfile->psymbol_obstack); \
+ free (demangled_name); \
+ } \
+ } \
} while (0);
-#ifdef DEBUG
-
-/* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */
-
-#define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \
- add_psymbol_to_list (name, namelength, namespace, class, &list, value)
-
-#define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value) \
- add_psymbol_addr_to_list (name, namelength, namespace, class, &list, value)
-
-#else /* !DEBUG */
-
/* Add a symbol with an integer value to a psymtab. */
-#define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \
- ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE)
+#define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value, language, objfile) \
+ ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE, language, objfile)
/* Add a symbol with a CORE_ADDR value to a psymtab. */
-#define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value)\
- ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE_ADDRESS)
+#define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value, language, objfile)\
+ ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE_ADDRESS, language, objfile)
-#endif /* DEBUG */
+#endif /* INLINE_ADD_PSYMBOL */
/* Functions */
fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile -> name);
for (index = 0, msymbol = objfile -> msymbols;
- msymbol -> name != NULL; msymbol++, index++)
+ SYMBOL_NAME (msymbol) != NULL; msymbol++, index++)
{
switch (msymbol -> type)
{
ms_type = '?';
break;
}
- fprintf_filtered (outfile, "[%2d] %c %#10x %s\n", index, ms_type,
- msymbol -> address, msymbol -> name);
+ fprintf_filtered (outfile, "[%2d] %c %#10x %s", index, ms_type,
+ SYMBOL_VALUE_ADDRESS (msymbol), SYMBOL_NAME (msymbol));
+ if (SYMBOL_LANGUAGE (msymbol) == language_cplus &&
+ SYMBOL_DEMANGLED_NAME (msymbol) != NULL)
+ {
+ fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol));
+ }
+ fputs_filtered ("\n", outfile);
}
if (objfile -> minimal_symbol_count != index)
{
if (BLOCK_SUPERBLOCK (b))
fprintf (outfile, " (under 0x%x)", (unsigned int) BLOCK_SUPERBLOCK (b));
if (BLOCK_FUNCTION (b))
- fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b)));
+ {
+ fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b)));
+ if (SYMBOL_LANGUAGE (BLOCK_FUNCTION (b)) == language_cplus &&
+ SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL)
+ {
+ fprintf (outfile, " %s",
+ SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)));
+ }
+ }
if (BLOCK_GCC_COMPILED(b))
fprintf (outfile, " gcc%d compiled", BLOCK_GCC_COMPILED(b));
fputc ('\n', outfile);
immediate_quit++;
ALL_SYMTABS (objfile, s)
- if (symname == NULL || (strcmp (symname, s -> filename) == 0))
+ if (symname == NULL || (STREQ (symname, s -> filename)))
dump_symtab (objfile, s, outfile);
immediate_quit--;
do_cleanups (cleanups);
print_spaces (depth, outfile);
if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE)
{
- fprintf (outfile, "label %s at 0x%x\n", SYMBOL_NAME (symbol),
+ fprintf (outfile, "label %s at 0x%x\n", SYMBOL_SOURCE_NAME (symbol),
SYMBOL_VALUE_ADDRESS (symbol));
return;
}
fprintf (outfile, "; ");
}
else
- fprintf (outfile, "%s ", SYMBOL_NAME (symbol));
+ fprintf (outfile, "%s ", SYMBOL_SOURCE_NAME (symbol));
switch (SYMBOL_CLASS (symbol))
{
immediate_quit++;
ALL_PSYMTABS (objfile, ps)
- if (symname == NULL || (strcmp (symname, ps -> filename) == 0))
+ if (symname == NULL || (STREQ (symname, ps -> filename)))
dump_psymtab (objfile, ps, outfile);
immediate_quit--;
do_cleanups (cleanups);
fprintf_filtered (outfile, " %s partial symbols:\n", what);
while (count-- > 0)
{
- fprintf_filtered (outfile, " `%s', ", SYMBOL_NAME(p));
+ fprintf_filtered (outfile, " `%s'", SYMBOL_NAME(p));
+ if (SYMBOL_LANGUAGE (p) == language_cplus &&
+ SYMBOL_DEMANGLED_NAME (p) != NULL)
+ {
+ fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (p));
+ }
+ fputs_filtered (", ", outfile);
switch (SYMBOL_NAMESPACE (p))
{
case UNDEF_NAMESPACE:
immediate_quit++;
ALL_OBJFILES (objfile)
- if (symname == NULL || (strcmp (symname, objfile -> name) == 0))
+ if (symname == NULL || (STREQ (symname, objfile -> name)))
dump_msymbols (objfile, outfile);
immediate_quit--;
fprintf_filtered (outfile, "\n\n");
listp->next = listp->list + listp->size;
listp->size = new_size;
}
-
-#ifdef DEBUG
-
-/* The work performed by this function is normally done by the macro
- ADD_PSYMBOL_TO_LIST defined in symfile.h. When debugging gdb, this
- function makes things easier. */
-
-void
-add_psymbol_to_list (name, namelength, namespace, class, listp, psymval)
- char *name;
- int namelength;
- enum namespace namespace;
- enum address_class class;
- struct psymbol_allocation_list *listp;
- unsigned long psymval;
-{
- register struct partial_symbol *psym;
-
- if (listp -> next >= listp -> list + listp -> size)
- extend_psymbol_list (listp, objfile);
- psym = listp -> next++;
- SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack,
- namelength + 1);
- memcpy (SYMBOL_NAME (psym), name, namelength);
- SYMBOL_NAME (psym)[namelength] = '\0';
- SYMBOL_NAMESPACE (psym) = namespace;
- SYMBOL_CLASS (psym) = class;
- SYMBOL_VALUE (psym) = psymval;
-}
-
-/* The work performed by this function is normally done by the macro
- ADD_PSYMBOL_ADDR_TO_LIST defined in symfile.h. When debugging gdb, this
- function makes things easier. */
-
-void
-add_psymbol_addr_to_list (name, namelength, namespace, class, listp, psymval)
- char *name;
- int namelength;
- enum namespace namespace;
- enum address_class class;
- struct psymbol_allocation_list *listp;
- CORE_ADDR psymval;
-{
- register struct partial_symbol *psym;
-
- if (listp -> next >= listp -> list + listp -> size)
- extend_psymbol_list (listp, objfile);
- psym = listp -> next++;
- SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack,
- namelength + 1);
- memcpy (SYMBOL_NAME (psym), name, namelength);
- SYMBOL_NAME (psym)[namelength] = '\0';
- SYMBOL_NAMESPACE (psym) = namespace;
- SYMBOL_CLASS (psym) = class;
- SYMBOL_VALUE_ADDRESS (psym) = psymval;
-}
-
-#endif /* DEBUG */
/* Prototypes for local functions */
-static char *
-expensive_mangler PARAMS ((const char *));
-
extern int
-find_methods PARAMS ((struct type *, char *, char **, struct symbol **));
+find_methods PARAMS ((struct type *, char *, struct symbol **));
static void
-completion_list_add_symbol PARAMS ((char *, char *, int));
+completion_list_add_name PARAMS ((char *, char *, int));
static struct symtabs_and_lines
decode_line_2 PARAMS ((struct symbol *[], int, int));
lookup_partial_symbol PARAMS ((struct partial_symtab *, const char *,
int, enum namespace));
-static struct partial_symbol *
-lookup_demangled_partial_symbol PARAMS ((const struct partial_symtab *,
- const char *));
-
-static struct symbol *
-lookup_demangled_block_symbol PARAMS ((const struct block *, const char *));
-
static struct symtab *
lookup_symtab_1 PARAMS ((char *));
/* First, search for an exact match */
ALL_SYMTABS (objfile, s)
- if (strcmp (name, s->filename) == 0)
+ if (STREQ (name, s->filename))
return s;
slash = strchr (name, '/');
if (tail)
p = tail + 1;
- if (strcmp (p, name) == 0)
+ if (STREQ (p, name))
return s;
}
psymtabs. */
ALL_PSYMTABS (objfile, ps)
- if (strcmp (name, ps -> filename) == 0)
+ if (STREQ (name, ps -> filename))
goto got_psymtab;
if (!slash)
if (tail)
p = tail + 1;
- if (strcmp (p, name) == 0)
+ if (STREQ (p, name))
goto got_psymtab;
}
ALL_PSYMTABS (objfile, pst)
{
- if (strcmp (name, pst -> filename) == 0)
+ if (STREQ (name, pst -> filename))
{
return (pst);
}
char *field_name = TYPE_FN_FIELDLIST_NAME (type, i);
char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
char *newname = type_name_no_tag (type);
- int is_constructor = strcmp(field_name, newname) == 0;
+ int is_constructor = STREQ (field_name, newname);
int is_destructor = is_constructor && physname[0] == '_'
&& physname[1] == CPLUS_MARKER && physname[2] == '_';
/* Need a new type prefix. */
char *temp;
extern char *gdb_completer_word_break_characters;
- /* If NAME contains any characters from gdb_completer_word_break_characters
- then it is probably from a quoted name string. So check to see if it
- has a C++ mangled equivalent, and if so, use the mangled equivalent. */
-
- if (strpbrk (name, gdb_completer_word_break_characters) != NULL)
- {
- if ((temp = expensive_mangler (name)) != NULL)
- {
- name = temp;
- }
- }
-
/* Search specified block and its superiors. */
while (block != 0)
block = BLOCK_SUPERBLOCK (block);
}
- /* But that doesn't do any demangling for the STATIC_BLOCK.
- I'm not sure whether demangling is needed in the case of
- nested function in inner blocks; if so this needs to be changed.
-
- Don't need to mess with the psymtabs; if we have a block,
+ /* Don't need to mess with the psymtabs; if we have a block,
that file is read in. If we don't, then we deal later with
all the psymtab stuff that needs checking. */
if (namespace == VAR_NAMESPACE && block != NULL)
if (BLOCK_START (b) <= BLOCK_START (block)
&& BLOCK_END (b) > BLOCK_START (block))
{
- sym = lookup_demangled_block_symbol (b, name);
+ sym = lookup_block_symbol (b, name, VAR_NAMESPACE);
if (sym)
{
block_found = b;
if (namespace == VAR_NAMESPACE)
{
msymbol = lookup_minimal_symbol (name, (struct objfile *) NULL);
-
- if (msymbol == NULL)
- {
- /* Test each minimal symbol to see if the minimal symbol's name
- is a C++ mangled name that matches a user visible name. */
-
- char *demangled;
-
- ALL_MSYMBOLS (objfile, msymbol)
- {
- demangled = demangle_and_match (msymbol -> name, name,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- goto found_msym;
- }
- }
- msymbol = NULL; /* Not found */
- }
-
-found_msym:
if (msymbol != NULL)
{
- s = find_pc_symtab (msymbol -> address);
+ s = find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol));
/* If S is NULL, there are no debug symbols for this file.
Skip this stuff and check for matching static symbols below. */
if (s != NULL)
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, msymbol -> name, namespace);
+ sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
+ namespace);
/* We kept static functions in minimal symbol table as well as
in static scope. We want to find them in the symbol table. */
if (!sym) {
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, msymbol -> name,
+ sym = lookup_block_symbol (block, SYMBOL_NAME (msymbol),
namespace);
}
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_demangled_block_symbol (block, name);
+ sym = lookup_block_symbol (block, name, VAR_NAMESPACE);
if (sym)
{
block_found = block;
ALL_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_demangled_partial_symbol (ps, name))
+ if (!ps->readin && lookup_partial_symbol (ps, name, 0, VAR_NAMESPACE))
{
s = PSYMTAB_TO_SYMTAB(ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_demangled_block_symbol (block, name);
+ sym = lookup_block_symbol (block, name, VAR_NAMESPACE);
if (!sym)
error ("Internal: mangled static symbol `%s' found in %s psymtab but not in symtab", name, ps->filename);
if (symtab != NULL)
return 0;
}
-/* Look for a static demangled symbol in block BLOCK. */
-
-static struct symbol *
-lookup_demangled_block_symbol (block, name)
- register const struct block *block;
- const char *name;
-{
- register int bot, top;
- register struct symbol *sym;
- char *demangled;
-
- bot = 0;
- top = BLOCK_NSYMS (block);
-
- while (bot < top)
- {
- sym = BLOCK_SYM (block, bot);
- if (SYMBOL_NAMESPACE (sym) == VAR_NAMESPACE)
- {
- demangled = demangle_and_match (SYMBOL_NAME (sym), name,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (sym);
- }
- }
- bot++;
- }
-
- return (NULL);
-}
-
-/* Look, in partial_symtab PST, for static mangled symbol NAME. */
-
-static struct partial_symbol *
-lookup_demangled_partial_symbol (pst, name)
- const struct partial_symtab *pst;
- const char *name;
-{
- struct partial_symbol *start, *psym;
- int length = pst->n_static_syms;
- char *demangled;
-
- if (!length)
- return (struct partial_symbol *) 0;
-
- start = pst->objfile->static_psymbols.list + pst->statics_offset;
- for (psym = start; psym < start + length; psym++)
- {
- if (SYMBOL_NAMESPACE (psym) == VAR_NAMESPACE)
- {
- demangled = demangle_and_match (SYMBOL_NAME (psym), name,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (psym);
- }
- }
- }
-
- return (NULL);
-}
-
/* Look, in partial_symtab PST, for symbol NAME. Check the global
symbols if GLOBAL, the static symbols if not */
enum namespace namespace;
{
struct partial_symbol *start, *psym;
+ struct partial_symbol *top, *bottom, *center;
int length = (global ? pst->n_global_syms : pst->n_static_syms);
+ int do_linear_search = 1;
- if (!length)
- return (struct partial_symbol *) 0;
+ if (length == 0)
+ {
+ return (NULL);
+ }
start = (global ?
pst->objfile->global_psymbols.list + pst->globals_offset :
pst->objfile->static_psymbols.list + pst->statics_offset );
- if (global) /* This means we can use a binary */
- /* search. */
+ if (global) /* This means we can use a binary search. */
{
- struct partial_symbol *top, *bottom, *center;
+ do_linear_search = 0;
/* Binary search. This search is guaranteed to end with center
pointing at the earliest partial symbol with the correct
name. At that point *all* partial symbols with that name
will be checked against the correct namespace. */
+
bottom = start;
top = start + length - 1;
while (top > bottom)
{
center = bottom + (top - bottom) / 2;
-
assert (center < top);
-
- if (strcmp (SYMBOL_NAME (center), name) >= 0)
- top = center;
+ if (!do_linear_search && SYMBOL_LANGUAGE (center) == language_cplus)
+ {
+ do_linear_search = 1;
+ }
+ if (STRCMP (SYMBOL_NAME (center), name) >= 0)
+ {
+ top = center;
+ }
else
- bottom = center + 1;
+ {
+ bottom = center + 1;
+ }
}
assert (top == bottom);
-
- while (!strcmp (SYMBOL_NAME (top), name))
+ while (STREQ (SYMBOL_NAME (top), name))
{
if (SYMBOL_NAMESPACE (top) == namespace)
- return top;
+ {
+ return top;
+ }
top ++;
}
}
- else
+
+ /* Can't use a binary search or else we found during the binary search that
+ we should also do a linear search. */
+
+ if (do_linear_search)
{
- /* Can't use a binary search */
for (psym = start; psym < start + length; psym++)
- if (namespace == SYMBOL_NAMESPACE (psym)
- && !strcmp (name, SYMBOL_NAME (psym)))
- return psym;
+ {
+ if (namespace == SYMBOL_NAMESPACE (psym))
+ {
+ if (SYMBOL_MATCHES_NAME (psym, name))
+ {
+ return (psym);
+ }
+ }
+ }
}
- return (struct partial_symbol *) 0;
+ return (NULL);
}
/* Find the psymtab containing main(). */
return (NULL);
}
-/* Look for a symbol in block BLOCK. */
+/* Search BLOCK for symbol NAME in NAMESPACE.
+
+ Note that if NAME is the demangled form of a C++ symbol, we will fail
+ to find a match during the binary search of the non-encoded names, but
+ for now we don't worry about the slight inefficiency of looking for
+ a match we'll never find, since it will go pretty quick. Once the
+ binary search terminates, we drop through and do a straight linear
+ search on the symbols. Each symbol which is marked as being a C++
+ symbol (language_cplus set) has both the encoded and non-encoded names
+ tested for a match. */
struct symbol *
lookup_block_symbol (block, name, namespace)
const enum namespace namespace;
{
register int bot, top, inc;
- register struct symbol *sym, *parameter_sym;
-
- top = BLOCK_NSYMS (block);
- bot = 0;
+ register struct symbol *sym;
+ register struct symbol *sym_found = NULL;
+ register int do_linear_search = 1;
/* If the blocks's symbols were sorted, start with a binary search. */
if (BLOCK_SHOULD_SORT (block))
{
- /* First, advance BOT to not far before
- the first symbol whose name is NAME. */
+ /* Reset the linear search flag so if the binary search fails, we
+ won't do the linear search once unless we find some reason to
+ do so, such as finding a C++ symbol during the binary search.
+ Note that for C++ modules, ALL the symbols in a block should
+ end up marked as C++ symbols. */
+
+ do_linear_search = 0;
+ top = BLOCK_NSYMS (block);
+ bot = 0;
+
+ /* Advance BOT to not far before the first symbol whose name is NAME. */
while (1)
{
inc = (top - bot + 1);
/* No need to keep binary searching for the last few bits worth. */
if (inc < 4)
- break;
+ {
+ break;
+ }
inc = (inc >> 1) + bot;
sym = BLOCK_SYM (block, inc);
+ if (!do_linear_search && SYMBOL_LANGUAGE (sym) == language_cplus)
+ {
+ do_linear_search = 1;
+ }
if (SYMBOL_NAME (sym)[0] < name[0])
- bot = inc;
+ {
+ bot = inc;
+ }
else if (SYMBOL_NAME (sym)[0] > name[0])
- top = inc;
- else if (strcmp (SYMBOL_NAME (sym), name) < 0)
- bot = inc;
+ {
+ top = inc;
+ }
+ else if (STRCMP (SYMBOL_NAME (sym), name) < 0)
+ {
+ bot = inc;
+ }
else
- top = inc;
+ {
+ top = inc;
+ }
}
- /* Now scan forward until we run out of symbols,
- find one whose name is greater than NAME,
- or find one we want.
- If there is more than one symbol with the right name and namespace,
- we return the first one. dbxread.c is careful to make sure
- that if one is a register then it comes first. */
+ /* Now scan forward until we run out of symbols, find one whose name is
+ greater than NAME, or find one we want. If there is more than one
+ symbol with the right name and namespace, we return the first one.
+ dbxread.c is careful to make sure that if one is a register then it
+ comes first. */
top = BLOCK_NSYMS (block);
while (bot < top)
sym = BLOCK_SYM (block, bot);
inc = SYMBOL_NAME (sym)[0] - name[0];
if (inc == 0)
- inc = strcmp (SYMBOL_NAME (sym), name);
+ {
+ inc = STRCMP (SYMBOL_NAME (sym), name);
+ }
if (inc == 0 && SYMBOL_NAMESPACE (sym) == namespace)
- return sym;
+ {
+ return (sym);
+ }
if (inc > 0)
- return 0;
+ {
+ break;
+ }
bot++;
}
- return 0;
}
- /* Here if block isn't sorted.
- This loop is equivalent to the loop above,
- but hacked greatly for speed.
+ /* Here if block isn't sorted, or we fail to find a match during the
+ binary search above. If during the binary search above, we find a
+ symbol which is a C++ symbol, then we have re-enabled the linear
+ search flag which was reset when starting the binary search.
+
+ This loop is equivalent to the loop above, but hacked greatly for speed.
Note that parameter symbols do not always show up last in the
list; this loop makes sure to take anything else other than
last resort. Note that this only takes up extra computation
time on a match. */
- parameter_sym = (struct symbol *) 0;
- top = BLOCK_NSYMS (block);
- inc = name[0];
- while (bot < top)
+ if (do_linear_search)
{
- sym = BLOCK_SYM (block, bot);
- if (SYMBOL_NAME (sym)[0] == inc
- && !strcmp (SYMBOL_NAME (sym), name)
- && SYMBOL_NAMESPACE (sym) == namespace)
+ top = BLOCK_NSYMS (block);
+ bot = 0;
+ while (bot < top)
{
- if (SYMBOL_CLASS (sym) == LOC_ARG
- || SYMBOL_CLASS (sym) == LOC_LOCAL_ARG
- || SYMBOL_CLASS (sym) == LOC_REF_ARG
- || SYMBOL_CLASS (sym) == LOC_REGPARM)
- parameter_sym = sym;
- else
- return sym;
+ sym = BLOCK_SYM (block, bot);
+ if (SYMBOL_NAMESPACE (sym) == namespace &&
+ SYMBOL_MATCHES_NAME (sym, name))
+ {
+ sym_found = sym;
+ if (SYMBOL_CLASS (sym) != LOC_ARG &&
+ SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
+ SYMBOL_CLASS (sym) != LOC_REF_ARG &&
+ SYMBOL_CLASS (sym) != LOC_REGPARM)
+ {
+ break;
+ }
+ }
+ bot++;
}
- bot++;
}
- return parameter_sym; /* Will be 0 if not found. */
+ return (sym_found); /* Will be NULL if not found. */
}
+
\f
/* Return the symbol for the function which contains a specified
lexical block, described by a struct block BL. */
/* Recursive helper function for decode_line_1.
* Look for methods named NAME in type T.
* Return number of matches.
- * Put matches in PHYSNAMES and SYM_ARR (which better be big enough!).
+ * Put matches in SYM_ARR (which better be big enough!).
* These allocations seem to define "big enough":
* sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*));
- * physnames = (char **) alloca (TYPE_NFN_FIELDS_TOTAL (t) * sizeof(char*));
*/
int
-find_methods (t, name, physnames, sym_arr)
+find_methods (t, name, sym_arr)
struct type *t;
char *name;
- char **physnames;
struct symbol **sym_arr;
{
int i1 = 0;
struct fn_field *f = TYPE_FN_FIELDLIST1 (t, method_counter);
char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter);
- if (!strcmp (name, method_name))
+ if (STREQ (name, method_name))
/* Find all the fields with that name. */
for (field_counter = TYPE_FN_FIELDLIST_LENGTH (t, method_counter) - 1;
field_counter >= 0;
if (TYPE_FN_FIELD_STUB (f, field_counter))
check_stub_method (t, method_counter, field_counter);
phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
- physnames[i1] = (char*) alloca (strlen (phys_name) + 1);
- strcpy (physnames[i1], phys_name);
sym_arr[i1] = lookup_symbol (phys_name,
SYMBOL_BLOCK_VALUE (sym_class),
VAR_NAMESPACE,
return i1;
for (ibase = 0; ibase < TYPE_N_BASECLASSES (t); ibase++)
i1 += find_methods(TYPE_BASECLASS(t, ibase), name,
- physnames + i1, sym_arr + i1);
+ sym_arr + i1);
return i1;
}
int is_quoted;
struct symbol **sym_arr;
struct type *t;
- char **physnames;
char *saved_arg = *argptr;
extern char *gdb_completer_quote_characters;
i1 = 0; /* counter for the symbol array */
t = SYMBOL_TYPE (sym_class);
sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*));
- physnames = (char **) alloca (TYPE_NFN_FIELDS_TOTAL (t) * sizeof(char*));
if (destructor_name_p (copy, t))
{
struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0);
int len = TYPE_FN_FIELDLIST_LENGTH (t, 0) - 1;
char *phys_name = TYPE_FN_FIELD_PHYSNAME (f, len);
- physnames[i1] = (char *)alloca (strlen (phys_name) + 1);
- strcpy (physnames[i1], phys_name);
sym_arr[i1] =
lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class),
VAR_NAMESPACE, 0, (struct symtab **)NULL);
if (sym_arr[i1]) i1++;
}
else
- i1 = find_methods (t, copy, physnames, sym_arr);
+ i1 = find_methods (t, copy, sym_arr);
if (i1 == 1)
{
/* There is exactly one field with that name. */
tmp = copy;
if (tmp[0] == '~')
warning ("the class `%s' does not have destructor defined",
- sym_class->name);
+ SYMBOL_SOURCE_NAME(sym_class));
else
warning ("the class %s does not have any method named %s",
- sym_class->name, tmp);
+ SYMBOL_SOURCE_NAME(sym_class), tmp);
cplusplus_hint (saved_arg);
return_to_top_level ();
}
char *temp;
copy [p - *argptr - 1] = '\0';
copy++;
- if ((temp = expensive_mangler (copy)) != NULL)
- {
- copy = temp;
- }
}
while (*p == ' ' || *p == '\t') p++;
*argptr = p;
{
val.symtab = 0;
val.line = 0;
- val.pc = msymbol -> address + FUNCTION_START_OFFSET;
+ val.pc = SYMBOL_VALUE_ADDRESS (msymbol) + FUNCTION_START_OFFSET;
if (funfirstline)
SKIP_PROLOGUE (val.pc);
values.sals = (struct symtab_and_line *)xmalloc (sizeof (struct symtab_and_line));
return sals;
}
-/* Given a list of NELTS symbols in sym_arr (with corresponding
- mangled names in physnames), return a list of lines to operate on
- (ask user if necessary). */
+/* Given a list of NELTS symbols in sym_arr, return a list of lines to
+ operate on (ask user if necessary). */
+
static struct symtabs_and_lines
decode_line_2 (sym_arr, nelts, funfirstline)
struct symbol *sym_arr[];
char *args, *arg1;
int i;
char *prompt;
- char *demangled;
+ char *symname;
values.sals = (struct symtab_and_line *) alloca (nelts * sizeof(struct symtab_and_line));
return_values.sals = (struct symtab_and_line *) xmalloc (nelts * sizeof(struct symtab_and_line));
values.sals[i] = find_pc_line (pc, 0);
values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ?
values.sals[i].end : pc;
- demangled = cplus_demangle (SYMBOL_NAME (sym_arr[i]),
- DMGL_PARAMS | DMGL_ANSI);
- printf("[%d] %s at %s:%d\n", (i+2),
- demangled ? demangled : SYMBOL_NAME (sym_arr[i]),
+ printf("[%d] %s at %s:%d\n", (i+2), SYMBOL_SOURCE_NAME (sym_arr[i]),
values.sals[i].symtab->filename, values.sals[i].line);
- if (demangled != NULL)
- {
- free (demangled);
- }
}
else printf ("?HERE\n");
i++;
/* Is NAME in tab? */
for (p = tab; p < tab + tab_cur_size; p++)
- if (strcmp (*p, name) == 0)
+ if (STREQ (*p, name))
/* Yes; don't print it again. */
return;
/* No; add it to tab. */
printf_filtered ("\n");
}
-static int
-name_match (name)
- char *name;
-{
- char *demangled = cplus_demangle (name, DMGL_ANSI);
- if (demangled != NULL)
- {
- int cond = re_exec (demangled);
- free (demangled);
- return (cond);
- }
- return (re_exec (name));
-}
-#define NAME_MATCH(NAME) name_match(NAME)
-
-/* List all symbols (if REGEXP is 0) or all symbols matching REGEXP.
+/* List all symbols (if REGEXP is NULL) or all symbols matching REGEXP.
If CLASS is zero, list all symbols except functions, type names, and
constants (enums).
If CLASS is 1, list only functions.
enum minimal_symbol_type ourtype = types[class];
enum minimal_symbol_type ourtype2 = types2[class];
- if (regexp)
+ if (regexp != NULL)
{
/* Make sure spacing is right for C++ operators.
This is just a courtesy to make the matching less sensitive
/* If it would match (logic taken from loop below)
load the file and go on to the next one */
- if ((regexp == 0 || NAME_MATCH (SYMBOL_NAME (psym)))
+ if ((regexp == NULL || SYMBOL_MATCHES_REGEXP (psym))
&& ((class == 0 && SYMBOL_CLASS (psym) != LOC_TYPEDEF
&& SYMBOL_CLASS (psym) != LOC_BLOCK)
|| (class == 1 && SYMBOL_CLASS (psym) == LOC_BLOCK)
{
ALL_MSYMBOLS (objfile, msymbol)
{
- if (msymbol -> type == ourtype || msymbol -> type == ourtype2)
+ if (MSYMBOL_TYPE (msymbol) == ourtype ||
+ MSYMBOL_TYPE (msymbol) == ourtype2)
{
- if (regexp == 0 || NAME_MATCH (msymbol -> name))
+ if (regexp == NULL || SYMBOL_MATCHES_REGEXP (msymbol))
{
- if (0 == find_pc_symtab (msymbol -> address))
+ if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)))
{
found_misc = 1;
}
{
QUIT;
sym = BLOCK_SYM (b, j);
- if ((regexp == 0 || NAME_MATCH (SYMBOL_NAME (sym)))
+ if ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
&& ((class == 0 && SYMBOL_CLASS (sym) != LOC_TYPEDEF
&& SYMBOL_CLASS (sym) != LOC_BLOCK
&& SYMBOL_CLASS (sym) != LOC_CONST)
{
type_print (SYMBOL_TYPE (sym),
(SYMBOL_CLASS (sym) == LOC_TYPEDEF
- ? "" : SYMBOL_NAME (sym)),
+ ? "" : SYMBOL_SOURCE_NAME (sym)),
stdout, 0);
printf_filtered (";\n");
found_in_file = 0;
ALL_MSYMBOLS (objfile, msymbol)
{
- if (msymbol -> type == ourtype || msymbol -> type == ourtype2)
+ if (MSYMBOL_TYPE (msymbol) == ourtype ||
+ MSYMBOL_TYPE (msymbol) == ourtype2)
{
- if (regexp == 0 || NAME_MATCH (msymbol -> name))
+ if (regexp == NULL || SYMBOL_MATCHES_REGEXP (msymbol))
{
/* Functions: Look up by address. */
if (class != 1 ||
- (0 == find_pc_symtab (msymbol -> address)))
+ (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol))))
{
/* Variables/Absolutes: Look up by name */
- if (lookup_symbol (msymbol -> name,
- (struct block *) 0, VAR_NAMESPACE, 0,
- (struct symtab **) 0) == NULL)
+ if (lookup_symbol (SYMBOL_NAME (msymbol),
+ (struct block *) NULL, VAR_NAMESPACE,
+ 0, (struct symtab **) NULL) == NULL)
{
if (!found_in_file)
{
found_in_file = 1;
}
printf_filtered (" %08x %s\n",
- msymbol -> address,
- msymbol -> name);
+ SYMBOL_VALUE_ADDRESS (msymbol),
+ SYMBOL_SOURCE_NAME (msymbol));
}
}
}
static int return_val_index;
static char **return_val;
-/* Test to see if the symbol specified by SYMNAME (or it's demangled
- equivalent) matches TEXT in the first TEXT_LEN characters. If so,
- add it to the current completion list. */
+#define COMPLETION_LIST_ADD_SYMBOL(symbol, text, len) \
+ do { \
+ completion_list_add_name (SYMBOL_NAME (symbol), text, len); \
+ if (SYMBOL_LANGUAGE (symbol) == language_cplus && \
+ SYMBOL_DEMANGLED_NAME (symbol) != NULL) \
+ completion_list_add_name (SYMBOL_DEMANGLED_NAME (symbol), text, len); \
+ } while (0)
+
+/* Test to see if the symbol specified by SYMNAME (which is already
+ demangled for C++ symbols) matches TEXT in the first TEXT_LEN
+ characters. If so, add it to the current completion list. */
static void
-completion_list_add_symbol (symname, text, text_len)
+completion_list_add_name (symname, text, text_len)
char *symname;
char *text;
int text_len;
{
- char *demangled;
int newsize;
int i;
/* clip symbols that cannot match */
- if (!cplus_match (symname, text, text_len)) {
- return;
- }
-
- /* matches mangled, may match unmangled. now clip any symbol names
- that we've already considered. (This is a time optimization) */
-
- for (i = 0; i < return_val_index; ++i) {
- if (strcmp (symname, return_val[i]) == 0) {
+ if (strncmp (symname, text, text_len) != 0)
+ {
return;
}
- }
-
- /* See if SYMNAME is a C++ mangled name, and if so, use the
- demangled name instead, including any parameters. */
- if ((demangled = cplus_demangle (symname, DMGL_PARAMS | DMGL_ANSI)) != NULL)
- {
- if (strncmp (demangled, text, text_len) != 0) {
- return;
- } /* demangled, but didn't match so clip it */
+ /* Clip any symbol names that we've already considered. (This is a
+ time optimization) */
- symname = demangled;
- } else {
- symname = savestring (symname, strlen (symname));
+ for (i = 0; i < return_val_index; ++i)
+ {
+ if (STREQ (symname, return_val[i]))
+ {
+ return;
+ }
}
+
+ /* We have a match for a completion, so add SYMNAME to the current list
+ of matches. Note that the name is moved to freshly malloc'd space. */
- /* If we have a match for a completion, then add SYMNAME to the current
- list of matches. Note that the name is in freshly malloc'd space;
- either from cplus_demangle or from savestring above. */
-
+ symname = savestring (symname, strlen (symname));
if (return_val_index + 3 > return_val_size)
{
newsize = (return_val_size *= 2) * sizeof (char *);
}
return_val[return_val_index++] = symname;
return_val[return_val_index] = NULL;
-
- return;
}
/* Return a NULL terminated array of all symbols (regardless of class) which
{
/* If interrupted, then quit. */
QUIT;
- completion_list_add_symbol (SYMBOL_NAME (psym), text, text_len);
+ COMPLETION_LIST_ADD_SYMBOL (psym, text, text_len);
}
for (psym = objfile->static_psymbols.list + ps->statics_offset;
psym++)
{
QUIT;
- completion_list_add_symbol (SYMBOL_NAME (psym), text, text_len);
+ COMPLETION_LIST_ADD_SYMBOL (psym, text, text_len);
}
}
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- completion_list_add_symbol (msymbol -> name, text, text_len);
+ COMPLETION_LIST_ADD_SYMBOL (msymbol, text, text_len);
}
/* Search upwards from currently selected frame (so that we can
for (i = 0; i < BLOCK_NSYMS (b); i++)
{
sym = BLOCK_SYM (b, i);
- completion_list_add_symbol (SYMBOL_NAME (sym), text, text_len);
+ COMPLETION_LIST_ADD_SYMBOL (sym, text, text_len);
if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
struct type *t = SYMBOL_TYPE (sym);
{
if (TYPE_FIELD_NAME (t, j))
{
- completion_list_add_symbol (TYPE_FIELD_NAME (t, j),
+ completion_list_add_name (TYPE_FIELD_NAME (t, j),
text, text_len);
}
}
for (i = 0; i < BLOCK_NSYMS (b); i++)
{
sym = BLOCK_SYM (b, i);
- completion_list_add_symbol (SYMBOL_NAME (sym), text, text_len);
+ COMPLETION_LIST_ADD_SYMBOL (sym, text, text_len);
}
}
for (i = 0; i < BLOCK_NSYMS (b); i++)
{
sym = BLOCK_SYM (b, i);
- completion_list_add_symbol (SYMBOL_NAME (sym), text, text_len);
+ COMPLETION_LIST_ADD_SYMBOL (sym, text, text_len);
}
}
return (return_val);
}
-\f
-/* Find a mangled symbol that corresponds to LOOKFOR using brute force.
- Basically we go munging through available symbols, demangling each one,
- looking for a match on the demangled result. */
-
-static char *
-expensive_mangler (lookfor)
- const char *lookfor;
-{
- register struct symbol *sym;
- register struct symtab *s;
- register struct partial_symtab *ps;
- register struct minimal_symbol *msymbol;
- register struct objfile *objfile;
- register struct block *b, *surrounding_static_block = 0;
- register int i, j;
- struct partial_symbol *psym;
- char *demangled;
-
- /* Look through the partial symtabs for a symbol that matches */
-
- ALL_PSYMTABS (objfile, ps)
- {
- /* If the psymtab's been read in we'll get it when we search
- through the blockvector. */
- if (ps->readin) continue;
-
- for (psym = objfile->global_psymbols.list + ps->globals_offset;
- psym < (objfile->global_psymbols.list + ps->globals_offset
- + ps->n_global_syms);
- psym++)
- {
- QUIT; /* If interrupted, then quit. */
- demangled = demangle_and_match (SYMBOL_NAME (psym), lookfor,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (SYMBOL_NAME (psym));
- }
- }
-
- for (psym = objfile->static_psymbols.list + ps->statics_offset;
- psym < (objfile->static_psymbols.list + ps->statics_offset
- + ps->n_static_syms);
- psym++)
- {
- QUIT;
- demangled = demangle_and_match (SYMBOL_NAME (psym), lookfor,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (SYMBOL_NAME (psym));
- }
- }
- }
-
- /* Scan through the misc symbol vectors looking for a match. */
-
- ALL_MSYMBOLS (objfile, msymbol)
- {
- QUIT;
- demangled = demangle_and_match (msymbol -> name, lookfor,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (msymbol -> name);
- }
- }
-
- /* Search upwards from currently selected frame looking for a match */
-
- for (b = get_selected_block (); b; b = BLOCK_SUPERBLOCK (b))
- {
- if (!BLOCK_SUPERBLOCK (b))
- surrounding_static_block = b; /* For elmin of dups */
-
- /* Also catch fields of types defined in this places which
- match our text string. Only complete on types visible
- from current context. */
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- {
- sym = BLOCK_SYM (b, i);
- demangled = demangle_and_match (SYMBOL_NAME (sym), lookfor,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (SYMBOL_NAME (sym));
- }
- if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- {
- struct type *t = SYMBOL_TYPE (sym);
- enum type_code c = TYPE_CODE (t);
-
- if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
- {
- for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
- {
- if (TYPE_FIELD_NAME (t, j))
- {
- demangled =
- demangle_and_match (TYPE_FIELD_NAME (t, j),
- lookfor,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (TYPE_FIELD_NAME (t, j));
- }
- }
- }
- }
- }
- }
- }
-
- /* Go through the symtabs and check the externs and statics for
- symbols which match. */
-
- ALL_SYMTABS (objfile, s)
- {
- QUIT;
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- {
- sym = BLOCK_SYM (b, i);
- demangled = demangle_and_match (SYMBOL_NAME (sym), lookfor,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (SYMBOL_NAME (sym));
- }
- }
- }
-
- ALL_SYMTABS (objfile, s)
- {
- QUIT;
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
- /* Don't do this block twice. */
- if (b == surrounding_static_block) continue;
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- {
- sym = BLOCK_SYM (b, i);
- demangled = demangle_and_match (SYMBOL_NAME (sym), lookfor,
- DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- free (demangled);
- return (SYMBOL_NAME (sym));
- }
- }
- }
-
- return (NULL);
-}
-
\f
#if 0
/* Add the type of the symbol sym to the type of the current
#if !defined (SYMTAB_H)
#define SYMTAB_H 1
-#include "obstack.h"
-
-/* See the comment in symfile.c about how current_objfile is used. */
-
-extern struct objfile *current_objfile;
/* Some definitions and declarations to go with use of obstacks. */
+
+#include "obstack.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-/* Some macros for char-based bitfields. */
-#define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7)))
-#define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
-#define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7)))
-#define B_TYPE unsigned char
-#define B_BYTES(x) ( 1 + ((x)>>3) )
-#define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
+/* Define a structure for the information that is common to all symbol types,
+ including minimal symbols, partial symbols, and full symbols. */
+
+struct general_symbol_info
+{
+ /* Name of the symbol. This is a required field. Storage for the name is
+ allocated on the psymbol_obstack or symbol_obstack for the associated
+ objfile. */
+
+ char *name;
+
+ /* Constant value, or address if static, or register number,
+ or offset in arguments, or offset in stack frame. All of
+ these are in host byte order (though what they point to might
+ be in target byte order, e.g. LOC_CONST_BYTES).
+
+ Note that the address of a function is SYMBOL_VALUE_ADDRESS (pst)
+ in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st))
+ in a symbol table. */
+
+ union
+ {
+ /* for LOC_CONST, LOC_REGISTER, LOC_ARG, LOC_REF_ARG, LOC_REGPARM,
+ LOC_LOCAL */
+
+ long value;
+
+ /* for LOC_BLOCK */
+
+ struct block *block;
+
+ /* for LOC_CONST_BYTES */
+
+ char *bytes;
+
+ /* for LOC_STATIC, LOC_LABEL */
+
+ CORE_ADDR address;
+
+ /* for opaque typedef struct chain */
+ struct symbol *chain;
+ }
+ value;
+
+ /* In a multilanguage environment, some language specific information may
+ need to be recorded along with each symbol. */
+
+ struct language_dependent_info
+ {
+
+ /* Record the language that this information applies to. */
+
+ enum language language;
+
+ /* Since one and only one language can apply, wrap the information inside
+ a union. */
+ union
+ {
+ /* For C++ */
+ struct
+ {
+ char *demangled_name;
+ } cplus_specific;
+ } lang_u;
+ } lang_specific;
+};
+
+#define SYMBOL_NAME(symbol) (symbol)->ginfo.name
+#define SYMBOL_VALUE(symbol) (symbol)->ginfo.value.value
+#define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->ginfo.value.address
+#define SYMBOL_VALUE_BYTES(symbol) (symbol)->ginfo.value.bytes
+#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->ginfo.value.block
+#define SYMBOL_VALUE_CHAIN(symbol) (symbol)->ginfo.value.chain
+#define SYMBOL_LANGUAGE(symbol) (symbol)->ginfo.lang_specific.language
+#define SYMBOL_DEMANGLED_NAME(symbol) \
+ (symbol)->ginfo.lang_specific.lang_u.cplus_specific.demangled_name
+
+extern int demangle; /* We reference it, so go ahead and declare it. */
+
+/* Macro that returns the "natural source name" of a symbol. In C++ this is
+ the "demangled" form of the name if demangle is on and the "mangled" form
+ of the name if demangle is off. In other languages this is just the
+ symbol name. */
+
+#define SYMBOL_SOURCE_NAME(symbol) \
+ ((demangle && (SYMBOL_LANGUAGE(symbol) == language_cplus) && \
+ (SYMBOL_DEMANGLED_NAME(symbol) != NULL)) ? \
+ SYMBOL_DEMANGLED_NAME (symbol) : SYMBOL_NAME (symbol))
+
+/* Macro that returns the "natural assembly name" of a symbol. In C++ this is
+ the "mangled" form of the name if demangle is off, or if demangle is on and
+ asm_demangle is off. Otherwise if asm_demangle is on it is the "demangled"
+ form. In other languages this is just the symbol name. */
+
+#define SYMBOL_LINKAGE_NAME(symbol) \
+ ((demangle && asm_demangle && (SYMBOL_LANGUAGE(symbol) == language_cplus) &&\
+ (SYMBOL_DEMANGLED_NAME(symbol) != NULL)) ? \
+ SYMBOL_DEMANGLED_NAME (symbol) : SYMBOL_NAME (symbol))
+
+/* Macro that tests a symbol for a match against a specified name string.
+ First test the unencoded name, then looks for and test a C++ encoded
+ name if it exists. Note that whitespace is ignored while attempting to
+ match a C++ encoded name, so that "foo::bar(int,long)" is the same as
+ "foo :: bar (int, long)".
+ Evaluates to zero if the match fails, or nonzero if it succeeds. */
+
+#define SYMBOL_MATCHES_NAME(symbol, name) \
+ (STREQ (SYMBOL_NAME (symbol), (name)) || \
+ (SYMBOL_LANGUAGE (symbol) == language_cplus && \
+ SYMBOL_DEMANGLED_NAME (symbol) != NULL && \
+ strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0))
+
+/* Macro that tests a symbol for an re-match against the last compiled regular
+ expression. First test the unencoded name, then look for and test a C++
+ encoded name if it exists.
+ Evaluates to zero if the match fails, or nonzero if it succeeds. */
+
+#define SYMBOL_MATCHES_REGEXP(symbol) \
+ (re_exec (SYMBOL_NAME (symbol)) != 0 || \
+ (SYMBOL_LANGUAGE (symbol) == language_cplus && \
+ SYMBOL_DEMANGLED_NAME (symbol) != NULL && \
+ re_exec (SYMBOL_DEMANGLED_NAME (symbol)) != 0))
+
/* Define a simple structure used to hold some very basic information about
- all defined global symbols (text, data, bss, abs, etc). The only two
- required pieces of information are the symbol's name and the address
- associated with that symbol. In many cases, even if a file was compiled
- with no special options for debugging at all, as long as was not stripped
- it will contain sufficient information to build a useful minimal symbol
- table using this structure. Even when a file contains enough debugging
- information to build a full symbol table, these minimal symbols are still
- useful for quickly mapping between names and addresses, and vice versa.
- They are also sometimes used to figure out what full symbol table entries
- need to be read in. */
+ all defined global symbols (text, data, bss, abs, etc). The only required
+ information is the general_symbol_info.
+
+ In many cases, even if a file was compiled with no special options for
+ debugging at all, as long as was not stripped it will contain sufficient
+ information to build a useful minimal symbol table using this structure.
+ Even when a file contains enough debugging information to build a full
+ symbol table, these minimal symbols are still useful for quickly mapping
+ between names and addresses, and vice versa. They are also sometimes
+ used to figure out what full symbol table entries need to be read in. */
struct minimal_symbol
{
- /* Name of the symbol. This is a required field. Storage for the name is
- allocated on the symbol_obstack for the associated objfile. */
-
- char *name;
-
- /* Address of the symbol. This is a required field. */
+ /* The general symbol info required for all types of symbols. */
- CORE_ADDR address;
+ struct general_symbol_info ginfo;
/* The info field is available for caching machine-specific information that
The AMD 29000 tdep.c uses it to remember things it has decoded from the
};
+#define MSYMBOL_INFO(msymbol) (msymbol)->info
+#define MSYMBOL_TYPE(msymbol) (msymbol)->type
+
\f
/* All of the name-scope contours of the program
are represented by `struct block' objects.
struct block *block[1];
};
+#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
+#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
+
/* Special block numbers */
-#define GLOBAL_BLOCK 0
-#define STATIC_BLOCK 1
+
+#define GLOBAL_BLOCK 0
+#define STATIC_BLOCK 1
#define FIRST_LOCAL_BLOCK 2
struct block
{
+
/* Addresses in the executable code that are in this block.
Note: in an unrelocated symbol segment in a file,
these are always zero. They can be filled in from the
N_LBRAC and N_RBRAC symbols in the loader symbol table. */
- CORE_ADDR startaddr, endaddr;
+
+ CORE_ADDR startaddr;
+ CORE_ADDR endaddr;
+
/* The symbol that names this block,
if the block is the body of a function;
otherwise, zero.
(since the name resides in a higher block).
Since the symbol does point to the block (as its value),
it is possible to find the block and set its name properly. */
+
struct symbol *function;
- /* The `struct block' for the containing block, or 0 if none. */
- /* Note that in an unrelocated symbol segment in an object file
+
+ /* The `struct block' for the containing block, or 0 if none.
+ Note that in an unrelocated symbol segment in an object file
this pointer may be zero when the correct value should be
the second special block (for symbols whose scope is one compilation).
This is because the compiler outputs the special blocks at the
very end, after the other blocks. */
+
struct block *superblock;
+
/* A flag indicating whether or not the function corresponding
to this block was compiled with gcc or not. If there is no
function corresponding to this block, this meaning of this flag
is undefined. (In practice it will be 1 if the block was created
while processing a file compiled with gcc and 0 when not). */
+
unsigned char gcc_compile_flag;
+
/* Number of local symbols. */
+
int nsyms;
+
/* The symbols. */
+
struct symbol *sym[1];
};
-\f
-/* Represent one symbol name; a variable, constant, function or typedef. */
-/* Different name spaces for symbols. Looking up a symbol specifies
- a namespace and ignores symbol definitions in other name spaces.
+#define BLOCK_START(bl) (bl)->startaddr
+#define BLOCK_END(bl) (bl)->endaddr
+#define BLOCK_NSYMS(bl) (bl)->nsyms
+#define BLOCK_SYM(bl, n) (bl)->sym[n]
+#define BLOCK_FUNCTION(bl) (bl)->function
+#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
+#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
- VAR_NAMESPACE is the usual namespace.
- In C, this contains variables, function names, typedef names
- and enum type values.
+/* Nonzero if symbols of block BL should be sorted alphabetically. */
- STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
- Thus, if `struct foo' is used in a C program,
- it produces a symbol named `foo' in the STRUCT_NAMESPACE.
+#define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40)
- LABEL_NAMESPACE may be used for names of labels (for gotos);
- currently it is not used and labels are not recorded at all. */
+\f
+/* Represent one symbol name; a variable, constant, function or typedef. */
/* For a non-global symbol allocated statically,
the correct core address cannot be determined by the compiler.
This index number can be matched with the "desc" field of
an entry in the loader symbol table. */
+/* Different name spaces for symbols. Looking up a symbol specifies a
+ namespace and ignores symbol definitions in other name spaces. */
+
enum namespace
{
- UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE
+ /* UNDEF_NAMESPACE is used when a namespace has not been discovered or
+ none of the following apply. This usually indicates an error either
+ in the symbol information or in gdb's handling of symbols. */
+
+ UNDEF_NAMESPACE,
+
+ /* VAR_NAMESPACE is the usual namespace. In C, this contains variables,
+ function names, typedef names and enum type values. */
+
+ VAR_NAMESPACE,
+
+ /* STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
+ Thus, if `struct foo' is used in a C program, it produces a symbol named
+ `foo' in the STRUCT_NAMESPACE. */
+
+ STRUCT_NAMESPACE,
+
+ /* LABEL_NAMESPACE may be used for names of labels (for gotos);
+ currently it is not used and labels are not recorded at all. */
+
+ LABEL_NAMESPACE
};
/* An address-class says where to find the value of a symbol. */
enum address_class
{
- LOC_UNDEF, /* Not used; catches errors */
- LOC_CONST, /* Value is constant int SYMBOL_VALUE, host byteorder */
- LOC_STATIC, /* Value is at fixed address SYMBOL_VALUE_ADDRESS */
- LOC_REGISTER, /* Value is in register */
- LOC_ARG, /* Value is at spec'd offset in arglist */
- LOC_REF_ARG, /* Value address is at spec'd offset in arglist. */
- LOC_REGPARM, /* Value is at spec'd offset in register window */
- LOC_LOCAL, /* Value is at spec'd offset in stack frame */
- LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE
- Symbols in the namespace STRUCT_NAMESPACE
- all have this class. */
- LOC_LABEL, /* Value is address SYMBOL_VALUE_ADDRESS in the code */
- LOC_BLOCK, /* Value is address SYMBOL_VALUE_BLOCK of a
- `struct block'. Function names have this class. */
- LOC_CONST_BYTES, /* Value is a constant byte-sequence pointed to by
- SYMBOL_VALUE_ADDRESS, in target byte order. */
- LOC_LOCAL_ARG /* Value is arg at spec'd offset in stack frame.
- Differs from LOC_LOCAL in that symbol is an
- argument; differs from LOC_ARG in that we find it
- in the frame (FRAME_LOCALS_ADDRESS), not in the
- arglist (FRAME_ARGS_ADDRESS). Added for i960,
- which passes args in regs then copies to frame. */
+ /* Not used; catches errors */
+
+ LOC_UNDEF,
+
+ /* Value is constant int SYMBOL_VALUE, host byteorder */
+
+ LOC_CONST,
+
+ /* Value is at fixed address SYMBOL_VALUE_ADDRESS */
+
+ LOC_STATIC,
+
+ /* Value is in register */
+
+ LOC_REGISTER,
+
+ /* Value is at spec'd offset in arglist */
+
+ LOC_ARG,
+
+ /* Value address is at spec'd offset in arglist. */
+
+ LOC_REF_ARG,
+
+ /* Value is at spec'd offset in register window */
+
+ LOC_REGPARM,
+
+ /* Value is at spec'd offset in stack frame */
+
+ LOC_LOCAL,
+
+ /* Value not used; definition in SYMBOL_TYPE. Symbols in the namespace
+ STRUCT_NAMESPACE all have this class. */
+
+ LOC_TYPEDEF,
+
+ /* Value is address SYMBOL_VALUE_ADDRESS in the code */
+
+ LOC_LABEL,
+
+ /* Value is address SYMBOL_VALUE_BLOCK of a `struct block'. Function names
+ have this class. */
+
+ LOC_BLOCK,
+
+ /* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_ADDRESS, in
+ target byte order. */
+
+ LOC_CONST_BYTES,
+
+ /* Value is arg at spec'd offset in stack frame. Differs from LOC_LOCAL in
+ that symbol is an argument; differs from LOC_ARG in that we find it
+ in the frame (FRAME_LOCALS_ADDRESS), not in the arglist
+ (FRAME_ARGS_ADDRESS). Added for i960, which passes args in regs then
+ copies to frame. */
+
+ LOC_LOCAL_ARG
+
};
struct symbol
{
- /* Symbol name */
- char *name;
+
+ /* The general symbol info required for all types of symbols. */
+
+ struct general_symbol_info ginfo;
+
/* Name space code. */
+
enum namespace namespace;
+
/* Address class */
+
enum address_class class;
+
/* Data type of value */
+
struct type *type;
- /* Line number of definition. */
+ /* Line number of definition. FIXME: Should we really make the assumption
+ that nobody will try to debug files longer than 64K lines? What about
+ machine generated programs? */
+
unsigned short line;
- /* constant value, or address if static, or register number,
- or offset in arguments, or offset in stack frame. All of
- these are in host byte order (though what they point to might
- be in target byte order, e.g. LOC_CONST_BYTES). */
- union
- {
- long value; /* for LOC_CONST, LOC_REGISTER, LOC_ARG,
- LOC_REF_ARG, LOC_REGPARM, LOC_LOCAL */
- struct block *block; /* for LOC_BLOCK */
- char *bytes; /* for LOC_CONST_BYTES */
- CORE_ADDR address; /* for LOC_STATIC, LOC_LABEL */
- struct symbol *chain; /* for opaque typedef struct chain */
- }
- value;
-
/* Some symbols require an additional value to be recorded on a per-
symbol basis. Stash those values here. */
+
union
{
- struct /* for OP_BASEREG in DWARF location specs */
+ /* for OP_BASEREG in DWARF location specs */
+ struct
{
short regno_valid; /* 0 == regno invalid; !0 == regno valid */
short regno; /* base register number {0, 1, 2, ...} */
} basereg;
}
aux_value;
+
};
+#define SYMBOL_NAMESPACE(symbol) (symbol)->namespace
+#define SYMBOL_CLASS(symbol) (symbol)->class
+#define SYMBOL_TYPE(symbol) (symbol)->type
+#define SYMBOL_LINE(symbol) (symbol)->line
+#define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg.regno
+/* This currently fails because some symbols are not being initialized
+ to zero on allocation, and no code is currently setting this value.
+ Basereg handling will probably change significantly in the next release.
+ FIXME -fnf */
+
+#if 0
+#define SYMBOL_BASEREG_VALID(symbol) (symbol)->aux_value.basereg.regno_valid
+#else
+#define SYMBOL_BASEREG_VALID(symbol) 0
+#endif
+
+\f
/* A partial_symbol records the name, namespace, and address class of
symbols whose types we have not parsed yet. For functions, it also
contains their memory address, so we can find them from a PC value.
struct partial_symbol
{
- /* Symbol name */
- char *name;
+
+ /* The general symbol info required for all types of symbols. */
+
+ struct general_symbol_info ginfo;
+
/* Name space code. */
+
enum namespace namespace;
+
/* Address class (for info_symbols) */
+
enum address_class class;
- /* Value (only used for static functions currently). Done this
- way so that we can use the struct symbol macros.
- Note that the address of a function is SYMBOL_VALUE_ADDRESS (pst)
- in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st))
- in a symbol table. */
- union
- {
- long value;
- CORE_ADDR address;
- }
- value;
+
};
+
+#define PSYMBOL_NAMESPACE(psymbol) (psymbol)->namespace
+#define PSYMBOL_CLASS(psymbol) (psymbol)->class
+
\f
-/* Source-file information.
- This describes the relation between source files and line numbers
- and addresses in the program text. */
+/* Source-file information. This describes the relation between source files,
+ ine numbers and addresses in the program text. */
struct sourcevector
{
struct symtab
{
+
/* Chain of all existing symtabs. */
+
struct symtab *next;
+
/* List of all symbol scope blocks for this symtab. */
+
struct blockvector *blockvector;
+
/* Table mapping core addresses to line numbers for this file.
Can be NULL if none. */
+
struct linetable *linetable;
+
/* Name of this source file. */
+
char *filename;
+
/* Directory in which it was compiled, or NULL if we don't know. */
+
char *dirname;
+
/* This component says how to free the data we point to:
free_contents => do a tree walk and free each object.
free_nothing => do nothing; some other symtab will free
the data this one uses.
- free_linetable => free just the linetable. */
- enum free_code {free_nothing, free_contents, free_linetable}
- free_code;
+ free_linetable => free just the linetable. */
+
+ enum free_code
+ {
+ free_nothing, free_contents, free_linetable
+ }
+ free_code;
+
/* Pointer to one block of storage to be freed, if nonzero. */
/* This is IN ADDITION to the action indicated by free_code. */
+
char *free_ptr;
+
/* Total number of lines found in source file. */
+
int nlines;
+
/* Array mapping line number to character position. */
+
int *line_charpos;
+
/* Language of this source file. */
+
enum language language;
+
/* String of version information. May be zero. */
+
char *version;
+
/* Full name of file as found by searching the source path.
- 0 if not yet known. */
+ NULL if not yet known. */
+
char *fullname;
/* Object file from which this symbol information was read. */
+
struct objfile *objfile;
/* Anything extra for this symtab. This is for target machines
with special debugging info of some sort (which cannot just
be represented in a normal symtab). */
+
#if defined (EXTRA_SYMTAB_INFO)
EXTRA_SYMTAB_INFO
#endif
+
};
+#define BLOCKVECTOR(symtab) (symtab)->blockvector
+#define LINETABLE(symtab) (symtab)->linetable
+
+\f
/* Each source file that has not been fully read in is represented by
a partial_symtab. This contains the information on where in the
executable the debugging symbols for a specific file are, and a
struct partial_symtab
{
+
/* Chain of all existing partial symtabs. */
+
struct partial_symtab *next;
+
/* Name of the source file which this partial_symtab defines */
+
char *filename;
/* Information about the object file from which symbols should be read. */
+
struct objfile *objfile;
/* Set of relocation offsets to apply to each section. */
+
struct section_offsets *section_offsets;
/* Range of text addresses covered by this file; texthigh is the
beginning of the next section. */
- CORE_ADDR textlow, texthigh;
+
+ CORE_ADDR textlow;
+ CORE_ADDR texthigh;
+
/* Array of pointers to all of the partial_symtab's which this one
depends on. Since this array can only be set to previous or
the current (?) psymtab, this dependency tree is guaranteed not
to have any loops. */
+
struct partial_symtab **dependencies;
+
int number_of_dependencies;
+
/* Global symbol list. This list will be sorted after readin to
improve access. Binary search will be the usual method of
finding a symbol within it. globals_offset is an integer offset
within global_psymbols[]. */
- int globals_offset, n_global_syms;
+
+ int globals_offset;
+ int n_global_syms;
+
/* Static symbol list. This list will *not* be sorted after readin;
to find a symbol in it, exhaustive search must be used. This is
reasonable because searches through this list will eventually
to take a *lot* of time; check) or an error (and we don't care
how long errors take). This is an offset and size within
static_psymbols[]. */
- int statics_offset, n_static_syms;
+
+ int statics_offset;
+ int n_static_syms;
+
/* Pointer to symtab eventually allocated for this source file, 0 if
!readin or if we haven't looked for the symtab after it was readin. */
+
struct symtab *symtab;
+
/* Pointer to function which will read in the symtab corresponding to
this psymtab. */
+
void (*read_symtab) PARAMS ((struct partial_symtab *));
+
/* Information that lets read_symtab() locate the part of the symbol table
that this psymtab corresponds to. This information is private to the
format-dependent symbol reading routines. For further detail examine
the various symbol reading modules. Should really be (void *) but is
(char *) as with other such gdb variables. (FIXME) */
+
char *read_symtab_private;
- /* Non-zero if the symtab corresponding to this psymtab has been
- readin */
+
+ /* Non-zero if the symtab corresponding to this psymtab has been readin */
+
unsigned char readin;
};
/* A fast way to get from a psymtab to its symtab (after the first time). */
-#define PSYMTAB_TO_SYMTAB(pst) ((pst)->symtab? \
- (pst)->symtab: \
- psymtab_to_symtab (pst) )
-
-/* This symtab variable specifies the current file for printing source lines */
-
-extern struct symtab *current_source_symtab;
-
-/* This is the next line to print for listing source lines. */
-
-extern int current_source_line;
-
-#define BLOCKVECTOR(symtab) (symtab)->blockvector
+#define PSYMTAB_TO_SYMTAB(pst) \
+ ((pst) -> symtab != NULL ? (pst) -> symtab : psymtab_to_symtab (pst))
-#define LINETABLE(symtab) (symtab)->linetable
\f
-/* Macros normally used to access components of symbol table structures. */
-
-#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
-#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
-
-#define BLOCK_START(bl) (bl)->startaddr
-#define BLOCK_END(bl) (bl)->endaddr
-#define BLOCK_NSYMS(bl) (bl)->nsyms
-#define BLOCK_SYM(bl, n) (bl)->sym[n]
-#define BLOCK_FUNCTION(bl) (bl)->function
-#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
-#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
-
-/* Nonzero if symbols of block BL should be sorted alphabetically. */
-#define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40)
-
-#define SYMBOL_NAME(symbol) (symbol)->name
-#define SYMBOL_NAMESPACE(symbol) (symbol)->namespace
-#define SYMBOL_CLASS(symbol) (symbol)->class
-#define SYMBOL_VALUE(symbol) (symbol)->value.value
-#define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->value.address
-#define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes
-#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
-#define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain
-#define SYMBOL_TYPE(symbol) (symbol)->type
-#define SYMBOL_LINE(symbol) (symbol)->line
-#if 0
-/* This currently fails because some symbols are not being initialized
- to zero on allocation, and no code is currently setting this value.
- Basereg handling will probably change significantly in the next release.
- FIXME -fnf */
-#define SYMBOL_BASEREG_VALID(symbol) (symbol)->aux_value.basereg.regno_valid
-#else
-#define SYMBOL_BASEREG_VALID(symbol) 0
-#endif
-#define SYMBOL_BASEREG(symbol) (symbol)->aux_value.basereg.regno
-
-/* The virtual function table is now an array of structures
- which have the form { int16 offset, delta; void *pfn; }.
+/* The virtual function table is now an array of structures which have the
+ form { int16 offset, delta; void *pfn; }.
In normal virtual function tables, OFFSET is unused.
DELTA is the amount which is added to the apparent object's base
#define VTBL_FNADDR_OFFSET 2
-/* Macro that yields non-zero value iff NAME is the prefix
- for C++ operator names. If you leave out the parenthesis
- here you will lose!
-
+/* Macro that yields non-zero value iff NAME is the prefix for C++ operator
+ names. If you leave out the parenthesis here you will lose!
Currently 'o' 'p' CPLUS_MARKER is used for both the symbol in the
symbol-file and the names in gdb's symbol table. */
-#define OPNAME_PREFIX_P(NAME) ((NAME)[0] == 'o' && (NAME)[1] == 'p' \
- && (NAME)[2] == CPLUS_MARKER)
-#define VTBL_PREFIX_P(NAME) ((NAME)[3] == CPLUS_MARKER \
- && !strncmp ((NAME), "_vt", 3))
+#define OPNAME_PREFIX_P(NAME) \
+ ((NAME)[0] == 'o' && (NAME)[1] == 'p' && (NAME)[2] == CPLUS_MARKER)
+
+#define VTBL_PREFIX_P(NAME) \
+ ((NAME)[3] == CPLUS_MARKER && !strncmp ((NAME), "_vt", 3))
+
\f
-/* Functions that work on the objects described above */
+/* External variables and functions for the objects described above. */
+
+/* This symtab variable specifies the current file for printing source lines */
+
+extern struct symtab *current_source_symtab;
+
+/* This is the next line to print for listing source lines. */
+
+extern int current_source_line;
+
+/* See the comment in symfile.c about how current_objfile is used. */
+
+extern struct objfile *current_objfile;
extern struct symtab *
lookup_symtab PARAMS ((char *));
extern struct type *
lookup_enum PARAMS ((char *, struct block *));
-extern struct type *
-check_struct PARAMS ((struct type *));
-
-extern struct type *
-check_union PARAMS ((struct type *));
-
-extern struct type *
-check_enum PARAMS ((struct type *));
-
extern struct symbol *
block_function PARAMS ((struct block *));
int nelts;
};
-/* Given a pc value, return line number it is in.
- Second arg nonzero means if pc is on the boundary
- use the previous statement's line number. */
+/* Given a pc value, return line number it is in. Second arg nonzero means
+ if pc is on the boundary use the previous statement's line number. */
extern struct symtab_and_line
find_pc_line PARAMS ((CORE_ADDR, int));
extern void
resolve_sal_pc PARAMS ((struct symtab_and_line *));
-/* Given a string, return the line specified by it.
- For commands like "list" and "breakpoint". */
+/* Given a string, return the line specified by it. For commands like "list"
+ and "breakpoint". */
extern struct symtabs_and_lines
decode_line_spec PARAMS ((char *, int));
extern struct partial_symtab *
find_main_psymtab PARAMS ((void));
-extern struct type *
-find_nested_type PARAMS ((struct type *, char*));
-
/* blockframe.c */
extern struct blockvector *
(((num) > LR0_REGNUM + 127) \
? fprintf(stderr, \
"Invalid register number %d in symbol table entry for %s\n", \
- (num), SYMBOL_NAME (sym)), (num) \
+ (num), SYMBOL_SOURCE_NAME (sym)), (num) \
: (num))
The horribly ugly wait_for_inferior() routine uses this macro to detect
when we have stepped into one of these fragments. */
-#define IN_SOLIB_TRAMPOLINE(pc,name) ((name) && (strcmp ("_init", name) == 0))
+#define IN_SOLIB_TRAMPOLINE(pc,name) ((name) && (STREQ ("_init", name)))
/* In SVR4 ELF files, the ABI defines (pg. 4-25) that "External C symbols
have the same names in C, assembly code, and object files' symbol
*/
#if !defined(KERNEL_DEBUGGING)
#ifdef SYM1
-# define IN_SIGTRAMP(pc, name) (name && !strcmp ("sigtramp", name))
+# define IN_SIGTRAMP(pc, name) (name && STREQ ("sigtramp", name))
#else
Need to define IN_SIGTRAMP() for sym2.
#endif
don't (slightly different than strcmp()'s range of return values).
As an extra hack, string1=="FOO(ARGS)" matches string2=="FOO".
- This "feature" is useful for demangle_and_match(), which is used
- when searching for matching C++ function names (such as if the
- user types 'break FOO', where FOO is a mangled C++ function). */
+ This "feature" is useful when searching for matching C++ function names
+ (such as if the user types 'break FOO', where FOO is a mangled C++
+ function). */
int
strcmp_iw (string1, string2)
return (*string1 != '\0' && *string1 != '(') || (*string2 != '\0');
}
-/* Demangle NAME and compare the result with LOOKFOR, ignoring any differences
- in whitespace.
-
- If a match is found, returns a pointer to the demangled version of NAME
- in malloc'd memory, which needs to be freed by the caller after use.
- If a match is not found, returns NULL.
-
- OPTIONS is a flags word that controls the demangling process and is just
- passed on to the demangler.
-
- When the caller sees a non-NULL result, it knows that NAME is the mangled
- equivalent of LOOKFOR, and it can use either NAME, the "official demangled"
- version of NAME (the return value) or the "unofficial demangled" version
- of NAME (LOOKFOR, which it already knows). */
-
-char *
-demangle_and_match (name, lookfor, options)
- const char *name;
- const char *lookfor;
- int options;
-{
- char *demangled;
-
- if ((demangled = cplus_demangle (name, options)) != NULL)
- {
- if (strcmp_iw (demangled, lookfor) != 0)
- {
- free (demangled);
- demangled = NULL;
- }
- }
- return (demangled);
-}
-
\f
void
_initialize_utils ()
#include "inferior.h"
#include "gdbcore.h"
#include "target.h"
+#include "demangle.h"
#include <errno.h>
val = read_var_value (var, (FRAME) 0);
if (val == 0)
- error ("Address of symbol \"%s\" is unknown.", SYMBOL_NAME (var));
+ error ("Address of symbol \"%s\" is unknown.", SYMBOL_SOURCE_NAME (var));
return val;
}
val =
value_from_longest (lookup_pointer_type (lookup_function_type (
lookup_pointer_type (builtin_type_char))),
- (LONGEST) msymbol -> address);
+ (LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
else
error ("String constants require the program to have a function \"malloc\".");
}
{
char *t_field_name = TYPE_FIELD_NAME (type, i);
- if (t_field_name && !strcmp (t_field_name, name))
+ if (t_field_name && STREQ (t_field_name, name))
{
value v;
if (TYPE_FIELD_STATIC (type, i))
{
char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, i);
struct symbol *sym =
- lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL);
- if (! sym) error (
- "Internal error: could not find physical static variable named %s",
- phys_name);
+ lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL);
+ if (sym == NULL)
+ error ("Internal error: could not find physical static variable named %s",
+ phys_name);
v = value_at (TYPE_FIELD_TYPE (type, i),
(CORE_ADDR)SYMBOL_BLOCK_VALUE (sym));
}
/* If we are looking for baseclasses, this is what we get when we
hit them. */
int found_baseclass = (looking_for_baseclass
- && !strcmp (name, TYPE_BASECLASS_NAME (type, i)));
+ && STREQ (name, TYPE_BASECLASS_NAME (type, i)));
if (BASETYPE_VIA_VIRTUAL (type, i))
{
for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--)
{
char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
- if (t_field_name && !strcmp (t_field_name, name))
+ if (t_field_name && STREQ (t_field_name, name))
{
int j = TYPE_FN_FIELDLIST_LENGTH (type, i) - 1;
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
if (name[0] == '~')
{
char *dname = type_name_no_tag (type);
- if (strcmp (dname, name+1))
+ if (!STREQ (dname, name+1))
error ("name of destructor must equal name of class");
else
return 1;
for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
{
char *t_field_name = TYPE_FIELD_NAME (type, i);
- if (t_field_name && !strcmp (t_field_name, name))
+ if (t_field_name && STREQ (t_field_name, name))
return 1;
}
for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
{
- if (!strcmp (TYPE_FN_FIELDLIST_NAME (type, i), name))
+ if (STREQ (TYPE_FN_FIELDLIST_NAME (type, i), name))
return 1;
}
{
char *t_field_name = TYPE_FIELD_NAME (t, i);
- if (t_field_name && !strcmp (t_field_name, name))
+ if (t_field_name && STREQ (t_field_name, name))
{
if (TYPE_FIELD_STATIC (t, i))
{
char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (t, i);
struct symbol *sym =
lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL);
- if (! sym)
- error (
- "Internal error: could not find physical static variable named %s",
+ if (sym == NULL)
+ error ("Internal error: could not find physical static variable named %s",
phys_name);
return value_at (SYMBOL_TYPE (sym),
(CORE_ADDR)SYMBOL_BLOCK_VALUE (sym));
for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
{
- if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
+ if (STREQ (TYPE_FN_FIELDLIST_NAME (t, i), name))
{
int j = TYPE_FN_FIELDLIST_LENGTH (t, i);
struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
register struct internalvar *var;
for (var = internalvars; var; var = var->next)
- if (!strcmp (var->name, name))
+ if (STREQ (var->name, name))
return var;
var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
/* Check that VTBL looks like it points to a virtual function table. */
msymbol = lookup_minimal_symbol_by_pc (VALUE_ADDRESS (vtbl));
if (msymbol == NULL
- || !VTBL_PREFIX_P (demangled_name = msymbol -> name))
+ || !VTBL_PREFIX_P (demangled_name = SYMBOL_NAME (msymbol)))
{
/* If we expected to find a vtable, but did not, let the user
know that we aren't happy, but don't throw an error.
*(strchr (demangled_name, ':')) = '\0';
}
sym = lookup_symbol (demangled_name, 0, VAR_NAMESPACE, 0, 0);
- if (sym == 0)
- error ("could not find type declaration for `%s'", SYMBOL_NAME (sym));
+ if (sym == NULL)
+ error ("could not find type declaration for `%s'", demangled_name);
if (best_entry)
{
free (demangled_name);
in the fields. */
for (i = n_baseclasses; i < len; i++)
{
- if (! strcmp (vbase_name, TYPE_FIELD_NAME (type, i)))
+ if (STREQ (vbase_name, TYPE_FIELD_NAME (type, i)))
{
CORE_ADDR addr
= unpack_pointer (TYPE_FIELD_TYPE (type, i),
in the fields. */
for (i = n_baseclasses; i < len; i++)
{
- if (! strcmp (vbase_name, TYPE_FIELD_NAME (type, i)))
+ if (STREQ (vbase_name, TYPE_FIELD_NAME (type, i)))
{
value val = allocate_value (basetype);
CORE_ADDR addr;
struct section_table *exec_sections, *exec_sections_end;
-#define eq(s0, s1) !strcmp(s0, s1)
-
/* Whether to open exec and core files read-only or read-write. */
int write_files = 0;
if ((bfd_get_section_flags(bf, sex) & SEC_LOAD) == 0)
return;
- if (!strcmp(bfd_section_name(bf, sex), ".text")) {
+ if (STREQ(bfd_section_name(bf, sex), ".text")) {
vp->tstart = 0;
vp->tend = vp->tstart + bfd_section_size(bf, sex);
vp->tadj = sex->filepos - bfd_section_vma(bf, sex);
}
- else if (!strcmp(bfd_section_name(bf, sex), ".data")) {
+ else if (STREQ(bfd_section_name(bf, sex), ".data")) {
vp->dstart = 0;
vp->dend = vp->dstart + bfd_section_size(bf, sex);
}
- else if (!strcmp(bfd_section_name(bf, sex), ".bss")) /* FIXMEmgo */
+ else if (STREQ(bfd_section_name(bf, sex), ".bss")) /* FIXMEmgo */
printf ("bss section in exec! Don't know what the heck to do!\n");
}
* FIXME??? am I tossing BFDs? bfd?
*/
while (last = bfd_openr_next_archived_file(bfd, last))
- if (eq(mem, last->filename))
+ if (STREQ(mem, last->filename))
break;
if (!last) {
for (i=0; &exec_ops.to_sections[i] < exec_ops.to_sections_end; i++)
{
- if (strcmp(".text", exec_ops.to_sections[i].sec_ptr->name) == 0)
+ if (STREQ(".text", exec_ops.to_sections[i].sec_ptr->name))
{
exec_ops.to_sections[i].addr += vmap->tstart;
exec_ops.to_sections[i].endaddr += vmap->tstart;
}
- else if (strcmp(".data", exec_ops.to_sections[i].sec_ptr->name) == 0)
+ else if (STREQ(".data", exec_ops.to_sections[i].sec_ptr->name))
{
exec_ops.to_sections[i].addr += vmap->dstart;
exec_ops.to_sections[i].endaddr += vmap->dstart;
/* The filenames are not always sufficient to match on. */
- if ((name[0] == "/" && !eq(name, vp->name))
- || (memb[0] && !eq(memb, vp->member)))
+ if ((name[0] == "/" && !STREQ(name, vp->name))
+ || (memb[0] && !STREQ(memb, vp->member)))
continue;
io = bfd_cache_lookup(vp->bfd); /* totally opaque! */
/* Names that are less should come first. */
register struct symbol **s1 = (struct symbol **) s1p;
register struct symbol **s2 = (struct symbol **) s2p;
- register int namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2));
+ register int namediff = STRCMP (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2));
if (namediff != 0)
return namediff;
case C_FCN:
- if (strcmp (cs->c_name, ".bf") == 0) {
+ if (STREQ (cs->c_name, ".bf")) {
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
main_aux);
(fcn_cs_saved.c_value, fcn_stab_saved.c_name, 0, 0, objfile);
#endif
}
- else if (strcmp (cs->c_name, ".ef") == 0) {
+ else if (STREQ (cs->c_name, ".ef")) {
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
main_aux);
break;
case C_BLOCK :
- if (strcmp (cs->c_name, ".bb") == 0) {
+ if (STREQ (cs->c_name, ".bb")) {
depth++;
new = push_context (depth, cs->c_value);
}
- else if (strcmp (cs->c_name, ".eb") == 0) {
+ else if (STREQ (cs->c_name, ".eb")) {
new = pop_context ();
if (depth != new->depth)
error ("Invalid symbol data: .bb/.eb symbol mismatch at symbol %d.",
for (ii = 0; ii < 50; ii++) {
bfd_coff_swap_sym_in (symfile_bfd,
symtable + (symno*local_symesz), symbol);
- if (symbol->n_sclass == C_FCN && 0 == strcmp (symbol->n_name, ".bf"))
+ if (symbol->n_sclass == C_FCN && STREQ (symbol->n_name, ".bf"))
goto gotit;
symno += symbol->n_numaux+1;
}
count = asect->lineno_count;
- if (strcmp (asect->name, ".text") || count == 0)
+ if (!STREQ (asect->name, ".text") || count == 0)
return;
size = count * coff_data (symfile_bfd)->local_linesz;