From 3456e70c9d69da8d62a0ea1f8c2e643648afc654 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 4 Oct 2021 08:44:22 -0600 Subject: Use unique_xmalloc_ptr when demangling I noticed that some methods in language_defn could use unique_xmalloc_ptr rather than a plain 'char *'. This patch implements this change, fixing up the fallout and changing gdb_demangle to also return this type. In one spot, std::string is used to simplify some related code, and in another, an auto_obstack is used to avoid manual management. Regression tested on x86-64 Fedora 34. --- gdb/f-lang.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gdb/f-lang.h') diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 1ccdd39..154edfd 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -67,7 +67,8 @@ public: /* See language.h. */ - char *demangle_symbol (const char *mangled, int options) const override + gdb::unique_xmalloc_ptr demangle_symbol (const char *mangled, + int options) const override { /* We could support demangling here to provide module namespaces also for inferiors with only minimal symbol table (ELF symbols). -- cgit v1.1