DEMANGLE(1) User Commands DEMANGLE(1)

demangle
demangle symbols

demangle [-l lang] [symbol...]

The demangle utility attempts to detect mangled symbols and transform them back into a more human friendly version of the symbol.

Some languages allow the same identifier to refer to multiple things (functions, variables, etc.) where some additional context such as parameter types, return types, etc. are used to disambiguate between the symbols sharing the same name. When compiling such languages into an executable form, most binary formats do not allow for duplicate symbol names or provide a way to disambiguate between duplicate names.

To solve this problem, many languages will use the additional context from the source code to transform the symbol name into a unique name. This process is called name mangling. While the resulting name is predictable, the mangled names are often difficult for humans to interpret.

The demangle utility can be invoked in one of two ways. In the first method, symbol is demangled and the result is written to standard out, one line per input symbol. If any input symbol cannot be demangled, the original value of symbol is output unchanged. In the second method, demangle reads standard in, and whenever it encounters a potential symbol, it will attempt to replace the symbol in stdandard out with the demangled version. If the symbol cannot be demangled, it is output unchanged.

lang
Treat all potential symbols as symbols from lang. By default, demangle will attempt to detect the language and demangle symbols for all supported languages. Current supported values of lang are:
c++
The C++ mangling format defined by the Itanium ABI. While the mangling format was originally defined for the Itanium processor, g++ and clang use this format for all their supported platforms (including x86 and SPARC).
rust
The legacy rust mangling format.
auto
Attempt to detect the language automatically (default).

The demangle utility exits 0 on success, and >0 if an error occurs.

Example 1 Demangle symbols given as command line arguments.
% demangle '_ZGVN9__gnu_cxx16bitmap_allocatorIwE13_S_mem_blocksE'
guard variable for __gnu_cxx::bitmap_allocator<wchar_t>::_S_mem_blocks
%

Example 2 Demangle symbols from the output of another command.

% grep slice rust.c | head -1
    T("__ZN4core5slice89_$LT$impl$u20$core..iter..traits..IntoIterator$u20$for$u20$$RF$$u27$a$u20$$u5b$T$u5d$$GT$9into_iter17h450e234d27262170E",
% grep slice rust.c | head -1 | demangle
    T("core::slice::<impl core::iter::traits::IntoIterator for &'a [T]>::into_iter::h450e234d27262170",
%

The command line options are not stable. The output is uncommitted.
February 15, 2020 illumos