From c16652f3e43726f62dc0a1f70f8cfcab9f5bc117 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 18 Jun 2021 10:10:29 -0600 Subject: Use DW_LANG_Rust in DWARF This changes the GCC DWARF emitterto use DW_LANG_Rust or DW_LANG_Rust_old as appropriate. --- gcc/dwarf2out.c | 7 +++++++ gcc/testsuite/rust/debug/debug.exp | 33 +++++++++++++++++++++++++++++++++ gcc/testsuite/rust/debug/lang.rs | 6 ++++++ gcc/testsuite/rust/debug/oldlang.rs | 6 ++++++ 4 files changed, 52 insertions(+) create mode 100644 gcc/testsuite/rust/debug/debug.exp create mode 100644 gcc/testsuite/rust/debug/lang.rs create mode 100644 gcc/testsuite/rust/debug/oldlang.rs (limited to 'gcc') diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 395170a..7252887 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -24634,6 +24634,13 @@ gen_compile_unit_die (const char *filename) } else if (strcmp (language_string, "GNU F77") == 0) language = DW_LANG_Fortran77; + else if (strcmp (language_string, "GNU Rust") == 0) + { + if (dwarf_version >= 5 || !dwarf_strict) + language = DW_LANG_Rust; + else + language = DW_LANG_Rust_old; + } else if (dwarf_version >= 3 || !dwarf_strict) { if (strcmp (language_string, "GNU Ada") == 0) diff --git a/gcc/testsuite/rust/debug/debug.exp b/gcc/testsuite/rust/debug/debug.exp new file mode 100644 index 0000000..7de43e6 --- /dev/null +++ b/gcc/testsuite/rust/debug/debug.exp @@ -0,0 +1,33 @@ +# Copyright (C) 2021 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/lang.rs b/gcc/testsuite/rust/debug/lang.rs new file mode 100644 index 0000000..eec5264 --- /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\[^\n\r]* DW_AT_language" } } */ +} diff --git a/gcc/testsuite/rust/debug/oldlang.rs b/gcc/testsuite/rust/debug/oldlang.rs new file mode 100644 index 0000000..d80a5db --- /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\[^\n\r]* DW_AT_language" } } */ +} -- cgit v1.1