[1/2] Remove uses of fprintf_symbol_filtered

Message ID 20210716194919.3754102-2-tromey@adacore.com
State New
Headers show
Series
  • Fix decoding of some Ada names
Related show

Commit Message

Tom Tromey July 16, 2021, 7:49 p.m.
I believe that many calls to fprintf_symbol_filtered are incorrect.
In particular, there are some that pass a symbol's print name, like:

  fprintf_symbol_filtered (gdb_stdout, sym->print_name (),
			   current_language->la_language, DMGL_ANSI);

fprintf_symbol_filtered uses the "demangle" global to decide whether
or not to demangle -- but print_name does this as well.  This can lead
to double-demangling.  Normally this could be innocuous, except I also
plan to change Ada demangling in a way that causes this to fail.
---
 gdb/printcmd.c              |  3 +--
 gdb/python/py-framefilter.c |  8 ++------
 gdb/stack.c                 | 13 ++++---------
 3 files changed, 7 insertions(+), 17 deletions(-)

-- 
2.26.3

Patch

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 3cd42f817f5..f8a66ca1c86 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1660,8 +1660,7 @@  info_address_command (const char *exp, int from_tty)
     }
 
   printf_filtered ("Symbol \"");
-  fprintf_symbol_filtered (gdb_stdout, sym->print_name (),
-			   current_language->la_language, DMGL_ANSI);
+  fputs_filtered (sym->print_name (), gdb_stdout);
   printf_filtered ("\" is ");
   val = SYMBOL_VALUE (sym);
   if (SYMBOL_OBJFILE_OWNED (sym))
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 54ac907a838..fd0b7f9e1f2 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -348,16 +348,12 @@  py_print_single_arg (struct ui_out *out,
     {
       string_file stb;
 
-      fprintf_symbol_filtered (&stb, fa->sym->print_name (),
-			       fa->sym->language (),
-			       DMGL_PARAMS | DMGL_ANSI);
+      fputs_filtered (fa->sym->print_name (), &stb);
       if (fa->entry_kind == print_entry_values_compact)
 	{
 	  stb.puts ("=");
 
-	  fprintf_symbol_filtered (&stb, fa->sym->print_name (),
-				   fa->sym->language (),
-				   DMGL_PARAMS | DMGL_ANSI);
+	  fputs_filtered (fa->sym->print_name (), &stb);
 	}
       if (fa->entry_kind == print_entry_values_only
 	  || fa->entry_kind == print_entry_values_compact)
diff --git a/gdb/stack.c b/gdb/stack.c
index aa20018ad9f..516e4d45696 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -427,17 +427,14 @@  print_frame_arg (const frame_print_options &fp_opts,
 
   annotate_arg_emitter arg_emitter;
   ui_out_emit_tuple tuple_emitter (uiout, NULL);
-  fprintf_symbol_filtered (&stb, arg->sym->print_name (),
-			   arg->sym->language (), DMGL_PARAMS | DMGL_ANSI);
+  fputs_filtered (arg->sym->print_name (), &stb);
   if (arg->entry_kind == print_entry_values_compact)
     {
       /* It is OK to provide invalid MI-like stream as with
 	 PRINT_ENTRY_VALUE_COMPACT we never use MI.  */
       stb.puts ("=");
 
-      fprintf_symbol_filtered (&stb, arg->sym->print_name (),
-			       arg->sym->language (),
-			       DMGL_PARAMS | DMGL_ANSI);
+      fputs_filtered (arg->sym->print_name (), &stb);
     }
   if (arg->entry_kind == print_entry_values_only
       || arg->entry_kind == print_entry_values_compact)
@@ -1368,8 +1365,7 @@  print_frame (const frame_print_options &fp_opts,
     annotate_frame_function_name ();
 
     string_file stb;
-    fprintf_symbol_filtered (&stb, funname ? funname.get () : "??",
-			     funlang, DMGL_ANSI);
+    fputs_filtered (funname ? funname.get () : "??", &stb);
     uiout->field_stream ("func", stb, function_name_style.style ());
     uiout->wrap_hint ("   ");
     annotate_frame_args ();
@@ -1564,8 +1560,7 @@  info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
   if (funname)
     {
       printf_filtered (" in ");
-      fprintf_symbol_filtered (gdb_stdout, funname, funlang,
-			       DMGL_ANSI | DMGL_PARAMS);
+      fputs_filtered (funname, gdb_stdout);
     }
   wrap_here ("   ");
   if (sal.symtab)