From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by sourceware.org (Postfix) with ESMTPS id 512FC3858D35 for ; Wed, 15 Feb 2023 15:13:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 512FC3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f43.google.com with SMTP id j29-20020a05600c1c1d00b003dc52fed235so1788514wms.1 for ; Wed, 15 Feb 2023 07:13:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JlCeWOxcYKJ5crLFBDbLbWRdf8pRQ/IftNKzQ784nUQ=; b=y1ZFR6X8LrF3a62eT5rC+5CUm3Y1Nunc8UBKGSGEMgzvyiUUU1r/DXtTPCmTxk3i9D 9zaFIQ7sZWSwo0MeCAPjKD8NvHgMDwibwwadoXL6ctf82HW+b5StyH8YGPkQj3KTpecK RMxMUeET3lMmWPmEvfSDWoMbERFf1WATbEXPzaNqcGCDEYum+7rRuy6VJQaoewgAE4lL imG+NQxmQcy7xEUzV+76gfsGMGRXRK0Fp0/meGMBa70988rg6eTJlqtxoLwOYKCmlzF+ Y43cPQCX5PjTeVA8FFRGTwWuLJ/C2GZjLHfCa0rv0yls9hGhjRCR2Q/gwreFiSI7aOB9 rt8g== X-Gm-Message-State: AO0yUKWu3FFd/k3sZTPUNV7VaVE6vOd8oZvwZs3Wst75oVL+Cd5OUOo7 9JjrgZHcp8ca3jecHmStkQqOurCO0ePfEg== X-Google-Smtp-Source: AK7set/cWEP5SHRwgKYs9CSP1GedwJT4LynvvfqhhvAq/tqvbfIkyDivYUHiPWQz66ZcFmxjWrcf9Q== X-Received: by 2002:a05:600c:130e:b0:3e0:9fe:34dd with SMTP id j14-20020a05600c130e00b003e009fe34ddmr2205315wmf.4.1676474013424; Wed, 15 Feb 2023 07:13:33 -0800 (PST) Received: from ?IPv6:2001:8a0:f92b:9e00::1fe? ([2001:8a0:f92b:9e00::1fe]) by smtp.gmail.com with ESMTPSA id u22-20020a05600c211600b003e2058a7109sm1649890wml.14.2023.02.15.07.13.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Feb 2023 07:13:33 -0800 (PST) Subject: Re: [PATCH 2/6] Make "ptype INTERNAL_FUNCTION" in Ada print like other languages From: Pedro Alves To: Tom Tromey , Andrew Burgess via Gdb-patches Cc: Andrew Burgess References: <20230210233604.2228450-1-pedro@palves.net> <20230210233604.2228450-3-pedro@palves.net> <878rh1tuyt.fsf@redhat.com> <87y1p0tgcb.fsf@tromey.com> <0165619c-2905-d164-954b-8a0237d1072b@palves.net> Message-ID: <749baf4d-111c-2229-42b2-69d81abfab09@palves.net> Date: Wed, 15 Feb 2023 15:13:30 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <0165619c-2905-d164-954b-8a0237d1072b@palves.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-02-15 1:38 p.m., Pedro Alves wrote: > On 2023-02-14 3:30 p.m., Tom Tromey wrote: > >>>> Fix this by simply adding an early check for >>>> TYPE_CODE_INTERNAL_FUNCTION. >> >> Andrew> I confess, this is not the solution I though you'd go with. I was >> Andrew> expecting you to handle TYPE_CODE_INTERNAL_FUNCTION in the switch, just >> Andrew> to leave things consistent. >> >> I think this would be better. > > My point with adding this check early is that these functions' type never > has anything to do with Ada, so all that code at the beginning of ada_print_type, > like decoded_type_name, ada_is_aligner_type, ada_is_constrained_packed_array_type, > etc. is always a nop for internal functions, so might as well skip it all. > > I actually started out by considering moving TYPE_CODE_INTERNAL_FUNCTION printing > to common code (say, rename the virtual language_defn::print_type to do_print_type, > and add a new non-virtual wrapper language_defn::print_type method and print > TYPE_CODE_INTERNAL_FUNCTION there), and I didn't pursue that as I couldn't really convince > myself that a different language might want to print it differently (say, some other > characters instead of "<>"), and I guess that's why I ended up with putting it at the start > of the function, as that is the closest to putting it at the caller instead. > Here's the alternative patch handling TYPE_CODE_INTERNAL_FUNCTION in the switch. WDYT? From: Pedro Alves Subject: [PATCH 2/6] 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 = <> while all other languages print it with a single <>, like: (gdb) with language c -- ptype $_isvoid type = 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 making ada_print_type handle TYPE_CODE_INTERNAL_FUNCTION. Change-Id: Ic2b6527b9240a367471431023f6e27e6daed5501 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30105 --- gdb/ada-typeprint.c | 3 +++ gdb/testsuite/gdb.base/internal-functions-ptype.exp | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index e95034c9285..e094bc4c9f4 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -991,6 +991,9 @@ ada_print_type (struct type *type0, const char *varstring, c_print_type (type, "", stream, show, level, language_ada, flags); gdb_printf (stream, ">"); break; + case TYPE_CODE_INTERNAL_FUNCTION: + c_print_type (type, "", stream, show, level, language_ada, flags); + break; case TYPE_CODE_PTR: case TYPE_CODE_TYPEDEF: /* An __XVL field is not truly a pointer, so don't print 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" "<>" } else { gdb_test "ptype \$_isvoid" "" } base-commit: 5036bde964bc1a18282dde536a95aecd0d2c08fb -- 2.36.0