From patchwork Wed Aug 24 11:59:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: herron.philip@googlemail.com X-Patchwork-Id: 703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1383655wro; Wed, 24 Aug 2022 05:04:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4AdpzBRZUOQO7rmAu4P4XgZn0ZDmxmkbwvtzAPCU+in5id9bmInbGyIBJXuFjQxwQ8vj+u X-Received: by 2002:a17:907:2c75:b0:73d:c6de:f144 with SMTP id ib21-20020a1709072c7500b0073dc6def144mr131197ejc.256.1661342693867; Wed, 24 Aug 2022 05:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661342693; cv=none; d=google.com; s=arc-20160816; b=xtVN2MSmCKGrrYv4CV6zIcv1mB+D8sT1XcoLgoi7MN3k1+YYXfVvklON0Sl1VF2VPy f4Xo9tTNQcziiNe2DwQXm55Q/BY0yHgPF814t1fVFiyUFJdhvwIf//luqr2dFJl9ICct /oG7trL4Iz1rJt/ys2EY9iCpoqar/1LI83PHMI2CkRe1tlnH7honFeaPCMwa3MgX7+9x h4NqC8gTiRAajaKrOzY7TDaHu6Z/L/VnJMBNUdGjNp1c34CqnDacFjZBRCYtMMB8p8b5 FoyWhpGNkHOiTVhMDXqjxir/ee+NEDWXuTqteKF3EPWG/K3rL2wD30Tbe5wZur/aCefE QvTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature:dmarc-filter :delivered-to; bh=p4JDD1WbIQhaecFaGqVIjJdoG7TAeLt5iH/ZmRxdkuI=; b=TWJcPMDoPPWeAyKdhq76xRHYnPwJ+aQtYIgolOZgg2pZouBYvx2qqPq6B56IBXIYry c6hgzX+Ay2b9XGEgyPM+d/8zQVHtHNHLhODDagF9TvtsFI+F3gVCLwt0bImsoa4zQMIV 6m+osPpbYCNlCg09maJxWxVWy97okhDAQrN7rhApzOVi63n3TncYQmJIzqPj3kUGZfRW dzBdxWwK0bohMtd/7qfIY0MvSDVs4a65zdW4Lh5Cb4b7si5+2bNpiuEfRbNOlJ+Nk1sm FuW1Kb6ujECrMeLFNVelNA9EJpAszwrw60bjELLOhqZGuQOxM4Rha4tgHIgLhRmXHoYo Byug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20210112 header.b=QJ6iqqxl; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v7-20020a056402348700b0044671cc4913si4979489edc.72.2022.08.24.05.04.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:04:53 -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=@googlemail.com header.s=20210112 header.b=QJ6iqqxl; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E34D3394C82D for ; Wed, 24 Aug 2022 12:01:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 7CF6A385023F; Wed, 24 Aug 2022 12:00:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CF6A385023F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=googlemail.com Received: by mail-wm1-x330.google.com with SMTP id j26so8670933wms.0; Wed, 24 Aug 2022 05:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc; bh=p4JDD1WbIQhaecFaGqVIjJdoG7TAeLt5iH/ZmRxdkuI=; b=QJ6iqqxlyOcyK1bIntgZo2xuWktOsaorFHi4/9iwAOMAT6YnUh3Sxdo3qz5h+/DJ+r FIpPgfpZRq0+gjGFZ2mR5BlXJ4Sj7//eUXQTthloyCbO9DPOIaUyCbbxXRH/SIycvBKF Wo3tCwtBGViyD0gyn1ZMRbVp0O7vQ6WOA1QK2D2BFaef5tivsnXRFaX5ODxR1cdXH2iD SB4+X9Q0MjMuXJuxchPB2jFrthiFMRs6NSiHeH262I+Nt7VaUftRfglWAdY79n3xL8FQ 4K1Fot7que1SwLJDuDzz03K7fMUxaMPNPD1UHdoVBiQdFNqngSERw6D2UXnZVxy7l4Um VAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc; bh=p4JDD1WbIQhaecFaGqVIjJdoG7TAeLt5iH/ZmRxdkuI=; b=nJBgEQ67mEcKOXRSc2EJrdB+P3VT6j0pDVQaWhSXAGchtWN2FjlPGtvK03knpzwX2T HPtj3uKUTQLfUUCm2uM7JEA9g9C2HbQLVShpxR8Y0I/EndA2buXFuprDg9eqrT9jqoIt h+xxnyw28Jf9oY/EhVQ3Yir3vIoRM+lIDGbgxZ7wI9xAZje9r9aAJzvha6PS/UvsGPxJ tz+3gDctdRGmzggzFgZ5i4vHYf7Nq0fJC3Wb3pvq6E7SWyfaJ59o/9Jo96ISkO1N4+FR PBKrFhu+qCcSKjaIyjGqs9czvlIrOMzDbmCwHolUEESKa9K7bWWyeCbOOeGF3mq9Oxfj zQVQ== X-Gm-Message-State: ACgBeo3VhJXqJ1xcSuSkj3tHzgq1pQ7B3XZMfZzvuK+z8EptsLWsLr2C 3lmqjGst/iKDcD5f2klBjmfC6TyIs04= X-Received: by 2002:a1c:7916:0:b0:3a6:3540:5b3c with SMTP id l22-20020a1c7916000000b003a635405b3cmr4923175wme.178.1661342428057; Wed, 24 Aug 2022 05:00:28 -0700 (PDT) Received: from localhost.localdomain ([86.14.124.218]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0022571d43d32sm1697676wrb.21.2022.08.24.05.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:00:27 -0700 (PDT) From: herron.philip@googlemail.com X-Google-Original-From: philip.herron@embecosm.com To: gcc-patches@gcc.gnu.org Subject: [PATCH Rust front-end v2 03/37] gccrs: Add Debug info testsuite Date: Wed, 24 Aug 2022 12:59:22 +0100 Message-Id: <20220824115956.737931-4-philip.herron@embecosm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824115956.737931-1-philip.herron@embecosm.com> References: <20220824115956.737931-1-philip.herron@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Reply-To: philip.herron@embecosm.com Cc: gcc-rust@gcc.gnu.org, Philip Herron , Tom Tromey 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?1742044076257586723?= X-GMAIL-MSGID: =?utf-8?q?1742044076257586723?= From: Philip Herron This testsuite is specifically about testcases which scan the asm debug info for results. Co-authored-by: Tom Tromey --- gcc/testsuite/rust/debug/chartype.rs | 10 ++++++ .../rust/debug/custom_link_section.rs | 13 ++++++++ gcc/testsuite/rust/debug/debug.exp | 33 +++++++++++++++++++ gcc/testsuite/rust/debug/i8u8.rs | 12 +++++++ gcc/testsuite/rust/debug/lang.rs | 6 ++++ gcc/testsuite/rust/debug/no_mangle.rs | 17 ++++++++++ gcc/testsuite/rust/debug/oldlang.rs | 6 ++++ gcc/testsuite/rust/debug/tuple.rs | 8 +++++ gcc/testsuite/rust/debug/win64-abi.rs | 11 +++++++ 9 files changed, 116 insertions(+) create mode 100644 gcc/testsuite/rust/debug/chartype.rs create mode 100644 gcc/testsuite/rust/debug/custom_link_section.rs create mode 100644 gcc/testsuite/rust/debug/debug.exp create mode 100644 gcc/testsuite/rust/debug/i8u8.rs create mode 100644 gcc/testsuite/rust/debug/lang.rs create mode 100644 gcc/testsuite/rust/debug/no_mangle.rs create mode 100644 gcc/testsuite/rust/debug/oldlang.rs create mode 100644 gcc/testsuite/rust/debug/tuple.rs create mode 100644 gcc/testsuite/rust/debug/win64-abi.rs diff --git a/gcc/testsuite/rust/debug/chartype.rs b/gcc/testsuite/rust/debug/chartype.rs new file mode 100644 index 00000000000..69e7ab0b17f --- /dev/null +++ b/gcc/testsuite/rust/debug/chartype.rs @@ -0,0 +1,10 @@ +// 'char' should use DW_ATE_UTF +fn main () { + let c = 'x'; +// { dg-do compile } +// Use -w to avoid warnings about the unused variables +// DW_ATE_UTF entered in DWARF 4. +// { dg-options "-w -gdwarf-4 -dA" } +// DW_ATE_UTF = 0x10 +// { dg-final { scan-assembler "0x10\[ \t]\[^\n\r]* DW_AT_encoding" } } */ +} diff --git a/gcc/testsuite/rust/debug/custom_link_section.rs b/gcc/testsuite/rust/debug/custom_link_section.rs new file mode 100644 index 00000000000..142f3513136 --- /dev/null +++ b/gcc/testsuite/rust/debug/custom_link_section.rs @@ -0,0 +1,13 @@ +#[link_section = ".universe"] +fn not_in_text() -> i32 { + 42 +} + +fn main() -> i32 { +// { dg-do compile } +// { dg-options "-gdwarf-5 -dA -w" } + not_in_text(); +// { dg-final { scan-assembler ".universe" } } */ + + 0 +} diff --git a/gcc/testsuite/rust/debug/debug.exp b/gcc/testsuite/rust/debug/debug.exp new file mode 100644 index 00000000000..c71b5930d90 --- /dev/null +++ b/gcc/testsuite/rust/debug/debug.exp @@ -0,0 +1,33 @@ +# Copyright (C) 2021-2022 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# Debugging tests. + +# Load support procs. +load_lib rust-dg.exp + +# Initialize `dg'. +dg-init + +# Main loop. +set saved-dg-do-what-default ${dg-do-what-default} + +set dg-do-what-default "compile" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.rs]] "" "" +set dg-do-what-default ${saved-dg-do-what-default} + +# All done. +dg-finish diff --git a/gcc/testsuite/rust/debug/i8u8.rs b/gcc/testsuite/rust/debug/i8u8.rs new file mode 100644 index 00000000000..1cd21a4a8ff --- /dev/null +++ b/gcc/testsuite/rust/debug/i8u8.rs @@ -0,0 +1,12 @@ +// i8 and u8 types should not have the DWARF 'char' encoding. +fn main () { + let x : i8 = 5; + let y : u8 = 7; +// { dg-do compile } +// Use -w to avoid warnings about the unused variables +// { dg-options "-w -g -dA" } +// DW_ATE_signed_char = 6 +// { dg-final { scan-assembler-not "0x6\[ \t]\[^\n\r]* DW_AT_encoding" } } */ +// DW_ATE_unsigned_char = 8 +// { dg-final { scan-assembler-not "0x8\[ \t]\[^\n\r]* DW_AT_encoding" } } */ +} diff --git a/gcc/testsuite/rust/debug/lang.rs b/gcc/testsuite/rust/debug/lang.rs new file mode 100644 index 00000000000..12e0b587a02 --- /dev/null +++ b/gcc/testsuite/rust/debug/lang.rs @@ -0,0 +1,6 @@ +fn main () { +// { dg-do compile } +// { dg-options "-gdwarf-5 -dA" } +// DW_LANG_Rust is 0x1c +// { dg-final { scan-assembler "0x1c\[ \t]\[^\n\r]* DW_AT_language" } } */ +} diff --git a/gcc/testsuite/rust/debug/no_mangle.rs b/gcc/testsuite/rust/debug/no_mangle.rs new file mode 100644 index 00000000000..0cef40482f4 --- /dev/null +++ b/gcc/testsuite/rust/debug/no_mangle.rs @@ -0,0 +1,17 @@ +#[no_mangle] +fn do_not_mangle() -> i32 { + 0 +} + +fn please_mangle() {} + +fn main() { +// { dg-do compile } +// { dg-options "-gdwarf-5 -dA" } + let _ = do_not_mangle(); + please_mangle(); +// look for unmangled function name: +// { dg-final { scan-assembler "do_not_mangle:" } } */ +// look for legacy mangled function name: +// { dg-final { scan-assembler "13please_mangle" } } */ +} diff --git a/gcc/testsuite/rust/debug/oldlang.rs b/gcc/testsuite/rust/debug/oldlang.rs new file mode 100644 index 00000000000..ddacf0e4392 --- /dev/null +++ b/gcc/testsuite/rust/debug/oldlang.rs @@ -0,0 +1,6 @@ +fn main () { +// { dg-do compile } +// { dg-options "-gstrict-dwarf -gdwarf-3 -dA" } +// DW_LANG_Rust_old is 0x9000 +// { dg-final { scan-assembler "0x9000\[ \t]\[^\n\r]* DW_AT_language" } } */ +} diff --git a/gcc/testsuite/rust/debug/tuple.rs b/gcc/testsuite/rust/debug/tuple.rs new file mode 100644 index 00000000000..e51a5ffdbb6 --- /dev/null +++ b/gcc/testsuite/rust/debug/tuple.rs @@ -0,0 +1,8 @@ +fn main () { +// { dg-do compile } +// { dg-options "-gdwarf-5 -dA -w" } + let x = (32, 32); +// Look for field __0 and __1 +// { dg-final { scan-assembler "__0" } } */ +// { dg-final { scan-assembler "__1" } } */ +} diff --git a/gcc/testsuite/rust/debug/win64-abi.rs b/gcc/testsuite/rust/debug/win64-abi.rs new file mode 100644 index 00000000000..b2b08cd5114 --- /dev/null +++ b/gcc/testsuite/rust/debug/win64-abi.rs @@ -0,0 +1,11 @@ +// { dg-do compile { target { x86_64-*-* } } } +// { dg-options "-gdwarf-5 -dA -w -O1 -m64" } +pub extern "win64" fn square(num: i32) -> i32 { + num * num +} + +fn main() { + // MS ABI dictates that the first argument is ecx instead of edi from the sysv world + // { dg-final { scan-assembler "%ecx, %ecx" } } + square(1); +}