+2019-08-06 Tom Tromey <tom@tromey.com>
+
+ * xcoffread.c (SYMNAME_ALLOC, process_xcoff_symbol): Use
+ obstack_strdup.
+ * typeprint.c (typedef_hash_table::find_global_typedef): Use
+ obstack_strdup.
+ * symfile.c (allocate_compunit_symtab): Use obstack_strdup.
+ * stabsread.c (common_block_start): Use obstack_strdup.
+ * objfiles.c (set_objfile_main_name, objfile): Use
+ obstack_strdup.
+ * namespace.c (add_using_directive): Use obstack_strdup.
+ * mdebugread.c (parse_symbol, parse_type): Use obstack_strdup.
+ * jit.c (finalize_symtab): Use obstack_strdup.
+ * dwarf2read.c (fixup_go_packaging, dwarf2_physname)
+ (guess_partial_die_structure_name, partial_die_info::fixup)
+ (dwarf2_name): Use obstack_strdup.
+ * coffread.c (coff_read_struct_type, coff_read_enum_type): Use
+ obstack_strdup.
+ * c-exp.y (scan_macro_expansion): Use obstack_strdup.
+ * buildsym.c (buildsym_compunit::end_symtab_with_blockvector): Use
+ obstack_strdup.
+ * ada-lang.c (ada_decode_symbol): Use obstack_strdup.
+
2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* unittests/help-doc-selftests.c: New file.
gsymbol->ada_mangled = 1;
if (obstack != NULL)
- *resultp
- = (const char *) obstack_copy0 (obstack, decoded, strlen (decoded));
+ *resultp = obstack_strdup (obstack, decoded);
else
{
/* Sometimes, we can't find a corresponding objfile, in
{
/* Reallocate the dirname on the symbol obstack. */
const char *comp_dir = m_comp_dir.get ();
- COMPUNIT_DIRNAME (cu)
- = (const char *) obstack_copy0 (&m_objfile->objfile_obstack,
- comp_dir, strlen (comp_dir));
+ COMPUNIT_DIRNAME (cu) = obstack_strdup (&m_objfile->objfile_obstack,
+ comp_dir);
}
/* Save the debug format string (if any) in the symtab. */
static void
scan_macro_expansion (char *expansion)
{
- char *copy;
+ const char *copy;
/* We'd better not be trying to push the stack twice. */
gdb_assert (! cpstate->macro_original_text);
/* Copy to the obstack, and then free the intermediate
expansion. */
- copy = (char *) obstack_copy0 (&cpstate->expansion_obstack, expansion,
- strlen (expansion));
+ copy = obstack_strdup (&cpstate->expansion_obstack, expansion);
xfree (expansion);
/* Save the old lexptr value, so we can return to it when we're done
list = newobj;
/* Save the data. */
- list->field.name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- name, strlen (name));
+ list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
&sub_aux, objfile);
SET_FIELD_BITPOS (list->field, 8 * ms->c_value);
list = newobj;
/* Save the data. */
- list->field.name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- name, strlen (name));
+ list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
FIELD_TYPE (list->field) = decode_type (ms, ms->c_type,
&sub_aux, objfile);
SET_FIELD_BITPOS (list->field, ms->c_value);
case C_MOE:
sym = allocate_symbol (objfile);
- name = (char *) obstack_copy0 (&objfile->objfile_obstack, name,
- strlen (name));
+ name = obstack_strdup (&objfile->objfile_obstack, name);
SYMBOL_SET_LINKAGE_NAME (sym, name);
SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
const char *saved_package_name
- = (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
- package_name,
- strlen (package_name));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name);
struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
saved_package_name);
struct symbol *sym;
retval = canon;
if (need_copy)
- retval = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- retval, strlen (retval)));
+ retval = obstack_strdup (&objfile->per_bfd->storage_obstack, retval);
return retval;
}
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
struct_pdi->name
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- actual_class_name,
- strlen (actual_class_name)));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ actual_class_name);
xfree (actual_class_name);
}
break;
base = demangled;
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- name
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- base, strlen (base)));
+ name = obstack_strdup (&objfile->per_bfd->storage_obstack, base);
xfree (demangled);
}
}
/* FIXME: we already did this for the partial symbol... */
DW_STRING (attr)
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- demangled, strlen (demangled)));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ demangled);
DW_STRING_IS_CANONICAL (attr) = 1;
xfree (demangled);
SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
SYMBOL_BLOCK_VALUE (block_name) = new_block;
- block_name->ginfo.name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- gdb_block_iter->name,
- strlen (gdb_block_iter->name));
+ block_name->ginfo.name = obstack_strdup (&objfile->objfile_obstack,
+ gdb_block_iter->name);
BLOCK_FUNCTION (new_block) = block_name;
enum_sym = allocate_symbol (mdebugread_objfile);
SYMBOL_SET_LINKAGE_NAME
(enum_sym,
- (char *) obstack_copy0 (&mdebugread_objfile->objfile_obstack,
- f->name, strlen (f->name)));
+ obstack_strdup (&mdebugread_objfile->objfile_obstack,
+ f->name));
SYMBOL_ACLASS_INDEX (enum_sym) = LOC_CONST;
SYMBOL_TYPE (enum_sym) = t;
SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN;
else if (TYPE_NAME (tp) == NULL
|| strcmp (TYPE_NAME (tp), name) != 0)
TYPE_NAME (tp)
- = ((const char *)
- obstack_copy0 (&mdebugread_objfile->objfile_obstack,
- name, strlen (name)));
+ = obstack_strdup (&mdebugread_objfile->objfile_obstack, name);
}
}
if (TYPE_NAME (tp) == NULL
|| strcmp (TYPE_NAME (tp), name) != 0)
TYPE_NAME (tp)
- = ((const char *)
- obstack_copy0 (&mdebugread_objfile->objfile_obstack,
- name, strlen (name)));
+ = obstack_strdup (&mdebugread_objfile->objfile_obstack, name);
}
}
if (t->bt == btTypedef)
if (copy_names)
{
- newobj->import_src
- = (const char *) obstack_copy0 (obstack, src, strlen (src));
- newobj->import_dest
- = (const char *) obstack_copy0 (obstack, dest, strlen (dest));
+ newobj->import_src = obstack_strdup (obstack, src);
+ newobj->import_dest = obstack_strdup (obstack, dest);
}
else
{
}
if (alias != NULL && copy_names)
- newobj->alias
- = (const char *) obstack_copy0 (obstack, alias, strlen (alias));
+ newobj->alias = obstack_strdup (obstack, alias);
else
newobj->alias = alias;
if (declaration != NULL && copy_names)
- newobj->declaration
- = (const char *) obstack_copy0 (obstack, declaration,
- strlen (declaration));
+ newobj->declaration = obstack_strdup (obstack, declaration);
else
newobj->declaration = declaration;
if (objfile->per_bfd->name_of_main == NULL
|| strcmp (objfile->per_bfd->name_of_main, name) != 0)
objfile->per_bfd->name_of_main
- = (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack, name,
- strlen (name));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack, name);
objfile->per_bfd->language_of_main = lang;
}
name_holder = gdb_abspath (name);
expanded_name = name_holder.get ();
}
- original_name
- = (char *) obstack_copy0 (&objfile_obstack,
- expanded_name,
- strlen (expanded_name));
+ original_name = obstack_strdup (&objfile_obstack, expanded_name);
/* Update the per-objfile information that comes from the bfd, ensuring
that any data that is reference is saved in the per-objfile data
}
common_block = *get_local_symbols ();
common_block_i = common_block ? common_block->nsyms : 0;
- common_block_name = (char *) obstack_copy0 (&objfile->objfile_obstack, name,
- strlen (name));
+ common_block_name = obstack_strdup (&objfile->objfile_obstack, name);
}
/* Process a N_ECOMM symbol. */
Just save the basename to avoid path issues (too long for display,
relative vs absolute, etc.). */
saved_name = lbasename (name);
- cu->name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack, saved_name,
- strlen (saved_name));
+ cu->name = obstack_strdup (&objfile->objfile_obstack, saved_name);
COMPUNIT_DEBUGFORMAT (cu) = "unknown";
if (applied != NULL)
{
- new_tf->name
- = (const char *) obstack_copy0 (&flags->global_typedefs->m_storage,
- applied, strlen (applied));
+ new_tf->name = obstack_strdup (&flags->global_typedefs->m_storage,
+ applied);
xfree (applied);
}
#define SYMNAME_ALLOC(NAME, ALLOCED) \
- ((ALLOCED) ? (NAME) : obstack_copy0 (&objfile->objfile_obstack, \
- (NAME), strlen (NAME)))
+ ((ALLOCED) ? (NAME) : obstack_strdup (&objfile->objfile_obstack, \
+ (NAME)))
/* process one xcoff symbol. */
will be patched with the type from its stab entry later on in
patch_block_stabs (), unless the file was compiled without -g. */
- SYMBOL_SET_LINKAGE_NAME (sym, ((const char *)
- SYMNAME_ALLOC (name, symname_alloced)));
+ SYMBOL_SET_LINKAGE_NAME (sym, SYMNAME_ALLOC (name, symname_alloced));
SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_text_symbol;
SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;