Use obstack_strdup more
This changes gdb to use obstack_strdup when appropriate, rather than the wordier obstack_copy0. gdb/ChangeLog 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.
This commit is contained in:
parent
b3c6d7ff98
commit
021887d88a
14 changed files with 57 additions and 72 deletions
|
@ -1,3 +1,26 @@
|
|||
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.
|
||||
|
|
|
@ -1395,8 +1395,7 @@ ada_decode_symbol (const struct general_symbol_info *arg)
|
|||
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
|
||||
|
|
|
@ -1031,9 +1031,8 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
|
|||
{
|
||||
/* 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. */
|
||||
|
|
|
@ -2490,15 +2490,14 @@ static const struct token ident_tokens[] =
|
|||
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
|
||||
|
|
|
@ -2019,9 +2019,7 @@ coff_read_struct_type (int index, int length, int lastsym,
|
|||
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);
|
||||
|
@ -2037,9 +2035,7 @@ coff_read_struct_type (int index, int length, int lastsym,
|
|||
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);
|
||||
|
@ -2109,8 +2105,7 @@ coff_read_enum_type (int index, int length, int lastsym,
|
|||
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;
|
||||
|
|
|
@ -9806,9 +9806,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
|
|||
{
|
||||
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;
|
||||
|
@ -11070,9 +11068,7 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu)
|
|||
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;
|
||||
}
|
||||
|
@ -18982,10 +18978,8 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
|
|||
{
|
||||
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;
|
||||
|
@ -19067,10 +19061,7 @@ partial_die_info::fixup (struct dwarf2_cu *cu)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
@ -22725,9 +22716,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
|
|||
|
||||
/* 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);
|
||||
|
||||
|
|
|
@ -700,10 +700,8 @@ 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
|
||||
= (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;
|
||||
|
||||
|
|
|
@ -1066,8 +1066,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
|
|||
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;
|
||||
|
@ -1688,9 +1688,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1726,9 +1724,7 @@ 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)
|
||||
= ((const char *)
|
||||
obstack_copy0 (&mdebugread_objfile->objfile_obstack,
|
||||
name, strlen (name)));
|
||||
= obstack_strdup (&mdebugread_objfile->objfile_obstack, name);
|
||||
}
|
||||
}
|
||||
if (t->bt == btTypedef)
|
||||
|
|
|
@ -87,10 +87,8 @@ add_using_directive (struct using_direct **using_directives,
|
|||
|
||||
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
|
||||
{
|
||||
|
@ -99,15 +97,12 @@ add_using_directive (struct using_direct **using_directives,
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -166,8 +166,7 @@ set_objfile_main_name (struct objfile *objfile,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -356,10 +355,7 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
|
|||
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
|
||||
|
|
|
@ -4293,8 +4293,7 @@ common_block_start (const char *name, struct objfile *objfile)
|
|||
}
|
||||
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. */
|
||||
|
|
|
@ -2882,9 +2882,7 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
|
|||
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";
|
||||
|
||||
|
|
|
@ -325,9 +325,8 @@ typedef_hash_table::find_global_typedef (const struct type_print_options *flags,
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1539,8 +1539,8 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
|
|||
|
||||
|
||||
#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. */
|
||||
|
@ -1586,8 +1586,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue