* dwarf2read.c (fixup_go_packaging): Save package name

on objfile obstack.
	* gdbtypes.c (init_type): Don't copy name.
This commit is contained in:
Tom Tromey 2013-01-21 18:10:33 +00:00
parent 15d034d05c
commit 86f62fd71f
3 changed files with 16 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2013-01-21 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (fixup_go_packaging): Save package name
on objfile obstack.
* gdbtypes.c (init_type): Don't copy name.
2013-01-21 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (struct partial_die_info) <name, scope>: Now

View File

@ -6803,15 +6803,19 @@ 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);
struct type *type = init_type (TYPE_CODE_MODULE, 0, 0,
package_name, objfile);
saved_package_name, objfile);
struct symbol *sym;
TYPE_TAG_NAME (type) = TYPE_NAME (type);
sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
SYMBOL_SET_LANGUAGE (sym, language_go);
SYMBOL_SET_NAMES (sym, package_name, strlen (package_name), 1, objfile);
SYMBOL_SET_NAMES (sym, saved_package_name,
strlen (saved_package_name), 0, objfile);
/* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
e.g., "main" finds the "main" module and not C's main(). */
SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;

View File

@ -1950,10 +1950,9 @@ allocate_gnat_aux_type (struct type *type)
/* Helper function to initialize the standard scalar types.
If NAME is non-NULL, then we make a copy of the string pointed
to by name in the objfile_obstack for that objfile, and initialize
the type name to that copy. There are places (mipsread.c in particular),
where init_type is called with a NULL value for NAME). */
If NAME is non-NULL, then it is used to initialize the type name.
Note that NAME is not copied; it is required to have a lifetime at
least as long as OBJFILE. */
struct type *
init_type (enum type_code code, int length, int flags,
@ -1991,9 +1990,7 @@ init_type (enum type_code code, int length, int flags,
if (flags & TYPE_FLAG_GNU_IFUNC)
TYPE_GNU_IFUNC (type) = 1;
if (name)
TYPE_NAME (type) = obsavestring (name, strlen (name),
&objfile->objfile_obstack);
TYPE_NAME (type) = name;
/* C++ fancies. */