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.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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678808566; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=P+4Ji0A9SH/KinntfDkZ09bcoiGZyygg960Cr2Wx3iY=; b=M/vd8EO53w89t+glVHPkPUwKAWReu9VXGzxqrMxtF4SugSuq94hCUrK7I7IudcnOb+HzE0 6udm3SAbVC0pWXsSfAXNbmsKsQF6WiqNVQCrW3GD/vY/Q+a1FZrLVfQPL7EoOSsTYZao7i eb89N+B802tbexwS72jibQ3fRyxlxZU= 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 From: Jakub Jelinek 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: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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') Jakub