From 2e4964adfc1fe8192c7b44012c84f0544cc4b911 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Wed, 23 Dec 1992 06:34:57 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 107 +++++++ gdb/buildsym.c | 48 +++- gdb/buildsym.h | 1 + gdb/c-exp.y | 6 +- gdb/c-typeprint.c | 28 +- gdb/c-valprint.c | 10 +- gdb/command.c | 4 +- gdb/convex-tdep.c | 26 +- gdb/cp-valprint.c | 2 +- gdb/dbxread.c | 30 +- gdb/defs.h | 12 +- gdb/demangle.c | 4 +- gdb/dwarfread.c | 50 +++- gdb/elfread.c | 50 +--- gdb/energize.c | 8 +- gdb/expprint.c | 2 +- gdb/gdbtypes.c | 4 +- gdb/gdbtypes.h | 9 + gdb/i960-tdep.c | 2 +- gdb/infcmd.c | 16 +- gdb/infrun.hacked.c | 2 +- gdb/language.c | 20 +- gdb/m2-exp.y | 2 +- gdb/main.c | 8 +- gdb/minsyms.c | 185 +++++++++---- gdb/objfiles.h | 2 +- gdb/partial-stab.h | 50 ++-- gdb/printcmd.c | 15 +- gdb/remote-es1800.c | 4 +- gdb/remote-nindy.c | 2 +- gdb/remote-udi.c | 12 +- gdb/rs6000-tdep.c | 2 +- gdb/solib.c | 12 +- gdb/source.c | 10 +- gdb/sparc-pinsn.c | 2 +- gdb/stabsread.c | 57 ++-- gdb/standalone.c | 2 +- gdb/state.c | 4 +- gdb/stuff.c | 6 +- gdb/symfile.c | 112 ++++++-- gdb/symfile.h | 70 +++-- gdb/symmisc.c | 98 ++----- gdb/symtab.c | 660 ++++++++++++++------------------------------ gdb/symtab.h | 594 ++++++++++++++++++++++++++------------- gdb/tm-29k.h | 2 +- gdb/tm-sysv4.h | 2 +- gdb/tm-ultra3.h | 2 +- gdb/utils.c | 40 +-- gdb/valops.c | 34 +-- gdb/values.c | 12 +- gdb/xcoffexec.c | 18 +- gdb/xcoffread.c | 14 +- 52 files changed, 1352 insertions(+), 1122 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 69512a61b43..46d4973c16e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,110 @@ +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 diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 73ca9b24ce6..1e569547f14 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -257,7 +257,8 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile) { if (symbol) { - complain (&innerblock_complaint, SYMBOL_NAME (symbol)); + complain (&innerblock_complaint, + SYMBOL_SOURCE_NAME (symbol)); } else { @@ -371,7 +372,7 @@ start_subfile (name, dirname) for (subfile = subfiles; subfile; subfile = subfile->next) { - if (!strcmp (subfile->name, name)) + if (STREQ (subfile->name, name)) { current_subfile = subfile; return; @@ -393,6 +394,24 @@ start_subfile (name, dirname) /* 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 @@ -417,6 +436,24 @@ patch_subfile_names (subfile, name) { 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; + } } } @@ -709,6 +746,13 @@ end_symtab (end_addr, sort_pending, sort_linevec, objfile) 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 diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 1f82c857e79..31e92313e32 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -59,6 +59,7 @@ struct subfile char *dirname; struct linetable *line_vector; int line_vector_length; + enum language language; }; EXTERN struct subfile *subfiles; diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 8d77232bf9f..1129cf60f59 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -552,7 +552,7 @@ qualified_name: typebase COLONCOLON name 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); @@ -591,7 +591,7 @@ variable: qualified_name { 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 || @@ -676,7 +676,7 @@ variable: name_not_typename { 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 || diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 503c22e21f0..40e3f52369c 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -72,18 +72,16 @@ c_typedef_print (type, new, stream) 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, " = "); type_print(type,"",stream,0); @@ -113,7 +111,6 @@ c_print_type (type, varstring, stream, show, level) int level; { register enum type_code code; - char *demangled = NULL; int demangled_args; c_type_print_base (type, stream, show, level); @@ -132,25 +129,14 @@ c_print_type (type, varstring, 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. */ @@ -622,7 +608,7 @@ c_type_print_base (type, stream, show, level) 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; diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 91d9a575743..d4627e0f5a8 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -186,8 +186,8 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse, 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; } @@ -333,11 +333,11 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse, 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) diff --git a/gdb/command.c b/gdb/command.c index e12db1b5f74..412ff21137c 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -260,7 +260,7 @@ delete_cmd (name, list) 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 */ @@ -272,7 +272,7 @@ delete_cmd (name, list) 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. */ diff --git a/gdb/convex-tdep.c b/gdb/convex-tdep.c index cf9577686ef..bd1a6b7fe37 100644 --- a/gdb/convex-tdep.c +++ b/gdb/convex-tdep.c @@ -316,9 +316,9 @@ is_trapped_internalvar (name) 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; } @@ -336,17 +336,17 @@ value_of_trapped_internalvar (var) 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; @@ -408,13 +408,13 @@ set_trapped_internalvar (var, val, bitpos, bitsize, offset) 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 { @@ -498,9 +498,9 @@ set_pipelining_command (arg) 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."); @@ -517,9 +517,9 @@ set_parallel_command (arg) 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\ diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 5222f7b9475..172edde9e3c 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -71,7 +71,7 @@ cp_is_vtbl_ptr_type(type) 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 diff --git a/gdb/dbxread.c b/gdb/dbxread.c index a8595973cd8..0101a3ce57a 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -133,6 +133,10 @@ struct symloc { #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; @@ -345,7 +349,7 @@ add_old_header_file (name, instance) 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; @@ -811,7 +815,7 @@ find_corresponding_bincl_psymtab (name, instance) 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; @@ -963,7 +967,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) /* 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) { @@ -971,10 +975,10 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) 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), @@ -1105,6 +1109,9 @@ start_psymtab (objfile, section_offsets, 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; } @@ -1179,7 +1186,8 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset, 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 @@ -1473,9 +1481,9 @@ read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size, 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; } @@ -1537,9 +1545,9 @@ read_ofile_symtab (objfile, sym_offset, sym_size, text_offset, text_size, 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 */ @@ -1970,7 +1978,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) 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 */ diff --git a/gdb/defs.h b/gdb/defs.h index 8495050744e..53d1784d2c1 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -33,6 +33,13 @@ typedef unsigned int CORE_ADDR; #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 */ @@ -93,7 +100,7 @@ inside_entry_file PARAMS ((CORE_ADDR addr)); extern int inside_main_func PARAMS ((CORE_ADDR pc)); -/* From cplus-dem.c */ +/* From libiberty.a */ extern char * cplus_demangle PARAMS ((const char *, int)); @@ -126,9 +133,6 @@ mmalloc_getkey PARAMS ((PTR, int)); /* From utils.c */ -extern char * -demangle_and_match PARAMS ((const char *, const char *, int)); - extern int strcmp_iw PARAMS ((const char *, const char *)); diff --git a/gdb/demangle.c b/gdb/demangle.c index 1fdfdc8f63d..45e130c3220 100644 --- a/gdb/demangle.c +++ b/gdb/demangle.c @@ -111,8 +111,8 @@ set_demangling_command (ignore, from_tty) 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; diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 3054ddf90b5..dd1f0130838 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -207,9 +207,6 @@ typedef unsigned int DIE_REF; /* Reference to a DIE */ #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 @@ -691,9 +688,13 @@ set_cu_language (dip) 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); } @@ -1736,6 +1737,8 @@ enum_type (dip, objfile) 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; @@ -2543,7 +2546,8 @@ add_enum_psymbol (dip, objfile) { 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; } } @@ -2579,7 +2583,7 @@ add_partial_symbol (dip, objfile) 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), @@ -2587,25 +2591,25 @@ add_partial_symbol (dip, objfile) 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: @@ -2614,14 +2618,14 @@ add_partial_symbol (dip, objfile) 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; } @@ -2928,6 +2932,26 @@ new_symbol (dip, objfile) 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: @@ -3056,6 +3080,8 @@ synthesize_typedef (dip, objfile, type) 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; diff --git a/gdb/elfread.c b/gdb/elfread.c index 5135e10fc70..d51a0f70de8 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -45,8 +45,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdb-stabs.h" #include "complaints.h" #include - -#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. @@ -96,12 +95,6 @@ free_elfinfo PARAMS ((PTR)); 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 *, @@ -185,39 +178,6 @@ elf_interpreter (abfd) #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; @@ -351,15 +311,15 @@ elf_symtab_read (abfd, addr, objfile) 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; } @@ -628,7 +588,7 @@ elfstab_offset_sections (objfile, pst) 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. */ diff --git a/gdb/energize.c b/gdb/energize.c index b9bce2fb1fa..efee08e7fd2 100644 --- a/gdb/energize.c +++ b/gdb/energize.c @@ -1117,7 +1117,7 @@ kernel_dispatch(queue) 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') @@ -1576,9 +1576,9 @@ energize_call_command(cmdblk, arg, from_tty) 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(); diff --git a/gdb/expprint.c b/gdb/expprint.c index 38df56dd6da..616623a303a 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -102,7 +102,7 @@ print_subexp (exp, pos, stream, prec) 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: diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 94b25679bd3..e2673812cf2 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -476,7 +476,7 @@ lookup_primitive_typename (name) for (p = current_language -> la_builtin_type_vector; *p != NULL; p++) { - if (!strcmp ((**p) -> name, name)) + if (STREQ ((**p) -> name, name)) { return (**p); } @@ -676,7 +676,7 @@ lookup_struct_elt_type (type, name, noerr) { 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); } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index d15e0c43d35..a54b62adadf 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -56,6 +56,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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 diff --git a/gdb/i960-tdep.c b/gdb/i960-tdep.c index 115bfe2aa45..7ab0661dda6 100644 --- a/gdb/i960-tdep.c +++ b/gdb/i960-tdep.c @@ -472,7 +472,7 @@ leafproc_return (ip) 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 */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 179aa98d137..c190ffe5bb3 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -371,14 +371,14 @@ step_1 (skip_subroutines, single_inst, count_string) 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 @@ -420,8 +420,6 @@ jump_command (arg, from_tty) struct symtab_and_line sal; struct symbol *fn; struct symbol *sfn; - char *fname; - struct cleanup *back_to; ERROR_NO_INFERIOR; @@ -447,14 +445,12 @@ jump_command (arg, from_tty) 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); @@ -572,7 +568,7 @@ until_next_command (from_tty) 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 diff --git a/gdb/infrun.hacked.c b/gdb/infrun.hacked.c index 4fbb14d3392..9cf2fcf3e0b 100644 --- a/gdb/infrun.hacked.c +++ b/gdb/infrun.hacked.c @@ -174,7 +174,7 @@ extern char *inferior_thisrun_terminal; 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. */ diff --git a/gdb/language.c b/gdb/language.c index 9d55936e609..445e816a0d8 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -176,7 +176,7 @@ set_language_command (ignore, from_tty) /* 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. */ @@ -224,22 +224,22 @@ set_type_command(ignore, from_tty) 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(); @@ -270,22 +270,22 @@ set_range_command(ignore, from_tty) 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(); @@ -762,7 +762,7 @@ value_true(val) } 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 */ diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 12a8a50de92..037a07419b4 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -631,7 +631,7 @@ variable: NAME { 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 || diff --git a/gdb/main.c b/gdb/main.c index eabe44c9401..c937921ac8a 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -757,7 +757,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); 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. */ @@ -1767,7 +1767,7 @@ define_command (comname, from_tty) /* 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) @@ -1789,7 +1789,7 @@ define_command (comname, from_tty) /* 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) { @@ -1960,7 +1960,7 @@ pwd_command (args, from_tty) 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 diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 269d5683f6c..66ac9228542 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -42,6 +42,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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 @@ -105,29 +106,32 @@ lookup_minimal_symbol (name, objf) 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 @@ -197,14 +201,15 @@ lookup_minimal_symbol_by_pc (pc) 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; } @@ -218,7 +223,8 @@ lookup_minimal_symbol_by_pc (pc) 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]; } @@ -247,6 +253,7 @@ prim_record_minimal_symbol (name, address, ms_type) enum minimal_symbol_type ms_type; { register struct msym_bunch *new; + register struct minimal_symbol *msymbol; if (msym_bunch_index == BUNCH_SIZE) { @@ -255,14 +262,25 @@ prim_record_minimal_symbol (name, address, ms_type) 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; @@ -271,6 +289,7 @@ prim_record_minimal_symbol_and_info (name, address, ms_type, info) char *info; { register struct msym_bunch *new; + register struct minimal_symbol *msymbol; if (msym_bunch_index == BUNCH_SIZE) { @@ -279,12 +298,18 @@ prim_record_minimal_symbol_and_info (name, address, ms_type, info) 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++; } @@ -303,11 +328,11 @@ compare_minimal_symbols (fn1p, fn2p) 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); } @@ -389,12 +414,13 @@ compact_minimal_symbols (msymbol, mcount) 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++; } @@ -409,11 +435,28 @@ compact_minimal_symbols (msymbol, mcount) 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) @@ -425,6 +468,7 @@ install_minimal_symbols (objfile) register struct minimal_symbol *msymbols; int alloc_count; register char leading_char; + char *demangled_name; if (msym_count > 0) { @@ -459,9 +503,10 @@ install_minimal_symbols (objfile) 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; @@ -482,19 +527,20 @@ install_minimal_symbols (objfile) 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 @@ -502,6 +548,31 @@ install_minimal_symbols (objfile) 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); + } + } + } } } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 53e67866fd5..78a60614e81 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -339,7 +339,7 @@ have_minimal_symbols PARAMS ((void)); /* 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. */ diff --git a/gdb/partial-stab.h b/gdb/partial-stab.h index 06adc8f838f..8361ff07d7a 100644 --- a/gdb/partial-stab.h +++ b/gdb/partial-stab.h @@ -80,7 +80,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ && 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 ) { @@ -119,7 +119,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 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. */ @@ -297,12 +297,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 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; @@ -345,13 +345,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ { 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; } } @@ -361,7 +365,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ { 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 @@ -411,7 +417,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 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. */ @@ -427,7 +434,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* 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 @@ -468,27 +476,33 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 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': @@ -505,7 +519,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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 @@ -527,7 +542,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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 diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 33d2300bbea..aecd57c2632 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -549,7 +549,8 @@ set_next_address (addr) 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) @@ -569,10 +570,10 @@ 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 @@ -876,7 +877,7 @@ address_info (exp, from_tty) 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) { @@ -888,7 +889,7 @@ address_info (exp, from_tty) 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; @@ -1503,7 +1504,7 @@ print_frame_args (func, fi, num, stream) 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 diff --git a/gdb/remote-es1800.c b/gdb/remote-es1800.c index 53298692eec..7f575792adb 100644 --- a/gdb/remote-es1800.c +++ b/gdb/remote-es1800.c @@ -595,7 +595,7 @@ damn_b (rate) 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); } @@ -1307,7 +1307,7 @@ verify_break (vec) { memory_error (status, memaddress); } - return (strcmp (instr, buf)); + return (STRCMP (instr, buf)); } return (-1); } diff --git a/gdb/remote-nindy.c b/gdb/remote-nindy.c index d6f66770f04..cff37d7a2ff 100644 --- a/gdb/remote-nindy.c +++ b/gdb/remote-nindy.c @@ -921,7 +921,7 @@ nindy_before_main_loop () ; } *p2= '\0'; - if ( !strcmp("quit",p) ){ + if ( STREQ("quit",p) ){ exit(1); } diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index f731d9ea5fe..af846e619ac 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -1035,9 +1035,9 @@ download(load_arg_string, from_tty) { 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 { @@ -1094,13 +1094,13 @@ download(load_arg_string, from_tty) 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); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 14c88a45fb6..b7e1f0009df 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -276,7 +276,7 @@ CORE_ADDR pc; 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; } } diff --git a/gdb/solib.c b/gdb/solib.c index 4b050de2dab..31ff369c95d 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -233,7 +233,7 @@ solib_map_sections (so) 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; } @@ -361,7 +361,7 @@ bfd_lookup_symbol (abfd, symname) 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; @@ -516,9 +516,9 @@ locate_base () 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); @@ -1056,9 +1056,9 @@ enable_break () 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 { diff --git a/gdb/source.c b/gdb/source.c index 982e7dfeaf9..2c2c518b152 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -154,7 +154,7 @@ select_source_symtab (s) { 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; } @@ -171,7 +171,7 @@ select_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; } @@ -910,7 +910,7 @@ list_command (arg, from_tty) /* "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\"."); @@ -920,7 +920,7 @@ list_command (arg, from_tty) } /* "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\"."); @@ -1010,7 +1010,7 @@ list_command (arg, from_tty) 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 diff --git a/gdb/sparc-pinsn.c b/gdb/sparc-pinsn.c index 2b232f047d3..60a91fbf283 100644 --- a/gdb/sparc-pinsn.c +++ b/gdb/sparc-pinsn.c @@ -433,7 +433,7 @@ compare_opcodes (a, b) /* 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; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 65ca5746863..7259df4d74f 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -34,6 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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 /**/ @@ -491,9 +492,12 @@ define_symbol (valu, string, desc, type, objfile) 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); @@ -503,6 +507,24 @@ define_symbol (valu, string, desc, type, objfile) } *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++; @@ -785,7 +807,7 @@ define_symbol (valu, string, desc, type, objfile) 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; @@ -799,7 +821,7 @@ define_symbol (valu, string, desc, type, objfile) 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; @@ -864,12 +886,10 @@ define_symbol (valu, string, desc, type, objfile) 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; @@ -1121,7 +1141,7 @@ read_type (pp, objfile) 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); @@ -2435,6 +2455,7 @@ read_enum_type (pp, type, objfile) 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; @@ -2485,10 +2506,10 @@ read_enum_type (pp, type, objfile) /* 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 @@ -3090,7 +3111,7 @@ cleanup_undefined_types () && 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)); @@ -3147,7 +3168,7 @@ scan_file_globals (objfile) 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; @@ -3156,12 +3177,12 @@ scan_file_globals (objfile) /* 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. */ @@ -3180,11 +3201,11 @@ scan_file_globals (objfile) 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) diff --git a/gdb/standalone.c b/gdb/standalone.c index 163a6399b6a..687b3183b68 100644 --- a/gdb/standalone.c +++ b/gdb/standalone.c @@ -144,7 +144,7 @@ open (filename, modes) 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)); diff --git a/gdb/state.c b/gdb/state.c index 8b51bf70414..51b73fa31ce 100644 --- a/gdb/state.c +++ b/gdb/state.c @@ -470,7 +470,7 @@ load_state_command (arg_string, from_tty) while (*++argv != NULL) { - if (strcmp (*argv, "symbols") == 0) + if (STREQ (*argv, "symbols")) { if (from_tty && !query ("load symbol table state from file \"%s\"? ", @@ -533,7 +533,7 @@ dump_state_command (arg_string, from_tty) fseek (asfd -> fp, sizeof (sf_hdr), SEEK_SET); while (*++argv != NULL) { - if (strcmp (*argv, "objfile") == 0) + if (STREQ (*argv, "objfile")) { write_objfile_state (asfd); } diff --git a/gdb/stuff.c b/gdb/stuff.c index c30f1dfc7a9..1ce07efdd7b 100644 --- a/gdb/stuff.c +++ b/gdb/stuff.c @@ -47,7 +47,7 @@ main (argc, argv) 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) @@ -66,7 +66,7 @@ main (argc, argv) * 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], @@ -152,7 +152,7 @@ find_symbol (sym_name, symbol_table, length, strings) { 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); diff --git a/gdb/symfile.c b/gdb/symfile.c index f01ae36d413..1c8fe1d8ca4 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -31,6 +31,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "breakpoint.h" #include "language.h" #include "complaints.h" +#include "demangle.h" #include #include @@ -131,7 +132,7 @@ compare_symbols (s1p, s2p) 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. */ @@ -179,7 +180,7 @@ compare_psymbols (s1p, s2p) } else { - return (strcmp (st1 + 2, st2 + 2)); + return (STRCMP (st1 + 2, st2 + 2)); } } @@ -428,7 +429,7 @@ syms_from_objfile (objfile, addr, mainline, verbo) 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, @@ -670,11 +671,11 @@ symbol_file_command (args, from_tty) 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; } @@ -872,11 +873,11 @@ add_symbol_file_command (args, from_tty) { 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; } @@ -969,14 +970,14 @@ deduce_language_from_filename (filename) 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 */ @@ -1193,7 +1194,7 @@ free_named_symtabs (name) 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 */ } @@ -1203,7 +1204,7 @@ again2: for (s = symtab_list; s; s = s->next) { - if (!strcmp (name, s->filename)) + if (STREQ (name, s->filename)) break; prev = s; } @@ -1291,40 +1292,109 @@ start_psymtab_common (objfile, section_offsets, /* 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 */ + void _initialize_symfile () diff --git a/gdb/symfile.h b/gdb/symfile.h index 3f232ec2b29..b1355d3d528 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -99,45 +99,69 @@ extend_psymbol_list PARAMS ((struct psymbol_allocation_list *, /* 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 */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index be9d6e064c0..670f527e781 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -202,7 +202,7 @@ dump_msymbols (objfile, outfile) 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) { @@ -225,8 +225,14 @@ dump_msymbols (objfile, outfile) 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) { @@ -325,7 +331,15 @@ dump_symtab (objfile, symtab, outfile) 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); @@ -383,7 +397,7 @@ maintenance_print_symbols (args, from_tty) 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); @@ -398,7 +412,7 @@ print_symbol (symbol, depth, outfile) 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; } @@ -433,7 +447,7 @@ print_symbol (symbol, depth, outfile) fprintf (outfile, "; "); } else - fprintf (outfile, "%s ", SYMBOL_NAME (symbol)); + fprintf (outfile, "%s ", SYMBOL_SOURCE_NAME (symbol)); switch (SYMBOL_CLASS (symbol)) { @@ -572,7 +586,7 @@ maintenance_print_psymbols (args, from_tty) 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); @@ -589,7 +603,13 @@ print_partial_symbol (p, count, what, outfile) 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: @@ -703,7 +723,7 @@ maintenance_print_msymbols (args, from_tty) 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"); @@ -771,61 +791,3 @@ extend_psymbol_list (listp, objfile) 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 */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 7e6c0225d85..5a371aecf02 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -45,14 +45,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* 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)); @@ -88,13 +85,6 @@ static struct partial_symbol * 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 *)); @@ -141,7 +131,7 @@ lookup_symtab_1 (name) /* 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, '/'); @@ -157,7 +147,7 @@ lookup_symtab_1 (name) if (tail) p = tail + 1; - if (strcmp (p, name) == 0) + if (STREQ (p, name)) return s; } @@ -165,7 +155,7 @@ lookup_symtab_1 (name) psymtabs. */ ALL_PSYMTABS (objfile, ps) - if (strcmp (name, ps -> filename) == 0) + if (STREQ (name, ps -> filename)) goto got_psymtab; if (!slash) @@ -177,7 +167,7 @@ lookup_symtab_1 (name) if (tail) p = tail + 1; - if (strcmp (p, name) == 0) + if (STREQ (p, name)) goto got_psymtab; } @@ -243,7 +233,7 @@ char *name; ALL_PSYMTABS (objfile, pst) { - if (strcmp (name, pst -> filename) == 0) + if (STREQ (name, pst -> filename)) { return (pst); } @@ -264,7 +254,7 @@ gdb_mangle_name (type, i, j) 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. */ @@ -442,18 +432,6 @@ lookup_symbol (name, block, namespace, is_a_field_of_this, symtab) 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) @@ -483,11 +461,7 @@ found: 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) @@ -501,7 +475,7 @@ found: 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; @@ -554,43 +528,22 @@ found: 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); } @@ -673,7 +626,7 @@ found_msym: { 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; @@ -685,12 +638,12 @@ found_msym: 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) @@ -705,71 +658,6 @@ found_msym: 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 */ @@ -781,56 +669,76 @@ lookup_partial_symbol (pst, name, global, namespace) 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(). */ @@ -853,7 +761,16 @@ find_main_psymtab () 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) @@ -862,42 +779,63 @@ 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) @@ -905,19 +843,27 @@ lookup_block_symbol (block, name, namespace) 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 @@ -925,28 +871,31 @@ lookup_block_symbol (block, name, namespace) 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. */ } + /* Return the symbol for the function which contains a specified lexical block, described by a struct block BL. */ @@ -1366,17 +1315,15 @@ operator_chars (p, end) /* 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; @@ -1418,7 +1365,7 @@ find_methods (t, name, physnames, sym_arr) 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; @@ -1428,8 +1375,6 @@ find_methods (t, name, physnames, sym_arr) 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, @@ -1452,7 +1397,7 @@ find_methods (t, name, physnames, sym_arr) 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; } @@ -1539,7 +1484,6 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) int is_quoted; struct symbol **sym_arr; struct type *t; - char **physnames; char *saved_arg = *argptr; extern char *gdb_completer_quote_characters; @@ -1643,7 +1587,6 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) 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)) { @@ -1651,15 +1594,13 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) 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. */ @@ -1702,10 +1643,10 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) 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 (); } @@ -1821,10 +1762,6 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) char *temp; copy [p - *argptr - 1] = '\0'; copy++; - if ((temp = expensive_mangler (copy)) != NULL) - { - copy = temp; - } } while (*p == ' ' || *p == '\t') p++; *argptr = p; @@ -1896,7 +1833,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line) { 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)); @@ -1928,9 +1865,9 @@ decode_line_spec (string, funfirstline) 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[]; @@ -1942,7 +1879,7 @@ decode_line_2 (sym_arr, nelts, funfirstline) 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)); @@ -1961,15 +1898,8 @@ decode_line_2 (sym_arr, nelts, funfirstline) 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++; @@ -2070,7 +2000,7 @@ output_source_filename (name, first) /* 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. */ @@ -2131,22 +2061,7 @@ sources_info (ignore, from_tty) 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. @@ -2184,7 +2099,7 @@ list_symbols (regexp, class, bpt) 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 @@ -2257,7 +2172,7 @@ list_symbols (regexp, class, bpt) /* 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) @@ -2282,11 +2197,12 @@ list_symbols (regexp, class, bpt) { 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; } @@ -2324,7 +2240,7 @@ list_symbols (regexp, class, bpt) { 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) @@ -2360,7 +2276,7 @@ list_symbols (regexp, class, bpt) { type_print (SYMBOL_TYPE (sym), (SYMBOL_CLASS (sym) == LOC_TYPEDEF - ? "" : SYMBOL_NAME (sym)), + ? "" : SYMBOL_SOURCE_NAME (sym)), stdout, 0); printf_filtered (";\n"); @@ -2392,18 +2308,19 @@ list_symbols (regexp, class, bpt) 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) { @@ -2411,8 +2328,8 @@ list_symbols (regexp, class, bpt) found_in_file = 1; } printf_filtered (" %08x %s\n", - msymbol -> address, - msymbol -> name); + SYMBOL_VALUE_ADDRESS (msymbol), + SYMBOL_SOURCE_NAME (msymbol)); } } } @@ -2485,53 +2402,49 @@ static int return_val_size; 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 *); @@ -2539,8 +2452,6 @@ completion_list_add_symbol (symname, text, text_len) } 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 @@ -2586,7 +2497,7 @@ make_symbol_completion_list (text) { /* 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; @@ -2595,7 +2506,7 @@ make_symbol_completion_list (text) psym++) { QUIT; - completion_list_add_symbol (SYMBOL_NAME (psym), text, text_len); + COMPLETION_LIST_ADD_SYMBOL (psym, text, text_len); } } @@ -2607,7 +2518,7 @@ make_symbol_completion_list (text) 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 @@ -2626,7 +2537,7 @@ make_symbol_completion_list (text) 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); @@ -2638,7 +2549,7 @@ make_symbol_completion_list (text) { 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); } } @@ -2657,7 +2568,7 @@ make_symbol_completion_list (text) 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); } } @@ -2670,174 +2581,13 @@ make_symbol_completion_list (text) 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); } - -/* 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); -} - #if 0 /* Add the type of the symbol sym to the type of the current diff --git a/gdb/symtab.h b/gdb/symtab.h index dae1e6189be..392ed4f5f7a 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -19,48 +19,156 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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 @@ -92,6 +200,9 @@ struct minimal_symbol }; +#define MSYMBOL_INFO(msymbol) (msymbol)->info +#define MSYMBOL_TYPE(msymbol) (msymbol)->type + /* All of the name-scope contours of the program are represented by `struct block' objects. @@ -127,18 +238,26 @@ struct blockvector 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. @@ -148,41 +267,49 @@ struct block (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]; }; - -/* 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. */ + +/* 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. @@ -190,82 +317,158 @@ struct block 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 + + /* 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. @@ -275,28 +478,27 @@ struct symbol 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 + -/* 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 { @@ -356,50 +558,84 @@ struct section_offsets 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 + + /* 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 @@ -413,31 +649,46 @@ struct symtab 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 @@ -445,80 +696,40 @@ struct partial_symtab 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 -/* 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 @@ -528,19 +739,31 @@ extern int current_source_line; #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)) + -/* 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 *)); @@ -562,15 +785,6 @@ lookup_union PARAMS ((char *, struct block *)); 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 *)); @@ -645,9 +859,8 @@ struct symtabs_and_lines 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)); @@ -663,8 +876,8 @@ find_line_pc_range PARAMS ((struct symtab *, int, CORE_ADDR *, CORE_ADDR *)); 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)); @@ -732,9 +945,6 @@ clear_symtab_users_once PARAMS ((void)); extern struct partial_symtab * find_main_psymtab PARAMS ((void)); -extern struct type * -find_nested_type PARAMS ((struct type *, char*)); - /* blockframe.c */ extern struct blockvector * diff --git a/gdb/tm-29k.h b/gdb/tm-29k.h index ce6b499ae9c..ab89a2aae4f 100644 --- a/gdb/tm-29k.h +++ b/gdb/tm-29k.h @@ -710,5 +710,5 @@ extern void pop_frame (); (((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)) diff --git a/gdb/tm-sysv4.h b/gdb/tm-sysv4.h index 9348ec8edcb..cdf747b3250 100644 --- a/gdb/tm-sysv4.h +++ b/gdb/tm-sysv4.h @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 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 diff --git a/gdb/tm-ultra3.h b/gdb/tm-ultra3.h index 59dcaa3c413..71031444e29 100644 --- a/gdb/tm-ultra3.h +++ b/gdb/tm-ultra3.h @@ -177,7 +177,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ */ #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 diff --git a/gdb/utils.c b/gdb/utils.c index b087b52420f..a9414545ee6 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1401,9 +1401,9 @@ fprint_symbol (stream, name) 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) @@ -1433,40 +1433,6 @@ 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); -} - void _initialize_utils () diff --git a/gdb/valops.c b/gdb/valops.c index b72669eafa2..0ac1f9f86e8 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -25,6 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inferior.h" #include "gdbcore.h" #include "target.h" +#include "demangle.h" #include @@ -420,7 +421,7 @@ value_of_variable (var) 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; } @@ -950,7 +951,7 @@ value_string (ptr, len) 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\"."); } @@ -989,17 +990,17 @@ search_struct_field (name, arg1, offset, type, looking_for_baseclass) { 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)); } @@ -1017,7 +1018,7 @@ search_struct_field (name, arg1, offset, type, looking_for_baseclass) /* 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)) { @@ -1062,7 +1063,7 @@ search_struct_method (name, arg1p, args, offset, static_memfuncp, type) 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); @@ -1235,7 +1236,7 @@ destructor_name_p (name, type) 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; @@ -1257,7 +1258,7 @@ check_field_in (type, name) 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; } @@ -1270,7 +1271,7 @@ check_field_in (type, name) 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; } @@ -1337,16 +1338,15 @@ value_struct_elt_for_reference (domain, offset, curtype, name, intype) { 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)); @@ -1376,7 +1376,7 @@ value_struct_elt_for_reference (domain, offset, curtype, name, intype) 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); diff --git a/gdb/values.c b/gdb/values.c index 76a66f24c8b..fbffe20195f 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -391,7 +391,7 @@ lookup_internalvar (name) 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)); @@ -1045,7 +1045,7 @@ value_headof (arg, btype, dtype) /* 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. @@ -1091,8 +1091,8 @@ value_headof (arg, btype, dtype) *(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); @@ -1152,7 +1152,7 @@ baseclass_offset (type, index, arg, offset) 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), @@ -1220,7 +1220,7 @@ baseclass_addr (type, index, valaddr, valuep, errp) 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; diff --git a/gdb/xcoffexec.c b/gdb/xcoffexec.c index 3b2c7a631ef..ed783c588e6 100644 --- a/gdb/xcoffexec.c +++ b/gdb/xcoffexec.c @@ -52,8 +52,6 @@ exec_close PARAMS ((int)); 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; @@ -293,7 +291,7 @@ sex_to_vmap(bfd *bf, sec_ptr sex, struct vmap_and_bfd *vmap_bfd) 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); @@ -305,12 +303,12 @@ sex_to_vmap(bfd *bf, sec_ptr sex, struct vmap_and_bfd *vmap_bfd) 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"); } @@ -579,7 +577,7 @@ register struct ld_info *ldi; { * 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) { @@ -631,12 +629,12 @@ vmap_exec () 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; @@ -707,8 +705,8 @@ retry: /* 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! */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 923e5e913f1..d58b40623f1 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -233,7 +233,7 @@ compare_symbols (s1p, s2p) /* 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; @@ -1419,7 +1419,7 @@ function_entry_point: 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); @@ -1503,7 +1503,7 @@ function_entry_point: (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); @@ -1565,11 +1565,11 @@ function_entry_point: 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.", @@ -1951,7 +1951,7 @@ read_symbol_lineno (symtable, symno) 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; } @@ -1986,7 +1986,7 @@ PTR vpinfo; 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; -- 2.30.2