From 30d844bf11d4e7d17ea63ae144d1c63090efc3e3 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 20 Jun 2021 18:01:18 -0600 Subject: 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. --- gcc/rust/backend/rust-compile-context.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gcc/rust/backend') 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)); -- cgit v1.1