From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Minor 'debug_*' function improvements
Date: Fri, 7 Aug 2026 08:56:44 +0200 [thread overview]
Message-ID: <271db128-b510-4d26-9567-3c0eff498f24@suse.de> (raw)
In-Reply-To: <20260806203039.1140017-1-tromey@adacore.com>
On 8/6/26 10:30 PM, Tom Tromey wrote:
> 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.
Hi Tom,
thanks for doing this.
No further comments.
Approved-By: Tom de Vries <tdevries@suse.de>
Thanks,
- Tom
> ---
> gdb/expprint.c | 4 ++--
> gdb/gmp-utils.c | 12 ++++++++++++
> gdb/typeprint.c | 7 ++++---
> gdb/valprint.c | 7 ++++---
> 4 files changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/gdb/expprint.c b/gdb/expprint.c
> index bc1929b1a1b..4859d48f6a4 100644
> --- a/gdb/expprint.c
> +++ b/gdb/expprint.c
> @@ -35,13 +35,13 @@
>
>
> /* 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);
> diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c
> index 168479c50df..b7fed9a82d1 100644
> --- a/gdb/gmp-utils.c
> +++ b/gdb/gmp-utils.c
> @@ -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
> diff --git a/gdb/typeprint.c b/gdb/typeprint.c
> index 31a9c1814a3..7d1ebc6fdca 100644
> --- a/gdb/typeprint.c
> +++ b/gdb/typeprint.c
> @@ -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);
> }
>
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index 50a4663ca3b..3e7a37338b3 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -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);
> }
>
>
> base-commit: 035b2e70824ab51ec4d6754345456622c618b450
prev parent reply other threads:[~2026-08-07 6:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 20:30 Tom Tromey
2026-08-07 6:56 ` Tom de Vries [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=271db128-b510-4d26-9567-3c0eff498f24@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox