public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove language_demangle
@ 2023-03-29 20:29 Tom Tromey
  2023-03-30 13:57 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2023-03-29 20:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that language_demangle shadows the global
"current_language".  When I went to fix this, though, I then saw that
language_demangle is only called in two places, and has a comment
saying it should be removed.  This patch removes it.  Note that the
NULL check in language_demangle is not needed by either of the
existing callers.

Regression tested on x86-64 Fedora 36.
---
 gdb/gdb-demangle.c |  2 +-
 gdb/language.c     | 15 ---------------
 gdb/language.h     |  5 -----
 gdb/utils.c        |  2 +-
 4 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/gdb/gdb-demangle.c b/gdb/gdb-demangle.c
index 3af3182572b..4bcdd981d97 100644
--- a/gdb/gdb-demangle.c
+++ b/gdb/gdb-demangle.c
@@ -202,7 +202,7 @@ demangle_command (const char *args, int from_tty)
     lang = current_language;
 
   gdb::unique_xmalloc_ptr<char> demangled
-    = language_demangle (lang, name, DMGL_ANSI | DMGL_PARAMS);
+    = lang->demangle_symbol (name, DMGL_ANSI | DMGL_PARAMS);
   if (demangled != NULL)
     gdb_printf ("%s\n", demangled.get ());
   else
diff --git a/gdb/language.c b/gdb/language.c
index 50a53c647f5..fb065ef6a75 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -540,21 +540,6 @@ skip_language_trampoline (frame_info_ptr frame, CORE_ADDR pc)
   return 0;
 }
 
-/* Return demangled language symbol, or NULL.
-   FIXME: Options are only useful for certain languages and ignored
-   by others, so it would be better to remove them here and have a
-   more flexible demangler for the languages that need it.
-   FIXME: Sometimes the demangler is invoked when we don't know the
-   language, so we can't use this everywhere.  */
-gdb::unique_xmalloc_ptr<char>
-language_demangle (const struct language_defn *current_language, 
-				const char *mangled, int options)
-{
-  if (current_language != NULL)
-    return current_language->demangle_symbol (mangled, options);
-  return NULL;
-}
-
 /* Return information about whether TYPE should be passed
    (and returned) by reference at the language level.  */
 
diff --git a/gdb/language.h b/gdb/language.h
index a51ddf97381..57df8acd0a3 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -791,11 +791,6 @@ extern const char *language_str (enum language);
 
 extern CORE_ADDR skip_language_trampoline (frame_info_ptr, CORE_ADDR pc);
 
-/* Return demangled language symbol, or NULL.  */
-extern gdb::unique_xmalloc_ptr<char> language_demangle
-     (const struct language_defn *current_language,
-      const char *mangled, int options);
-
 /* Return information about whether TYPE should be passed
    (and returned) by reference at the language level.  */
 struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
diff --git a/gdb/utils.c b/gdb/utils.c
index 4c7d6657b1f..6ec1cc0d48d 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1909,7 +1909,7 @@ fprintf_symbol (struct ui_file *stream, const char *name,
       else
 	{
 	  gdb::unique_xmalloc_ptr<char> demangled
-	    = language_demangle (language_def (lang), name, arg_mode);
+	    = language_def (lang)->demangle_symbol (name, arg_mode);
 	  gdb_puts (demangled ? demangled.get () : name, stream);
 	}
     }
-- 
2.39.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Remove language_demangle
  2023-03-29 20:29 [PATCH] Remove language_demangle Tom Tromey
@ 2023-03-30 13:57 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2023-03-30 13:57 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 3/29/23 16:29, Tom Tromey wrote:
> I noticed that language_demangle shadows the global
> "current_language".  When I went to fix this, though, I then saw that
> language_demangle is only called in two places, and has a comment
> saying it should be removed.  This patch removes it.  Note that the
> NULL check in language_demangle is not needed by either of the
> existing callers.

Makes sense to me:

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-30 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 20:29 [PATCH] Remove language_demangle Tom Tromey
2023-03-30 13:57 ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).