diff options
author | Tom Tromey <tom@tromey.com> | 2021-06-20 18:01:18 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-06-21 14:07:20 -0600 |
commit | 30d844bf11d4e7d17ea63ae144d1c63090efc3e3 (patch) | |
tree | 3386d73cfd50696ab0bfd1daf353e74ec7e0952d | |
parent | 8528f4b25f59cf10c093715d56f7a37c4ab6b732 (diff) | |
download | gcc-30d844bf11d4e7d17ea63ae144d1c63090efc3e3.zip gcc-30d844bf11d4e7d17ea63ae144d1c63090efc3e3.tar.gz gcc-30d844bf11d4e7d17ea63ae144d1c63090efc3e3.tar.bz2 |
Rename tuple field names
Tuples currently use plain integer field names in the DWARF. However,
rustc prefixes these with "__", and GDB understands this convention.
This patch changes gccrs to match, and adds an explanatory comment.
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 11 | ||||
-rw-r--r-- | gcc/testsuite/rust/debug/tuple.rs | 8 |
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 5df0d89..5bd1e96 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Free Software Foundation, Inc. +// Copyright (C) 2020, 2021 Free Software Foundation, Inc. // This file is part of GCC. @@ -439,7 +439,14 @@ public: TyTy::BaseType *field = type.get_field (i); Btype *compiled_field_ty = TyTyResolveCompile::compile (ctx, field); - Backend::Btyped_identifier f (std::to_string (i), compiled_field_ty, + // rustc uses the convention __N, where N is an integer, to + // name the fields of a tuple. We follow this as well, + // because this is used by GDB. One further reason to prefer + // this, rather than simply emitting the integer, is that this + // approach makes it simpler to use a C-only debugger, or + // GDB's C mode, when debugging Rust. + Backend::Btyped_identifier f ("__" + std::to_string (i), + compiled_field_ty, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); diff --git a/gcc/testsuite/rust/debug/tuple.rs b/gcc/testsuite/rust/debug/tuple.rs new file mode 100644 index 0000000..e51a5ff --- /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" } } */ +} |