• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

third_party/H26-Feb-2018-

LICENSEH A D26-Feb-201811.1 KiB

README.mdH A D26-Feb-20182.5 KiB

RELEASINGH A D26-Feb-2018697

demumble.ccH A D26-Feb-20184.3 KiB

demumble_test.pyH A D26-Feb-20182.1 KiB

README.md

1# demumble
2
3`demumble` demangles both POSIX and Visual Studio symbols. It runs on both
4POSIX and Windows.
5
6    $ ./demumble _Z4funcPci
7    func(char*, int)
8    $ ./demumble "?Fx_i@@YAHP6AHH@Z@Z"
9    int __cdecl Fx_i(int (__cdecl*)(int))
10
11## Download
12
13There are prebuilt x64 binaries for Linux, Mac (10.9+), and Windows on the
14[releases page](https://github.com/nico/demumble/releases).
15
16## But why
17
18It has several nice features that c++filt lacks (and lacks many of c++filt's
19features I never use).
20
21Smart about underscores: C++ symbols have an additional leading underscore on
22OS X. `operator new` is mangled as `_Znw` on Linux but `__Znw` on Mac. OS X's
23c++filt automatically strips one leading underscore, but Linux's c++filt
24doesn't. So if you want to demangle a Linux symbol on OS X, you need to pass
25`-n` to tell it to not strip the underscore, and if you want to demangle an OS
26X symbol on Linux you likewise need to pass `-_`. demumble just does the right
27thing:
28
29    $ c++filt _Znw
30    _Znw
31    $ c++filt __Znw
32    operator new
33    $ demumble _Znw
34    operator new
35    $ demumble __Znw
36    operator new
37
38Smart about filtering: Both c++filt and demumble can work as a stdin filter.
39demumble only demangles function symbols (which never look like other words),
40while c++filt defaults to demangling type names too, which are likely to look
41like regular words. demumble does demangle types when they're passed as args:
42
43    $ echo 'I like Pi and _Znw' | c++filt
44    I like int* and _Znw
45    $ echo 'I like Pi and _Znw' | demumble
46    I like Pi and operator new
47    $ c++filt Pi
48    int*
49    $ demumble Pi
50    int*
51
52Cross-platform: demumble runs on Windows. demumble can demangle Windows-style
53symbols (also when running on non-Windows).
54
55    $ demumble '??2@YAPEAX_K@Z'
56    void * __ptr64 __cdecl operator new(unsigned __int64)
57    $ c++filt '??2@YAPEAX_K@Z'
58    ??2@YAPEAX_K@Z
59
60demumble also has a flag to make it print only things that look like symbols.
61For example, print demangled names of all functions defined in a bitcode file:
62
63    $ grep '^define' bitcode-win.ll  | demumble -m | head -1
64    unsigned int __cdecl v8::RoundUpToPowerOfTwo32(unsigned int)
65
66## Build instructions
67
68Use cmake to build: `cmake -G Ninja && ninja`
69
70Run tests after building: `python demumble_test.py`
71
72`cxa_demangle.cpp` needs more C++11 than Visual Studio 2013 supports, so
73to build on Windows you need to use Visual Studion 2015 or use clang-cl
74as C++ compiler like so:
75
76    cmake -G Ninja -DCMAKE_CXX_COMPILER=path/to/llvm-build/bin/clang-cl.exe
77