* [pushed 1/2] gdb: make class_name_from_physname return gdb::unique_xmalloc_ptr
@ 2026-10-14 19:46 Simon Marchi
2026-10-14 19:46 ` [pushed 2/2] gdb: make gdb_cplus_demangle_print " Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Simon Marchi @ 2026-10-14 19:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
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
^ permalink raw reply [flat|nested] 2+ messages in thread* [pushed 2/2] gdb: make gdb_cplus_demangle_print return gdb::unique_xmalloc_ptr
2026-10-14 19:46 [pushed 1/2] gdb: make class_name_from_physname return gdb::unique_xmalloc_ptr Simon Marchi
@ 2026-10-14 19:46 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2026-10-14 19:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change gdb_cplus_demangle_print to return a
gdb::unique_xmalloc_ptr<char> instead of a raw pointer.
Change-Id: I116c0e53f504b926848afa9b398c2ddf88dbe0b4
---
gdb/cp-name-parser.c | 5 ++---
gdb/cp-support.c | 7 ++++---
gdb/cp-support.h | 7 +++----
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/gdb/cp-name-parser.c b/gdb/cp-name-parser.c
index 80779fbc6062..fe2ffd61a6c8 100644
--- a/gdb/cp-name-parser.c
+++ b/gdb/cp-name-parser.c
@@ -382,9 +382,8 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len)
{
size_t err;
- char *res = gdb_cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI,
- result, estimated_len, &err);
- return gdb::unique_xmalloc_ptr<char> (res);
+ return gdb_cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, result,
+ estimated_len, &err);
}
/* Merge the two parse trees given by DEST and SRC. The parse tree
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index c386f7fea271..3881d4b4cdeb 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1678,14 +1678,15 @@ gdb_demangle (const char *name, int options)
/* See cp-support.h. */
-char *
+gdb::unique_xmalloc_ptr<char>
gdb_cplus_demangle_print (int options,
struct demangle_component *tree,
int estimated_length,
size_t *p_allocated_size)
{
- return cplus_demangle_print (options | DMGL_VERBOSE, tree,
- estimated_length, p_allocated_size);
+ return gdb::unique_xmalloc_ptr<char>
+ (cplus_demangle_print (options | DMGL_VERBOSE, tree,
+ estimated_length, p_allocated_size));
}
/* A wrapper for cplus_demangle_v3_components that forces
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 87eee25a5798..2263d5b725c0 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -202,10 +202,9 @@ gdb::unique_xmalloc_ptr<char> gdb_demangle (const char *name, int options);
/* A wrapper for cplus_demangle_print. */
-extern char *gdb_cplus_demangle_print (int options,
- struct demangle_component *tree,
- int estimated_length,
- size_t *p_allocated_size);
+extern gdb::unique_xmalloc_ptr<char> gdb_cplus_demangle_print
+ (int options, struct demangle_component *tree, int estimated_length,
+ size_t *p_allocated_size);
/* Find an instance of the character C in the string S that is outside
of all parenthesis pairs, single-quoted strings, and double-quoted
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-14 19:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-14 19:46 [pushed 1/2] gdb: make class_name_from_physname return gdb::unique_xmalloc_ptr Simon Marchi
2026-10-14 19:46 ` [pushed 2/2] gdb: make gdb_cplus_demangle_print " Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox