From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D963F3858D28 for ; Fri, 5 Nov 2021 12:36:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D963F3858D28 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-v4q_wvqBN6SSbCjk-m40sA-1; Fri, 05 Nov 2021 08:36:00 -0400 X-MC-Unique: v4q_wvqBN6SSbCjk-m40sA-1 Received: by mail-wm1-f69.google.com with SMTP id m18-20020a05600c3b1200b0033283ea5facso2576374wms.1 for ; Fri, 05 Nov 2021 05:36:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=r8nk2Rdg/XjYEHO13s+mAS89GDbYbHdZJ8bwavzow9M=; b=H9a/+iYSEW8BvRD86GvfsUhREyp2vGhoRCZPu4EV0qba2OX8hsJSCRfYlKzlqa2rZ0 xebSLHP1IyEGoqrC591v9330XmxfVqycrwyWv03g1F9PeQbyp32xLIdrz60xuv6ZSehG V9M3iQnYvvwQPcK4xPBfr85V/mRIHYDqhqofGuXKltpQFM90bFWpyoUwNsKtHeOjZ7fF hGrAU2gYTXbq6m0PVhkHvw9DBaOZg1/YqtfUsEe4eQZHwqLHGalhMFTEyihPYStj7V39 XCNQNgNfaM6cbnTBPjeeeT2234G71WlpF4myZJdXe71Uawa0JsKH5RvBreSzZai0ECNG wBhQ== X-Gm-Message-State: AOAM532WEKCiGwoc5X0AU/DQtIRxf5ToyhS1bsl6CtligPKSyRL6UgWt 94WddlNj0JI86L63+AGavnH4ze8vKVpWy9j7FddmLq8WQDjGTyuSe1WTAX9VSXu8oRm0AllIQHb nCXp8AesRcd9ffociw7fNdQ== X-Received: by 2002:a7b:c005:: with SMTP id c5mr30025946wmb.150.1636115759574; Fri, 05 Nov 2021 05:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTWv/TynAGCJ76wluv6WAgksyyuVnI1iFPl3hv3smsT4z34fkaU4tjzjnQXkR2CI2ybnaaHA== X-Received: by 2002:a7b:c005:: with SMTP id c5mr30025908wmb.150.1636115759291; Fri, 05 Nov 2021 05:35:59 -0700 (PDT) Received: from localhost (host86-166-129-255.range86-166.btcentralplus.com. [86.166.129.255]) by smtp.gmail.com with ESMTPSA id d11sm7645236wrs.38.2021.11.05.05.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Nov 2021 05:35:58 -0700 (PDT) Date: Fri, 5 Nov 2021 12:35:57 +0000 From: Andrew Burgess To: Christina Schimpe Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/1] gdb: Print cv qualifiers if class attributes are substituted Message-ID: <20211105123557.GB1816063@redhat.com> References: <20211104133048.2588854-1-christina.schimpe@intel.com> MIME-Version: 1.0 In-Reply-To: <20211104133048.2588854-1-christina.schimpe@intel.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 11:57:37 up 4 days, 2:31, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2021 12:36:09 -0000 * Christina Schimpe via Gdb-patches [2021-11-04 14:30:48 +0100]: > Make ptype print const/volatile qualifiers when template or typedef > attributes are substituted. > > For a programm like > ~~~ > template > class Cfoo > { > typedef float myfloat; > public: > DataT me0; > const DataT me1=1; > const myfloat me2=2.0; > }; > > int main() > { > Cfoo cfoo; > return 0; > } > ~~~ > > gdb outputs the following type for cfoo's attributes: > > ~~~ > (gdb) b 14 > Breakpoint 1 at 0x1170: file tmp.cc, line 14. > (gdb) run > Starting program: /tmp > > Breakpoint 1, main () at tmp.cc:14 > 14 return 0; > (gdb) ptype cfoo > type = class Cfoo [with DataT = int] { > public: > DataT me0; > DataT me1; > myfloat me2; > > private: > typedef float myfloat; > } > > ~~~ > > The cv qualifiers (const in this case) are ignored for me1 and me2. > > After: > ~~~ > (gdb) ptype cfoo > type = class Cfoo [with DataT = int] { > public: > DataT me0; > const DataT me1; > const myfloat me2; > > private: > typedef float myfloat; > } > ~~~ > > gdb/ChangeLog: > 2021-10-25 Christina Schimpe > > * gdb/c-typeprint.c: Print cv qualifiers in case of parameter > substitution. > > gdb/testsuite/ChangeLog: > 2021-10-25 Christina Schimpe > > * gdb.cp/ptype-cv-cp.cc: New const and volatile typdef > variables. > * gdb.cp/ptype-cv-cp.exp: Add new tests for new variables. > * gdb.cp/templates.cc: New template class Cfoo with const, > template, typdef and integer attributes. > * gdb.cp/templates.exp: Add new test using ptype and ptype/r > commmands for template class CFoo. > > Signed-off-by: Christina Schimpe > --- > gdb/c-typeprint.c | 1 + > gdb/testsuite/gdb.cp/ptype-cv-cp.cc | 8 ++++-- > gdb/testsuite/gdb.cp/ptype-cv-cp.exp | 6 ++++ > gdb/testsuite/gdb.cp/templates.cc | 14 +++++++++ > gdb/testsuite/gdb.cp/templates.exp | 43 ++++++++++++++++++++++++++-- > 5 files changed, 66 insertions(+), 6 deletions(-) > > diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c > index 5f20233c78..a6228248e9 100644 > --- a/gdb/c-typeprint.c > +++ b/gdb/c-typeprint.c > @@ -119,6 +119,7 @@ c_print_type_1 (struct type *type, > code = type->code (); > if (local_name != NULL) > { > + c_type_print_modifier (type, stream, 0, 1, language); > fputs_filtered (local_name, stream); > if (varstring != NULL && *varstring != '\0') > fputs_filtered (" ", stream); > diff --git a/gdb/testsuite/gdb.cp/ptype-cv-cp.cc b/gdb/testsuite/gdb.cp/ptype-cv-cp.cc > index 9560dfa80b..0c5e10cd84 100644 > --- a/gdb/testsuite/gdb.cp/ptype-cv-cp.cc > +++ b/gdb/testsuite/gdb.cp/ptype-cv-cp.cc > @@ -23,9 +23,11 @@ typedef const volatile_my_int const_volatile_my_int; > > my_int v_my_int (0); > __attribute__((used)) const_my_int v_const_my_int (1); > -volatile_my_int v_volatile_my_int (2); > -const_volatile_my_int v_const_volatile_my_int (3); > -volatile_const_my_int v_volatile_const_my_int (4); > +__attribute__((used)) const my_int v2_const_my_int (2); > +volatile_my_int v_volatile_my_int (3); > +volatile my_int v2_volatile_my_int (4); > +const_volatile_my_int v_const_volatile_my_int (5); > +volatile_const_my_int v_volatile_const_my_int (6); > > int > main () All of these tests pass both before and after this patch, and I don't think these pass through the code you modified. I'm happy for these tests to go in, but I think they should be in a separate commit to make it clear that they are not directly related to the change in this commit. It also seemed odd that you'd not covered: const volatile my_int v_const_volatile_my_int (7); volatile const my_int v_volatile_const_my_int (8); > diff --git a/gdb/testsuite/gdb.cp/ptype-cv-cp.exp b/gdb/testsuite/gdb.cp/ptype-cv-cp.exp > index b3574cbd34..8214e89350 100644 > --- a/gdb/testsuite/gdb.cp/ptype-cv-cp.exp > +++ b/gdb/testsuite/gdb.cp/ptype-cv-cp.exp > @@ -41,3 +41,9 @@ if {[test_compiler_info {gcc-[0-3]-*}] > setup_xfail "gcc/45997" "*-*-*" > } > gdb_test "ptype v_volatile_const_my_int" "type = const volatile int" > + > +gdb_test "ptype v2_const_my_int" "type = const int" > +gdb_test "whatis v2_const_my_int" "type = const my_int" > + > +gdb_test "ptype v2_volatile_my_int" "type = volatile int" > +gdb_test "whatis v2_volatile_my_int" "type = volatile my_int" > diff --git a/gdb/testsuite/gdb.cp/templates.cc b/gdb/testsuite/gdb.cp/templates.cc > index 49cf6b66ef..5e418ed272 100644 > --- a/gdb/testsuite/gdb.cp/templates.cc > +++ b/gdb/testsuite/gdb.cp/templates.cc > @@ -690,6 +690,18 @@ int gf2 (int a) { > > char string[3]; > > +// Template class with typdefs and const attributes Comments should end with '.' unless the test requires otherwise. > +template > +class Cfoo > +{ > + typedef float myfloat; > +public: > + DataT me0; > + const DataT me1=1; > + const myfloat me2=2.0; > + const int me3=0; > +}; > + > > // Template for nested instantiations And here. > > @@ -778,6 +790,8 @@ int main() > sic.spec ('c'); > siip.spec (&x); > > + Cfoo cfoo; > + > Garply f; > Garply fc; > f.x = 13; > diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp > index 388c4f268c..2ca154e4f5 100644 > --- a/gdb/testsuite/gdb.cp/templates.exp > +++ b/gdb/testsuite/gdb.cp/templates.exp > @@ -289,12 +289,12 @@ do_tests > # weren't breakpointing past a point where the below expressions were > # initialized in the actual source. - djb > > -gdb_test "b 770" \ > - "Breakpoint .* at .*, line 770." > +gdb_test "b 782" \ > + "Breakpoint .* at .*, line 782." > > gdb_test "c" \ > "Continuing.*Breakpoint .*" \ > - "continue to line 770" > + "continue to line 782" I've pushed a patch to master to replace this use of a hard-coded line number with gdb_get_line_number. If you rebase your patch you should find this change is no longer needed. > > gdb_test "print fint" \ > "\\$\[0-9\]* = \\{x = 0, t = 0\\}" > @@ -475,6 +475,43 @@ gdb_test_multiple "ptype/r bazint" "ptype bazint" { > } > } > > +# Check cv qualifiers and substitute parameters Add '.' at the end of your comments please. > + > +if {[test_compiler_info {clang-*}]} { > + setup_kfail "llvm/52262 " "*-*-*" > +} > +gdb_test "ptype cfoo" [multi_line \ > +"type = (class |)Cfoo \\\[with DataT = double\\\] \\{" \ > + "\[ \t\]*public:" \ > + "\[ \t\]*DataT me0;" \ > + "\[ \t\]*const DataT me1;" \ > + "\[ \t\]*const myfloat me2;" \ > + "\[ \t\]*const int me3;" \ > + "" \ > + "\[ \t\]*private:" \ > + "\[ \t\]*typedef float myfloat;" \ > +"\\}" \ > +] "print type of cfoo" > + > +# Check cv qualifiers and do not substitute And here. Thanks, Andrew > + > +if {[test_compiler_info {clang-*}]} { > + setup_kfail "llvm/52262 " "*-*-*" > +} > +gdb_test "ptype/r cfoo" [multi_line \ > +"type = (class |)Cfoo \\{" \ > + "\[ \t\]*public:" \ > + "\[ \t\]*double me0;" \ > + "\[ \t\]*const double me1;" \ > + "\[ \t\]*const Cfoo::myfloat me2;" \ > + "\[ \t\]*const int me3;" \ > + "" \ > + "\[ \t\]*private:" \ > + "\[ \t\]*typedef float myfloat;" \ > +"\\}" \ > +] "print raw type of cfoo" > + > + > # ptype Baz > > gdb_test_multiple "ptype/r bazint2" "ptype bazint2" { > -- > 2.25.1 > > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928 >