}
/* Possibly undo (1) */
+ // - C++ mangled symbols start with "_Z" (possibly with exceptions?)
+ // - Rust "legacy" mangled symbols start with "_Z".
+ // - Rust "v0" mangled symbols start with "_R".
+ // XXX: the Java/Rust/Ada demangling here probably doesn't work. See
+ // https://bugs.kde.org/show_bug.cgi?id=445235 for details.
if (do_cxx_demangling && VG_(clo_demangle)
- && orig != NULL && orig[0] == '_' && orig[1] == 'Z') {
+ && orig != NULL && orig[0] == '_' && (orig[1] == 'Z' || orig[1] == 'R')) {
/* !!! vvv STATIC vvv !!! */
static HChar* demangled = NULL;
/* !!! ^^^ STATIC ^^^ !!! */
--- /dev/null
+// Valgrind supports demangling Rust symbols (both the "v0" and "legacy"
+// mangling schemes), but we don't want to add a dependency on the Rust
+// compiler for a single test. So this is a C program with function names that
+// are mangled Rust symbols. In the output, they become demangled Rust names.
+// It's a hack, but a useful one.
+
+#include <stdlib.h>
+
+// A v0 symbol that demangles to: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver>
+int _RINvYNtNtCs4uGc65yWeeX_12rustc_middle2ty13PredicateKindNtNtB5_4fold12TypeFoldable9fold_withNtNtNtCsgI90OQiJWEs_11rustc_infer5infer7resolve24OpportunisticVarResolverECsdozMG8X9FIu_21rustc_trait_selection(int *p)
+{
+ return *p ? 1 : 2;
+}
+
+// A v0 symbol that demangles to: rustc_expand::mbe::macro_parser::parse_tt
+int _RNvNtNtCsaqSe1lZGvEL_12rustc_expand3mbe12macro_parser8parse_tt(int* p)
+{
+ return _RINvYNtNtCs4uGc65yWeeX_12rustc_middle2ty13PredicateKindNtNtB5_4fold12TypeFoldable9fold_withNtNtNtCsgI90OQiJWEs_11rustc_infer5infer7resolve24OpportunisticVarResolverECsdozMG8X9FIu_21rustc_trait_selection(p);
+}
+
+// A legacy symbol that demangles to: core::str::lossy::Utf8Lossy::from_bytes
+int _ZN4core3str5lossy9Utf8Lossy10from_bytes17heb1677c8cb728b0bE(int* p)
+{
+ return _RNvNtNtCsaqSe1lZGvEL_12rustc_expand3mbe12macro_parser8parse_tt(p);
+}
+
+int main(void)
+{
+ return _ZN4core3str5lossy9Utf8Lossy10from_bytes17heb1677c8cb728b0bE(malloc(sizeof(int)));
+}
+
--- /dev/null
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver> (demangle-rust.c:12)
+ by 0x........: rustc_expand::mbe::macro_parser::parse_tt (demangle-rust.c:18)
+ by 0x........: core::str::lossy::Utf8Lossy::from_bytes (demangle-rust.c:24)
+ by 0x........: main (demangle-rust.c:29)
+