]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Minor 'debug_*' function improvements
authorTom Tromey <tromey@adacore.com>
Wed, 22 Jul 2026 13:19:21 +0000 (07:19 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 7 Aug 2026 13:59:02 +0000 (07:59 -0600)
I wanted to get a summary of a type in gdb and then realized I had
forgotten the function name, so I had to dig around to find it.  This
made me think that perhaps renaming the debug_* functions to all just
be named 'debug' would be an improvement, since it's easier to
remember.

Then I noticed that debug_type and debug_val don't print a trailing
newline.

Finally, I needed to be able to see the contents of a gdb_mpz.

v2 changes these functions to use ATTRIBUTE_USED rather than
ATTRIBUTE_UNUSED, as the former indicates that these should not be
deleted even if apparently unused.

Approved-By: Tom de Vries <tdevries@suse.de>
gdb/expprint.c
gdb/gmp-utils.c
gdb/typeprint.c
gdb/valprint.c

index bc1929b1a1b5f18b0969d73567179600f367cca8..4859d48f6a4ef475bd1db74395fc3cd083be3138 100644 (file)
 
 
 /* Meant to be used in debug sessions, so don't export it in a header file.  */
-extern void ATTRIBUTE_USED debug_exp (struct expression *exp);
+extern void ATTRIBUTE_USED debug (struct expression *exp);
 
 /* Print EXP.  */
 
 void
 ATTRIBUTE_USED
-debug_exp (struct expression *exp)
+debug (struct expression *exp)
 {
   exp->dump (gdb_stdlog);
   gdb_flush (gdb_stdlog);
index 168479c50df5cdd7c1b87a77d48ecc118043e828..b7fed9a82d154aa0f1dadd45d42b3f4954c70ff3 100644 (file)
@@ -39,6 +39,18 @@ gmp_string_printf (const char *fmt, ...)
   return str;
 }
 
+/* Meant to be used in debug sessions, so don't export it in a header file.  */
+extern void ATTRIBUTE_USED debug (const gdb_mpz &);
+
+/* Print VAL.  */
+
+void ATTRIBUTE_USED
+debug (const gdb_mpz &val)
+{
+  gdb_printf (gdb_stdlog, "%s\n", val.str ().c_str ());
+  gdb_flush (gdb_stdlog);
+}
+
 /* See gmp-utils.h.  */
 
 void
index 31a9c1814a31be722c6fdc47c7b9c8c9341d4df8..7d1ebc6fdca1c899d486449b70122fc5d2aa9a8f 100644 (file)
@@ -516,14 +516,15 @@ ptype_command (const char *type_name, int from_tty)
 }
 
 /* Meant to be used in debug sessions, so don't export it in a header file.  */
-extern void ATTRIBUTE_UNUSED debug_type (struct type *type);
+extern void ATTRIBUTE_USED debug (struct type *type);
 
 /* Print TYPE.  */
 
-void ATTRIBUTE_UNUSED
-debug_type (struct type *type)
+void ATTRIBUTE_USED
+debug (struct type *type)
 {
   type_print (type, "", gdb_stdlog, 1);
+  gdb_printf (gdb_stdlog, "\n");
   gdb_flush (gdb_stdlog);
 }
 
index 50a4663ca3b5361d0498ec6ea39ea542afeb4700..3e7a37338b3667f535eafa2f2e671be6db880d7a 100644 (file)
@@ -1232,14 +1232,15 @@ value_print (struct value *val, struct ui_file *stream,
 }
 
 /* Meant to be used in debug sessions, so don't export it in a header file.  */
-extern void ATTRIBUTE_UNUSED debug_val (struct value *val);
+extern void ATTRIBUTE_USED debug (struct value *val);
 
 /* Print VAL.  */
 
-void ATTRIBUTE_UNUSED
-debug_val (struct value *val)
+void ATTRIBUTE_USED
+debug (struct value *val)
 {
   value_print (val, gdb_stdlog, &user_print_options);
+  gdb_printf (gdb_stdlog, "\n");
   gdb_flush (gdb_stdlog);
 }