aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-context.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-21 21:08:26 +0000
committerGitHub <noreply@github.com>2021-06-21 21:08:26 +0000
commitf2d9faf3862a75247adbd6c233c889010902a34b (patch)
tree897ef81f74ded5be76852a100683ee177daaf70f /gcc/rust/backend/rust-compile-context.h
parent470e5144f65433eaf16ef4bb8540390660c8d877 (diff)
parent30d844bf11d4e7d17ea63ae144d1c63090efc3e3 (diff)
downloadgcc-f2d9faf3862a75247adbd6c233c889010902a34b.zip
gcc-f2d9faf3862a75247adbd6c233c889010902a34b.tar.gz
gcc-f2d9faf3862a75247adbd6c233c889010902a34b.tar.bz2
Merge #514
514: Rename tuple field names r=philberty a=tromey 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. Co-authored-by: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r--gcc/rust/backend/rust-compile-context.h11
1 files changed, 9 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));