From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [pushed 1/2] gdb: make class_name_from_physname return gdb::unique_xmalloc_ptr
Date: Wed, 14 Oct 2026 15:46:01 -0400 [thread overview]
Message-ID: <20261014194606.523510-1-simon.marchi@efficios.com> (raw)
Change language_defn::class_name_from_physname and
cp_class_name_from_physname to return a gdb::unique_xmalloc_ptr<char>
instead of a raw pointer.
Change-Id: Ie050a6f301331232ecee0aa810236889e159055c
---
gdb/c-lang.c | 3 ++-
gdb/cp-support.c | 4 ++--
gdb/cp-support.h | 3 ++-
gdb/dwarf2/read.c | 2 +-
gdb/language.h | 3 ++-
5 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 6bc0782846bc..840320e76cc0 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -953,7 +953,8 @@ class cplus_language : public language_defn
/* See language.h. */
- char *class_name_from_physname (const char *physname) const override
+ gdb::unique_xmalloc_ptr<char> class_name_from_physname
+ (const char *physname) const override
{
return cp_class_name_from_physname (physname);
}
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 2eb4539d7b4a..c386f7fea271 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -714,7 +714,7 @@ mangled_name_to_comp (const char *mangled_name, int options,
/* Return the name of the class containing method PHYSNAME. */
-char *
+gdb::unique_xmalloc_ptr<char>
cp_class_name_from_physname (const char *physname)
{
void *storage = NULL;
@@ -797,7 +797,7 @@ cp_class_name_from_physname (const char *physname)
}
xfree (storage);
- return ret.release ();
+ return ret;
}
/* Return the child of COMP which is the basename of a method,
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index da8e777f516b..87eee25a5798 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -90,7 +90,8 @@ using canonicalization_ftype = const char * (struct type *, void *);
extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string_full
(const char *string, canonicalization_ftype *finder, void *data);
-extern char *cp_class_name_from_physname (const char *physname);
+extern gdb::unique_xmalloc_ptr<char> cp_class_name_from_physname
+ (const char *physname);
extern char *method_name_from_physname (const char *physname);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1fc6d7ffb4f5..aac8f8fa70b5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16279,7 +16279,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
if (linkage_name != NULL)
{
gdb::unique_xmalloc_ptr<char> actual_name
- (cu->language_defn->class_name_from_physname (linkage_name));
+ = cu->language_defn->class_name_from_physname (linkage_name);
const char *name = NULL;
if (actual_name != NULL)
diff --git a/gdb/language.h b/gdb/language.h
index 5f4f28079a4f..0ca7a030a8b2 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -447,7 +447,8 @@ struct language_defn
}
/* Return class name of a mangled method name or NULL. */
- virtual char *class_name_from_physname (const char *physname) const
+ virtual gdb::unique_xmalloc_ptr<char> class_name_from_physname
+ (const char *physname) const
{
return nullptr;
}
base-commit: 91a47f3ae9d6d494b0c794a3ccd81b242bd15b7d
--
2.56.0
next reply other threads:[~2026-10-14 19:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 19:46 Simon Marchi [this message]
2026-10-14 19:46 ` [pushed 2/2] gdb: make gdb_cplus_demangle_print " Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014194606.523510-1-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox