aboutsummaryrefslogtreecommitdiff
path: root/gdb/minsyms.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-10-04 08:44:22 -0600
committerTom Tromey <tromey@adacore.com>2021-10-04 13:45:38 -0600
commit3456e70c9d69da8d62a0ea1f8c2e643648afc654 (patch)
tree7959a8dc460685d2e8e3197478eddb4430d48708 /gdb/minsyms.c
parente133de4984cef9acb32fd756c607aa2fa1d090fb (diff)
downloadgdb-3456e70c9d69da8d62a0ea1f8c2e643648afc654.zip
gdb-3456e70c9d69da8d62a0ea1f8c2e643648afc654.tar.gz
gdb-3456e70c9d69da8d62a0ea1f8c2e643648afc654.tar.bz2
Use unique_xmalloc_ptr<char> when demangling
I noticed that some methods in language_defn could use unique_xmalloc_ptr<char> 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.
Diffstat (limited to 'gdb/minsyms.c')
-rw-r--r--gdb/minsyms.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 33560e3..5f4cf54 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1473,10 +1473,11 @@ minimal_symbol_reader::install ()
if (!msym->name_set)
{
/* This will be freed later, by compute_and_set_names. */
- char *demangled_name
+ gdb::unique_xmalloc_ptr<char> demangled_name
= symbol_find_demangled_name (msym, msym->linkage_name ());
msym->set_demangled_name
- (demangled_name, &m_objfile->per_bfd->storage_obstack);
+ (demangled_name.release (),
+ &m_objfile->per_bfd->storage_obstack);
msym->name_set = 1;
}
/* This mangled_name_hash computation has to be outside of