From 0d5cff5020224cfd67bc3d6e30b158105d03a324 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Tue, 7 Feb 2012 04:48:23 +0000 Subject: [PATCH] * gdbtypes.h (struct main_type): Change type of name,tag_name, and fields.name members from char * to const char *. All uses updated. (struct cplus_struct_type): Change type of fn_fieldlists.name member from char * to const char *. All uses updated. (type_name_no_tag): Update. (lookup_unsigned_typename, lookup_signed_typename): Update. * gdbtypes.c (type_name_no_tag): Change result type from char * to const char *. All callers updated. (lookup_unsigned_typename, lookup_signed_typename): Change type of name parameter from char * to const char *. * symtab.h (struct cplus_specific): Change type of demangled_name member from char * to const char *. All uses updated. (struct general_symbol_info): Change type of name and mangled_lang.demangled_name members from char * to const char *. All uses updated. (symbol_get_demangled_name, symbol_natural_name): Update. (symbol_demangled_name, symbol_search_name): Update. * symtab.c (symbol_get_demangled_name): Change result type from char * to const char *. All callers updated. (symbol_natural_name, symbol_demangled_name): Ditto. (symbol_search_name): Ditto. (completion_list_add_name): Change type of symname,sym_text, text,word parameters from char * to const char *. (completion_list_objc_symbol): Change type of sym_text, text,word parameters from char * to const char *. * ada-lang.c (find_struct_field): Change type of name parameter from char * to const char *. (encoded_ordered_before): Similarly for N0,N1 parameters. (old_renaming_is_invisible): Similarly for function_name parameter. (ada_type_name): Change result type from char * to const char *. All callers updated. * ada-lang.h (ada_type_name): Update. * buildsym.c (hashname): Change type of name parameter from char * to const char *. * buildsym.h (hashname): Update. * dbxread.c (end_psymtab): Change type of include_list parameter from char ** to const char **. * dwarf2read.c (determine_prefix): Change result type from char * to const char *. All callers updated. * f-lang.c (find_common_for_function): Change type of name, funcname parameters from char * to const char *. * f-lang.c (find_common_for_function): Update. * f-valprint.c (list_all_visible_commons): Change type of funcname parameters from char * to const char *. * gdbarch.sh (static_transform_name): Change type of name parameter and result from char * to const char *. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type of name parameter from char * to const char *. * jv-lang.c (java_primitive_type_from_name): Ditto. (java_demangled_signature_length): Similarly for signature parameter. (java_demangled_signature_copy): Ditto. (java_demangle_type_signature): Ditto. * jv-lang.h (java_primitive_type_from_name): Update. (java_demangle_type_signature): Update. * objc-lang.c (specialcmp): Change type of a,b parameters from char * to const char *. * p-lang.c (is_pascal_string_type): Change type of arrayname parameter from char * to const char *. All callers updated. * p-lang.h (is_pascal_string_type): Update. * solib-frv.c (find_canonical_descriptor_in_load_object): Change type of name parameter from char * to const char *. * sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto. * utils.c (fprintf_symbol_filtered): Ditto. * defs.h (fprintf_symbol_filtered): Update. * sparc-tdep.h (sparc_sol2_static_transform_name): Update. * stabsread.h (end_psymtab): Update. * stack.c (find_frame_funname): Change type of funname parameter from char ** to const char **. * stack.h (find_frame_funname): Update. * typeprint.c (type_print): Change type of varstring parameter from char * to const char *. * value.h (type_print): Update. * xcoffread.c (xcoff_start_psymtab): Change type of filename parameter from char * to const char *. All callers updated. (xcoff_end_psymtab): Change type of include_list parameter from char ** to const char **. All callers updated. (swap_sym): Similarly for name parameter. All callers updated. * coffread.c (patch_type): Add (char*) cast to xfree parameter. Use xstrdup. (process_coff_symbol): Use xstrdup. * stabsread.c (stabs_method_name_from_physname): Renamed from update_method_name_from_physname. Change result type from void to char *. All callers updated. (read_member_functions): In has_destructor case, store name in objfile obstack instead of malloc space. In !has_stub case, fix mem leak. --- gdb/ChangeLog | 90 +++++++++++++++++++++++++++++++++++++++++++ gdb/ada-lang.c | 67 ++++++++++++++++---------------- gdb/ada-lang.h | 2 +- gdb/ada-typeprint.c | 8 ++-- gdb/arm-wince-tdep.c | 2 +- gdb/ax-gdb.c | 4 +- gdb/buildsym.c | 4 +- gdb/buildsym.h | 2 +- gdb/c-lang.c | 2 +- gdb/c-typeprint.c | 14 +++---- gdb/coffread.c | 11 +++--- gdb/completer.c | 4 +- gdb/cp-support.c | 2 +- gdb/cp-valprint.c | 6 +-- gdb/dbxread.c | 17 ++++---- gdb/defs.h | 2 +- gdb/dwarf2read.c | 8 ++-- gdb/eval.c | 6 ++- gdb/f-lang.c | 2 +- gdb/f-lang.h | 3 +- gdb/f-valprint.c | 6 +-- gdb/gdbarch.c | 4 +- gdb/gdbarch.h | 4 +- gdb/gdbarch.sh | 2 +- gdb/gdbtypes.c | 14 +++---- gdb/gdbtypes.h | 22 ++++++----- gdb/gnu-v2-abi.c | 11 +++--- gdb/gnu-v3-abi.c | 4 +- gdb/i386-sol2-tdep.c | 4 +- gdb/i386-tdep.c | 2 +- gdb/jv-lang.c | 22 +++++------ gdb/jv-lang.h | 4 +- gdb/jv-typeprint.c | 6 +-- gdb/jv-valprint.c | 6 +-- gdb/linespec.c | 5 +-- gdb/m32c-tdep.c | 4 +- gdb/mdebugread.c | 16 ++++---- gdb/minsyms.c | 4 +- gdb/objc-lang.c | 22 +++++------ gdb/p-exp.y | 2 +- gdb/p-lang.c | 2 +- gdb/p-lang.h | 2 +- gdb/p-typeprint.c | 4 +- gdb/p-valprint.c | 4 +- gdb/printcmd.c | 2 +- gdb/python/py-frame.c | 2 +- gdb/python/py-type.c | 4 +- gdb/solib-frv.c | 6 +-- gdb/sparc-sol2-tdep.c | 4 +- gdb/sparc-tdep.h | 2 +- gdb/stabsread.c | 48 +++++++++++++---------- gdb/stabsread.h | 2 +- gdb/stack.c | 6 +-- gdb/stack.h | 2 +- gdb/symtab.c | 36 +++++++++-------- gdb/symtab.h | 17 ++++---- gdb/tracepoint.c | 3 +- gdb/typeprint.c | 2 +- gdb/utils.c | 2 +- gdb/valarith.c | 2 +- gdb/valops.c | 12 +++--- gdb/value.h | 2 +- gdb/varobj.c | 4 +- gdb/xcoffread.c | 43 ++++++++------------- 64 files changed, 367 insertions(+), 266 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bf6a42868e..5adc58781b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,93 @@ +2012-02-06 Doug Evans + + * gdbtypes.h (struct main_type): Change type of name,tag_name, + and fields.name members from char * to const char *. All uses updated. + (struct cplus_struct_type): Change type of fn_fieldlists.name member + from char * to const char *. All uses updated. + (type_name_no_tag): Update. + (lookup_unsigned_typename, lookup_signed_typename): Update. + * gdbtypes.c (type_name_no_tag): Change result type + from char * to const char *. All callers updated. + (lookup_unsigned_typename, lookup_signed_typename): Change type of + name parameter from char * to const char *. + * symtab.h (struct cplus_specific): Change type of demangled_name + member from char * to const char *. All uses updated. + (struct general_symbol_info): Change type of name and + mangled_lang.demangled_name members from char * to const char *. + All uses updated. + (symbol_get_demangled_name, symbol_natural_name): Update. + (symbol_demangled_name, symbol_search_name): Update. + * symtab.c (symbol_get_demangled_name): Change result type + from char * to const char *. All callers updated. + (symbol_natural_name, symbol_demangled_name): Ditto. + (symbol_search_name): Ditto. + (completion_list_add_name): Change type of symname,sym_text, + text,word parameters from char * to const char *. + (completion_list_objc_symbol): Change type of sym_text, + text,word parameters from char * to const char *. + * ada-lang.c (find_struct_field): Change type of name parameter + from char * to const char *. + (encoded_ordered_before): Similarly for N0,N1 parameters. + (old_renaming_is_invisible): Similarly for function_name parameter. + (ada_type_name): Change result type from char * to const char *. + All callers updated. + * ada-lang.h (ada_type_name): Update. + * buildsym.c (hashname): Change type of name parameter + from char * to const char *. + * buildsym.h (hashname): Update. + * dbxread.c (end_psymtab): Change type of include_list parameter + from char ** to const char **. + * dwarf2read.c (determine_prefix): Change result type + from char * to const char *. All callers updated. + * f-lang.c (find_common_for_function): Change type of name, funcname + parameters from char * to const char *. + * f-lang.c (find_common_for_function): Update. + * f-valprint.c (list_all_visible_commons): Change type of funcname + parameters from char * to const char *. + * gdbarch.sh (static_transform_name): Change type of name parameter + and result from char * to const char *. + * gdbarch.c: Regenerate. + * gdbarch.h: Regenerate. + * i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type + of name parameter from char * to const char *. + * jv-lang.c (java_primitive_type_from_name): Ditto. + (java_demangled_signature_length): Similarly for signature parameter. + (java_demangled_signature_copy): Ditto. + (java_demangle_type_signature): Ditto. + * jv-lang.h (java_primitive_type_from_name): Update. + (java_demangle_type_signature): Update. + * objc-lang.c (specialcmp): Change type of a,b parameters + from char * to const char *. + * p-lang.c (is_pascal_string_type): Change type of arrayname parameter + from char * to const char *. All callers updated. + * p-lang.h (is_pascal_string_type): Update. + * solib-frv.c (find_canonical_descriptor_in_load_object): Change type + of name parameter from char * to const char *. + * sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto. + * utils.c (fprintf_symbol_filtered): Ditto. + * defs.h (fprintf_symbol_filtered): Update. + * sparc-tdep.h (sparc_sol2_static_transform_name): Update. + * stabsread.h (end_psymtab): Update. + * stack.c (find_frame_funname): Change type of funname parameter + from char ** to const char **. + * stack.h (find_frame_funname): Update. + * typeprint.c (type_print): Change type of varstring parameter + from char * to const char *. + * value.h (type_print): Update. + * xcoffread.c (xcoff_start_psymtab): Change type of filename parameter + from char * to const char *. All callers updated. + (xcoff_end_psymtab): Change type of include_list parameter + from char ** to const char **. All callers updated. + (swap_sym): Similarly for name parameter. All callers updated. + * coffread.c (patch_type): Add (char*) cast to xfree parameter. + Use xstrdup. + (process_coff_symbol): Use xstrdup. + * stabsread.c (stabs_method_name_from_physname): Renamed from + update_method_name_from_physname. Change result type from void + to char *. All callers updated. + (read_member_functions): In has_destructor case, store name in objfile + obstack instead of malloc space. In !has_stub case, fix mem leak. + 2012-02-06 Luca Pizzamiglio * configure: Rebuild. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 6ea013c307..49178cfa96 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -223,7 +223,7 @@ static struct value *ada_search_struct_field (char *, struct value *, int, static struct value *ada_value_primitive_field (struct value *, int, int, struct type *); -static int find_struct_field (char *, struct type *, int, +static int find_struct_field (const char *, struct type *, int, struct type **, int *, int *, int *, int *); static struct value *ada_to_fixed_value_create (struct type *, CORE_ADDR, @@ -1370,7 +1370,7 @@ ada_fixup_array_indexes_type (struct type *index_desc_type) /* Fixup each field of INDEX_DESC_TYPE. */ for (i = 0; i < TYPE_NFIELDS (index_desc_type); i++) { - char *name = TYPE_FIELD_NAME (index_desc_type, i); + const char *name = TYPE_FIELD_NAME (index_desc_type, i); struct type *raw_type = ada_check_typedef (ada_find_any_type (name)); if (raw_type) @@ -1962,8 +1962,8 @@ ada_is_unconstrained_packed_array_type (struct type *type) static long decode_packed_array_bitsize (struct type *type) { - char *raw_name; - char *tail; + const char *raw_name; + const char *tail; long bits; /* Access to arrays implemented as fat pointers are encoded as a typedef @@ -2042,9 +2042,9 @@ constrained_packed_array_type (struct type *type, long *elt_bits) static struct type * decode_constrained_packed_array_type (struct type *type) { - char *raw_name = ada_type_name (ada_check_typedef (type)); + const char *raw_name = ada_type_name (ada_check_typedef (type)); char *name; - char *tail; + const char *tail; struct type *shadow_type; long bits; @@ -3407,7 +3407,7 @@ ada_resolve_function (struct ada_symbol_info syms[], such symbols by their trailing number (__N or $N). */ static int -encoded_ordered_before (char *N0, char *N1) +encoded_ordered_before (const char *N0, const char *N1) { if (N1 == NULL) return 0; @@ -4248,8 +4248,8 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1) { struct type *type0 = SYMBOL_TYPE (sym0); struct type *type1 = SYMBOL_TYPE (sym1); - char *name0 = SYMBOL_LINKAGE_NAME (sym0); - char *name1 = SYMBOL_LINKAGE_NAME (sym1); + const char *name0 = SYMBOL_LINKAGE_NAME (sym0); + const char *name1 = SYMBOL_LINKAGE_NAME (sym1); int len0 = strlen (name0); return @@ -4380,7 +4380,7 @@ add_symbols_from_enclosing_procs (struct obstack *obstackp, static int is_nondebugging_type (struct type *type) { - char *name = ada_type_name (type); + const char *name = ada_type_name (type); return (name != NULL && strcmp (name, "") == 0); } @@ -4411,8 +4411,8 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2) suffix). */ for (i = 0; i < TYPE_NFIELDS (type1); i++) { - char *name_1 = TYPE_FIELD_NAME (type1, i); - char *name_2 = TYPE_FIELD_NAME (type2, i); + const char *name_1 = TYPE_FIELD_NAME (type1, i); + const char *name_2 = TYPE_FIELD_NAME (type2, i); int len_1 = strlen (name_1); int len_2 = strlen (name_2); @@ -4647,7 +4647,7 @@ is_package_name (const char *name) not visible from FUNCTION_NAME. */ static int -old_renaming_is_invisible (const struct symbol *sym, char *function_name) +old_renaming_is_invisible (const struct symbol *sym, const char *function_name) { char *scope; @@ -4717,7 +4717,7 @@ remove_irrelevant_renamings (struct ada_symbol_info *syms, int nsyms, const struct block *current_block) { struct symbol *current_function; - char *current_function_name; + const char *current_function_name; int i; int is_new_style_renaming; @@ -5854,7 +5854,7 @@ ada_make_symbol_completion_list (char *text0, char *word) static int ada_is_dispatch_table_ptr_type (struct type *type) { - char *name; + const char *name; if (TYPE_CODE (type) != TYPE_CODE_PTR) return 0; @@ -6367,7 +6367,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno, Returns 1 if found, 0 otherwise. */ static int -find_struct_field (char *name, struct type *type, int offset, +find_struct_field (const char *name, struct type *type, int offset, struct type **field_type_p, int *byte_offset_p, int *bit_offset_p, int *bit_size_p, int *index_p) @@ -6389,7 +6389,7 @@ find_struct_field (char *name, struct type *type, int offset, { int bit_pos = TYPE_FIELD_BITPOS (type, i); int fld_offset = offset + bit_pos / 8; - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); if (t_field_name == NULL) continue; @@ -6466,7 +6466,7 @@ ada_search_struct_field (char *name, struct value *arg, int offset, type = ada_check_typedef (type); for (i = 0; i < TYPE_NFIELDS (type); i += 1) { - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); if (t_field_name == NULL) continue; @@ -6725,7 +6725,7 @@ ada_lookup_struct_elt_type (struct type *type, char *name, int refok, for (i = 0; i < TYPE_NFIELDS (type); i += 1) { - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); struct type *t; int disp; @@ -6764,7 +6764,7 @@ ada_lookup_struct_elt_type (struct type *type, char *name, int refok, NOT wrapped in a struct, since the compiler sometimes generates these for unchecked variant types. Revisit if the compiler changes this practice. */ - char *v_field_name = TYPE_FIELD_NAME (field_type, j); + const char *v_field_name = TYPE_FIELD_NAME (field_type, j); disp = 0; if (v_field_name != NULL && field_name_match (v_field_name, name)) @@ -7030,7 +7030,7 @@ find_old_style_renaming_symbol (const char *name, struct block *block) qualified. This means we need to prepend the function name as well as adding the ``___XR'' suffix to build the name of the associated renaming symbol. */ - char *function_name = SYMBOL_LINKAGE_NAME (function_sym); + const char *function_name = SYMBOL_LINKAGE_NAME (function_sym); /* Function names sometimes contain suffixes used for instance to qualify nested subprograms. When building the XR type name, we need to make sure that this suffix is @@ -7110,7 +7110,7 @@ ada_prefer_type (struct type *type0, struct type *type1) /* The name of TYPE, which is either its TYPE_NAME, or, if that is null, its TYPE_TAG_NAME. Null if TYPE is null. */ -char * +const char * ada_type_name (struct type *type) { if (type == NULL) @@ -7137,7 +7137,7 @@ find_parallel_type_by_descriptive_type (struct type *type, const char *name) result = TYPE_DESCRIPTIVE_TYPE (type); while (result != NULL) { - char *result_name = ada_type_name (result); + const char *result_name = ada_type_name (result); if (result_name == NULL) { @@ -7189,7 +7189,8 @@ ada_find_parallel_type_with_name (struct type *type, const char *name) struct type * ada_find_parallel_type (struct type *type, const char *suffix) { - char *name, *typename = ada_type_name (type); + char *name; + const char *typename = ada_type_name (type); int len; if (typename == NULL) @@ -7895,7 +7896,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, If there is, then it provides the actual size of our type. */ else if (ada_type_name (fixed_record_type) != NULL) { - char *name = ada_type_name (fixed_record_type); + const char *name = ada_type_name (fixed_record_type); char *xvz_name = alloca (strlen (name) + 7 /* "___XVZ\0" */); int xvz_found = 0; LONGEST size; @@ -8090,7 +8091,7 @@ ada_check_typedef (struct type *type) return type; else { - char *name = TYPE_TAG_NAME (type); + const char *name = TYPE_TAG_NAME (type); struct type *type1 = ada_find_any_type (name); if (type1 == NULL) @@ -8870,7 +8871,7 @@ aggregate_assign_from_choices (struct value *container, else { int ind; - char *name; + const char *name; switch (op) { @@ -9879,7 +9880,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, else if (discrete_type_p (type_arg)) { struct type *range_type; - char *name = ada_type_name (type_arg); + const char *name = ada_type_name (type_arg); range_type = NULL; if (name != NULL && TYPE_CODE (type_arg) != TYPE_CODE_ENUM) @@ -10411,7 +10412,7 @@ get_int_var_value (char *name, int *flag) static struct type * to_fixed_range_type (struct type *raw_type, struct value *dval) { - char *name; + const char *name; struct type *base_type; char *subtype_info; @@ -10534,8 +10535,8 @@ ada_is_modular_type (struct type *type) int ada_modulus_from_name (struct type *type, ULONGEST *modulus) { - char *name = ada_type_name (type); - char *suffix; + const char *name = ada_type_name (type); + const char *suffix; int k; LONGEST U; @@ -10781,7 +10782,7 @@ static int is_known_support_routine (struct frame_info *frame) { struct symtab_and_line sal; - char *func_name; + const char *func_name; enum language func_lang; int i; @@ -10884,7 +10885,7 @@ ada_unhandled_exception_name_addr_from_raise (void) while (fi != NULL) { - char *func_name; + const char *func_name; enum language func_lang; find_frame_funname (fi, &func_name, &func_lang, NULL); diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 375fab0cee..2a6cd57d9f 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -322,7 +322,7 @@ extern struct type *ada_template_to_fixed_record_type_1 (struct type *type, extern int ada_name_prefix_len (const char *); -extern char *ada_type_name (struct type *); +extern const char *ada_type_name (struct type *); extern struct type *ada_find_parallel_type (struct type *, const char *suffix); diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 97ab937d1c..5599278daa 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -76,7 +76,7 @@ decoded_type_name (struct type *type) return NULL; else { - char *raw_name = ada_type_name (type); + const char *raw_name = ada_type_name (type); char *s, *q; if (name_buffer == NULL || name_buffer_len <= strlen (raw_name)) @@ -223,9 +223,9 @@ print_dynamic_range_bound (struct type *type, const char *name, int name_len, static void print_range_type (struct type *raw_type, struct ui_file *stream) { - char *name; + const char *name; struct type *base_type; - char *subtype_info; + const char *subtype_info; gdb_assert (raw_type != NULL); name = TYPE_NAME (raw_type); @@ -810,7 +810,7 @@ ada_print_type (struct type *type0, const char *varstring, print_fixed_point_type (type, stream); else { - char *name = ada_type_name (type); + const char *name = ada_type_name (type); if (!ada_is_range_type_name (name)) fprintf_filtered (stream, _("<%d-byte integer>"), diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c index dabdf9ede0..5463f6a3ea 100644 --- a/gdb/arm-wince-tdep.c +++ b/gdb/arm-wince-tdep.c @@ -44,7 +44,7 @@ arm_pe_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST indirect; struct minimal_symbol *indsym; - char *symname; + const char *symname; CORE_ADDR next_pc; /* The format of an ARM DLL trampoline is: diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 31e91b9315..739677f0f3 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1477,7 +1477,7 @@ gen_struct_ref_recursive (struct expression *exp, struct agent_expr *ax, for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--) { - char *this_name = TYPE_FIELD_NAME (type, i); + const char *this_name = TYPE_FIELD_NAME (type, i); if (this_name) { @@ -1625,7 +1625,7 @@ gen_struct_elt_for_reference (struct expression *exp, for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--) { - char *t_field_name = TYPE_FIELD_NAME (t, i); + const char *t_field_name = TYPE_FIELD_NAME (t, i); if (t_field_name && strcmp (t_field_name, fieldname) == 0) { diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 38bde22e20..a7f141eb5d 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -151,7 +151,7 @@ struct symbol * find_symbol_in_list (struct pending *list, char *name, int length) { int j; - char *pp; + const char *pp; while (list != NULL) { @@ -1251,7 +1251,7 @@ pop_context (void) /* Compute a small integer hash code for the given name. */ int -hashname (char *name) +hashname (const char *name) { return (hash(name,strlen(name)) % HASHSIZE); } diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 1604ef51fb..4bc6c7f516 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -279,7 +279,7 @@ extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc); extern void start_symtab (char *name, char *dirname, CORE_ADDR start_addr); -extern int hashname (char *name); +extern int hashname (const char *name); extern void free_pending_blocks (void); diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 6e92fb93ba..9e571eace7 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -87,7 +87,7 @@ classify_type (struct type *elttype, struct gdbarch *gdbarch, that would do the wrong thing. */ while (elttype) { - char *name = TYPE_NAME (elttype); + const char *name = TYPE_NAME (elttype); if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name) { diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index db254dce29..21887c608a 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -142,7 +142,7 @@ static void cp_type_print_derivation_info (struct ui_file *stream, struct type *type) { - char *name; + const char *name; int i; for (i = 0; i < TYPE_N_BASECLASSES (type); i++) @@ -165,8 +165,8 @@ cp_type_print_derivation_info (struct ui_file *stream, /* Print the C++ method arguments ARGS to the file STREAM. */ static void -cp_type_print_method_args (struct type *mtype, char *prefix, - char *varstring, int staticp, +cp_type_print_method_args (struct type *mtype, const char *prefix, + const char *varstring, int staticp, struct ui_file *stream) { struct field *args = TYPE_FIELDS (mtype); @@ -238,7 +238,7 @@ c_type_print_varspec_prefix (struct type *type, int show, int passed_a_ptr, int need_post_space) { - char *name; + const char *name; if (type == 0) return; @@ -471,7 +471,7 @@ is_type_conversion_operator (struct type *type, int i, int j) by their name is pretty terrible. But I don't think our present data structure gives us any other way to tell. If you know of some other way, feel free to rewrite this function. */ - char *name = TYPE_FN_FIELDLIST_NAME (type, i); + const char *name = TYPE_FN_FIELDLIST_NAME (type, i); if (strncmp (name, "operator", 8) != 0) return 0; @@ -990,8 +990,8 @@ c_type_print_base (struct type *type, struct ui_file *stream, { struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); - char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); - char *name = type_name_no_tag (type); + const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); + const char *name = type_name_no_tag (type); int is_constructor = name && strcmp (method_name, name) == 0; diff --git a/gdb/coffread.c b/gdb/coffread.c index c727228b8f..30bf3f73ab 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1455,10 +1455,11 @@ patch_type (struct type *type, struct type *real_type) if (TYPE_NAME (real_target)) { + /* The previous copy of TYPE_NAME is allocated by + process_coff_symbol. */ if (TYPE_NAME (target)) - xfree (TYPE_NAME (target)); - TYPE_NAME (target) = concat (TYPE_NAME (real_target), - (char *) NULL); + xfree ((char*) TYPE_NAME (target)); + TYPE_NAME (target) = xstrdup (TYPE_NAME (real_target)); } } @@ -1486,7 +1487,7 @@ patch_opaque_types (struct symtab *s) && TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR && TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0) { - char *name = SYMBOL_LINKAGE_NAME (real_sym); + const char *name = SYMBOL_LINKAGE_NAME (real_sym); int hash = hashname (name); struct symbol *sym, *prev; @@ -1675,7 +1676,7 @@ process_coff_symbol (struct coff_symbol *cs, } else TYPE_NAME (SYMBOL_TYPE (sym)) = - concat (SYMBOL_LINKAGE_NAME (sym), (char *) NULL); + xstrdup (SYMBOL_LINKAGE_NAME (sym)); } /* Keep track of any type which points to empty structured diff --git a/gdb/completer.c b/gdb/completer.c index 48a4e463a7..5939d08124 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -386,7 +386,7 @@ add_struct_fields (struct type *type, int *nextp, char **output, { int i; int computed_type_name = 0; - char *type_name = NULL; + const char *type_name = NULL; CHECK_TYPEDEF (type); for (i = 0; i < TYPE_NFIELDS (type); ++i) @@ -416,7 +416,7 @@ add_struct_fields (struct type *type, int *nextp, char **output, for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i) { - char *name = TYPE_FN_FIELDLIST_NAME (type, i); + const char *name = TYPE_FN_FIELDLIST_NAME (type, i); if (name && ! strncmp (name, fieldname, namelen)) { diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 4902e50e3c..0620aa7dbf 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1205,7 +1205,7 @@ make_symbol_overload_list_adl_namespace (struct type *type, const char *func_name) { char *namespace; - char *type_name; + const char *type_name; int i, prefix_len; while (TYPE_CODE (type) == TYPE_CODE_PTR diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 7df9adfba4..169700660f 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -98,7 +98,7 @@ const char vtbl_ptr_name[] = "__vtbl_ptr_type"; int cp_is_vtbl_ptr_type (struct type *type) { - char *typename = type_name_no_tag (type); + const char *typename = type_name_no_tag (type); return (typename != NULL && !strcmp (typename, vtbl_ptr_name)); } @@ -495,7 +495,7 @@ cp_print_value (struct type *type, struct type *real_type, int boffset = 0; int skip; struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); - char *basename = TYPE_NAME (baseclass); + const char *basename = TYPE_NAME (baseclass); const gdb_byte *base_valaddr = NULL; const struct value *base_val = NULL; volatile struct gdb_exception ex; @@ -794,7 +794,7 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type, if (domain != NULL) { - char *name; + const char *name; fputs_filtered (prefix, stream); name = type_name_no_tag (domain); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index adf8315759..1725112971 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1210,7 +1210,7 @@ read_dbx_symtab (struct objfile *objfile) struct partial_symtab *pst; /* List of current psymtab's include files. */ - char **psymtab_include_list; + const char **psymtab_include_list; int includes_allocated; int includes_used; @@ -1232,8 +1232,8 @@ read_dbx_symtab (struct objfile *objfile) includes_allocated = 30; includes_used = 0; - psymtab_include_list = (char **) alloca (includes_allocated * - sizeof (char *)); + psymtab_include_list = (const char **) alloca (includes_allocated * + sizeof (const char *)); dependencies_allocated = 30; dependencies_used = 0; @@ -1635,12 +1635,12 @@ read_dbx_symtab (struct objfile *objfile) psymtab_include_list[includes_used++] = namestring; if (includes_used >= includes_allocated) { - char **orig = psymtab_include_list; + const char **orig = psymtab_include_list; - psymtab_include_list = (char **) - alloca ((includes_allocated *= 2) * sizeof (char *)); + psymtab_include_list = (const char **) + alloca ((includes_allocated *= 2) * sizeof (const char *)); memcpy (psymtab_include_list, orig, - includes_used * sizeof (char *)); + includes_used * sizeof (const char *)); } continue; } @@ -2226,7 +2226,8 @@ start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow, FIXME: List variables and peculiarities of same. */ struct partial_symtab * -end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes, +end_psymtab (struct partial_symtab *pst, + const char **include_list, int num_includes, int capping_symbol_offset, CORE_ADDR capping_text, struct partial_symtab **dependency_list, int number_dependencies, int textlow_not_set) diff --git a/gdb/defs.h b/gdb/defs.h index 83a716a983..a97487a480 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -582,7 +582,7 @@ extern CORE_ADDR string_to_core_addr (const char *my_string); extern char *hex_string (LONGEST); extern char *hex_string_custom (LONGEST, int); -extern void fprintf_symbol_filtered (struct ui_file *, char *, +extern void fprintf_symbol_filtered (struct ui_file *, const char *, enum language, int); extern void perror_with_name (const char *) ATTRIBUTE_NORETURN; diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index fc0d2e24b9..0576defd67 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1029,7 +1029,7 @@ static struct type *read_type_die (struct die_info *, struct dwarf2_cu *); static struct type *read_type_die_1 (struct die_info *, struct dwarf2_cu *); -static char *determine_prefix (struct die_info *die, struct dwarf2_cu *); +static const char *determine_prefix (struct die_info *die, struct dwarf2_cu *); static char *typename_concat (struct obstack *obs, const char *prefix, const char *suffix, int physname, @@ -5013,7 +5013,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu, if (die_needs_namespace (die, cu)) { long length; - char *prefix; + const char *prefix; struct ui_file *buf; prefix = determine_prefix (die, cu); @@ -7729,7 +7729,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) i >= TYPE_N_BASECLASSES (t); --i) { - char *fieldname = TYPE_FIELD_NAME (t, i); + const char *fieldname = TYPE_FIELD_NAME (t, i); if (is_vtable_name (fieldname, cu)) { @@ -12479,7 +12479,7 @@ anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu) then determine_prefix on foo's die will return "N::C". */ -static char * +static const char * determine_prefix (struct die_info *die, struct dwarf2_cu *cu) { struct die_info *parent, *spec_die; diff --git a/gdb/eval.c b/gdb/eval.c index 0244f7a039..9913a72b0e 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -335,7 +335,8 @@ evaluate_struct_tuple (struct value *struct_val, for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type); fieldno++) { - char *field_name = TYPE_FIELD_NAME (struct_type, fieldno); + const char *field_name = + TYPE_FIELD_NAME (struct_type, fieldno); if (field_name != NULL && strcmp (field_name, label) == 0) { @@ -348,7 +349,8 @@ evaluate_struct_tuple (struct value *struct_val, for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type); fieldno++) { - char *field_name = TYPE_FIELD_NAME (struct_type, fieldno); + const char *field_name = + TYPE_FIELD_NAME (struct_type, fieldno); field_type = TYPE_FIELD_TYPE (struct_type, fieldno); if ((field_name == 0 || *field_name == '\0') diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 5f1540299a..7f9afb68c4 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -572,7 +572,7 @@ find_first_common_named (char *name) that belongs to function funcname. */ SAVED_F77_COMMON_PTR -find_common_for_function (char *name, char *funcname) +find_common_for_function (const char *name, const char *funcname) { SAVED_F77_COMMON_PTR tmp; diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 3a46ebf67a..4e5563d3b8 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -75,7 +75,8 @@ extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */ extern SAVED_F77_COMMON_PTR tail_common_list; /* Ptr to last saved COMMON */ extern SAVED_F77_COMMON_PTR current_common; /* Ptr to current COMMON */ -extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *); +extern SAVED_F77_COMMON_PTR find_common_for_function (const char *, + const char *); #define UNINITIALIZED_SECNUM -1 #define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM) diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 87b2ed1a1a..17f747f5cd 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -41,7 +41,7 @@ static int there_is_a_visible_common_named (char *); extern void _initialize_f_valprint (void); static void info_common_command (char *, int); -static void list_all_visible_commons (char *); +static void list_all_visible_commons (const char *); static void f77_create_arrayprint_offset_tbl (struct type *, struct ui_file *); static void f77_get_dynamic_length_of_aggregate (struct type *); @@ -518,7 +518,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, } static void -list_all_visible_commons (char *funname) +list_all_visible_commons (const char *funname) { SAVED_F77_COMMON_PTR tmp; @@ -545,7 +545,7 @@ info_common_command (char *comname, int from_tty) SAVED_F77_COMMON_PTR the_common; COMMON_ENTRY_PTR entry; struct frame_info *fi; - char *funname = 0; + const char *funname = 0; struct symbol *func; /* We have been told to display the contents of F77 COMMON diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 64accebcd5..c079932199 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3646,8 +3646,8 @@ gdbarch_static_transform_name_p (struct gdbarch *gdbarch) return gdbarch->static_transform_name != NULL; } -char * -gdbarch_static_transform_name (struct gdbarch *gdbarch, char *name) +const char * +gdbarch_static_transform_name (struct gdbarch *gdbarch, const char *name) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->static_transform_name != NULL); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 12fe2f0810..84e6ff8de1 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -909,8 +909,8 @@ extern void set_gdbarch_core_read_description (struct gdbarch *gdbarch, gdbarch_ extern int gdbarch_static_transform_name_p (struct gdbarch *gdbarch); -typedef char * (gdbarch_static_transform_name_ftype) (char *name); -extern char * gdbarch_static_transform_name (struct gdbarch *gdbarch, char *name); +typedef const char * (gdbarch_static_transform_name_ftype) (const char *name); +extern const char * gdbarch_static_transform_name (struct gdbarch *gdbarch, const char *name); extern void set_gdbarch_static_transform_name (struct gdbarch *gdbarch, gdbarch_static_transform_name_ftype *static_transform_name); /* Set if the address in N_SO or N_FUN stabs may be zero. */ diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index ee15f290f2..5831172bfa 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -758,7 +758,7 @@ F:void:overlay_update:struct obj_section *osect:osect M:const struct target_desc *:core_read_description:struct target_ops *target, bfd *abfd:target, abfd # Handle special encoding of static variables in stabs debug info. -F:char *:static_transform_name:char *name:name +F:const char *:static_transform_name:const char *name:name # Set if the address in N_SO or N_FUN stabs may be zero. v:int:sofun_address_maybe_missing:::0:0::0 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b09c1ec3bf..b6e8b4c235 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1092,7 +1092,7 @@ smash_to_method_type (struct type *type, struct type *domain, /* Return a typename for a struct/union/enum type without "struct ", "union ", or "enum ". If the type has a NULL name, return NULL. */ -char * +const char * type_name_no_tag (const struct type *type) { if (TYPE_TAG_NAME (type) != NULL) @@ -1164,7 +1164,7 @@ lookup_typename (const struct language_defn *language, struct type * lookup_unsigned_typename (const struct language_defn *language, - struct gdbarch *gdbarch, char *name) + struct gdbarch *gdbarch, const char *name) { char *uns = alloca (strlen (name) + 10); @@ -1175,7 +1175,7 @@ lookup_unsigned_typename (const struct language_defn *language, struct type * lookup_signed_typename (const struct language_defn *language, - struct gdbarch *gdbarch, char *name) + struct gdbarch *gdbarch, const char *name) { struct type *t; char *uns = alloca (strlen (name) + 8); @@ -1338,7 +1338,7 @@ lookup_struct_elt_type (struct type *type, char *name, int noerr) for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) { - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) { @@ -1480,7 +1480,7 @@ check_typedef (struct type *type) { if (!TYPE_TARGET_TYPE (type)) { - char *name; + const char *name; struct symbol *sym; /* It is dangerous to call lookup_symbol if we are currently @@ -1543,7 +1543,7 @@ check_typedef (struct type *type) && opaque_type_resolution && !currently_reading_symtab) { - char *name = type_name_no_tag (type); + const char *name = type_name_no_tag (type); struct type *newtype; if (name == NULL) @@ -1577,7 +1577,7 @@ check_typedef (struct type *type) types. */ else if (TYPE_STUB (type) && !currently_reading_symtab) { - char *name = type_name_no_tag (type); + const char *name = type_name_no_tag (type); /* FIXME: shouldn't we separately check the TYPE_NAME and the TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN as appropriate? (this code was written before TYPE_NAME and diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 2070f0006d..cddd2d00ac 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -436,9 +436,11 @@ struct main_type /* Name of this type, or NULL if none. This is used for printing only, except by poorly designed C++ code. - For looking up a name, look for a symbol in the VAR_DOMAIN. */ + For looking up a name, look for a symbol in the VAR_DOMAIN. + This is generally allocated in the objfile's obstack. + However coffread.c uses malloc. */ - char *name; + const char *name; /* Tag name for this type, or NULL if none. This means that the name of the type consists of a keyword followed by the tag name. @@ -451,7 +453,7 @@ struct main_type One more legitimate use is that if TYPE_FLAG_STUB is set, this is the name to use to look for definitions in other files. */ - char *tag_name; + const char *tag_name; /* Every type is now associated with a particular objfile, and the type is allocated on the objfile_obstack for that objfile. One problem @@ -556,7 +558,7 @@ struct main_type NULL for range bounds, array domains, and member function arguments. */ - char *name; + const char *name; } *fields; /* Union member used for range types. */ @@ -761,9 +763,11 @@ struct cplus_struct_type struct fn_fieldlist { - /* The overloaded name. */ + /* The overloaded name. + This is generally allocated in the objfile's obstack. + However stabsread.c sometimes uses malloc. */ - char *name; + const char *name; /* The number of methods with this name. */ @@ -1461,7 +1465,7 @@ extern void smash_to_methodptr_type (struct type *, struct type *); extern struct type *allocate_stub_method (struct type *); -extern char *type_name_no_tag (const struct type *); +extern const char *type_name_no_tag (const struct type *); extern const char *type_name_no_tag_or_error (struct type *type); @@ -1489,10 +1493,10 @@ extern struct type *lookup_string_range_type (struct type *, int, int); extern struct type *create_set_type (struct type *, struct type *); extern struct type *lookup_unsigned_typename (const struct language_defn *, - struct gdbarch *,char *); + struct gdbarch *, const char *); extern struct type *lookup_signed_typename (const struct language_defn *, - struct gdbarch *,char *); + struct gdbarch *, const char *); extern struct type *check_typedef (struct type *); diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index de6f80aa48..e635e8f1a8 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -194,6 +194,7 @@ gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc) CORE_ADDR vtbl; struct minimal_symbol *minsym; char *demangled_name, *p; + const char *linkage_name; struct type *btype; struct type *known_type_vptr_basetype; int known_type_vptr_fieldno; @@ -246,12 +247,12 @@ gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc) /* Try to find a symbol that is the vtable. */ minsym=lookup_minimal_symbol_by_pc(vtbl); if (minsym==NULL - || (demangled_name=SYMBOL_LINKAGE_NAME (minsym))==NULL - || !is_vtable_name (demangled_name)) + || (linkage_name=SYMBOL_LINKAGE_NAME (minsym))==NULL + || !is_vtable_name (linkage_name)) return NULL; /* If we just skip the prefix, we get screwed by namespaces. */ - demangled_name=cplus_demangle(demangled_name,DMGL_PARAMS|DMGL_ANSI); + demangled_name=cplus_demangle(linkage_name,DMGL_PARAMS|DMGL_ANSI); p = strchr (demangled_name, ' '); if (p) *p = '\0'; @@ -297,8 +298,8 @@ static int vb_match (struct type *type, int index, struct type *basetype) { struct type *fieldtype; - char *name = TYPE_FIELD_NAME (type, index); - char *field_class_name = NULL; + const char *name = TYPE_FIELD_NAME (type, index); + const char *field_class_name = NULL; if (*name != '_') return 0; diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index a461bb0e67..f015af63a9 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -735,7 +735,7 @@ gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc) struct gdbarch *gdbarch = get_frame_arch (frame); struct minimal_symbol *thunk_sym, *fn_sym; struct obj_section *section; - char *thunk_name, *fn_name; + const char *thunk_name, *fn_name; real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, stop_pc); if (real_stop_pc == 0) @@ -804,7 +804,7 @@ gnuv3_pass_by_reference (struct type *type) fieldelem++) { struct fn_field *fn = TYPE_FN_FIELDLIST1 (type, fieldnum); - char *name = TYPE_FN_FIELDLIST_NAME (type, fieldnum); + const char *name = TYPE_FN_FIELDLIST_NAME (type, fieldnum); struct type *fieldtype = TYPE_FN_FIELD_TYPE (fn, fieldelem); /* If this function is marked as artificial, it is compiler-generated, diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c index e0964de7d2..5273f52a29 100644 --- a/gdb/i386-sol2-tdep.c +++ b/gdb/i386-sol2-tdep.c @@ -79,8 +79,8 @@ i386_sol2_mcontext_addr (struct frame_info *this_frame) /* SunPRO encodes the static variables. This is not related to C++ mangling, it is done for C too. */ -static char * -i386_sol2_static_transform_name (char *name) +static const char * +i386_sol2_static_transform_name (const char *name) { char *p; if (name[0] == '.') diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index cde14e5418..56e375e298 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3273,7 +3273,7 @@ i386_pe_skip_trampoline_code (struct frame_info *frame, read_memory_unsigned_integer (pc + 2, 4, byte_order); struct minimal_symbol *indsym = indirect ? lookup_minimal_symbol_by_pc (indirect) : 0; - char *symname = indsym ? SYMBOL_LINKAGE_NAME (indsym) : 0; + const char *symname = indsym ? SYMBOL_LINKAGE_NAME (indsym) : 0; if (symname) { diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index e6fcaee262..dc50b40540 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -45,8 +45,8 @@ extern void _initialize_java_language (void); -static int java_demangled_signature_length (char *); -static void java_demangled_signature_copy (char *, char *); +static int java_demangled_signature_length (const char *); +static void java_demangled_signature_copy (char *, const char *); static struct symtab *get_java_class_symtab (struct gdbarch *gdbarch); static char *get_java_utf8_name (struct obstack *obstack, struct value *name); @@ -341,8 +341,8 @@ java_link_class_type (struct gdbarch *gdbarch, struct type *type, struct value *clas) { struct value *temp; - char *unqualified_name; - char *name = TYPE_TAG_NAME (type); + const char *unqualified_name; + const char *name = TYPE_TAG_NAME (type); int ninterfaces, nfields, nmethods; int type_is_object = 0; struct fn_field *fn_fields; @@ -511,7 +511,7 @@ java_link_class_type (struct gdbarch *gdbarch, methods = NULL; for (i = 0; i < nmethods; i++) { - char *mname; + const char *mname; int k; if (methods == NULL) @@ -617,7 +617,7 @@ is_object_type (struct type *type) if (TYPE_CODE (type) == TYPE_CODE_PTR) { struct type *ttype = check_typedef (TYPE_TARGET_TYPE (type)); - char *name; + const char *name; if (TYPE_CODE (ttype) != TYPE_CODE_STRUCT) return 0; while (TYPE_N_BASECLASSES (ttype) > 0) @@ -667,7 +667,7 @@ java_primitive_type (struct gdbarch *gdbarch, int signature) struct type * java_primitive_type_from_name (struct gdbarch *gdbarch, - char *name, int namelen) + const char *name, int namelen) { const struct builtin_java_type *builtin = builtin_java_type (gdbarch); @@ -742,7 +742,7 @@ java_primitive_type_name (int signature) signature string SIGNATURE. */ static int -java_demangled_signature_length (char *signature) +java_demangled_signature_length (const char *signature) { int array = 0; @@ -762,7 +762,7 @@ java_demangled_signature_length (char *signature) RESULT. */ static void -java_demangled_signature_copy (char *result, char *signature) +java_demangled_signature_copy (char *result, const char *signature) { int array = 0; char *ptr; @@ -805,7 +805,7 @@ java_demangled_signature_copy (char *result, char *signature) as a freshly allocated copy. */ char * -java_demangle_type_signature (char *signature) +java_demangle_type_signature (const char *signature) { int length = java_demangled_signature_length (signature); char *result = xmalloc (length + 1); @@ -905,7 +905,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp, { int pc = *pos; int i; - char *name; + const char *name; enum exp_opcode op = exp->elts[*pos].opcode; struct value *arg1; struct value *arg2; diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h index 4344706ef4..d0610961d2 100644 --- a/gdb/jv-lang.h +++ b/gdb/jv-lang.h @@ -57,7 +57,7 @@ extern struct type *type_from_class (struct gdbarch *, struct value *); extern struct type *java_primitive_type (struct gdbarch *, int signature); extern struct type *java_primitive_type_from_name (struct gdbarch *, - char *, int); + const char *, int); extern struct type *java_array_type (struct type *, int); @@ -72,6 +72,6 @@ extern int is_object_type (struct type *); extern void java_print_type (struct type *, const char *, struct ui_file *, int, int); -extern char *java_demangle_type_signature (char *); +extern char *java_demangle_type_signature (const char *); #endif diff --git a/gdb/jv-typeprint.c b/gdb/jv-typeprint.c index c48e736c24..cc3bb158e3 100644 --- a/gdb/jv-typeprint.c +++ b/gdb/jv-typeprint.c @@ -39,7 +39,7 @@ static void java_type_print_base (struct type * type, static void java_type_print_derivation_info (struct ui_file *stream, struct type *type) { - char *name; + const char *name; int i; int n_bases; int prev; @@ -208,8 +208,8 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show, { struct fn_field *f; int j; - char *method_name; - char *name; + const char *method_name; + const char *name; int is_constructor; int n_overloads; diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index 2aea0e1aa0..d430ba090a 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -42,7 +42,7 @@ java_value_print (struct value *val, struct ui_file *stream, struct type *type; CORE_ADDR address; int i; - char *name; + const char *name; struct value_print_options opts; type = value_type (val); @@ -283,7 +283,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, { int boffset; struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); - char *basename = TYPE_NAME (baseclass); + const char *basename = TYPE_NAME (baseclass); const gdb_byte *base_valaddr; if (BASETYPE_VIA_VIRTUAL (type, i)) @@ -325,7 +325,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr, /* If requested, skip printing of static fields. */ if (field_is_static (&TYPE_FIELD (type, i))) { - char *name = TYPE_FIELD_NAME (type, i); + const char *name = TYPE_FIELD_NAME (type, i); if (!options->static_field_print) continue; diff --git a/gdb/linespec.c b/gdb/linespec.c index 4e427500a8..da88d1791b 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -435,8 +435,7 @@ find_methods (struct type *t, const char *name, { int i1 = 0; int ibase; - char *class_name = type_name_no_tag (t); - char *canon; + const char *class_name = type_name_no_tag (t); /* Ignore this class if it doesn't have a name. This is ugly, but unless we figure out how to get the physname without the name of @@ -456,7 +455,7 @@ find_methods (struct type *t, const char *name, method_counter >= 0; --method_counter) { - char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter); + const char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter); char dem_opname[64]; if (strncmp (method_name, "__", 2) == 0 || diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 0a006ca51c..1211624e5e 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -2452,7 +2452,7 @@ m32c_m16c_address_to_pointer (struct gdbarch *gdbarch, if (target_code == TYPE_CODE_FUNC || target_code == TYPE_CODE_METHOD) { - char *func_name; + const char *func_name; char *tramp_name; struct minimal_symbol *tramp_msym; @@ -2539,7 +2539,7 @@ m32c_m16c_pointer_to_address (struct gdbarch *gdbarch, if (ptr_msym) { - char *ptr_msym_name = SYMBOL_LINKAGE_NAME (ptr_msym); + const char *ptr_msym_name = SYMBOL_LINKAGE_NAME (ptr_msym); int len = strlen (ptr_msym_name); if (len > 4 diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index e6d3b8c739..299e94c251 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -2359,7 +2359,7 @@ parse_partial_symbols (struct objfile *objfile) int past_first_source_file = 0; /* List of current psymtab's include files. */ - char **psymtab_include_list; + const char **psymtab_include_list; int includes_allocated; int includes_used; EXTR *extern_tab; @@ -2389,8 +2389,8 @@ parse_partial_symbols (struct objfile *objfile) includes_allocated = 30; includes_used = 0; - psymtab_include_list = (char **) alloca (includes_allocated * - sizeof (char *)); + psymtab_include_list = (const char **) alloca (includes_allocated * + sizeof (const char *)); next_symbol_text_func = mdebug_next_symbol_text; dependencies_allocated = 30; @@ -2754,7 +2754,7 @@ parse_partial_symbols (struct objfile *objfile) for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++) { int type_code; - char *namestring; + const char *namestring; (*swap_sym_in) (cur_bfd, (((char *) debug_info->external_sym) @@ -3090,13 +3090,13 @@ parse_partial_symbols (struct objfile *objfile) psymtab_include_list[includes_used++] = namestring; if (includes_used >= includes_allocated) { - char **orig = psymtab_include_list; + const char **orig = psymtab_include_list; - psymtab_include_list = (char **) + psymtab_include_list = (const char **) alloca ((includes_allocated *= 2) * - sizeof (char *)); + sizeof (const char *)); memcpy (psymtab_include_list, orig, - includes_used * sizeof (char *)); + includes_used * sizeof (const char *)); } continue; } diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 2e7777b449..d762b2dc63 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -988,8 +988,8 @@ compare_minimal_symbols (const void *fn1p, const void *fn2p) else /* addrs are equal: sort by name */ { - char *name1 = SYMBOL_LINKAGE_NAME (fn1); - char *name2 = SYMBOL_LINKAGE_NAME (fn2); + const char *name1 = SYMBOL_LINKAGE_NAME (fn1); + const char *name2 = SYMBOL_LINKAGE_NAME (fn2); if (name1 && name2) /* both have names */ return strcmp (name1, name2); diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 94951fe470..c45f406812 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -636,14 +636,14 @@ end_msglist(void) } /* - * Function: specialcmp (char *a, char *b) + * Function: specialcmp (const char *a, const char *b) * * Special strcmp: treats ']' and ' ' as end-of-string. * Used for qsorting lists of objc methods (either by class or selector). */ static int -specialcmp (char *a, char *b) +specialcmp (const char *a, const char *b) { while (*a && *a != ' ' && *a != ']' && *b && *b != ' ' && *b != ']') { @@ -668,7 +668,7 @@ specialcmp (char *a, char *b) static int compare_selectors (const void *a, const void *b) { - char *aname, *bname; + const char *aname, *bname; aname = SYMBOL_PRINT_NAME (*(struct symbol **) a); bname = SYMBOL_PRINT_NAME (*(struct symbol **) b); @@ -697,7 +697,7 @@ selectors_info (char *regexp, int from_tty) { struct objfile *objfile; struct minimal_symbol *msymbol; - char *name; + const char *name; char *val; int matches = 0; int maxlen = 0; @@ -762,8 +762,8 @@ selectors_info (char *regexp, int from_tty) } if (regexp == NULL || re_exec(++name) != 0) { - char *mystart = name; - char *myend = (char *) strchr (mystart, ']'); + const char *mystart = name; + const char *myend = strchr (mystart, ']'); if (myend && (myend - mystart > maxlen)) maxlen = myend - mystart; /* Get longest selector. */ @@ -834,7 +834,7 @@ selectors_info (char *regexp, int from_tty) static int compare_classes (const void *a, const void *b) { - char *aname, *bname; + const char *aname, *bname; aname = SYMBOL_PRINT_NAME (*(struct symbol **) a); bname = SYMBOL_PRINT_NAME (*(struct symbol **) b); @@ -859,7 +859,7 @@ classes_info (char *regexp, int from_tty) { struct objfile *objfile; struct minimal_symbol *msymbol; - char *name; + const char *name; char *val; int matches = 0; int maxlen = 0; @@ -901,8 +901,8 @@ classes_info (char *regexp, int from_tty) if (regexp == NULL || re_exec(name+2) != 0) { /* Compute length of classname part. */ - char *mystart = name + 2; - char *myend = (char *) strchr(mystart, ' '); + const char *mystart = name + 2; + const char *myend = strchr (mystart, ' '); if (myend && (myend - mystart > maxlen)) maxlen = myend - mystart; @@ -1119,7 +1119,7 @@ find_methods (char type, const char *class, const char *category, { struct objfile *objfile = NULL; - char *symname = NULL; + const char *symname = NULL; char ntype = '\0'; char *nclass = NULL; diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 4be3e6e432..3b7984ecf3 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -338,7 +338,7 @@ exp : field_exp COMPLETE exp : exp '[' /* We need to save the current_type value. */ - { char *arrayname; + { const char *arrayname; int arrayfieldindex; arrayfieldindex = is_pascal_string_type ( current_type, NULL, NULL, diff --git a/gdb/p-lang.c b/gdb/p-lang.c index b634b9994a..6fe19c4e5b 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -99,7 +99,7 @@ int is_pascal_string_type (struct type *type,int *length_pos, int *length_size, int *string_pos, struct type **char_type, - char **arrayname) + const char **arrayname) { if (type != NULL && TYPE_CODE (type) == TYPE_CODE_STRUCT) { diff --git a/gdb/p-lang.h b/gdb/p-lang.h index 308b7b50dd..180c5448c4 100644 --- a/gdb/p-lang.h +++ b/gdb/p-lang.h @@ -50,7 +50,7 @@ extern void pascal_type_print_method_args (const char *, const char *, extern int is_pascal_string_type (struct type *, int *, int *, int *, - struct type **, char **); + struct type **, const char **); extern void pascal_printchar (int, struct type *, struct ui_file *); diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 7bcacdf161..ab82d90039 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -131,7 +131,7 @@ pascal_print_typedef (struct type *type, struct symbol *new_symbol, static void pascal_type_print_derivation_info (struct ui_file *stream, struct type *type) { - char *name; + const char *name; int i; for (i = 0; i < TYPE_N_BASECLASSES (type); i++) @@ -630,7 +630,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, { 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); + const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); /* this is GNU C++ specific how can we know constructor/destructor? diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index c5bef8a0ff..39eff10cca 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -649,7 +649,7 @@ const char pascal_vtbl_ptr_name[] = int pascal_object_is_vtbl_ptr_type (struct type *type) { - char *typename = type_name_no_tag (type); + const char *typename = type_name_no_tag (type); return (typename != NULL && strcmp (typename, pascal_vtbl_ptr_name) == 0); @@ -912,7 +912,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr, { int boffset = 0; struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); - char *basename = type_name_no_tag (baseclass); + const char *basename = type_name_no_tag (baseclass); const gdb_byte *base_valaddr = NULL; int thisoffset; volatile struct gdb_exception ex; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index bee8a85090..d441dfe524 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -638,7 +638,7 @@ build_address_symbolic (struct gdbarch *gdbarch, struct symbol *symbol; CORE_ADDR name_location = 0; struct obj_section *section = NULL; - char *name_temp = ""; + const char *name_temp = ""; /* Let's say it is mapped (not unmapped). */ *unmapped = 0; diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index a8ce5980a8..12cedc3ff3 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -124,7 +124,7 @@ static PyObject * frapy_name (PyObject *self, PyObject *args) { struct frame_info *frame; - char *name; + const char *name; enum language lang; PyObject *result; volatile struct gdb_exception except; diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index dadb0375a9..70ed5d6e38 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -1271,7 +1271,7 @@ typy_getitem (PyObject *self, PyObject *key) for (i = 0; i < TYPE_NFIELDS (type); i++) { - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); if (t_field_name && (strcmp_iw (t_field_name, field) == 0)) { @@ -1332,7 +1332,7 @@ typy_has_key (PyObject *self, PyObject *args) for (i = 0; i < TYPE_NFIELDS (type); i++) { - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); if (t_field_name && (strcmp_iw (t_field_name, field) == 0)) Py_RETURN_TRUE; diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index f29822e5b1..ce4943c897 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -961,7 +961,7 @@ frv_fdpic_find_global_pointer (CORE_ADDR addr) /* Forward declarations for frv_fdpic_find_canonical_descriptor(). */ static CORE_ADDR find_canonical_descriptor_in_load_object - (CORE_ADDR, CORE_ADDR, char *, bfd *, struct lm_info *); + (CORE_ADDR, CORE_ADDR, const char *, bfd *, struct lm_info *); /* Given a function entry point, attempt to find the canonical descriptor associated with that entry point. Return 0 if no canonical descriptor @@ -970,7 +970,7 @@ static CORE_ADDR find_canonical_descriptor_in_load_object CORE_ADDR frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point) { - char *name; + const char *name; CORE_ADDR addr; CORE_ADDR got_value; struct int_elf32_fdpic_loadmap *ldm = 0; @@ -1019,7 +1019,7 @@ frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point) static CORE_ADDR find_canonical_descriptor_in_load_object - (CORE_ADDR entry_point, CORE_ADDR got_value, char *name, bfd *abfd, + (CORE_ADDR entry_point, CORE_ADDR got_value, const char *name, bfd *abfd, struct lm_info *lm) { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c index aa3543f9e5..d2fc4d6512 100644 --- a/gdb/sparc-sol2-tdep.c +++ b/gdb/sparc-sol2-tdep.c @@ -173,8 +173,8 @@ static const struct frame_unwind sparc32_sol2_sigtramp_frame_unwind = /* Unglobalize NAME. */ -char * -sparc_sol2_static_transform_name (char *name) +const const char * +sparc_sol2_static_transform_name (const char *name) { /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO) convert file static variables into global values, a diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h index 67c2a3e8fd..db949945e6 100644 --- a/gdb/sparc-tdep.h +++ b/gdb/sparc-tdep.h @@ -217,7 +217,7 @@ extern const struct sparc_gregset sparc32_sol2_gregset; extern int sparc_sol2_pc_in_sigtramp (CORE_ADDR pc, const char *name); -extern char *sparc_sol2_static_transform_name (char *name); +extern const char *sparc_sol2_static_transform_name (const char *name); extern void sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index e3811dd7c9..afcfe0676f 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1173,7 +1173,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, NULL, objfile); if (msym != NULL) { - char *new_name = gdbarch_static_transform_name + const char *new_name = gdbarch_static_transform_name (gdbarch, SYMBOL_LINKAGE_NAME (sym)); SYMBOL_SET_LINKAGE_NAME (sym, new_name); @@ -1367,7 +1367,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, NULL, objfile); if (msym != NULL) { - char *new_name = gdbarch_static_transform_name + const char *new_name = gdbarch_static_transform_name (gdbarch, SYMBOL_LINKAGE_NAME (sym)); SYMBOL_SET_LINKAGE_NAME (sym, new_name); @@ -2232,10 +2232,11 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) /* This page contains subroutines of read_type. */ -/* Replace *OLD_NAME with the method name portion of PHYSNAME. */ +/* Wrapper around method_name_from_physname to flag a complaint + if there is an error. */ -static void -update_method_name_from_physname (char **old_name, const char *physname) +static char * +stabs_method_name_from_physname (const char *physname) { char *method_name; @@ -2245,16 +2246,10 @@ update_method_name_from_physname (char **old_name, const char *physname) { complaint (&symfile_complaints, _("Method has bad physname %s\n"), physname); - return; + return NULL; } - if (strcmp (*old_name, method_name) != 0) - { - xfree (*old_name); - *old_name = method_name; - } - else - xfree (method_name); + return method_name; } /* Read member function stabs info for C++ classes. The form of each member @@ -2687,14 +2682,24 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type, - in -gstabs instead of -gstabs+ - or for static methods, which are output as a function type instead of a method type. */ + char *new_method_name = + stabs_method_name_from_physname (sublist->fn_field.physname); - update_method_name_from_physname (&new_fnlist->fn_fieldlist.name, - sublist->fn_field.physname); + if (new_method_name != NULL + && strcmp (new_method_name, + new_fnlist->fn_fieldlist.name) != 0) + { + new_fnlist->fn_fieldlist.name = new_method_name; + xfree (main_fn_name); + } + else + xfree (new_method_name); } else if (has_destructor && new_fnlist->fn_fieldlist.name[0] != '~') { new_fnlist->fn_fieldlist.name = - concat ("~", main_fn_name, (char *)NULL); + obconcat (&objfile->objfile_obstack, + "~", main_fn_name, (char *)NULL); xfree (main_fn_name); } else if (!has_stub) @@ -2711,6 +2716,7 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type, new_fnlist->fn_fieldlist.name = obsavestring (dem_opname, strlen (dem_opname), &objfile->objfile_obstack); + xfree (main_fn_name); } new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *) @@ -2753,7 +2759,7 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type, struct objfile *objfile) { char *p; - char *name; + const char *name; char cpp_abbrev; struct type *context; @@ -3266,7 +3272,7 @@ read_tilde_fields (struct field_info *fip, char **pp, struct type *type, i >= TYPE_N_BASECLASSES (t); --i) { - char *name = TYPE_FIELD_NAME (t, i); + const char *name = TYPE_FIELD_NAME (t, i); if (!strncmp (name, vptr_name, sizeof (vptr_name) - 2) && is_cplus_marker (name[sizeof (vptr_name) - 2])) @@ -3406,8 +3412,8 @@ attach_fields_to_type (struct field_info *fip, struct type *type, static void complain_about_struct_wipeout (struct type *type) { - char *name = ""; - char *kind = ""; + const char *name = ""; + const char *kind = ""; if (TYPE_TAG_NAME (type)) { @@ -4545,7 +4551,7 @@ cleanup_undefined_types_1 (void) struct pending *ppt; int i; /* Name of the type, without "struct" or "union". */ - char *typename = TYPE_TAG_NAME (*type); + const char *typename = TYPE_TAG_NAME (*type); if (typename == NULL) { diff --git a/gdb/stabsread.h b/gdb/stabsread.h index 071552ea1d..a48f4b1d51 100644 --- a/gdb/stabsread.h +++ b/gdb/stabsread.h @@ -162,7 +162,7 @@ struct stab_section_list they are only used by some stabs readers. */ extern struct partial_symtab *end_psymtab (struct partial_symtab *pst, - char **include_list, + const char **include_list, int num_includes, int capping_symbol_offset, CORE_ADDR capping_text, diff --git a/gdb/stack.c b/gdb/stack.c index cf9125bcbb..95bb63116f 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -999,7 +999,7 @@ get_last_displayed_sal (struct symtab_and_line *sal) corresponding to FRAME. */ void -find_frame_funname (struct frame_info *frame, char **funname, +find_frame_funname (struct frame_info *frame, const char **funname, enum language *funlang, struct symbol **funcp) { struct symbol *func; @@ -1095,7 +1095,7 @@ print_frame (struct frame_info *frame, int print_level, { struct gdbarch *gdbarch = get_frame_arch (frame); struct ui_out *uiout = current_uiout; - char *funname = NULL; + const char *funname = NULL; enum language funlang = language_unknown; struct ui_stream *stb; struct cleanup *old_chain, *list_chain; @@ -1363,7 +1363,7 @@ frame_info (char *addr_exp, int from_tty) struct symtab *s; struct frame_info *calling_frame_info; int numregs; - char *funname = 0; + const char *funname = 0; enum language funlang = language_unknown; const char *pc_regname; int selected_frame_p; diff --git a/gdb/stack.h b/gdb/stack.h index 172d7c2f26..50b2477f76 100644 --- a/gdb/stack.h +++ b/gdb/stack.h @@ -22,7 +22,7 @@ void select_frame_command (char *level_exp, int from_tty); -void find_frame_funname (struct frame_info *frame, char **funname, +void find_frame_funname (struct frame_info *frame, const char **funname, enum language *funlang, struct symbol **funcp); typedef void (*iterate_over_block_arg_local_vars_cb) (const char *print_name, diff --git a/gdb/symtab.c b/gdb/symtab.c index 61f7536ab1..f74655140f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -65,8 +65,6 @@ /* Prototypes for local functions */ -static void completion_list_add_name (char *, char *, int, char *, char *); - static void rbreak_command (char *, int); static void types_info (char *, int); @@ -366,9 +364,9 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id) char *mangled_name; struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id); struct fn_field *method = &f[signature_id]; - char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id); + const char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id); const char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id); - char *newname = type_name_no_tag (type); + const char *newname = type_name_no_tag (type); /* Does the form of physname indicate that it is the full mangled name of a constructor (not just the args)? */ @@ -478,7 +476,7 @@ symbol_set_demangled_name (struct general_symbol_info *gsymbol, /* Return the demangled name of GSYMBOL. */ -char * +const char * symbol_get_demangled_name (const struct general_symbol_info *gsymbol) { if (gsymbol->language == language_cplus) @@ -686,12 +684,14 @@ symbol_set_names (struct general_symbol_info *gsymbol, name with the symbol, we don't need to use the same trick as Java. */ if (!copy_name) - gsymbol->name = (char *) linkage_name; + gsymbol->name = linkage_name; else { - gsymbol->name = obstack_alloc (&objfile->objfile_obstack, len + 1); - memcpy (gsymbol->name, linkage_name, len); - gsymbol->name[len] = '\0'; + char *name = obstack_alloc (&objfile->objfile_obstack, len + 1); + + memcpy (name, linkage_name, len); + name[len] = '\0'; + gsymbol->name = name; } symbol_set_demangled_name (gsymbol, NULL, NULL); @@ -797,7 +797,7 @@ symbol_set_names (struct general_symbol_info *gsymbol, /* Return the source code name of a symbol. In languages where demangling is necessary, this is the demangled name. */ -char * +const char * symbol_natural_name (const struct general_symbol_info *gsymbol) { switch (gsymbol->language) @@ -825,7 +825,7 @@ symbol_natural_name (const struct general_symbol_info *gsymbol) /* Return the demangled name for a symbol based on the language for that symbol. If no demangled name exists, return NULL. */ -char * +const char * symbol_demangled_name (const struct general_symbol_info *gsymbol) { switch (gsymbol->language) @@ -855,7 +855,7 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol) If there is no distinct demangled name, then returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */ -char * +const char * symbol_search_name (const struct general_symbol_info *gsymbol) { if (gsymbol->language == language_ada) @@ -3833,8 +3833,9 @@ static char **return_val; characters. If so, add it to the current completion list. */ static void -completion_list_add_name (char *symname, char *sym_text, int sym_text_len, - char *text, char *word) +completion_list_add_name (const char *symname, + const char *sym_text, int sym_text_len, + const char *text, const char *word) { int newsize; @@ -3882,13 +3883,14 @@ completion_list_add_name (char *symname, char *sym_text, int sym_text_len, again and feed all the selectors into the mill. */ static void -completion_list_objc_symbol (struct minimal_symbol *msymbol, char *sym_text, - int sym_text_len, char *text, char *word) +completion_list_objc_symbol (struct minimal_symbol *msymbol, + const char *sym_text, int sym_text_len, + const char *text, const char *word) { static char *tmp = NULL; static unsigned int tmplen = 0; - char *method, *category, *selector; + const char *method, *category, *selector; char *tmp2 = NULL; method = SYMBOL_NATURAL_NAME (msymbol); diff --git a/gdb/symtab.h b/gdb/symtab.h index 994f9f2ace..d9e5f4a3a2 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -81,7 +81,7 @@ struct language_defn; struct cplus_specific { - char *demangled_name; + const char *demangled_name; }; /* Define a structure for the information that is common to all symbol types, @@ -99,7 +99,7 @@ struct general_symbol_info the mangled name and demangled name, this is the mangled name. */ - char *name; + const char *name; /* Value of the symbol. Which member of this union to use, and what it means, depends on what kind of symbol this is and its @@ -135,7 +135,7 @@ struct general_symbol_info currently used by Ada, Java, and Objective C. */ struct mangled_lang { - char *demangled_name; + const char *demangled_name; } mangled_lang; @@ -166,7 +166,8 @@ struct general_symbol_info extern void symbol_set_demangled_name (struct general_symbol_info *, char *, struct objfile *); -extern char *symbol_get_demangled_name (const struct general_symbol_info *); +extern const char *symbol_get_demangled_name + (const struct general_symbol_info *); extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *); @@ -225,7 +226,8 @@ extern void symbol_set_names (struct general_symbol_info *symbol, #define SYMBOL_NATURAL_NAME(symbol) \ (symbol_natural_name (&(symbol)->ginfo)) -extern char *symbol_natural_name (const struct general_symbol_info *symbol); +extern const char *symbol_natural_name + (const struct general_symbol_info *symbol); /* Return SYMBOL's name from the point of view of the linker. In languages like C++ where symbols may be mangled for ease of @@ -238,7 +240,8 @@ extern char *symbol_natural_name (const struct general_symbol_info *symbol); that symbol. If no demangled name exists, return NULL. */ #define SYMBOL_DEMANGLED_NAME(symbol) \ (symbol_demangled_name (&(symbol)->ginfo)) -extern char *symbol_demangled_name (const struct general_symbol_info *symbol); +extern const char *symbol_demangled_name + (const struct general_symbol_info *symbol); /* Macro that returns a version of the name of a symbol that is suitable for output. In C++ this is the "demangled" form of the @@ -261,7 +264,7 @@ extern int demangle; returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */ #define SYMBOL_SEARCH_NAME(symbol) \ (symbol_search_name (&(symbol)->ginfo)) -extern char *symbol_search_name (const struct general_symbol_info *); +extern const char *symbol_search_name (const struct general_symbol_info *); /* Return non-zero if NAME matches the "search" name of SYMBOL. Whitespace and trailing parentheses are ignored. diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index ede3742f0a..37e1f52938 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2577,7 +2577,8 @@ scope_info (char *args, int from_tty) struct symbol *sym; struct minimal_symbol *msym; struct block *block; - char *symname, *save_args = args; + const char *symname; + char *save_args = args; struct dict_iterator iter; int j, count = 0; struct gdbarch *gdbarch; diff --git a/gdb/typeprint.c b/gdb/typeprint.c index de96fd5fcd..803d20bee6 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -73,7 +73,7 @@ default_print_typedef (struct type *type, struct symbol *new_symbol, If SHOW is negative, we never show the details of elements' types. */ void -type_print (struct type *type, char *varstring, struct ui_file *stream, +type_print (struct type *type, const char *varstring, struct ui_file *stream, int show) { LA_PRINT_TYPE (type, varstring, stream, show, 0); diff --git a/gdb/utils.c b/gdb/utils.c index 1ebb935413..1096b3ad12 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2589,7 +2589,7 @@ print_spaces_filtered (int n, struct ui_file *stream) demangling is off, the name is printed in its "raw" form. */ void -fprintf_symbol_filtered (struct ui_file *stream, char *name, +fprintf_symbol_filtered (struct ui_file *stream, const char *name, enum language lang, int arg_mode) { char *demangled; diff --git a/gdb/valarith.c b/gdb/valarith.c index b8bcc6b25d..a17c91af3f 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -64,7 +64,7 @@ find_size_for_pointer_math (struct type *ptr_type) sz = 1; else { - char *name; + const char *name; name = TYPE_NAME (ptr_target); if (name == NULL) diff --git a/gdb/valops.c b/gdb/valops.c index 5453b1ae89..fca601f338 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -2005,7 +2005,7 @@ search_struct_field (const char *name, struct value *arg1, int offset, if (!looking_for_baseclass) for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--) { - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) { @@ -2163,7 +2163,7 @@ search_struct_method (const char *name, struct value **arg1p, CHECK_TYPEDEF (type); for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--) { - char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i); + const char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i); /* FIXME! May need to check for ARM demangling here. */ if (strncmp (t_field_name, "__", 2) == 0 || @@ -2407,7 +2407,7 @@ find_method_list (struct value **argp, const char *method, for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--) { /* pai: FIXME What about operators and type conversions? */ - char *fn_field_name = TYPE_FN_FIELDLIST_NAME (type, i); + const char *fn_field_name = TYPE_FN_FIELDLIST_NAME (type, i); if (fn_field_name && (strcmp_iw (fn_field_name, method) == 0)) { @@ -3154,7 +3154,7 @@ check_field (struct type *type, const char *name) for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) { - char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = TYPE_FIELD_NAME (type, i); if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) return 1; @@ -3280,7 +3280,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--) { - char *t_field_name = TYPE_FIELD_NAME (t, i); + const char *t_field_name = TYPE_FIELD_NAME (t, i); if (t_field_name && strcmp (t_field_name, name) == 0) { @@ -3317,7 +3317,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i) { - char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i); + const char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i); char dem_opname[64]; if (strncmp (t_field_name, "__", 2) == 0 diff --git a/gdb/value.h b/gdb/value.h index 4727755f06..2a2274d83c 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -777,7 +777,7 @@ extern int record_latest_value (struct value *val); extern void modify_field (struct type *type, gdb_byte *addr, LONGEST fieldval, int bitpos, int bitsize); -extern void type_print (struct type *type, char *varstring, +extern void type_print (struct type *type, const char *varstring, struct ui_file *stream, int show); extern char *type_to_string (struct type *type); diff --git a/gdb/varobj.c b/gdb/varobj.c index 8162350d6c..8855ce3e78 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -3086,7 +3086,7 @@ c_describe_child (struct varobj *parent, int index, case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: { - char *field_name; + const char *field_name; /* If the type is anonymous and the field has no name, set an appropriate name. */ @@ -3515,7 +3515,7 @@ cplus_describe_child (struct varobj *parent, int index, enum accessibility acc = public_field; int vptr_fieldno; struct type *basetype = NULL; - char *field_name; + const char *field_name; vptr_fieldno = get_vptr_fieldno (type, &basetype); if (strcmp (parent->name, "private") == 0) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 1a2bb1464b..86ae8fb188 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -882,7 +882,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset, #define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \ { \ - char *namestr; \ + const char *namestr; \ \ namestr = (NAME); \ if (namestr[0] == '.') ++namestr; \ @@ -986,7 +986,7 @@ read_xcoff_symtab (struct partial_symtab *pst) char *filestring = " _start_ "; /* Name of the current file. */ - char *last_csect_name; /* Last seen csect's name and value. */ + const char *last_csect_name; /* Last seen csect's name and value. */ CORE_ADDR last_csect_val; int last_csect_sec; @@ -1989,10 +1989,6 @@ init_stringtab (bfd *abfd, file_ptr offset, struct objfile *objfile) for the psymtab. */ static unsigned int first_fun_line_offset; -static struct partial_symtab *xcoff_start_psymtab - (struct objfile *, char *, int, - struct partial_symbol **, struct partial_symbol **); - /* Allocate and partially fill a partial symtab. It will be completely filled at the end of the symbol list. @@ -2001,7 +1997,8 @@ static struct partial_symtab *xcoff_start_psymtab (normal). */ static struct partial_symtab * -xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum, +xcoff_start_psymtab (struct objfile *objfile, + const char *filename, int first_symnum, struct partial_symbol **global_syms, struct partial_symbol **static_syms) { @@ -2023,10 +2020,6 @@ xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum, return result; } -static struct partial_symtab *xcoff_end_psymtab - (struct partial_symtab *, char **, int, int, - struct partial_symtab **, int, int); - /* Close off the current usage of PST. Returns PST, or NULL if the partial symtab was empty and thrown away. @@ -2036,7 +2029,7 @@ static struct partial_symtab *xcoff_end_psymtab are the information for includes and dependencies. */ static struct partial_symtab * -xcoff_end_psymtab (struct partial_symtab *pst, char **include_list, +xcoff_end_psymtab (struct partial_symtab *pst, const char **include_list, int num_includes, int capping_symbol_number, struct partial_symtab **dependency_list, int number_dependencies, int textlow_not_set) @@ -2119,17 +2112,13 @@ xcoff_end_psymtab (struct partial_symtab *pst, char **include_list, return pst; } -static void swap_sym (struct internal_syment *, - union internal_auxent *, char **, char **, - unsigned int *, struct objfile *); - /* Swap raw symbol at *RAW and put the name in *NAME, the symbol in *SYMBOL, the first auxent in *AUX. Advance *RAW and *SYMNUMP over the symbol and its auxents. */ static void swap_sym (struct internal_syment *symbol, union internal_auxent *aux, - char **name, char **raw, unsigned int *symnump, + const char **name, char **raw, unsigned int *symnump, struct objfile *objfile) { bfd_coff_swap_sym_in (objfile->obfd, *raw, symbol); @@ -2189,9 +2178,9 @@ scan_xcoff_symtab (struct objfile *objfile) { struct gdbarch *gdbarch = get_objfile_arch (objfile); CORE_ADDR toc_offset = 0; /* toc offset value in data section. */ - char *filestring = NULL; + const char *filestring = NULL; - char *namestring; + const char *namestring; int past_first_source_file = 0; bfd *abfd; asection *bfd_sect; @@ -2201,7 +2190,7 @@ scan_xcoff_symtab (struct objfile *objfile) struct partial_symtab *pst; /* List of current psymtab's include files. */ - char **psymtab_include_list; + const char **psymtab_include_list; int includes_allocated; int includes_used; @@ -2214,7 +2203,7 @@ scan_xcoff_symtab (struct objfile *objfile) union internal_auxent main_aux[5]; unsigned int ssymnum; - char *last_csect_name = NULL; /* Last seen csect's name and value. */ + const char *last_csect_name = NULL; /* Last seen csect's name and value. */ CORE_ADDR last_csect_val = 0; int last_csect_sec = 0; int misc_func_recorded = 0; /* true if any misc. function. */ @@ -2224,8 +2213,8 @@ scan_xcoff_symtab (struct objfile *objfile) includes_allocated = 30; includes_used = 0; - psymtab_include_list = (char **) alloca (includes_allocated * - sizeof (char *)); + psymtab_include_list = (const char **) alloca (includes_allocated * + sizeof (const char *)); dependencies_allocated = 30; dependencies_used = 0; @@ -2619,13 +2608,13 @@ scan_xcoff_symtab (struct objfile *objfile) psymtab_include_list[includes_used++] = namestring; if (includes_used >= includes_allocated) { - char **orig = psymtab_include_list; + const char **orig = psymtab_include_list; - psymtab_include_list = (char **) + psymtab_include_list = (const char **) alloca ((includes_allocated *= 2) * - sizeof (char *)); + sizeof (const char *)); memcpy (psymtab_include_list, orig, - includes_used * sizeof (char *)); + includes_used * sizeof (const char *)); } continue; } -- 2.34.1