+/* Initialize the cplus_specific structure. 'cplus_specific' should
+ only be allocated for use with cplus symbols. */
+
+static void
+symbol_init_cplus_specific (struct general_symbol_info *gsymbol,
+ struct objfile *objfile)
+{
+ /* A language_specific structure should not have been previously
+ initialized. */
+ gdb_assert (gsymbol->language_specific.cplus_specific == NULL);
+ gdb_assert (objfile != NULL);
+
+ gsymbol->language_specific.cplus_specific =
+ OBSTACK_ZALLOC (&objfile->objfile_obstack, struct cplus_specific);
+}
+
+/* Set the demangled name of GSYMBOL to NAME. NAME must be already
+ correctly allocated. For C++ symbols a cplus_specific struct is
+ allocated so OBJFILE must not be NULL. If this is a non C++ symbol
+ OBJFILE can be NULL. */
+void
+symbol_set_demangled_name (struct general_symbol_info *gsymbol,
+ char *name,
+ struct objfile *objfile)
+{
+ if (gsymbol->language == language_cplus)
+ {
+ if (gsymbol->language_specific.cplus_specific == NULL)
+ symbol_init_cplus_specific (gsymbol, objfile);
+
+ gsymbol->language_specific.cplus_specific->demangled_name = name;
+ }
+ else
+ gsymbol->language_specific.mangled_lang.demangled_name = name;
+}
+
+/* Return the demangled name of GSYMBOL. */
+char *
+symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
+{
+ if (gsymbol->language == language_cplus)
+ {
+ gdb_assert (gsymbol->language_specific.cplus_specific != NULL);
+ return gsymbol->language_specific.cplus_specific->demangled_name;
+ }
+ else
+ return gsymbol->language_specific.mangled_lang.demangled_name;
+}
+