Bug 445235

Summary: Java/Ada/D demangling is probably broken
Product: [Developer tools] valgrind Reporter: Nick Nethercote <n.nethercote>
Component: generalAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal CC: jseward, mark, philippe.waroquiers, pjfloyd
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Bug Depends on: 445184    
Bug Blocks:    

Description Nick Nethercote 2021-11-09 22:52:43 UTC
+++ This bug was initially created as a clone of Bug #445184 +++

Valgrind has code to demangle symbols for: C++, Rust, Java, Ada, and D. But the Java/Ada/D demangling is probably broken because the code is unreachable.

`VG_(demangle)` has an initial test that requires that the first two chars be "_Z" or "_R", which excludes a bunch of cases. Also, the code in `ML_(cplus_demangle)` that calls the demanglers for Java/Ada/D is a bit different to that for C++ and Rust (in the way the `*_DEMANGLING` constants are used), which may also be a problem.

From a quick look at the code, I think the following is true.
- C++ symbols usually start with "_Z", but "_GLOBAL_" is also possible, which won't work.
- Rust symbols start with "_Z" or "_R".
- Java symbols are a subset of C++ symbols, so should be ok, modulo possible "_GLOBAL_" cases, and possible AUTO_DEMANGLING problems.
- D symbols start with "_D", and so will be broken.
- Ada symbols can start with "_ada_", or with a lower-case letter, and so will be broken.
Comment 1 Paul Floyd 2023-01-29 21:09:38 UTC
The D demangling should be fixed (see https://bugs.kde.org/show_bug.cgi?id=464969)