Function to mangle/demangle functions

Syntax_Error picture Syntax_Error · Feb 9, 2011 · Viewed 13.9k times · Source

I have previously, here, been shown that C++ functions aren't easily represented in assembly. Now I am interested in reading them one way or another because Callgrind, part of Valgrind, show them demangled while in assembly they are shown mangled.

So I would like to either mangle the Valgrind function output or demangle the assembly names of functions. Anyone ever tried something like that? I was looking at a website and found out the following:

Code to implement demangling is part of the GNU Binutils package; 
see libiberty/cplus-dem.c and include/demangle.h.

Has anyone ever tried something like that? I want to demangle/mangle in C.

My compiler is gcc 4.x.

Answer

Eugen Constantin Dinca picture Eugen Constantin Dinca · Feb 9, 2011

Use the c++filt command line tool to demangle the name.