Bug 372182 - Support more languages/demangling styles than just C++ (and Rust)
Summary: Support more languages/demangling styles than just C++ (and Rust)
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: 3.12 SVN
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on: 372120
Blocks:
  Show dependency treegraph
 
Reported: 2016-11-07 14:27 UTC by Mark Wielaard
Modified: 2016-11-07 14:31 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2016-11-07 14:27:35 UTC
+++ This bug was initially created as a clone of Bug #372120 +++

For the below code, the demanglers demangle a non c++ symbol as if it
would be a mangled c++ name.
This was detected on an Ada program (as gnat mangles Ada names by
replacing . by __) but that equally happens on c symbols having 2 underscores.
To reproduce:
gcc -g -o demang demang.c
./vg-in-place --leak-check=full ./demang
==30660== 90 bytes in 9 blocks are definitely lost in loss record 2 of 2
==30660==    at 0x4C27BB5: malloc (vg_replace_malloc.c:299)
==30660==    by 0x400515: main__calling__some(...)(long long,...)(char) (demang.c:7)
==30660==    by 0x40052C: main (demang.c:12)


#include <stdlib.h>
char *v;
void main__calling__some__exec(void)
{  
   int i;
   for (i = 0; i < 10; i++)
      v = malloc(10);
}

main ()
{
   main__calling__some__exec();
}
Comment 1 Mark Wielaard 2016-11-07 14:31:39 UTC
Currently we only support demangling (modern) C++ style symbol demangling (which includes Rust demangling, which is based on C++/gnu_v3 style demangling).

This is because not all demangling styles can be auto-detected (we only handle symbols starting with "_Z" at the moment).

We could detect the language if we have debuginfo from the CU DW_AT_language covering the symbol address. In that case we could set the language style first before calling ML_(cplus_demangle). See demangle.h for the language styles supported.