From: Andrew Burgess <aburgess@redhat.com>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/6] Make "ptype INTERNAL_FUNCTION" in Ada print like other languages
Date: Mon, 13 Feb 2023 16:02:02 +0000 [thread overview]
Message-ID: <878rh1tuyt.fsf@redhat.com> (raw)
In-Reply-To: <20230210233604.2228450-3-pedro@palves.net>
Pedro Alves <pedro@palves.net> writes:
> Currently, printing the type of an internal function in Ada shows
> double <>s, like:
>
> (gdb) with language ada -- ptype $_isvoid
> type = <<internal function>>
>
> while all other languages print it with a single <>, like:
>
> (gdb) with language c -- ptype $_isvoid
> type = <internal function>
>
> I don't think there's a reason that Ada needs to be different. We
> currently print the double <>s because we take this path in
> ada_print_type:
>
> switch (type->code ())
> {
> default:
> gdb_printf (stream, "<");
> c_print_type (type, "", stream, show, level, language_ada, flags);
> gdb_printf (stream, ">");
> break;
>
> ... and the type's name already has the <>s.
>
> Fix this by simply adding an early check for
> TYPE_CODE_INTERNAL_FUNCTION.
I confess, this is not the solution I though you'd go with. I was
expecting you to handle TYPE_CODE_INTERNAL_FUNCTION in the switch, just
to leave things consistent.
I guess it doesn't hurt though, so LGTM.
Thanks,
Andrew
>
> Change-Id: Ic2b6527b9240a367471431023f6e27e6daed5501
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30105
> ---
> gdb/ada-typeprint.c | 7 +++++++
> gdb/testsuite/gdb.base/internal-functions-ptype.exp | 2 --
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
> index e95034c9285..3866b2d35eb 100644
> --- a/gdb/ada-typeprint.c
> +++ b/gdb/ada-typeprint.c
> @@ -941,6 +941,13 @@ ada_print_type (struct type *type0, const char *varstring,
> struct ui_file *stream, int show, int level,
> const struct type_print_options *flags)
> {
> + if (type0->code () == TYPE_CODE_INTERNAL_FUNCTION)
> + {
> + c_print_type (type0, "", stream, show, level,
> + language_ada, flags);
> + return;
> + }
> +
> struct type *type = ada_check_typedef (ada_get_base_type (type0));
> /* If we can decode the original type name, use it. However, there
> are cases where the original type is an internally-generated type
> diff --git a/gdb/testsuite/gdb.base/internal-functions-ptype.exp b/gdb/testsuite/gdb.base/internal-functions-ptype.exp
> index 42caae05aad..748f33a87cd 100644
> --- a/gdb/testsuite/gdb.base/internal-functions-ptype.exp
> +++ b/gdb/testsuite/gdb.base/internal-functions-ptype.exp
> @@ -29,8 +29,6 @@ proc test_ptype_internal_function {} {
> if {$lang == "unknown"} {
> gdb_test "ptype \$_isvoid" \
> "expression parsing not implemented for language \"Unknown\""
> - } elseif {$lang == "ada"} {
> - gdb_test "ptype \$_isvoid" "<<internal function>>"
> } else {
> gdb_test "ptype \$_isvoid" "<internal function>"
> }
> --
> 2.36.0
next prev parent reply other threads:[~2023-02-13 16:02 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 23:35 [PATCH 0/6] Don't throw quit while handling inferior events Pedro Alves
2023-02-10 23:35 ` [PATCH 1/6] Fix "ptype INTERNAL_FUNC" (PR gdb/30105) Pedro Alves
2023-02-13 16:02 ` Andrew Burgess
2023-02-14 15:26 ` Tom Tromey
2023-02-15 21:10 ` Pedro Alves
2023-02-15 22:04 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 2/6] Make "ptype INTERNAL_FUNCTION" in Ada print like other languages Pedro Alves
2023-02-13 16:02 ` Andrew Burgess [this message]
2023-02-14 15:30 ` Tom Tromey
2023-02-15 13:38 ` Pedro Alves
2023-02-15 15:13 ` Pedro Alves
2023-02-15 16:56 ` Tom Tromey
2023-02-15 21:04 ` [PATCH] Move TYPE_CODE_INTERNAL_FUNCTION type printing to common code (was: Re: [PATCH 2/6] Make "ptype INTERNAL_FUNCTION" in Ada print like other languages) Pedro Alves
2023-02-20 15:28 ` Andrew Burgess
2023-02-10 23:36 ` [PATCH 3/6] Add new "$_shell(CMD)" internal function Pedro Alves
2023-02-11 8:02 ` Eli Zaretskii
2023-02-13 15:11 ` Pedro Alves
2023-02-13 15:36 ` Eli Zaretskii
2023-02-13 16:47 ` [PATCH] gdb/manual: Move @findex entries (was: Re: [PATCH 3/6] Add new "$_shell(CMD)" internal function) Pedro Alves
2023-02-13 17:00 ` Eli Zaretskii
2023-02-13 17:27 ` [PATCH 3/6] Add new "$_shell(CMD)" internal function Pedro Alves
2023-02-13 18:41 ` Eli Zaretskii
2023-02-14 15:38 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 4/6] Don't throw quit while handling inferior events Pedro Alves
2023-02-14 15:50 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 5/6] GC get_active_ext_lang Pedro Alves
2023-02-14 15:39 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 6/6] Don't throw quit while handling inferior events, part II Pedro Alves
2023-02-14 15:54 ` Tom Tromey
2023-02-15 21:16 ` Pedro Alves
2023-02-15 21:24 ` Pedro Alves
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=878rh1tuyt.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).