From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id E7EF7395B452 for ; Tue, 6 Dec 2022 10:11:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E7EF7395B452 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-wr1-x42d.google.com with SMTP id bs21so22754009wrb.4 for ; Tue, 06 Dec 2022 02:11:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=s8t7Tga+8hKOzjz6OoMX7Kspwdfvk82RZ+fgDlBONnE=; b=XZmB4MF8RewX///+VEEPDuIxu608lpfAT/Fqb0u4hEu+xlrS5AG/an6f5voMPizni7 o1JaC4ePhBBHYV6zkkcS8yZKdy7HTUT7bBegihIvcEm6lMajlBMitFlCmo8q8/CMpZHP cGBlYuAicW8v9gQD0WxxSShEbLL7qklyLfkEAYD1+VT/aosX0GAQBjM3U0EcdkT9OcuD Z3eMycbC0MXYIsJd/t4WYMFLBJMCckt72qbS1nqAQrWdi2haGjZtKchcDBXvab8zj7Yh r6/AQge7cwL0I23xQKNOEJtKTP/j1xMGoa7q43IQMWggptexuG9llaGubwV8sQZYw8n6 eZ9Q== 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:subject:date:message-id:reply-to; bh=s8t7Tga+8hKOzjz6OoMX7Kspwdfvk82RZ+fgDlBONnE=; b=NETCU2iIUrBAtwhx4RoHK2rJFU67M22b4x4QJ7xFWHJThitGqWeYK6fxB1pmokN6Go MudttIovqImSzfEF4kj/AM5iBK1kgClPZGp9wHC3LdbcjjyDRNfsb7C1ba8rksrqC5Th p+bepw/vsAJZtxXtMiGREdJryQQWDju6cWYM0/fQl2YewadadWyXTSgfszzmAD1868UP M8M6JKsw+30Rr+uli0QhPKrtDSYUwYHBMtIzeYiD3uZDsNuA8ul0fNDIcAPIMeVUh41O o/C3AYHQ306FrWfwDG6z9R5Bf0GCYHR0AuU99dnUf3dBecP5Xw93SK54Ic8cUApO9cCf XGgQ== X-Gm-Message-State: ANoB5pk305wv9NkdvzuoVgoG72bXOjHLTkhzsGhdD4RVaOY3Nzbdxbok xUDCgkruoaiySx63A+xeXp6u X-Google-Smtp-Source: AA0mqf4b4QBSR4+0iGxIPDOpmaAdBAahQZxS94IXGbCd0/MPmY+wDxqRKLKJ2Ac3Cu0zND2w2nw71Q== X-Received: by 2002:a5d:53c4:0:b0:242:1f22:df3b with SMTP id a4-20020a5d53c4000000b002421f22df3bmr20543058wrw.679.1670321506647; Tue, 06 Dec 2022 02:11:46 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.googlemail.com with ESMTPSA id r10-20020a05600c458a00b003cfd4a50d5asm27052699wmo.34.2022.12.06.02.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 02:11:46 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Philip Herron , Tom Tromey , Mark Wielaard , =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Subject: [PATCH Rust front-end v4 03/46] gccrs: Add Debug info testsuite Date: Tue, 6 Dec 2022 11:13:35 +0100 Message-Id: <20221206101417.778807-4-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206101417.778807-1-arthur.cohen@embecosm.com> References: <20221206101417.778807-1-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-50.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,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 List-Id: From: Philip Herron This testsuite is specifically about testcases which scan the asm debug info for results. Co-authored-by: Tom Tromey Co-authored-by: Mark Wielaard Co-authored-by: Marc Poulhiès --- 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..648d6b78f06 --- /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" } +// Strict DWARF < 5 uses DW_LANG_C = 0x0002 +// { dg-final { scan-assembler "0x2\[ \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); +} -- 2.38.1