From patchwork Tue Jan 31 13:22:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 50837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2745894wrn; Tue, 31 Jan 2023 05:19:56 -0800 (PST) X-Google-Smtp-Source: AK7set/qgZ1INbMJ6XexxQO1UmM/S0DAKdukkD6RG8B4KC3VmI56UehLg8Mf7OZyrbvv7sdLgSEP X-Received: by 2002:a05:6402:5:b0:4a2:4ce0:552a with SMTP id d5-20020a056402000500b004a24ce0552amr7477682edu.31.1675171196529; Tue, 31 Jan 2023 05:19:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675171196; cv=none; d=google.com; s=arc-20160816; b=f0ouVJWZAdSbxKKcPWvio2nB8Mz1IpERlCktaX/pYJBoTzZgF+g4tT1nim8NGYUMep FD42MRtebbm5+uBmPMuCQTnGdck+TlhNaeHKQe8zkvR/5ahbgrhL18w8kPNYualzGQ13 YV0mZlV1KlOY6I6eCBLNzrhYGnEqS6aQvZP1UHwtowcH1/Q3AXv8c3mnRFAXUbl5Oa+E 7ugYwbhY+a5hsj4sM4V0zb6sF9enI0oIbvlcAFGMhF7Ps8b+o/LazfQ0qyQYqFPiDUI6 3mHPCntvBlHqaNML2mi9/zF9H6U+WIujpMx1ihTJrCA4A/UEz9iWJXAEbhnUDKWpGoHf 596g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=FPxAp0DEXvGJOgsW1SYRuTDqZP1r++G9wyuQK6PrpqE=; b=znr0Ryc537Qpe/I01IzHFfC19g3nyqTbYYMj5RrjnPc2OrSXGQ2sfU/QVEHSauN8yX 8VaMHj2Nl+DjZewtwS2DJlWCWp9wgvSVfX+QsPNkQzlsuijQZDQ2aIc9uqnQMTo/h8/t 4TCMwaqEhTWKiE1CFBiyW1PEaX9FUa3JTJzkeK/H1lsrIhVFEeE0qcjBiE9amET7/heb Ev1Zta+2YUxHdFrAd5C34H2R2ba8va28hs3MsfL4HX/TEguSfydgX2sVEBjTQRocdS3M JaHrcdZtaXm6dpHOJQ1toBsNSLOtPMTlB+2UyhpicOgRIo3bYA7zIQrCkZls0M0RzuhJ 80gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=SAm2eQ2F; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f5-20020a056402194500b004a1aca719f9si14306946edz.29.2023.01.31.05.19.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:19:56 -0800 (PST) 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=@embecosm.com header.s=google header.b=SAm2eQ2F; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 390AC3851AB8 for ; Tue, 31 Jan 2023 13:19:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 9EE7F3858D33 for ; Tue, 31 Jan 2023 13:19:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9EE7F3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x335.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so12440022wmb.2 for ; Tue, 31 Jan 2023 05:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FPxAp0DEXvGJOgsW1SYRuTDqZP1r++G9wyuQK6PrpqE=; b=SAm2eQ2Fl9KykpIXwU/1ZKqzRGXiQJrEh/h+cObLkA32tkFzJAo77KTb1ZIOpOmt+z ZH+3ZN4QO2nU0nyZA8P6/5f7IpTk8OpzIvOhuBB2H7D/wRA+jfyh/Z65tpSMAERXrxi/ HrlBvGbFEj4PLc1pkygJDIXOXO7OHPf/sDsab+gq9hf9Fs3edN3RYZAJLYWL4pzaG/Oy OPAD0Ff4tG73P+xM4X5+eAANB5dXgHpRpnmkpJrHPCUjOv2tulZH7ptwYEra6cv2Jetn SJ7bzTmv9NmP9tgOMG21Er6Fkf2UMC8mLfC6wAWuikWgdvIPprXBtDz6/2ibeZZjpiYX CxaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FPxAp0DEXvGJOgsW1SYRuTDqZP1r++G9wyuQK6PrpqE=; b=6WxrFwFC38AfQu5cZWhRU4zpBgcsIHs1+Bk8n4Xx9eYMSeeJZzLm2nBqTTOrBvM+vQ J3zgC5Xb6AmtBdZVOHoiqEB5CC+pfniB6hXNKQdWhoImqszU2013JGTAFf0MmI1NviTR G51wf1ozMsT+7+yu+76kTVRnUxudGqHmbn/iWJugalagW3dXQ2QNag+YfXrHXNjCe5Db DFUL8ifr9nZ5MGAbBqh0taef2BUAzW7tLHdXsT6e1uLW0v12hb9qYnu7HBLrHvcx8YuZ p3yA2qHvkLAw6Z1BXDRvydCGaX9Oiw2k19jRELN5Ahrqeu1aey5VEDsUbd8qbFq6sIxW Tltw== X-Gm-Message-State: AO0yUKWbwrUYdINQnDDekUMWzz5dy7W2GZL335FV68J67GwP/VUBckEv FnqDSz3TFbOHvjQaRrLZ2tCCcngDpJkV853ZPQ== X-Received: by 2002:a05:600c:6016:b0:3dc:576c:ab07 with SMTP id az22-20020a05600c601600b003dc576cab07mr8402759wmb.14.1675171157124; Tue, 31 Jan 2023 05:19:17 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id v14-20020a1cf70e000000b003db0b0cc2afsm19869924wmh.30.2023.01.31.05.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:19:16 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [COMMITTED] gccrs: session-manager: Add ast-pretty-expanded dump Date: Tue, 31 Jan 2023 14:22:46 +0100 Message-Id: <20230131132246.660779-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: 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: , 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?1756544312884408849?= X-GMAIL-MSGID: =?utf-8?q?1756544312884408849?= gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Allow the dump of prettified AST (Session::dump_ast_pretty): New * rust-session-manager.h: Add new output file for pretty AST dump Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/rust-session-manager.cc | 10 ++++++++-- gcc/rust/rust-session-manager.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 2b33ddfa601..157f5099155 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -58,6 +58,7 @@ namespace Rust { const char *kLexDumpFile = "gccrs.lex.dump"; const char *kASTDumpFile = "gccrs.ast.dump"; const char *kASTPrettyDumpFile = "gccrs.ast-pretty.dump"; +const char *kASTPrettyDumpFileExpanded = "gccrs.ast-pretty-expanded.dump"; const char *kASTExpandedDumpFile = "gccrs.ast-expanded.dump"; const char *kHIRDumpFile = "gccrs.hir.dump"; const char *kHIRPrettyDumpFile = "gccrs.hir-pretty.dump"; @@ -531,6 +532,7 @@ Session::compile_crate (const char *filename) // dump AST with expanded stuff rust_debug ("BEGIN POST-EXPANSION AST DUMP"); dump_ast_expanded (parser, parsed_crate); + dump_ast_pretty (parsed_crate, true); rust_debug ("END POST-EXPANSION AST DUMP"); } @@ -832,10 +834,14 @@ Session::dump_ast (Parser &parser, AST::Crate &crate) const } void -Session::dump_ast_pretty (AST::Crate &crate) const +Session::dump_ast_pretty (AST::Crate &crate, bool expanded) const { std::ofstream out; - out.open (kASTPrettyDumpFile); + if (expanded) + out.open (kASTPrettyDumpFileExpanded); + else + out.open (kASTPrettyDumpFile); + if (out.fail ()) { rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored", diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index 055aea6b7e6..db915991809 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -319,7 +319,7 @@ private: void dump_lex (Parser &parser) const; void dump_ast (Parser &parser, AST::Crate &crate) const; - void dump_ast_pretty (AST::Crate &crate) const; + void dump_ast_pretty (AST::Crate &crate, bool expanded = false) const; void dump_ast_expanded (Parser &parser, AST::Crate &crate) const; void dump_hir (HIR::Crate &crate) const; void dump_hir_pretty (HIR::Crate &crate) const;