diff options
author | David Carlton <carlton@bactrian.org> | 2002-12-21 00:17:45 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2002-12-21 00:17:45 +0000 |
commit | 319df9cf32af8116752712775a95d17aaa1d49d1 (patch) | |
tree | e71d3692ff4f34163e4cefeb623f65a9efbb1728 | |
parent | 09c6cd51a673cc05b5348d306ff33e05cc0e27ef (diff) | |
download | gdb-319df9cf32af8116752712775a95d17aaa1d49d1.zip gdb-319df9cf32af8116752712775a95d17aaa1d49d1.tar.gz gdb-319df9cf32af8116752712775a95d17aaa1d49d1.tar.bz2 |
2002-12-20 David Carlton <carlton@math.stanford.edu>
* symtab.c (lookup_symbol_aux_minsyms): Don't call
lookup_symbol_aux from within this.
* values.c (value_static_field): lookup_symbol_linkage.
(value_fn_field): lookup_symbol_linkage.
* valops.c (value_struct_elt_for_reference): lookup_symbol_linkage.
* blockframe.c (inside_main_func): lookup_symbol_linkage.
* source.c (select_source_symtab): lookup_symbol_linkage.
* nlmread.c (nlm_symfile_read): Call lookup_symbol_linkage.
* nindy-tdep.c (nindy_frame_chain_valid): Call
lookup_symbol_linkage.
* linespec.c (count_methods): Call lookup_symbol_linkage.
(add_matching_methods): Ditto.
(add_constructors): Ditto.
* hppa-tdep.c (find_stub_with_shl_get): Call
lookup_symbol_linkage. Delete symbol2.
(initialize_hp_cxx_exception_support): Call lookup_symbol_linkage.
* cli/cli-cmds.c (edit_command): SYMBOL_PRINT_NAME.
(list_command): SYMBOL_PRINT_NAME.
* valops.c (value_of_variable): SYMBOL_PRINT_NAME
(hand_function_call): SYMBOL_PRINT_NAME.
* typeprint.c (typedef_print): SYMBOL_PRINT_NAME.
* tracepoint.c (tracepoints_info): SYMBOL_PRINT_NAME.
* symtab.c (lookup_partial_symbol): SYMBOL_BEST_NAME.
(compare_search_syms): SYMBOL_BEST_NAME.
(print_symbol_info): SYMBOL_PRINT_NAME.
(print_msymbol_info): SYMBOL_PRINT_NAME.
(rbreak_command): SYMBOL_PRINT_NAME.
* symmisc.c (print_symbol): SYMBOL_PRINT_NAME.
* stack.c (print_frame): SYMBOL_PRINT_NAME.
(frame_info): SYMBOL_PRINT_NAME.
(print_block_frame_locals): SYMBOL_PRINT_NAME.
(print_block_frame_labels): SYMBOL_PRINT_NAME.
(print_frame_arg_vars): SYMBOL_PRINT_NAME.
(return_command): SYMBOL_PRINT_NAME.
* stabsread.c (define_symbol): SYMBOL_PRINT_NAME.
* p-valprint.c (pascal_val_print): SYMBOL_PRINT_NAME.
* printcmd.c (build_address_symbolic): SYMBOL_PRINT_NAME.
(sym_info): SYMBOL_PRINT_NAME.
(print_frame_args): SYMBOL_PRINT_NAME.
* objc-lang.c (compare_selectors): SYMBOL_BEST_NAME.
(compare_classes): SYMBOL_BEST_NAME.
* maint.c (maintenance_translate_address): SYMBOL_PRINT_NAME.
* linespec.c (find_method): SYMBOL_PRINT_NAME.
(select_symbols): SYMBOL_PRINT_NAME.
* infcmd.c (jump_command): SYMBOL_PRINT_NAME.
* findvar.c (locate_var_value): SYMBOL_PRINT_NAME.
* expprint.c (print_subexp): SYMBOL_PRINT_NAME.
* c-valprint.c (c_val_print): SYMBOL_PRINT_NAME.
* buildsym.c (finish_block): SYMBOL_PRINT_NAME.
* breakpoint.c (print_one_breakpoint): SYMBOL_PRINT_NAME.
* ax-gdb.c (gen_var_ref): SYMBOL_PRINT_NAME.
* ada-typeprint.c (ada_typedef_print): SYMBOL_PRINT_NAME.
* ada-lang.c (user_select_syms): Use SYMBOL_PRINT_NAME instead of
SYMBOL_SOURCE_NAME.
(user_select_syms):
(ada_finish_decode_line_1): Use SYMBOL_BEST_NAME instead of
SYMBOL_SOURCE_NAME.
* symtab.h (SYMBOL_PRINT_NAME): Rename from SYMBOL_SOURCE_NAME.
* symfile.c (compare_symbols): Use SYMBOL_BEST_NAME, not
SYMBOL_SOURCE_NAME.
(compare_psymbols): Ditto.
* symtab.c (lookup_symbol_linkage): New function.
* symtab.h: Declare lookup_symbol_linkage.
* c-valprint.c (c_val_print): Call lookup_symbol_minsym.
* symtab.c (lookup_symbol_aux_minsyms): Call minsym_static.
* minsyms.c (minsym_static): New function.
* symtab.h: Declare minsym_static.
* symtab.c (lookup_symbol_minsym): New function.
(search_symbols): Call lookup_symbol_minsym instead of
lookup_symbol.
(lookup_symbol_namespace): Don't take apart NAME.
* symtab.h: Declare lookup_symbol_minsym.
* printcmd.c (build_address_symbolic): Don't use old version of
SYMBOL_LINKAGE_NAME.
* symtab.c (lookup_block_symbol): Change mangled names to linkage
name, and use SYMBOL_LINKAGE_NAME as appropriate.
* symtab.h (SYMBOL_LINKAGE_NAME): New macro, with a different
meaning from the old macro of the same name. Also, add comments
about proper uses of names.
37 files changed, 330 insertions, 227 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a880e44..a6b11ee 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,85 @@ +2002-12-20 David Carlton <carlton@math.stanford.edu> + + * symtab.c (lookup_symbol_aux_minsyms): Don't call + lookup_symbol_aux from within this. + * values.c (value_static_field): lookup_symbol_linkage. + (value_fn_field): lookup_symbol_linkage. + * valops.c (value_struct_elt_for_reference): lookup_symbol_linkage. + * blockframe.c (inside_main_func): lookup_symbol_linkage. + * source.c (select_source_symtab): lookup_symbol_linkage. + * nlmread.c (nlm_symfile_read): Call lookup_symbol_linkage. + * nindy-tdep.c (nindy_frame_chain_valid): Call + lookup_symbol_linkage. + * linespec.c (count_methods): Call lookup_symbol_linkage. + (add_matching_methods): Ditto. + (add_constructors): Ditto. + * hppa-tdep.c (find_stub_with_shl_get): Call + lookup_symbol_linkage. Delete symbol2. + (initialize_hp_cxx_exception_support): Call lookup_symbol_linkage. + * cli/cli-cmds.c (edit_command): SYMBOL_PRINT_NAME. + (list_command): SYMBOL_PRINT_NAME. + * valops.c (value_of_variable): SYMBOL_PRINT_NAME + (hand_function_call): SYMBOL_PRINT_NAME. + * typeprint.c (typedef_print): SYMBOL_PRINT_NAME. + * tracepoint.c (tracepoints_info): SYMBOL_PRINT_NAME. + * symtab.c (lookup_partial_symbol): SYMBOL_BEST_NAME. + (compare_search_syms): SYMBOL_BEST_NAME. + (print_symbol_info): SYMBOL_PRINT_NAME. + (print_msymbol_info): SYMBOL_PRINT_NAME. + (rbreak_command): SYMBOL_PRINT_NAME. + * symmisc.c (print_symbol): SYMBOL_PRINT_NAME. + * stack.c (print_frame): SYMBOL_PRINT_NAME. + (frame_info): SYMBOL_PRINT_NAME. + (print_block_frame_locals): SYMBOL_PRINT_NAME. + (print_block_frame_labels): SYMBOL_PRINT_NAME. + (print_frame_arg_vars): SYMBOL_PRINT_NAME. + (return_command): SYMBOL_PRINT_NAME. + * stabsread.c (define_symbol): SYMBOL_PRINT_NAME. + * p-valprint.c (pascal_val_print): SYMBOL_PRINT_NAME. + * printcmd.c (build_address_symbolic): SYMBOL_PRINT_NAME. + (sym_info): SYMBOL_PRINT_NAME. + (print_frame_args): SYMBOL_PRINT_NAME. + * objc-lang.c (compare_selectors): SYMBOL_BEST_NAME. + (compare_classes): SYMBOL_BEST_NAME. + * maint.c (maintenance_translate_address): SYMBOL_PRINT_NAME. + * linespec.c (find_method): SYMBOL_PRINT_NAME. + (select_symbols): SYMBOL_PRINT_NAME. + * infcmd.c (jump_command): SYMBOL_PRINT_NAME. + * findvar.c (locate_var_value): SYMBOL_PRINT_NAME. + * expprint.c (print_subexp): SYMBOL_PRINT_NAME. + * c-valprint.c (c_val_print): SYMBOL_PRINT_NAME. + * buildsym.c (finish_block): SYMBOL_PRINT_NAME. + * breakpoint.c (print_one_breakpoint): SYMBOL_PRINT_NAME. + * ax-gdb.c (gen_var_ref): SYMBOL_PRINT_NAME. + * ada-typeprint.c (ada_typedef_print): SYMBOL_PRINT_NAME. + * ada-lang.c (user_select_syms): Use SYMBOL_PRINT_NAME instead of + SYMBOL_SOURCE_NAME. + (user_select_syms): + (ada_finish_decode_line_1): Use SYMBOL_BEST_NAME instead of + SYMBOL_SOURCE_NAME. + * symtab.h (SYMBOL_PRINT_NAME): Rename from SYMBOL_SOURCE_NAME. + * symfile.c (compare_symbols): Use SYMBOL_BEST_NAME, not + SYMBOL_SOURCE_NAME. + (compare_psymbols): Ditto. + * symtab.c (lookup_symbol_linkage): New function. + * symtab.h: Declare lookup_symbol_linkage. + * c-valprint.c (c_val_print): Call lookup_symbol_minsym. + * symtab.c (lookup_symbol_aux_minsyms): Call minsym_static. + * minsyms.c (minsym_static): New function. + * symtab.h: Declare minsym_static. + * symtab.c (lookup_symbol_minsym): New function. + (search_symbols): Call lookup_symbol_minsym instead of + lookup_symbol. + (lookup_symbol_namespace): Don't take apart NAME. + * symtab.h: Declare lookup_symbol_minsym. + * printcmd.c (build_address_symbolic): Don't use old version of + SYMBOL_LINKAGE_NAME. + * symtab.c (lookup_block_symbol): Change mangled names to linkage + name, and use SYMBOL_LINKAGE_NAME as appropriate. + * symtab.h (SYMBOL_LINKAGE_NAME): New macro, with a different + meaning from the old macro of the same name. Also, add comments + about proper uses of names. + 2002-12-18 David Carlton <carlton@math.stanford.edu> * symtab.c (lookup_symbol_aux_file): Call diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2d46699a..99abad6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2616,7 +2616,7 @@ user_select_syms (struct symbol *syms[], struct block *blocks[], int nsyms, struct symtab_and_line sal = find_function_start_sal (syms[i], 1); printf_unfiltered ("[%d] %s at %s:%d\n", i + first_choice, - SYMBOL_SOURCE_NAME (syms[i]), + SYMBOL_PRINT_NAME (syms[i]), sal.symtab == NULL ? "<no source file available>" : sal.symtab->filename, sal.line); @@ -2633,28 +2633,28 @@ user_select_syms (struct symbol *syms[], struct block *blocks[], int nsyms, if (SYMBOL_LINE (syms[i]) != 0 && symtab != NULL) printf_unfiltered ("[%d] %s at %s:%d\n", i + first_choice, - SYMBOL_SOURCE_NAME (syms[i]), + SYMBOL_PRINT_NAME (syms[i]), symtab->filename, SYMBOL_LINE (syms[i])); else if (is_enumeral && TYPE_NAME (SYMBOL_TYPE (syms[i])) != NULL) { printf_unfiltered ("[%d] ", i + first_choice); ada_print_type (SYMBOL_TYPE (syms[i]), NULL, gdb_stdout, -1, 0); printf_unfiltered ("'(%s) (enumeral)\n", - SYMBOL_SOURCE_NAME (syms[i])); + SYMBOL_PRINT_NAME (syms[i])); } else if (symtab != NULL) printf_unfiltered (is_enumeral ? "[%d] %s in %s (enumeral)\n" : "[%d] %s at %s:?\n", i + first_choice, - SYMBOL_SOURCE_NAME (syms[i]), + SYMBOL_PRINT_NAME (syms[i]), symtab->filename); else printf_unfiltered (is_enumeral ? "[%d] %s (enumeral)\n" : "[%d] %s at ?\n", i + first_choice, - SYMBOL_SOURCE_NAME (syms[i])); + SYMBOL_PRINT_NAME (syms[i])); } } @@ -4416,7 +4416,7 @@ ada_finish_decode_line_1 (char **spec, struct symtab *file_table, for (i = 0; i < selected.nelts; i += 1) (*canonical)[i] = extended_canonical_line_spec (selected.sals[i], - SYMBOL_SOURCE_NAME (symbols[i])); + SYMBOL_BEST_NAME (symbols[i])); } discard_cleanups (old_chain); diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index c18aa85..f6c92d9 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -124,8 +124,8 @@ ada_typedef_print (struct type *type, struct symbol *new, struct ui_file *stream) { fprintf_filtered (stream, "type %.*s is ", - ada_name_prefix_len (SYMBOL_SOURCE_NAME (new)), - SYMBOL_SOURCE_NAME (new)); + ada_name_prefix_len (SYMBOL_PRINT_NAME (new)), + SYMBOL_PRINT_NAME (new)); type_print (type, "", stream, 1); } diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 277b5ca..5ff21f0 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -856,6 +856,7 @@ find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame) symbol reading. */ sym = NULL; else + sym = lookup_symbol (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE, 0, NULL); } diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index fda8436..dc2adef 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -577,7 +577,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) case LOC_TYPEDEF: error ("Cannot compute value of typedef `%s'.", - SYMBOL_SOURCE_NAME (var)); + SYMBOL_PRINT_NAME (var)); break; case LOC_BLOCK: @@ -608,7 +608,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) struct minimal_symbol *msym = lookup_minimal_symbol (SYMBOL_NAME (var), NULL, NULL); if (!msym) - error ("Couldn't resolve symbol `%s'.", SYMBOL_SOURCE_NAME (var)); + error ("Couldn't resolve symbol `%s'.", SYMBOL_PRINT_NAME (var)); /* Push the address of the variable. */ ax_const_l (ax, SYMBOL_VALUE_ADDRESS (msym)); @@ -618,12 +618,12 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) case LOC_OPTIMIZED_OUT: error ("The variable `%s' has been optimized out.", - SYMBOL_SOURCE_NAME (var)); + SYMBOL_PRINT_NAME (var)); break; default: error ("Cannot find value of botched symbol `%s'.", - SYMBOL_SOURCE_NAME (var)); + SYMBOL_PRINT_NAME (var)); break; } } diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 1bc4395..7b92044 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -125,7 +125,7 @@ inside_main_func (CORE_ADDR pc) { struct symbol *mainsym; - mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL); + mainsym = lookup_symbol_linkage (main_name ()); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) { symfile_objfile->ei.main_func_lowpc = diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index df74c3d..80f31c2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3390,7 +3390,7 @@ print_one_breakpoint (struct breakpoint *b, { ui_out_text (uiout, "in "); ui_out_field_string (uiout, "func", - SYMBOL_SOURCE_NAME (sym)); + SYMBOL_PRINT_NAME (sym)); ui_out_wrap_hint (uiout, wrap_indent); ui_out_text (uiout, " at "); } diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 6d0fd5f..8583942 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -508,7 +508,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, { if (symbol) { - complain (&block_end_complaint, SYMBOL_SOURCE_NAME (symbol)); + complain (&block_end_complaint, SYMBOL_PRINT_NAME (symbol)); } else { @@ -539,7 +539,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, if (symbol) { complain (&innerblock_complaint, - SYMBOL_SOURCE_NAME (symbol)); + SYMBOL_PRINT_NAME (symbol)); } else { diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 1098cab..ed1dfee 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -205,7 +205,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset, (vt_address == SYMBOL_VALUE_ADDRESS (msymbol))) { fputs_filtered (" <", stream); - fputs_filtered (SYMBOL_SOURCE_NAME (msymbol), stream); + fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream); fputs_filtered (">", stream); } if (vt_address && vtblprint) @@ -213,12 +213,9 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset, struct value *vt_val; struct symbol *wsym = (struct symbol *) NULL; struct type *wtype; - struct block *block = (struct block *) NULL; - int is_this_fld; if (msymbol != NULL) - wsym = lookup_symbol (SYMBOL_NAME (msymbol), block, - VAR_NAMESPACE, &is_this_fld, NULL); + wsym = lookup_symbol_minsym (msymbol); if (wsym) { diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 9d58291..fb7c237 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -604,7 +604,7 @@ edit_command (char *arg, int from_tty) { print_address_numeric (sal.pc, 1, gdb_stdout); printf_filtered (" is in "); - fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout); + fputs_filtered (SYMBOL_PRINT_NAME (sym), gdb_stdout); printf_filtered (" (%s:%d).\n", sal.symtab->filename, sal.line); } else @@ -771,7 +771,7 @@ list_command (char *arg, int from_tty) { print_address_numeric (sal.pc, 1, gdb_stdout); printf_filtered (" is in "); - fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout); + fputs_filtered (SYMBOL_PRINT_NAME (sym), gdb_stdout); printf_filtered (" (%s:%d).\n", sal.symtab->filename, sal.line); } else diff --git a/gdb/expprint.c b/gdb/expprint.c index 23c6eb4..edaa6f9 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -105,12 +105,12 @@ print_subexp (register struct expression *exp, register int *pos, b = exp->elts[pc + 1].block; if (b != NULL && BLOCK_FUNCTION (b) != NULL - && SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b)) != NULL) + && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL) { - fputs_filtered (SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b)), stream); + fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream); fputs_filtered ("::", stream); } - fputs_filtered (SYMBOL_SOURCE_NAME (exp->elts[pc + 2].symbol), stream); + fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream); } return; diff --git a/gdb/findvar.c b/gdb/findvar.c index 99b9485..6f38b6f 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -875,7 +875,7 @@ locate_var_value (register struct symbol *var, struct frame_info *frame) lazy_value = read_var_value (var, frame); if (lazy_value == 0) - error ("Address of \"%s\" is unknown.", SYMBOL_SOURCE_NAME (var)); + error ("Address of \"%s\" is unknown.", SYMBOL_PRINT_NAME (var)); if (VALUE_LAZY (lazy_value) || TYPE_CODE (type) == TYPE_CODE_FUNC) @@ -896,7 +896,7 @@ locate_var_value (register struct symbol *var, struct frame_info *frame) && *REGISTER_NAME (VALUE_REGNO (lazy_value)) != '\0'); error("Address requested for identifier " "\"%s\" which is in register $%s", - SYMBOL_SOURCE_NAME (var), + SYMBOL_PRINT_NAME (var), REGISTER_NAME (VALUE_REGNO (lazy_value))); break; @@ -905,13 +905,13 @@ locate_var_value (register struct symbol *var, struct frame_info *frame) && *REGISTER_NAME (VALUE_FRAME_REGNUM (lazy_value)) != '\0'); error("Address requested for identifier " "\"%s\" which is in frame register $%s", - SYMBOL_SOURCE_NAME (var), + SYMBOL_PRINT_NAME (var), REGISTER_NAME (VALUE_FRAME_REGNUM (lazy_value))); break; default: error ("Can't take address of \"%s\" which isn't an lvalue.", - SYMBOL_SOURCE_NAME (var)); + SYMBOL_PRINT_NAME (var)); break; } return 0; /* For lint -- never reached */ diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index a3f9561..e0f7d9e 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1938,7 +1938,7 @@ hppa_value_returned_from_stack (register struct type *valtype, CORE_ADDR addr) CORE_ADDR find_stub_with_shl_get (struct minimal_symbol *function, CORE_ADDR handle) { - struct symbol *get_sym, *symbol2; + struct symbol *get_sym; struct minimal_symbol *buff_minsym, *msymbol; struct type *ftype; struct value **args; @@ -1952,10 +1952,9 @@ find_stub_with_shl_get (struct minimal_symbol *function, CORE_ADDR handle) args = alloca (sizeof (struct value *) * 8); /* 6 for the arguments and one null one??? */ funcval = find_function_in_inferior ("__d_shl_get"); - get_sym = lookup_symbol ("__d_shl_get", NULL, VAR_NAMESPACE, NULL, NULL); + get_sym = lookup_symbol_linkage ("__d_shl_get"); buff_minsym = lookup_minimal_symbol ("__buffer", NULL, NULL); msymbol = lookup_minimal_symbol ("__shldp", NULL, NULL); - symbol2 = lookup_symbol ("__shldp", NULL, VAR_NAMESPACE, NULL, NULL); endo_buff_addr = SYMBOL_VALUE_ADDRESS (buff_minsym); namelen = strlen (SYMBOL_NAME (function)); value_return_addr = endo_buff_addr + namelen; @@ -4308,8 +4307,7 @@ initialize_hp_cxx_exception_support (void) } /* Next look for the catch enable flag provided in end.o */ - sym = lookup_symbol (HP_ACC_EH_catch_catch, (struct block *) NULL, - VAR_NAMESPACE, 0, (struct symtab **) NULL); + sym = lookup_symbol_linkage (HP_ACC_EH_catch_catch); if (sym) /* sometimes present in debug info */ { eh_catch_catch_addr = SYMBOL_VALUE_ADDRESS (sym); @@ -4334,8 +4332,7 @@ initialize_hp_cxx_exception_support (void) } /* Next look for the catch enable flag provided end.o */ - sym = lookup_symbol (HP_ACC_EH_catch_catch, (struct block *) NULL, - VAR_NAMESPACE, 0, (struct symtab **) NULL); + sym = lookup_symbol (HP_ACC_EH_catch_catch); if (sym) /* sometimes present in debug info */ { eh_catch_throw_addr = SYMBOL_VALUE_ADDRESS (sym); diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 01d45b3..9988f62 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -846,7 +846,7 @@ jump_command (char *arg, int from_tty) if (fn != NULL && sfn != fn) { if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line, - SYMBOL_SOURCE_NAME (fn))) + SYMBOL_PRINT_NAME (fn))) { error ("Not confirmed."); /* NOTREACHED */ diff --git a/gdb/linespec.c b/gdb/linespec.c index 952d51d..1db423b 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -846,11 +846,11 @@ find_method (int funfirstline, char ***canonical, char *saved_arg, if (tmp[0] == '~') cplusplus_error (saved_arg, "the class `%s' does not have destructor defined\n", - SYMBOL_SOURCE_NAME (class_sym)); + SYMBOL_PRINT_NAME (class_sym)); else cplusplus_error (saved_arg, "the class %s does not have any method named %s\n", - SYMBOL_SOURCE_NAME (class_sym), tmp); + SYMBOL_PRINT_NAME (class_sym), tmp); } return values; @@ -876,8 +876,7 @@ count_methods (struct type *class_type, char *method, struct fn_field *f = TYPE_FN_FIELDLIST1 (class_type, m_index); sym_arr[count] = - lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, f_index), - NULL, VAR_NAMESPACE, NULL, NULL); + lookup_symbol_linkage (TYPE_FN_FIELD_PHYSNAME (f, f_index)); if (sym_arr[count]) count++; } @@ -1016,8 +1015,7 @@ add_matching_methods (int method_counter, struct type *class_type, if (is_destructor_name (phys_name) != 0) continue; - sym_arr[count] = lookup_symbol (phys_name, NULL, VAR_NAMESPACE, - NULL, NULL); + sym_arr[count] = lookup_symbol_linkage (phys_name); if (sym_arr[count]) count++; else @@ -1071,8 +1069,7 @@ add_constructors (int method_counter, struct type *class_type, /* If this method is actually defined, include it in the list. */ - sym_arr[count] = lookup_symbol (phys_name, NULL, VAR_NAMESPACE, - NULL, NULL); + sym_arr[count] = lookup_symbol_linkage (phys_name); if (sym_arr[count]) count++; } @@ -1117,7 +1114,7 @@ select_symbols (struct symbol **sym_arr, int nelts, int funfirstline, values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); printf_unfiltered ("[%d] %s at %s:%d\n", (i + 2), - SYMBOL_SOURCE_NAME (sym_arr[i]), + SYMBOL_PRINT_NAME (sym_arr[i]), values.sals[i].symtab->filename, values.sals[i].line); } diff --git a/gdb/maint.c b/gdb/maint.c index 6a849f9..e45d54d 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -484,7 +484,7 @@ maintenance_translate_address (char *arg, int from_tty) if (sym) printf_filtered ("%s+%s\n", - SYMBOL_SOURCE_NAME (sym), + SYMBOL_PRINT_NAME (sym), paddr_u (address - SYMBOL_VALUE_ADDRESS (sym))); else if (sect) printf_filtered ("no symbol at %s:0x%s\n", sect->name, paddr (address)); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index e4aa86b..77a6aa1 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4742,16 +4742,16 @@ fixup_sigtramp (void) /* We have to handle the following cases here: a) The Mips library has a sigtramp label within sigvec. b) Irix has a _sigtramp which we want to use, but it also has sigvec. */ - s = lookup_symbol ("sigvec", 0, VAR_NAMESPACE, 0, NULL); + s = lookup_symbol_linkage ("sigvec"); if (s != 0) { b0 = SYMBOL_BLOCK_VALUE (s); - s = lookup_symbol ("sigtramp", b0, VAR_NAMESPACE, 0, NULL); + s = lookup_symbol_linkage ("sigtramp"); } if (s == 0) { /* No sigvec or no sigtramp inside sigvec, try _sigtramp. */ - s = lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE, 0, NULL); + s = lookup_symbol_linkage ("_sigtramp"); } /* But maybe this program uses its own version of sigvec */ diff --git a/gdb/minsyms.c b/gdb/minsyms.c index b1ef28f..080c5bc 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -985,3 +985,19 @@ find_solib_trampoline_target (CORE_ADDR pc) } return 0; } + +/* Test whether or not MINSYM corresponnds to a static symbol (i.e. is + file-local) or not. */ +int +minsym_static (const struct minimal_symbol *minsym) +{ + switch (MSYMBOL_TYPE (minsym)) + { + case mst_file_text: + case mst_file_data: + case mst_file_bss: + return 1; + default: + return 0; + } +} diff --git a/gdb/nindy-tdep.c b/gdb/nindy-tdep.c index 1f35062..8e058c9 100644 --- a/gdb/nindy-tdep.c +++ b/gdb/nindy-tdep.c @@ -60,8 +60,7 @@ nindy_frame_chain_valid (CORE_ADDR chain, struct frame_info *curframe) return 0; } - sym = lookup_symbol (sf, 0, VAR_NAMESPACE, (int *) NULL, - (struct symtab **) NULL); + sym = lookup_symbol_linkage (sf); if (sym != 0) { a = SYMBOL_VALUE (sym); diff --git a/gdb/nlmread.c b/gdb/nlmread.c index 9d692dd..1ad4a02 100644 --- a/gdb/nlmread.c +++ b/gdb/nlmread.c @@ -194,7 +194,7 @@ nlm_symfile_read (struct objfile *objfile, int mainline) stabsect_build_psymtabs (objfile, mainline, ".stab", ".stabstr", ".text"); - mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL); + mainsym = lookup_symbol_linkage (main_name ()); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 21453d0..924c79c 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -808,8 +808,8 @@ compare_selectors (void *a, void *b) { char *aname, *bname; - aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a); - bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b); + aname = SYMBOL_BEST_NAME (*(struct symbol **) a); + bname = SYMBOL_BEST_NAME (*(struct symbol **) b); if (aname == NULL || bname == NULL) error ("internal: compare_selectors(1)"); @@ -966,8 +966,8 @@ compare_classes (void *a, void *b) { char *aname, *bname; - aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a); - bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b); + aname = SYMBOL_BEST_NAME (*(struct symbol **) a); + bname = SYMBOL_BEST_NAME (*(struct symbol **) b); if (aname == NULL || bname == NULL) error ("internal: compare_classes(1)"); diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 1a145f9..4e092302 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -213,7 +213,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset, && (vt_address == SYMBOL_VALUE_ADDRESS (msymbol))) { fputs_filtered (" <", stream); - fputs_filtered (SYMBOL_SOURCE_NAME (msymbol), stream); + fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream); fputs_filtered (">", stream); } if (vt_address && vtblprint) diff --git a/gdb/parse.c b/gdb/parse.c index 3180bd1..f44bcec 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -471,8 +471,7 @@ write_dollar_variable (struct stoken str) /* This code is not enabled on non HP-UX systems, since worst case symbol table lookup performance is awful, to put it mildly. */ - sym = lookup_symbol (copy_name (str), (struct block *) NULL, - VAR_NAMESPACE, (int *) NULL, (struct symtab **) NULL); + sym = lookup_symbol_linkage (copy_name (str)); if (sym) { write_exp_elt_opcode (OP_VAR_VALUE); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index e7f4cf9..4cab350 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -652,8 +652,8 @@ build_address_symbolic (CORE_ADDR addr, /* IN */ if (symbol) { name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)); - if (do_demangle) - name_temp = SYMBOL_SOURCE_NAME (symbol); + if (do_demangle || asm_demangle) + name_temp = SYMBOL_PRINT_NAME (symbol); else name_temp = SYMBOL_LINKAGE_NAME (symbol); } @@ -667,8 +667,8 @@ build_address_symbolic (CORE_ADDR addr, /* IN */ symbol = 0; symtab = 0; name_location = SYMBOL_VALUE_ADDRESS (msymbol); - if (do_demangle) - name_temp = SYMBOL_SOURCE_NAME (msymbol); + if (do_demangle || asm_demangle) + name_temp = SYMBOL_PRINT_NAME (msymbol); else name_temp = SYMBOL_LINKAGE_NAME (msymbol); } @@ -1064,10 +1064,10 @@ sym_info (char *arg, int from_tty) offset = sect_addr - SYMBOL_VALUE_ADDRESS (msymbol); if (offset) printf_filtered ("%s + %u in ", - SYMBOL_SOURCE_NAME (msymbol), offset); + SYMBOL_PRINT_NAME (msymbol), offset); else printf_filtered ("%s in ", - SYMBOL_SOURCE_NAME (msymbol)); + SYMBOL_PRINT_NAME (msymbol)); if (pc_in_unmapped_range (addr, sect)) printf_filtered ("load address range of "); if (section_is_overlay (sect)) @@ -1903,7 +1903,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num, annotate_arg_begin (); list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); - fprintf_symbol_filtered (stb->stream, SYMBOL_SOURCE_NAME (sym), + fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (sym), SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI); ui_out_field_stream (uiout, "name", stb); annotate_arg_name_end (); diff --git a/gdb/source.c b/gdb/source.c index 0107bfa..293913e 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -238,7 +238,7 @@ select_source_symtab (register struct symtab *s) /* Make the default place to list be the function `main' if one exists. */ - if (lookup_symbol (main_name (), 0, VAR_NAMESPACE, 0, NULL)) + if (lookup_symbol_linkage (main_name ())) { sals = decode_line_spec (main_name (), 1); sal = sals.sals[0]; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7c09d76..a4807e3 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1815,7 +1815,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, { complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS + NUM_PSEUDO_REGS, - SYMBOL_SOURCE_NAME (sym)); + SYMBOL_PRINT_NAME (sym)); SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ } SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; @@ -1831,7 +1831,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, { complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS + NUM_PSEUDO_REGS, - SYMBOL_SOURCE_NAME (sym)); + SYMBOL_PRINT_NAME (sym)); SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ } SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; @@ -2085,7 +2085,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, { complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS + NUM_PSEUDO_REGS, - SYMBOL_SOURCE_NAME (sym)); + SYMBOL_PRINT_NAME (sym)); SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ } SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; diff --git a/gdb/stack.c b/gdb/stack.c index 5aa3621..734132d 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -514,7 +514,7 @@ print_frame (struct frame_info *fi, } else { - /* I'd like to use SYMBOL_SOURCE_NAME() here, to display the + /* I'd like to use SYMBOL_PRINT_NAME() here, to display the demangled name that we already have stored in the symbol table, but we stored a version with DMGL_PARAMS turned on, and here we don't want to display parameters. So call @@ -535,7 +535,7 @@ print_frame (struct frame_info *fi, /* If the demangler fails, try the demangled name from the symbol table. This'll have parameters, but that's preferable to diplaying a mangled name. */ - funname = SYMBOL_SOURCE_NAME (func); + funname = SYMBOL_PRINT_NAME (func); } } } @@ -801,7 +801,7 @@ frame_info (char *addr_exp, int from_tty) s = find_pc_symtab (fi->pc); if (func) { - /* I'd like to use SYMBOL_SOURCE_NAME() here, to display + /* I'd like to use SYMBOL_PRINT_NAME() here, to display * the demangled name that we already have stored in * the symbol table, but we stored a version with * DMGL_PARAMS turned on, and here we don't want @@ -825,7 +825,7 @@ frame_info (char *addr_exp, int from_tty) * but that's preferable to diplaying a mangled name. */ if (demangled == NULL) - funname = SYMBOL_SOURCE_NAME (func); + funname = SYMBOL_PRINT_NAME (func); } } else @@ -1245,7 +1245,7 @@ print_block_frame_locals (struct block *b, register struct frame_info *fi, values_printed = 1; for (j = 0; j < num_tabs; j++) fputs_filtered ("\t", stream); - fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream); + fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); fputs_filtered (" = ", stream); print_variable_value (sym, fi, stream); fprintf_filtered (stream, "\n"); @@ -1282,7 +1282,7 @@ print_block_frame_labels (struct block *b, int *have_default, struct symtab_and_line sal; sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0); values_printed = 1; - fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream); + fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); if (addressprint) { fprintf_filtered (stream, " "); @@ -1469,7 +1469,7 @@ print_frame_arg_vars (register struct frame_info *fi, case LOC_REGPARM_ADDR: case LOC_BASEREG_ARG: values_printed = 1; - fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream); + fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); fputs_filtered (" = ", stream); /* We have to look up the symbol because arguments can have @@ -1804,7 +1804,7 @@ return_command (char *retval_exp, int from_tty) { if (thisfun != 0) { - if (!query ("Make %s return now? ", SYMBOL_SOURCE_NAME (thisfun))) + if (!query ("Make %s return now? ", SYMBOL_PRINT_NAME (thisfun))) { error ("Not confirmed."); /* NOTREACHED */ diff --git a/gdb/symfile.c b/gdb/symfile.c index cd87b1d..b3d3afa 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -204,7 +204,7 @@ compare_symbols (const void *s1p, const void *s2p) s1 = (struct symbol **) s1p; s2 = (struct symbol **) s2p; - return (strcmp (SYMBOL_SOURCE_NAME (*s1), SYMBOL_SOURCE_NAME (*s2))); + return (strcmp (SYMBOL_BEST_NAME (*s1), SYMBOL_BEST_NAME (*s2))); } /* @@ -237,8 +237,8 @@ compare_psymbols (const void *s1p, const void *s2p) s1 = (struct partial_symbol **) s1p; s2 = (struct partial_symbol **) s2p; - st1 = SYMBOL_SOURCE_NAME (*s1); - st2 = SYMBOL_SOURCE_NAME (*s2); + st1 = SYMBOL_BEST_NAME (*s1); + st2 = SYMBOL_BEST_NAME (*s2); if ((st1[0] - st2[0]) || !st1[0]) diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 42b27e3..86ba9d9 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -591,7 +591,7 @@ print_symbol (PTR args) print_spaces (depth, outfile); if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE) { - fprintf_filtered (outfile, "label %s at ", SYMBOL_SOURCE_NAME (symbol)); + fprintf_filtered (outfile, "label %s at ", SYMBOL_PRINT_NAME (symbol)); print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); if (SYMBOL_BFD_SECTION (symbol)) fprintf_filtered (outfile, " section %s\n", @@ -626,14 +626,14 @@ print_symbol (PTR args) if (SYMBOL_TYPE (symbol)) { /* Print details of types, except for enums where it's clutter. */ - LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_SOURCE_NAME (symbol), + LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_PRINT_NAME (symbol), outfile, TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM, depth); fprintf_filtered (outfile, "; "); } else - fprintf_filtered (outfile, "%s ", SYMBOL_SOURCE_NAME (symbol)); + fprintf_filtered (outfile, "%s ", SYMBOL_PRINT_NAME (symbol)); switch (SYMBOL_CLASS (symbol)) { diff --git a/gdb/symtab.c b/gdb/symtab.c index fdf269c..951991d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1275,19 +1275,9 @@ symbol *lookup_symbol_aux_using_loop (const char *name, /* This tries to look up NAME in the namespace given by the initial substring of NAMESPACE_NAME of length NAMESPACE_LEN. It applies - the using directives that are active in BLOCK. - - For example, assume that we have using directives adding A to the - global namespace, adding A::inner to namespace A, and adding B to - the global namespace. Then, when looking up a symbol "foo", we - want to recurse by looking up stuff in A::foo and seeing which - using directives still apply. The only one that still applies - converts that to A::inner::foo: we _don't_ want to then look at - B::A::foo (let alone A::A::foo!). So we end up just looking at - A::foo, A::inner::foo, and B::foo. (Though if the original caller - to lookup_symbol had specified A::foo, we would want to look up - stuff in A::A::foo, A::inner::A::foo, A::inner::foo, and - B::A::foo). */ + the using directives that are active in BLOCK. It doesn't look + into NAME at all, so if NAME happens to contain some namespaces, it + won't apply using directives to those namespaces. */ /* FIXME: carlton/2002-11-27: Currently, there's no way to specify that additional using directives are active. When we get around to @@ -1310,53 +1300,32 @@ lookup_symbol_namespace (const char *namespace_name, const struct using_direct *current; struct symbol *sym; + /* First, go through the using directives. If any of them add new + names to the namespace we're searching in, see if we can find a + match by applying them. */ + for (current = block_using_iterator_first (block, &iter); current != NULL; current = block_using_iterator_next (&iter)) { - /* First, see if the namespace matches the start of this using - directive. */ - if (namespace_len <= current->outer_length + if (namespace_len == current->outer_length && strncmp (namespace_name, current->name, namespace_len) == 0) { - /* Great, it matches: now does the rest of the using - directive match the rest of the name? */ - - const char *rest_of_outer = current->name + namespace_len; - int rest_of_outer_len - = current->outer_length - namespace_len; - /* Should we skip some colons? Should be true unless - NAMESPACE_LEN is zero (and hence we're in the global - namespace) or we've finished all of outer. */ - if (rest_of_outer_len != 0 && *rest_of_outer == ':') - { - rest_of_outer += 2; - rest_of_outer_len -= 2; - } - if (strncmp (rest_of_outer, name, rest_of_outer_len) == 0) - { - /* Everything matches! Yippee! So apply the using - directive and recurse. */ - const char *new_name = name + rest_of_outer_len; - if (*new_name == ':') - new_name += 2; - - sym = lookup_symbol_namespace (current->name, - current->inner_length, - new_name, - mangled_name, - block, - name_space, - symtab); - if (sym != NULL) - return sym; - } + sym = lookup_symbol_namespace (current->name, + current->inner_length, + name, + mangled_name, + block, + name_space, + symtab); + if (sym != NULL) + return sym; } } /* We didn't find anything by applying any of the using directives that are still applicable; so let's see if we've got a match - using the current name. */ + using the current namespace. */ if (namespace_len == 0) { @@ -1378,10 +1347,8 @@ lookup_symbol_namespace (const char *namespace_name, } } -/* Check for the possibility of the symbol being a function or a - mangled variable that is stored in one of the minimal symbol - tables. Eventually, all global symbols might be resolved in this - way. */ +/* Check for the possibility of the symbol being a function that is + stored in one of the minimal symbol tables. */ static struct symbol * lookup_symbol_aux_minsyms (int block_index, const char *name, @@ -1421,14 +1388,13 @@ lookup_symbol_aux_minsyms (int block_index, const char *name, that's okay: this is only called with block_index equal to STATIC_BLOCK if a global search has failed. */ - switch (MSYMBOL_TYPE (msymbol)) + if (minsym_static (msymbol)) { - case mst_file_text: - case mst_file_data: - case mst_file_bss: if (block_index == GLOBAL_BLOCK) return NULL; - default: + } + else + { if (block_index == STATIC_BLOCK) return NULL; } @@ -1453,16 +1419,6 @@ lookup_symbol_aux_minsyms (int block_index, const char *name, sym = lookup_block_symbol (block, name, mangled_name, namespace); - /* FIXME: carlton/2002-10-28: this next comment dates - from when this code was part of lookup_symbol_aux, so - this return could return NULL from lookup_symbol_aux. - Are there really situations where we want a minimal - symbol lookup to be able to force a NULL return from - lookup_symbol? If so, maybe the thing to do would be - to have lookup_symbol_aux_minsym to set a - minsym_found flag, and to have lookup_symbol_aux only - do the psymtab search if that flag is zero. */ - /* sym == 0 if symbol was found in the minimal symbol table but not in the symtab. Return 0 to use the msymbol definition of "foo_". @@ -1480,24 +1436,76 @@ lookup_symbol_aux_minsyms (int block_index, const char *name, *symtab = s; return fixup_symbol_section (sym, s->objfile); } - else if (MSYMBOL_TYPE (msymbol) != mst_text - && MSYMBOL_TYPE (msymbol) != mst_file_text - && strcmp (name, SYMBOL_NAME (msymbol)) != 0) - { - /* This is a mangled variable, look it up by its - mangled name. */ - return lookup_symbol_aux_nonlocal (block_index, - SYMBOL_NAME (msymbol), - mangled_name, - namespace, - symtab); - } } } return NULL; } +/* Lookup the symbol associated to a minimal symbol, if there is one. */ + +/* FIXME: carlton/2002-12-20: This is now implemented in a way that + doesn't work very well and that may, in fact return the wrong + symbol. For now, we're in a transition period where I want to + replace some calls to lookup_symbol by calls to + lookup_symbol_minsym, so it's okay for lookup_symbol_minsym to get + the answer wrong in circumstances where lookup_symbol would have + screwed it up, too; later, I'll fix lookup_symbol_minsym to get it + right as quickly and easily as possible. */ + +struct symbol * +lookup_symbol_minsym (const struct minimal_symbol *minsym) +{ + int block_index = minsym_static (minsym) ? STATIC_BLOCK : GLOBAL_BLOCK; + + return lookup_symbol_aux_nonlocal (block_index, + SYMBOL_BEST_NAME (minsym), + SYMBOL_LINKAGE_NAME (minsym), + VAR_NAMESPACE, + NULL); +} + +/* Lookup the symbol with a given linkage name. */ + +struct symbol * +lookup_symbol_linkage (const char *linkage_name) +{ + const char *name; + char *demangled_name = NULL; + struct symbol *sym; + + name = linkage_name; + + /* If we are using C++, then the linkage name might be a mangled C++ + name; lookup_symbol_aux_nonlocal expects the name to be + demangled. */ + + if (current_language->la_language == language_cplus) + { + demangled_name = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); + if (demangled_name != NULL) + { + name = demangled_name; + } + } + + sym = lookup_symbol_aux_nonlocal (GLOBAL_BLOCK, name, linkage_name, + VAR_NAMESPACE, NULL); + + if (sym != NULL) + { + xfree (demangled_name); + return sym; + } + + sym = lookup_symbol_aux_nonlocal (STATIC_BLOCK, name, linkage_name, + VAR_NAMESPACE, NULL); + + xfree (demangled_name); + return sym; +} + + /* Look up a type named NESTED_NAME that is nested inside the C++ class or namespace given by PARENT_TYPE, from within the context given by BLOCK. */ @@ -1588,7 +1596,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, { do_linear_search = 1; } - if (strcmp (SYMBOL_SOURCE_NAME (*center), name) >= 0) + if (strcmp (SYMBOL_BEST_NAME (*center), name) >= 0) { top = center; } @@ -1786,8 +1794,8 @@ find_main_psymtab (void) symbol (language_cplus set) has both the encoded and non-encoded names tested for a match. - If MANGLED_NAME is non-NULL, verify that any symbol we find has this - particular mangled name. + If LINKAGE_NAME is non-NULL, verify that any symbol we find has + this particular linkage name. */ /* FIXME: carlton/2002-09-26: I've slightly changed the semantics: I @@ -1803,7 +1811,7 @@ find_main_psymtab (void) struct symbol * lookup_block_symbol (register const struct block *block, const char *name, - const char *mangled_name, const namespace_enum namespace) + const char *linkage_name, const namespace_enum namespace) { struct dict_iterator iter; struct symbol *sym; @@ -1814,8 +1822,8 @@ lookup_block_symbol (register const struct block *block, const char *name, sym; sym = dict_iter_name_next (name, &iter)) { if (SYMBOL_NAMESPACE (sym) == namespace - && (mangled_name - ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0 : 1)) + && (linkage_name + ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1)) return sym; } return NULL; @@ -1834,8 +1842,8 @@ lookup_block_symbol (register const struct block *block, const char *name, sym; sym = dict_iter_name_next (name, &iter)) { if (SYMBOL_NAMESPACE (sym) == namespace - && (mangled_name - ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0 : 1)) + && (linkage_name + ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1)) { /* If SYM has aliases, then use any alias that is active at the current PC. If no alias is active at the current @@ -2860,8 +2868,8 @@ compare_search_syms (const void *sa, const void *sb) struct symbol_search **sym_a = (struct symbol_search **) sa; struct symbol_search **sym_b = (struct symbol_search **) sb; - return strcmp (SYMBOL_SOURCE_NAME ((*sym_a)->symbol), - SYMBOL_SOURCE_NAME ((*sym_b)->symbol)); + return strcmp (SYMBOL_BEST_NAME ((*sym_a)->symbol), + SYMBOL_BEST_NAME ((*sym_b)->symbol)); } /* Sort the ``nfound'' symbols in the list after prevtail. Leave @@ -3063,7 +3071,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[], The symbol will then be found during the scan of symtabs below. For functions, find_pc_symtab should succeed if we have debug info - for the function, for variables we have to call lookup_symbol + for the function, for variables we have to call lookup_symbol_minsym to determine if the variable has debug info. If the lookup fails, set found_misc so that we will rescan to print any matching symbols without debug info. @@ -3084,10 +3092,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[], if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol))) { if (kind == FUNCTIONS_NAMESPACE - || lookup_symbol (SYMBOL_NAME (msymbol), - (struct block *) NULL, - VAR_NAMESPACE, - 0, (struct symtab **) NULL) == NULL) + || lookup_symbol_minsym (msymbol) == NULL) found_misc = 1; } } @@ -3181,9 +3186,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[], (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)))) { /* Variables/Absolutes: Look up by name */ - if (lookup_symbol (SYMBOL_NAME (msymbol), - (struct block *) NULL, VAR_NAMESPACE, - 0, (struct symtab **) NULL) == NULL) + if (lookup_symbol_minsym (msymbol) == NULL) { /* match */ psr = @@ -3242,7 +3245,7 @@ print_symbol_info (namespace_enum kind, struct symtab *s, struct symbol *sym, { type_print (SYMBOL_TYPE (sym), (SYMBOL_CLASS (sym) == LOC_TYPEDEF - ? "" : SYMBOL_SOURCE_NAME (sym)), gdb_stdout, 0); + ? "" : SYMBOL_PRINT_NAME (sym)), gdb_stdout, 0); printf_filtered (";\n"); } @@ -3261,7 +3264,7 @@ print_msymbol_info (struct minimal_symbol *msymbol) & (CORE_ADDR) 0xffffffff, "08l"); else tmp = local_hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol), "016l"); - printf_filtered ("%s %s\n", tmp, SYMBOL_SOURCE_NAME (msymbol)); + printf_filtered ("%s %s\n", tmp, SYMBOL_PRINT_NAME (msymbol)); } /* This is the guts of the commands "info functions", "info types", and @@ -3369,7 +3372,7 @@ rbreak_command (char *regexp, int from_tty) { break_command (SYMBOL_NAME (p->msymbol), from_tty); printf_filtered ("<function, no debug info> %s;\n", - SYMBOL_SOURCE_NAME (p->msymbol)); + SYMBOL_PRINT_NAME (p->msymbol)); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index d96c0c6..b558e81 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -138,7 +138,6 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *); functions, unless the callers are changed to pass in the ginfo field only, instead of the SYMBOL parameter. */ -#define SYMBOL_NAME(symbol) (symbol)->ginfo.name #define SYMBOL_VALUE(symbol) (symbol)->ginfo.value.ivalue #define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->ginfo.value.address #define SYMBOL_VALUE_BYTES(symbol) (symbol)->ginfo.value.bytes @@ -148,6 +147,14 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, asection *); #define SYMBOL_SECTION(symbol) (symbol)->ginfo.section #define SYMBOL_BFD_SECTION(symbol) (symbol)->ginfo.bfd_section +/* FIXME: carlton/2002-12-20: The situation with all of these names is + a mess. As a first step, try to avoid using SYMBOL_NAME to access + the name of a symbol: use SYMBOL_BEST_NAME or SYMBOL_LINKAGE_NAME + instead, depending on which one you want. I'll try to add some + initialization functions later, too. */ + +#define SYMBOL_NAME(symbol) (symbol)->ginfo.name + #define SYMBOL_CPLUS_DEMANGLED_NAME(symbol) \ (symbol)->ginfo.language_specific.cplus_specific.demangled_name @@ -171,45 +178,36 @@ extern const char *symbol_demangled_name (const struct general_symbol_info *symbol); /* Macro that returns the demangled name of the symbol if if possible - and the symbol name if not possible. This is like - SYMBOL_SOURCE_NAME except that it doesn't depend on the value of - 'demangle' (and is hence more suitable for internal usage). The - result should never be NULL. */ - -/* FIXME: carlton/2002-09-26: Probably the situation with this and - SYMBOL_SOURCE_NAME should be rethought. */ + and the symbol name if not possible. The result should never be + NULL. */ #define SYMBOL_BEST_NAME(symbol) \ (SYMBOL_DEMANGLED_NAME (symbol) != NULL \ ? SYMBOL_DEMANGLED_NAME (symbol) \ : SYMBOL_NAME (symbol)) +/* Use this if you want to get at the linkage name of a symbol (which + might be mangled). */ + +#define SYMBOL_LINKAGE_NAME(symbol) SYMBOL_NAME (symbol) + /* OBSOLETE #define SYMBOL_CHILL_DEMANGLED_NAME(symbol) */ /* OBSOLETE (symbol)->ginfo.language_specific.chill_specific.demangled_name */ #define SYMBOL_OBJC_DEMANGLED_NAME(symbol) \ (symbol)->ginfo.language_specific.objc_specific.demangled_name -/* 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. The result should never be NULL. */ +/* Macro that returns the name of a name of a symbol that we want to + print. 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. The result should + never be NULL. */ /* NOTE: carlton/2002-09-26: For external use only; in many situations, SYMBOL_BEST_NAME is more appropriate. */ -#define SYMBOL_SOURCE_NAME(symbol) \ - (demangle ? SYMBOL_BEST_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. The result should - never be NULL. */ - -#define SYMBOL_LINKAGE_NAME(symbol) \ - (demangle && asm_demangle ? SYMBOL_BEST_NAME (symbol) \ - : SYMBOL_NAME (symbol)) +#define SYMBOL_PRINT_NAME(symbol) \ + (demangle ? SYMBOL_BEST_NAME (symbol) : SYMBOL_LINKAGE_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 @@ -953,6 +951,15 @@ extern struct symbol *lookup_symbol_namespace (const char *namespace_name, namespace_enum name_space, struct symtab **symtab); +/* Lookup the symbol associated to a minimal symbol. */ + +extern struct symbol *lookup_symbol_minsym (const struct minimal_symbol + *minsym); + +/* Lookup the symbol with a given linkage name. */ + +extern struct symbol *lookup_symbol_linkage (const char *linkage_name); + /* Lookup a type within a class or a namespace. */ extern struct type *lookup_nested_type (struct type *parent_type, @@ -1097,6 +1104,8 @@ extern void install_minimal_symbols (struct objfile *); extern void msymbols_sort (struct objfile *objfile); +int minsym_static (const struct minimal_symbol *minsym); + struct symtab_and_line { struct symtab *symtab; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 977114b..1f699e4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-12-20 David Carlton <carlton@math.stanford.edu> + + * gdb.c++/namespace.exp: Delete tests that try to apply using + directives to quoted namespaces. + 2002-12-17 David Carlton <carlton@math.stanford.edu> * gdb.c++/m-data.cc: Whitespace cleanup, to match mainline patch. diff --git a/gdb/testsuite/gdb.c++/namespace.exp b/gdb/testsuite/gdb.c++/namespace.exp index 1f0d7e1..78775b1 100644 --- a/gdb/testsuite/gdb.c++/namespace.exp +++ b/gdb/testsuite/gdb.c++/namespace.exp @@ -269,12 +269,10 @@ gdb_test "ptype C::OtherFileClass" "No symbol \"Class\" in namespace \"C::C\"." gdb_test "print cX" "\\$\[0-9\].* = 6" gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7" gdb_test "print F::cXf" "\\$\[0-9\].* = 7" -gdb_test "print 'F::cXfX'" "\\$\[0-9\].* = 8" gdb_test "print F::cXfX" "\\$\[0-9\].* = 8" gdb_test "print X" "\\$\[0-9\].* = 9" gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10" gdb_test "print G::Xg" "\\$\[0-9\].* = 10" -gdb_test "print 'G::XgX'" "\\$\[0-9\].* = 11" gdb_test "print G::XgX" "\\$\[0-9\].* = 11" # Test namespace renaming. diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index da10242..67cd6b5 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -516,7 +516,7 @@ tracepoints_info (char *tpnum_exp, int from_tty) if (sym) { fputs_filtered ("in ", gdb_stdout); - fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout); + fputs_filtered (SYMBOL_PRINT_NAME (sym), gdb_stdout); wrap_here (wrap_indent); fputs_filtered (" at ", gdb_stdout); } diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 58c6641..194e480 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -67,7 +67,7 @@ typedef_print (struct type *type, struct symbol *new, struct ui_file *stream) type_print (type, "", stream, 0); if (TYPE_NAME ((SYMBOL_TYPE (new))) == 0 || !STREQ (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new))) - fprintf_filtered (stream, " %s", SYMBOL_SOURCE_NAME (new)); + fprintf_filtered (stream, " %s", SYMBOL_PRINT_NAME (new)); break; #endif #ifdef _LANG_m2 @@ -75,7 +75,7 @@ typedef_print (struct type *type, struct symbol *new, struct ui_file *stream) fprintf_filtered (stream, "TYPE "); if (!TYPE_NAME (SYMBOL_TYPE (new)) || !STREQ (TYPE_NAME (SYMBOL_TYPE (new)), SYMBOL_NAME (new))) - fprintf_filtered (stream, "%s = ", SYMBOL_SOURCE_NAME (new)); + fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new)); else fprintf_filtered (stream, "<builtin> = "); type_print (type, "", stream, 0); @@ -84,7 +84,7 @@ typedef_print (struct type *type, struct symbol *new, struct ui_file *stream) #ifdef _LANG_pascal case language_pascal: fprintf_filtered (stream, "type "); - fprintf_filtered (stream, "%s = ", SYMBOL_SOURCE_NAME (new)); + fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new)); type_print (type, "", stream, 0); break; #endif @@ -93,7 +93,7 @@ typedef_print (struct type *type, struct symbol *new, struct ui_file *stream) /* OBSOLETE fprintf_filtered (stream, "SYNMODE "); */ /* OBSOLETE if (!TYPE_NAME (SYMBOL_TYPE (new)) || */ /* OBSOLETE !STREQ (TYPE_NAME (SYMBOL_TYPE (new)), SYMBOL_NAME (new))) */ - /* OBSOLETE fprintf_filtered (stream, "%s = ", SYMBOL_SOURCE_NAME (new)); */ + /* OBSOLETE fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new)); */ /* OBSOLETE else */ /* OBSOLETE fprintf_filtered (stream, "<builtin> = "); */ /* OBSOLETE type_print (type, "", stream, 0); */ diff --git a/gdb/valops.c b/gdb/valops.c index 209e504..129332e 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -856,9 +856,9 @@ value_of_variable (const struct symbol *var, const struct block *b) if (!frame) { if (BLOCK_FUNCTION (b) - && SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b))) + && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b))) error ("No frame is currently executing in block %s.", - SYMBOL_SOURCE_NAME (BLOCK_FUNCTION (b))); + SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b))); else error ("No frame is currently executing in specified block"); } @@ -866,7 +866,7 @@ value_of_variable (const struct symbol *var, const struct block *b) val = read_var_value (var, frame); if (!val) - error ("Address of symbol \"%s\" is unknown.", SYMBOL_SOURCE_NAME (var)); + error ("Address of symbol \"%s\" is unknown.", SYMBOL_PRINT_NAME (var)); return val; } @@ -1757,7 +1757,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name); symbol = find_pc_function (funaddr); if (symbol) { - name = SYMBOL_SOURCE_NAME (symbol); + name = SYMBOL_PRINT_NAME (symbol); } else { @@ -1766,7 +1766,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name); if (msymbol) { - name = SYMBOL_SOURCE_NAME (msymbol); + name = SYMBOL_PRINT_NAME (msymbol); } } if (name == NULL) @@ -3229,8 +3229,8 @@ value_struct_elt_for_reference (struct type *domain, int offset, } else { - struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_NAMESPACE, 0, NULL); + struct symbol *s + = lookup_symbol_linkage (TYPE_FN_FIELD_PHYSNAME (f, j)); if (s == NULL) { v = 0; diff --git a/gdb/values.c b/gdb/values.c index 5226aea..e78ad89 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -812,7 +812,7 @@ value_static_field (struct type *type, int fieldno) else { char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno); - struct symbol *sym = lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL); + struct symbol *sym = lookup_symbol_linkage (phys_name); if (sym == NULL) { /* With some compilers, e.g. HP aCC, static data members are reported @@ -986,7 +986,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *ty struct symbol *sym; struct minimal_symbol *msym; - sym = lookup_symbol (physname, 0, VAR_NAMESPACE, 0, NULL); + sym = lookup_symbol_linkage (physname); if (sym != NULL) { msym = NULL; |