Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [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

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