+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
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;
/* 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,
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. */