123

I'm getting a fairly long and confusing link error, and would love it if I could just paste it into some textbox on some website and have the names un-mangled for me.

Does anyone know of such a service?

Roman Starkov
  • 59,298
  • 38
  • 251
  • 324

5 Answers5

165

I have created such an online serivice: https://demangler.com

This is a gcc c++ symbol demangler. You just copy a stack trace, or the output of nm into a text box, and it will return the output with the names demangled.

@Update: It now demangles MSVC and Java symbols also.

Rafael Baptista
  • 11,181
  • 5
  • 39
  • 59
  • This one worked for me, but not the one in the more popular answer: _ZN9cdnalizer11rewriteHTMLINS_6apache8IteratorEcEET_RKSsRKNS_6ConfigES3_S3_St8functionIFS3_RKS3_SB_EES9_IFvSsEE – matiu Dec 28 '13 at 06:52
  • Your demangler cannot demangle ref qualifiers for Itanium. I am looking at _ZNR4test1fEv generated by Clang. – Puppy Jun 20 '14 at 20:53
  • Thanks, nice site! Could you please add `white-space: normal` or similar to the responseSection
     tag (and maybe add line numbers)? Long one-line output isn't readable currently.
    – jplatte Jun 22 '14 at 13:20
  • 1
    You should be careful. Most real-world implementations of demanglers are horribly buggy and insecure. They basically only work on mangled names that the same platform produced, but may run into high complexity or flat out memory errors on general inputs. – Kerrek SB Mar 29 '17 at 00:07
  • Nice site. Have you considered making it "reactive"? Needing to re-paste mangled names on every submission gets cumbersome. You could probably just recompute on every change too. – Cameron Tacklind Feb 18 '22 at 23:15
  • Link broken... :( – Devolus Mar 05 '22 at 13:28
  • site no longer up – BLuFeNiX May 04 '22 at 19:55
  • It been up for many years - and is up now. Very occasionally the site is down for a few minutes. Whenever that happens it tends to generate comments on SO. – Rafael Baptista May 10 '22 at 01:05
  • 3
    @RafaelBaptista understood. Also, just to let you know, your site's certificate is expired :) – BLuFeNiX Jun 06 '22 at 17:51
  • It did not translate `__unwindfunclet` to `~` for destructor (MSVC-2015, delete this comment once fixed). Still better than the other answer, which just says "Not a mangled C++ symbol". – Top-Master Sep 22 '22 at 13:05
  • 1
    The hacker's solution (in the sense of "it's a hack, but it works") is to substitute the mangled name into `extern "C" int YOURNAMEHERE = 0;` on Godbolt and then "Output > Demangle identifiers" in the assembly output. For example: https://godbolt.org/z/Mvh3xaoY8 (Works only for Itanium ABI, I suppose; MSVC's mangled names aren't valid identifiers.) – Quuxplusone Jan 03 '23 at 18:07
  • Link broken (bad ssl cert) – scrutari Mar 13 '23 at 15:31
111

I created one based on this question. It works with the inputs I tried on, supports g++ and msvc++ via __cxa_demangle and __unDName, compiled to Javascript via Emscripten.

Here it is: c++filtjs.

starball
  • 20,030
  • 7
  • 43
  • 238
nattofriends
  • 1,235
  • 2
  • 10
  • 5
  • 7
    Awesome! Thank you! Perhaps mention "Online C++ name demangler" somewhere on the page, so that people can find you via Google? – Roman Starkov Mar 19 '12 at 10:55
  • Is it possible to extend this tool for other OS? I wanted to particularly look forward to port it for AIX, Solaris and HPUX – Abhijit Oct 11 '12 at 07:47
  • very nice indeed, but I would like a small C source instead. – Zibri May 03 '13 at 18:55
  • 3
    @Zibri: a "small C source" is not online. For that, use the existing c++filt and undname utilities. – nattofriends May 03 '13 at 21:23
  • @Abhijit: It's not about an OS, it's about _toolchains_. g++ and msvc++ for instance. – Mooing Duck May 24 '13 at 17:27
  • 1
    @nattofriends: Your tool doesn't seem to escape brackets, see `??_R3?$KxSet@V?$KxSpe@DI@@I@@8`. – Mooing Duck May 24 '13 at 17:33
  • @nattofriends Template parameters seem to be lost in cases such as `_Z6kernelIfLj3EEvPT_5arrayIPKS0_XT0_EES5_S2_IjXT0_EES6_S0_`, although for `_Z8positionILj3EE5arrayIjXT_EERKS1_` the parameter of the function *is* displayed properly (probably because it starts with a number and therefore can't be an html tag) – Joe Jul 18 '13 at 11:34
  • 1
    Jup, definitely the escaping, just added [htmlEncode.js](http://www.tumuski.com/code/htmlencode/) and replaced `$("#out").html("
    "+out+"
    ");` by `$("#out").html("
    "+htmlEncode(out)+"
    ");` and now templates are displayed correctly
    – Joe Jul 18 '13 at 11:42
  • Thanks Joe, I'll do that soon. – nattofriends Jul 18 '13 at 18:22
  • 2
    It would be very helpful if you could fix your issue with templates that others have mentioned. This has caused at least one [spurious question](http://stackoverflow.com/questions/21284752/g-name-mangling-slightly-different) on SO. – Shafik Yaghmour Jan 22 '14 at 15:01
39

Many C++ compilers come with a built-in tool which does precisely what you are looking for:

Per Lundberg
  • 3,837
  • 1
  • 36
  • 46
Dummy00001
  • 16,630
  • 5
  • 41
  • 63
  • I want it with minimum effort as opposed to with a mouse click :) Oh well, I don't need it very often anyway. – Roman Starkov Jun 09 '10 at 14:09
  • 6
    my usual use case for c++filt is `objdump -dr ./AClass.o | c++filt | less` (disassembler) or `nm ./AClass.o | c++filt | less` (list of symbols inside of the object file) – Dummy00001 Jun 09 '10 at 14:46
  • 5
    Most compilers aren't GCC. Compilers that aren't GCC do not ship c++filt. By induction, most compilers do not ship c++filt. – IInspectable Aug 01 '19 at 15:10
  • 1
    `echo "" | c++filt` – Aaron Swan Dec 23 '20 at 23:02
  • 5
    **GCC**: [`c++filt`](https://sourceware.org/binutils/docs/binutils/c_002b_002bfilt.html) **Clang/LLVM**: [`llvm-cxxfilt`](https://llvm.org/docs/CommandGuide/llvm-cxxfilt.html) **MSVC**: [`undname`](https://learn.microsoft.com/en-us/cpp/build/reference/decorated-names#Undecorated). – Cameron Tacklind Feb 18 '22 at 23:38
  • Thanks @CameronTacklind, I edited this into the answer now to make it even more useful. – Per Lundberg Aug 17 '23 at 19:11
11

There are two copy-and-paste online solutions:

If you only need support for GCC and Clang, you also have the option of using Coliru, which is probably the most versatile online C++ compiler.

This is not quite as simple as cut, paste, and click - but not too much harder - and it looks like there are no issues with template parameters as was noted above. You just need to modify the command line to run something like this:

cat main.cpp | c++filt -t

See it live with this example which demangles:

_Z6kernelIfLj3EEvPT_5arrayIPKS0_XT0_EES5_S2_IjXT0_EES6_S0_

to:

void kernel<float, 3u>(float*, array<float const*, 3u>, array<float const*, 3u>, array<unsigned int, 3u>, array<unsigned int, 3u>, float)
           ^^^^^^^^^^^
Community
  • 1
  • 1
Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
2

FYI, there's also a Ruby gem to demangle Borland/MS/whatever mangled names: unmangler

zed_0xff
  • 32,417
  • 7
  • 53
  • 72