From 906bb4c58faa8e2c1c62e295f8054e75e910e5e8 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 24 Apr 2020 15:35:01 -0600 Subject: [PATCH] Fix Rust test cases PR rust/25025 notes that some Rust test cases fail. Debugging gdb revealed that the Rust compiler emits different linkage names that demangle to the same result. Enabling complaints when reading the test case is enough to show it: During symbol reading: Computed physname > does not match demangled (from linkage <_ZN8generics8identity17h8540b320af6656d6E>) - DIE at 0x424 [in module /home/tromey/gdb/build/gdb/testsuite/outputs/gdb.rust/generics/generics] During symbol reading: Computed physname > does not match demangled (from linkage <_ZN8generics8identity17hae302fad0c33bd7dE>) - DIE at 0x459 [in module /home/tromey/gdb/build/gdb/testsuite/outputs/gdb.rust/generics/generics] ... This patch changes the DWARF reader to prefer the computed physname, rather than the output of the demangler, for Rust. This fixes the bug. gdb/ChangeLog 2020-04-24 Tom Tromey PR rust/25025: * dwarf2/read.c (dwarf2_physname): Do not demangle for Rust. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2/read.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 829c0770a1..e1c64ab770 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-04-24 Tom Tromey + + PR rust/25025: + * dwarf2/read.c (dwarf2_physname): Do not demangle for Rust. + 2020-04-24 Tom Tromey PR symtab/12707: diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 613c3cd71a..976261372b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -10318,7 +10318,8 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu) if (!die_needs_namespace (die, cu)) return dwarf2_compute_name (name, die, cu, 1); - mangled = dw2_linkage_name (die, cu); + if (cu->language != language_rust) + mangled = dw2_linkage_name (die, cu); /* DW_AT_linkage_name is missing in some cases - depend on what GDB has computed. */ -- 2.34.1