From patchwork Fri Sep 23 15:50:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 57978 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08A0B3857000 for ; Fri, 23 Sep 2022 15:54:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08A0B3857000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663948476; bh=lfGdwVqNoAA8Mlf0pjh1UPg5gJ/D5iSpDWT6PkThxZM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lvuRa+6MfSvAE80wXCvjYn3n92v6vR68SDfK2SvciKG73ogu30jf5sEdNf+42Vqxx mtub5narKuyBb1jJvTxVgx16ZiIAqMrUnH7u95nxVvv1ISCgcCv7yTPNsizTEzZt38 87lf/VG+5Dreao5m22l0x0tuWFA5IL59+OLwMbnI= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 216A93857B8D for ; Fri, 23 Sep 2022 15:54:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 216A93857B8D Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-WOliSVMiO0GOFj6hyLwD1A-1; Fri, 23 Sep 2022 11:54:11 -0400 X-MC-Unique: WOliSVMiO0GOFj6hyLwD1A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F867185A79C for ; Fri, 23 Sep 2022 15:54:11 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CB44C15BA4; Fri, 23 Sep 2022 15:54:09 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH] Fix printing destructors with void in parameters for clang programs Date: Fri, 23 Sep 2022 17:50:14 +0200 Message-Id: <20220923155013.124413-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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-Patchwork-Original-From: Bruno Larsen via Gdb-patches From: Guinevere Larsen Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" When GDB prints the methods of a C++ class, it will always skip the first parameter, assuming it to be a 'this' pointer. However, when deciding if it should print "void" for the parameters, it disregards the fact that the first parameter was skipped, so if the method only had that parameter, for instance how clang compiles destructors, we'd see ~foo(void) instead of ~foo(). Fix this behavior by explicitly testing if there were 0 arguments. --- There is another possibility for a fix, which is to stop ignoring the first parameter, but there is a comment at that part of the code that says "some compilers may not support artificial parameters". I'm not sure how true that still is, and I would certainly like a solution like that more, since (as keiths points out in here: https://sourceware.org/bugzilla/show_bug.cgi?id=8218) there is no actual rule saying that compilers must use an artificial 'this' as the first parameter. If anyone knows, please share with the class :) --- gdb/c-typeprint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 3a611cdac5d..8e05bdc81fe 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -300,7 +300,7 @@ cp_type_print_method_args (struct type *mtype, const char *prefix, } else if (varargs) gdb_printf (stream, "..."); - else if (language == language_cplus) + else if (language == language_cplus && nargs == 0) gdb_printf (stream, "void"); gdb_printf (stream, ")");