From: Tom Tromey Date: Mon, 21 Jan 2013 18:10:33 +0000 (+0000) Subject: * dwarf2read.c (fixup_go_packaging): Save package name X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=86f62fd71f25a7f64ff0f7747df29c3488269116;p=binutils-gdb.git * dwarf2read.c (fixup_go_packaging): Save package name on objfile obstack. * gdbtypes.c (init_type): Don't copy name. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 941902b6773..b5fd8eeb9f2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2013-01-21 Tom Tromey + + * dwarf2read.c (fixup_go_packaging): Save package name + on objfile obstack. + * gdbtypes.c (init_type): Don't copy name. + 2013-01-21 Tom Tromey * dwarf2read.c (struct partial_die_info) : Now diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 81d3cf96d63..76d469c7ee2 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -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; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 6a4b152bc22..12730d7b12b 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -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. */