From: Tom Tromey Date: Mon, 21 Jan 2013 18:13:14 +0000 (+0000) Subject: * symfile.h (obsavestring): Don't declare. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10f0c4bbfa440916bce5d7407fd2b7447db31ef6;p=binutils-gdb.git * symfile.h (obsavestring): Don't declare. * symfile.c (obsavestring): Remove. * ada-exp.y: Use obstack_copy0, not obsavestring. * ada-lang.c: Use obstack_copy0, not obsavestring. * coffread.c: Use obstack_copy0, not obsavestring. * cp-namespace.c: Use obstack_copy0, not obsavestring. * dbxread.c: Use obstack_copy0, not obsavestring. * dwarf2read.c: Use obstack_copy0, not obsavestring. * jit.c: Use obstack_copy0, not obsavestring. * mdebugread.c: Use obstack_copy0, not obsavestring. * psymtab.c: Use obstack_copy0, not obsavestring. * stabsread.c: Use obstack_copy0, not obsavestring. * xcoffread.c: Use obstack_copy0, not obsavestring. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b5fd8eeb9f2..74d1dcb0127 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2013-01-21 Tom Tromey + + * symfile.h (obsavestring): Don't declare. + * symfile.c (obsavestring): Remove. + * ada-exp.y: Use obstack_copy0, not obsavestring. + * ada-lang.c: Use obstack_copy0, not obsavestring. + * coffread.c: Use obstack_copy0, not obsavestring. + * cp-namespace.c: Use obstack_copy0, not obsavestring. + * dbxread.c: Use obstack_copy0, not obsavestring. + * dwarf2read.c: Use obstack_copy0, not obsavestring. + * jit.c: Use obstack_copy0, not obsavestring. + * mdebugread.c: Use obstack_copy0, not obsavestring. + * psymtab.c: Use obstack_copy0, not obsavestring. + * stabsread.c: Use obstack_copy0, not obsavestring. + * xcoffread.c: Use obstack_copy0, not obsavestring. + 2013-01-21 Tom Tromey * dwarf2read.c (fixup_go_packaging): Save package name diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 38ac317d3e7..e4bcfb38791 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -880,7 +880,7 @@ write_object_renaming (const struct block *orig_left_context, if (orig_left_context == NULL) orig_left_context = get_selected_block (NULL); - name = obsavestring (renamed_entity, renamed_entity_len, &temp_parse_space); + name = obstack_copy0 (&temp_parse_space, renamed_entity, renamed_entity_len); ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info); if (sym_info.sym == NULL) error (_("Could not find renamed variable: %s"), ada_decode (name)); @@ -949,8 +949,8 @@ write_object_renaming (const struct block *orig_left_context, end = renaming_expr + strlen (renaming_expr); index_name = - obsavestring (renaming_expr, end - renaming_expr, - &temp_parse_space); + obstack_copy0 (&temp_parse_space, renaming_expr, + end - renaming_expr); renaming_expr = end; ada_lookup_encoded_symbol (index_name, NULL, VAR_DOMAIN, @@ -1166,7 +1166,7 @@ write_ambiguous_var (const struct block *block, char *name, int len) obstack_alloc (&temp_parse_space, sizeof (struct symbol)); memset (sym, 0, sizeof (struct symbol)); SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN; - SYMBOL_LINKAGE_NAME (sym) = obsavestring (name, len, &temp_parse_space); + SYMBOL_LINKAGE_NAME (sym) = obstack_copy0 (&temp_parse_space, name, len); SYMBOL_LANGUAGE (sym) = language_ada; write_exp_elt_opcode (OP_VAR_VALUE); @@ -1263,7 +1263,7 @@ write_var_or_type (const struct block *block, struct stoken name0) encoded_name = ada_encode (name0.ptr); name_len = strlen (encoded_name); - encoded_name = obsavestring (encoded_name, name_len, &temp_parse_space); + encoded_name = obstack_copy0 (&temp_parse_space, encoded_name, name_len); for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1) { int tail_index; diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b4849a944e6..4488b88590b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1310,8 +1310,8 @@ ada_decode_symbol (const struct general_symbol_info *gsymbol) { struct objfile *objf = gsymbol->obj_section->objfile; - *resultp = obsavestring (decoded, strlen (decoded), - &objf->objfile_obstack); + *resultp = obstack_copy0 (&objf->objfile_obstack, + decoded, strlen (decoded)); } /* Sometimes, we can't find a corresponding objfile, in which case, we put the result on the heap. Since we only decode diff --git a/gdb/coffread.c b/gdb/coffread.c index 62565a8d01f..3cc14cefabe 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -2011,8 +2011,8 @@ coff_read_struct_type (int index, int length, int lastsym, list = new; /* Save the data. */ - list->field.name = obsavestring (name, strlen (name), - &objfile->objfile_obstack); + list->field.name = obstack_copy0 (&objfile->objfile_obstack, + name, strlen (name)); FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux, objfile); SET_FIELD_BITPOS (list->field, 8 * ms->c_value); @@ -2028,8 +2028,8 @@ coff_read_struct_type (int index, int length, int lastsym, list = new; /* Save the data. */ - list->field.name = obsavestring (name, strlen (name), - &objfile->objfile_obstack); + list->field.name = obstack_copy0 (&objfile->objfile_obstack, + name, strlen (name)); FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux, objfile); SET_FIELD_BITPOS (list->field, ms->c_value); @@ -2102,8 +2102,8 @@ coff_read_enum_type (int index, int length, int lastsym, memset (sym, 0, sizeof (struct symbol)); SYMBOL_SET_LINKAGE_NAME (sym, - obsavestring (name, strlen (name), - &objfile->objfile_obstack)); + obstack_copy0 (&objfile->objfile_obstack, + name, strlen (name))); SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_DOMAIN (sym) = VAR_DOMAIN; SYMBOL_VALUE (sym) = ms->c_value; diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 01844ffa0ce..8511bf10033 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -173,15 +173,15 @@ cp_add_using_directive (const char *dest, * sizeof (*new->excludes)))); memset (new, 0, sizeof (*new)); - new->import_src = obsavestring (src, strlen (src), obstack); - new->import_dest = obsavestring (dest, strlen (dest), obstack); + new->import_src = obstack_copy0 (obstack, src, strlen (src)); + new->import_dest = obstack_copy0 (obstack, dest, strlen (dest)); if (alias != NULL) - new->alias = obsavestring (alias, strlen (alias), obstack); + new->alias = obstack_copy0 (obstack, alias, strlen (alias)); if (declaration != NULL) - new->declaration = obsavestring (declaration, strlen (declaration), - obstack); + new->declaration = obstack_copy0 (obstack, + declaration, strlen (declaration)); memcpy (new->excludes, VEC_address (const_char_ptr, excludes), VEC_length (const_char_ptr, excludes) * sizeof (*new->excludes)); @@ -205,9 +205,8 @@ cp_set_block_scope (const struct symbol *symbol, if (processing_has_namespace_info) { block_set_scope - (block, obsavestring (processing_current_prefix, - strlen (processing_current_prefix), - obstack), + (block, obstack_copy0 (obstack, processing_current_prefix, + strlen (processing_current_prefix)), obstack); } else if (SYMBOL_DEMANGLED_NAME (symbol) != NULL) @@ -224,7 +223,7 @@ cp_set_block_scope (const struct symbol *symbol, unsigned int prefix_len = cp_entire_prefix_len (name); block_set_scope (block, - obsavestring (name, prefix_len, obstack), + obstack_copy0 (obstack, name, prefix_len), obstack); } } diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 5857e33ce1e..fcd4d821523 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1706,8 +1706,8 @@ read_dbx_symtab (struct objfile *objfile) if (new_name != NULL) { sym_len = strlen (new_name); - sym_name = obsavestring (new_name, sym_len, - &objfile->objfile_obstack); + sym_name = obstack_copy0 (&objfile->objfile_obstack, + new_name, sym_len); xfree (new_name); } xfree (name); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 76d469c7ee2..0c2572692eb 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6803,9 +6803,9 @@ fixup_go_packaging (struct dwarf2_cu *cu) if (package_name != NULL) { struct objfile *objfile = cu->objfile; - const char *saved_package_name = obsavestring (package_name, - strlen (package_name), - &objfile->objfile_obstack); + const char *saved_package_name = obstack_copy0 (&objfile->objfile_obstack, + package_name, + strlen (package_name)); struct type *type = init_type (TYPE_CODE_MODULE, 0, 0, saved_package_name, objfile); struct symbol *sym; @@ -7673,8 +7673,7 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu) retval = canon; if (need_copy) - retval = obsavestring (retval, strlen (retval), - &objfile->objfile_obstack); + retval = obstack_copy0 (&objfile->objfile_obstack, retval, strlen (retval)); do_cleanups (back_to); return retval; @@ -13873,9 +13872,9 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi, if (actual_class_name != NULL) { struct_pdi->name - = obsavestring (actual_class_name, - strlen (actual_class_name), - &cu->objfile->objfile_obstack); + = obstack_copy0 (&cu->objfile->objfile_obstack, + actual_class_name, + strlen (actual_class_name)); xfree (actual_class_name); } break; @@ -13959,8 +13958,8 @@ fixup_partial_die (struct partial_die_info *part_die, else base = demangled; - part_die->name = obsavestring (base, strlen (base), - &cu->objfile->objfile_obstack); + part_die->name = obstack_copy0 (&cu->objfile->objfile_obstack, + base, strlen (base)); xfree (demangled); } } @@ -16630,9 +16629,9 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) && actual_name[actual_name_len - die_name_len - 1] == ':') name = - obsavestring (actual_name, - actual_name_len - die_name_len - 2, - &cu->objfile->objfile_obstack); + obstack_copy0 (&cu->objfile->objfile_obstack, + actual_name, + actual_name_len - die_name_len - 2); } } xfree (actual_name); @@ -16676,8 +16675,8 @@ anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu) if (base == NULL || base == DW_STRING (attr) || base[-1] != ':') return ""; - return obsavestring (DW_STRING (attr), &base[-1] - DW_STRING (attr), - &cu->objfile->objfile_obstack); + return obstack_copy0 (&cu->objfile->objfile_obstack, + DW_STRING (attr), &base[-1] - DW_STRING (attr)); } /* Return the name of the namespace/class that DIE is defined within, @@ -16906,8 +16905,7 @@ dwarf2_canonicalize_name (const char *name, struct dwarf2_cu *cu, if (canon_name != NULL) { if (strcmp (canon_name, name) != 0) - name = obsavestring (canon_name, strlen (canon_name), - obstack); + name = obstack_copy0 (obstack, canon_name, strlen (canon_name)); xfree (canon_name); } } @@ -17008,8 +17006,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) char *base; /* FIXME: we already did this for the partial symbol... */ - DW_STRING (attr) = obsavestring (demangled, strlen (demangled), - &cu->objfile->objfile_obstack); + DW_STRING (attr) = obstack_copy0 (&cu->objfile->objfile_obstack, + demangled, strlen (demangled)); DW_STRING_IS_CANONICAL (attr) = 1; xfree (demangled); diff --git a/gdb/jit.c b/gdb/jit.c index 4623f15f1d4..b4294e84168 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -683,9 +683,9 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) SYMBOL_TYPE (block_name) = lookup_function_type (block_type); SYMBOL_BLOCK_VALUE (block_name) = new_block; - block_name->ginfo.name = obsavestring (gdb_block_iter->name, - strlen (gdb_block_iter->name), - &objfile->objfile_obstack); + block_name->ginfo.name = obstack_copy0 (&objfile->objfile_obstack, + gdb_block_iter->name, + strlen (gdb_block_iter->name)); BLOCK_FUNCTION (new_block) = block_name; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index aff4525928e..4f64342bc31 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1052,8 +1052,9 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, sizeof (struct symbol))); memset (enum_sym, 0, sizeof (struct symbol)); SYMBOL_SET_LINKAGE_NAME - (enum_sym, obsavestring (f->name, strlen (f->name), - &mdebugread_objfile->objfile_obstack)); + (enum_sym, + obstack_copy0 (&mdebugread_objfile->objfile_obstack, + f->name, strlen (f->name))); SYMBOL_CLASS (enum_sym) = LOC_CONST; SYMBOL_TYPE (enum_sym) = t; SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN; @@ -1697,8 +1698,8 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, else if (TYPE_TAG_NAME (tp) == NULL || strcmp (TYPE_TAG_NAME (tp), name) != 0) TYPE_TAG_NAME (tp) - = obsavestring (name, strlen (name), - &mdebugread_objfile->objfile_obstack); + = obstack_copy0 (&mdebugread_objfile->objfile_obstack, + name, strlen (name)); } } @@ -1733,8 +1734,9 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, } if (TYPE_NAME (tp) == NULL || strcmp (TYPE_NAME (tp), name) != 0) - TYPE_NAME (tp) = obsavestring (name, strlen (name), - &mdebugread_objfile->objfile_obstack); + TYPE_NAME (tp) + = obstack_copy0 (&mdebugread_objfile->objfile_obstack, + name, strlen (name)); } } if (t->bt == btTypedef) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 08eff0711cd..861512ee8f0 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1739,8 +1739,8 @@ allocate_psymtab (const char *filename, struct objfile *objfile) sizeof (struct partial_symtab)); memset (psymtab, 0, sizeof (struct partial_symtab)); - psymtab->filename = obsavestring (filename, strlen (filename), - &objfile->objfile_obstack); + psymtab->filename = obstack_copy0 (&objfile->objfile_obstack, + filename, strlen (filename)); psymtab->symtab = NULL; /* Prepend it to the psymtab list for the objfile it belongs to. diff --git a/gdb/stabsread.c b/gdb/stabsread.c index f89dbaed2f0..a38ead15528 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -387,8 +387,8 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs, SYMBOL_DOMAIN (sym) = VAR_DOMAIN; SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT; SYMBOL_SET_LINKAGE_NAME - (sym, obsavestring (name, pp - name, - &objfile->objfile_obstack)); + (sym, obstack_copy0 (&objfile->objfile_obstack, + name, pp - name)); pp += 2; if (*(pp - 1) == 'F' || *(pp - 1) == 'f') { @@ -1632,8 +1632,8 @@ again: new_name = cp_canonicalize_string (name); if (new_name != NULL) { - type_name = obsavestring (new_name, strlen (new_name), - &objfile->objfile_obstack); + type_name = obstack_copy0 (&objfile->objfile_obstack, + new_name, strlen (new_name)); xfree (new_name); } } @@ -2712,8 +2712,8 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type, dem_opname, 0); if (ret) new_fnlist->fn_fieldlist.name - = obsavestring (dem_opname, strlen (dem_opname), - &objfile->objfile_obstack); + = obstack_copy0 (&objfile->objfile_obstack, + dem_opname, strlen (dem_opname)); xfree (main_fn_name); } @@ -2855,7 +2855,7 @@ read_one_struct_field (struct field_info *fip, char **pp, char *p, struct gdbarch *gdbarch = get_objfile_arch (objfile); fip->list->field.name = - obsavestring (*pp, p - *pp, &objfile->objfile_obstack); + obstack_copy0 (&objfile->objfile_obstack, *pp, p - *pp); *pp = p + 1; /* This means we have a visibility for a field coming. */ @@ -3674,7 +3674,7 @@ read_enum_type (char **pp, struct type *type, p = *pp; while (*p != ':') p++; - name = obsavestring (*pp, p - *pp, &objfile->objfile_obstack); + name = obstack_copy0 (&objfile->objfile_obstack, *pp, p - *pp); *pp = p + 1; n = read_huge_number (pp, ',', &nbits, 0); if (nbits != 0) @@ -4328,8 +4328,8 @@ common_block_start (char *name, struct objfile *objfile) } common_block = local_symbols; common_block_i = local_symbols ? local_symbols->nsyms : 0; - common_block_name = obsavestring (name, strlen (name), - &objfile->objfile_obstack); + common_block_name = obstack_copy0 (&objfile->objfile_obstack, + name, strlen (name)); } /* Process a N_ECOMM symbol. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index 8aeab0479cc..f610e673b9d 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -151,30 +151,6 @@ static VEC (sym_fns_ptr) *symtab_fns = NULL; int auto_solib_add = 1; -/* Make a null terminated copy of the string at PTR with SIZE characters in - the obstack pointed to by OBSTACKP . Returns the address of the copy. - Note that the string at PTR does not have to be null terminated, I.e. it - may be part of a larger string and we are only saving a substring. */ - -char * -obsavestring (const char *ptr, int size, struct obstack *obstackp) -{ - char *p = (char *) obstack_alloc (obstackp, size + 1); - /* Open-coded memcpy--saves function call time. These strings are usually - short. FIXME: Is this really still true with a compiler that can - inline memcpy? */ - { - const char *p1 = ptr; - char *p2 = p; - const char *end = ptr + size; - - while (p1 != end) - *p2++ = *p1++; - } - p[size] = 0; - return p; -} - /* Concatenate NULL terminated variable argument list of `const char *' strings; return the new string. Space is found in the OBSTACKP. Argument list must be terminated by a sentinel expression `(char *) diff --git a/gdb/symfile.h b/gdb/symfile.h index 81492d22c37..ad9a4e27c8b 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -506,12 +506,6 @@ extern struct section_addr_info extern void free_section_addr_info (struct section_addr_info *); -/* Make a copy of the string at PTR with SIZE characters in the symbol - obstack (and add a null character at the end in the copy). Returns - the address of the copy. */ - -extern char *obsavestring (const char *, int, struct obstack *); - /* Concatenate NULL terminated variable argument list of `const char *' strings; return the new string. Space is found in the OBSTACKP. Argument list must be terminated by a sentinel expression `(char *) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index a71a958d4e6..896b817f148 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1512,8 +1512,8 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst) #define SYMNAME_ALLOC(NAME, ALLOCED) \ - ((ALLOCED) ? (NAME) : obsavestring ((NAME), strlen (NAME), \ - &objfile->objfile_obstack)) + ((ALLOCED) ? (NAME) : obstack_copy0 (&objfile->objfile_obstack, \ + (NAME), strlen (NAME))) /* process one xcoff symbol. */