public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pedro Alves <palves@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Make "ptype INTERNAL_FUNCTION" in Ada print like other languages
Date: Wed, 15 Feb 2023 21:01:38 +0000 (GMT)	[thread overview]
Message-ID: <20230215210138.2E0F3385700E@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=751495be92b2b319fb66ce4e12b562a0e27c15fe

commit 751495be92b2b319fb66ce4e12b562a0e27c15fe
Author: Pedro Alves <pedro@palves.net>
Date:   Fri Feb 10 11:55:00 2023 +0000

    Make "ptype INTERNAL_FUNCTION" in Ada print like other languages
    
    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.
    
    Approved-By: Andrew Burgess <aburgess@redhat.com>
    Approved-By: Tom Tromey <tom@tromey.com>
    Change-Id: Ic2b6527b9240a367471431023f6e27e6daed5501
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30105

Diff:
---
 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>"
 	}

                 reply	other threads:[~2023-02-15 21:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230215210138.2E0F3385700E@sourceware.org \
    --to=palves@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /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).