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: 69706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1832131wrd; Tue, 14 Mar 2023 08:43:32 -0700 (PDT) X-Google-Smtp-Source: AK7set/09MxZnPyzaCiNZX7UiIzYgr+SFW1Z8vlkRr/CIhc3ZskhbcQsWAnusQCVvaa4BqR1SR3f X-Received: by 2002:a17:906:e0a:b0:92b:846d:8928 with SMTP id l10-20020a1709060e0a00b0092b846d8928mr2825858eji.65.1678808612619; Tue, 14 Mar 2023 08:43:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678808612; cv=none; d=google.com; s=arc-20160816; b=mJO9GFA78+Ejg8u034WvR8bl7xvis2m3lqTq9toqLM6pVz4MOjzBapdS4uZuUg2jDy 1+0q8w9mSDKU4qcx0l5uczDE8qZS55RtfGG7jbNDUL/CyHtAKISuQKS/MCjinRLHP/k+ k+6CQqSv/2CKXifYxh4wp1gjvvRP1LtDwsBDyfpvEKSJnezwXD0jhBk5T46VAD4wyl27 EyVN9kbFURS9u61Pyt+hfKOp5gSgH+aO5k3Sl6KCcO/fotXanTycRPmDsQympsXxzOh5 IoSED+HEFcZTgy15hzHiEyW+UGW5XEjgLsHjzECbHXo/xGUtq41nTVLm1mUXXZorCfrR VPlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:cc:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=P+4Ji0A9SH/KinntfDkZ09bcoiGZyygg960Cr2Wx3iY=; b=tl4/mA7Uq4MZyrL/sx4gEzVO8ZaTIQiyuPXhmfa2+l9F6zOCsOvIGsXWu18jBGikn/ eV5cWHejKrtJ8IQNYZAUg3xF91zSlPf0qBW3U5zdR6DMLV1I8Bzotfrv0wPhhHEveHGl X0DxAn3i9YagITsojhUj97SZmtMeoM7I/dsnvpwm++GxJQjpiSOn2xWaxU0MQwjamNIc nSMGjlM5a9Oyxjbo/dqbB00Qo3gImHvGeN+RcOWP6gpQi5fN1L21iBKb7SlKsoerPJET Jivb4M/c03wJhIG6ffHAB0rE0nytXLt6pO0EnNcWRO1xCQgFho6+X+7o8QHkK8UCzEk7 R0sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZYuX2I1F; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qf17-20020a1709077f1100b009236a012047si3916706ejc.591.2023.03.14.08.43.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:43:32 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZYuX2I1F; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BEF03858430 for ; Tue, 14 Mar 2023 15:43:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BEF03858430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678808611; 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=ZYuX2I1F7H8v8DUjL57NfPwL5gfHMBPaNpEKA31ITHqctRyQto0ntVjrHdyXWj7v+ I7M1LC4ClcRfgW3SJBn3rxWztZwtpIYvpaKwXTvfT1RwDhJL+w6yjVsLBKcjldmwi+ JZE4sLJfagqv1o0+xz/mp19l9F2r+BML6+i3fBOw= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760358419977311697?= X-GMAIL-MSGID: =?utf-8?q?1760358419977311697?= 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')