From patchwork Tue Mar 14 15:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 66378 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 6012E3858417 for ; Tue, 14 Mar 2023 15:43:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6012E3858417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678808596; bh=P+4Ji0A9SH/KinntfDkZ09bcoiGZyygg960Cr2Wx3iY=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=wA/uh7s9q+kwnPOwa6I7tqf/s27VEfzsaV64CJJwRc/DbERAg+J1p/JFWMp4lCAwu GwC1IZj5r7VfqpPIRJ9Jv3UKqsDTHqN/kEqWWW2JEGLIaH3jiQIW8JVjJc/M6SsO6E J4Ir4kvC+08396N+6vsGsEDeIzV04b06T8NeV404= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.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 128C03858D37 for ; Tue, 14 Mar 2023 15:42:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 128C03858D37 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-421-nki3PUCCMa-A6ddnpIkNbA-1; Tue, 14 Mar 2023 11:42:45 -0400 X-MC-Unique: nki3PUCCMa-A6ddnpIkNbA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C3D187A9E3 for ; Tue, 14 Mar 2023 15:42:45 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF12340C6E67; Tue, 14 Mar 2023 15:42:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32EFgbP2654908 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 14 Mar 2023 16:42:42 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32EFgbQB654907; Tue, 14 Mar 2023 16:42:37 +0100 Date: Tue, 14 Mar 2023 16:42:36 +0100 To: Jason Merrill , Jonathan Wakely Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] gdbhooks: Update gdbhooks.py for recent tree_code_type changes [PR108634] Message-ID: References: <20230313201512.151814-1-jason@redhat.com> MIME-Version: 1.0 In-Reply-To: <20230313201512.151814-1-jason@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On Mon, Mar 13, 2023 at 04:15:12PM -0400, Jason Merrill wrote: > The r13-6577 change to use tree_code_type_tmpl in earlier C++ dialects broke > gdbhooks, which expects tree_code_type to always be available. I considered > trying to make gdbhooks more robust, but it seemed simpler to define > tree_code_type as a reference to the template. As I said earlier, I think it is better to tweak gdbhooks. The following patch does that, I've tested it now both with gcc 12 and older gcc as system compiler and the patch fixed the latter while keeping the former working as before. Ok for trunk? 2023-03-14 Jakub Jelinek PR plugins/108634 * gdbhooks.py (TreePrinter.to_string): Wrap gdb.parse_and_eval('tree_code_type') in a try block, parse and eval 'tree_code_type_tmpl<0>::tree_code_type' instead if it raises exception. Update comments for the recent tree_code_type changes. Jakub --- gcc/gdbhooks.py.jj 2023-03-04 11:24:01.348791347 +0100 +++ gcc/gdbhooks.py 2023-03-14 16:35:48.445671242 +0100 @@ -220,13 +220,23 @@ class TreePrinter: val_TREE_CODE = self.node.TREE_CODE() - # extern const enum tree_code_class tree_code_type[]; + # constexpr inline enum tree_code_class tree_code_type[] = { ... }; # #define TREE_CODE_CLASS(CODE) tree_code_type[(int) (CODE)] + # or + # template + # struct tree_code_type_tmpl { + # static constexpr enum tree_code_class tree_code_type[] = { ... }; + # }; }; + # #define TREE_CODE_CLASS(CODE) \ + # tree_code_type_tmpl <0>::tree_code_type[(int) (CODE)] if val_TREE_CODE == 0xa5a5: return '' % intptr(self.gdbval) - val_tree_code_type = gdb.parse_and_eval('tree_code_type') + try: + val_tree_code_type = gdb.parse_and_eval('tree_code_type') + except: + val_tree_code_type = gdb.parse_and_eval('tree_code_type_tmpl<0>::tree_code_type') val_tclass = val_tree_code_type[val_TREE_CODE] val_tree_code_name = gdb.parse_and_eval('tree_code_name')