From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by sourceware.org (Postfix) with ESMTPS id D129F3858C55 for ; Thu, 29 Sep 2022 20:02:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D129F3858C55 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-wr1-f44.google.com with SMTP id c11so3770909wrp.11 for ; Thu, 29 Sep 2022 13:02:05 -0700 (PDT) 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:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date; bh=jE0MiFY14ocJayu+3ZtGEqiZZKAuLRGF4kCJ7KI2a04=; b=GCG+tn7lcf5vD1AQEm2gbLB73pnYeeR8Xq9O9F2JvgODaBpydSVDwh/a2XFTyouZ2t Clroq6CUHrG/zFuK7PpQvOZPR4B11CU8hlLGL6HeRMphpMEWfdyspRrFs8DXuwfHp4hV AdzE13gEAWRAQJGXhFq48SDMhWk+EKgrwC0kNkYIXQ4T78EG87pRawPiJwD5I8kAArJb a/Z2sdxFh+NqIGfs9gZ6MR292GaoTVKAheHo9dtP6G5QzYcmeIZryStRvJNx5M7XYyBz HciSqA7tzDc/aGVu0uTLKUZ8sdCcbcxU07q9X5ZsTMrhgk0tFjsxlv5jkTTkRjhT7cG8 GnPw== X-Gm-Message-State: ACrzQf1Lk2+cwDWI3P33CmAANbbpDh0YS321wBk19QguMh4xbrk743j3 FuyTOfCOOmX1Mze2X+kJX18= X-Google-Smtp-Source: AMsMyM7KoyknzWUSZzn1aINiCrOWTn9V3L3ayyMfbMRIXYgPTgHcekpbX6ugputKvrILPfybhJH1BA== X-Received: by 2002:a05:6000:156e:b0:226:f190:448b with SMTP id 14-20020a056000156e00b00226f190448bmr3707048wrz.573.1664481724658; Thu, 29 Sep 2022 13:02:04 -0700 (PDT) Received: from ?IPv6:2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653? ([2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653]) by smtp.gmail.com with ESMTPSA id j11-20020a056000124b00b0022a3517d3besm303424wrx.5.2022.09.29.13.02.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Sep 2022 13:02:03 -0700 (PDT) Subject: Re: [PATCH][gdb/c++] Print destructor the same for gcc and clang To: Tom de Vries , gdb-patches@sourceware.org References: <20220927103546.GA27362@delia.home> From: Pedro Alves Message-ID: <506885b4-6ba7-6950-12ad-eae4afb0c543@palves.net> Date: Thu, 29 Sep 2022 21:01:58 +0100 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: <20220927103546.GA27362@delia.home> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, 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 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: Thu, 29 Sep 2022 20:02:07 -0000 On 2022-09-27 11:35 a.m., Tom de Vries wrote: > > Note that I consider the discussion of whether we want to print: > - A(void) / ~A(void), or > - A() / ~A() > out-of-scope for this patch. > I'd vote to remove the void. I can't think of a good reason to keep it (for C++). It just looks odd to C++ developers, IMHO. I'm fine with that being a separate decision from this patch, though. > diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c > index 3a611cdac5d..23e8a5a4d6f 100644 > --- a/gdb/c-typeprint.c > +++ b/gdb/c-typeprint.c > @@ -273,35 +273,44 @@ cp_type_print_method_args (struct type *mtype, const char *prefix, > language_cplus, DMGL_ANSI); > gdb_puts ("(", stream); > > - /* Skip the class variable. We keep this here to accommodate older > - compilers and debug formats which may not support artificial > - parameters. */ > - i = staticp ? 0 : 1; > - if (nargs > i) > + int printed_args = 0; > + for (i = 0; i < nargs; ++i) > { > - while (i < nargs) > + if (i == 0 && !staticp) > { > - struct field arg = args[i++]; > - > - /* Skip any artificial arguments. */ > - if (FIELD_ARTIFICIAL (arg)) > - continue; > + /* Skip the class variable. We keep this here to accommodate older > + compilers and debug formats which may not support artificial > + parameters. */ > + continue; > + } A remark on this preexisting "Skip the class variable." logic -- I strongly suspect that we'll need to revisit it for the C++23 "deducing this" feature: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0847r6.html With that feature, some methods we'll have explicit, named "this" parameters, and thus, I'd think, be non-artificial. E.g., from the proposal: struct X { void foo(this X const& self, int i); template void bar(this Self&& self); }; Plainly skipping printing the "self" parameter in these methods just because it is a non-static method, and "self" is the first parameter, will be incorrect. According to: https://gcc.gnu.org/projects/cxx-status.html https://clang.llvm.org/cxx_status.html neither GCC not Clang support that yet though. We don't have tests for many of the C++14, C++17 and C++20 features, so I'm not holding my breath waiting for tests for this, though. :-P > +++ b/gdb/testsuite/gdb.cp/print-method-args.exp > @@ -0,0 +1,36 @@ > +# Copyright (C) 2022 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# This file is part of the gdb testsuite. > + Can you add an intro comment? LGTM with that fixed.