How can i demangle name in MSVC? There's abi::__cxa_demangle function in gcc. In MSDN i've found UnDecorateSymbolName:
http://msdn.microsoft.com/ru-ru/library/windows/desktop/ms681400%28v=vs.85%29.aspx
Unfortunately, this function can't undecorate even such symbol:
#include <Windows.h>
#include <DbgHelp.h>
#include <cstdlib>
#include <iostream>
#include <typeinfo>
int main()
{
SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
if (!SymInitialize(GetCurrentProcess(), NULL, TRUE))
{
std::cout << "SymInitialize returned error: " << GetLastError() << '
';
return EXIT_FAILURE;
}
class Foo {};
Foo instance;
const char* decorated_name = typeid(instance).name();
char undecorated_name[1024];
if (!UnDecorateSymbolName(decorated_name, undecorated_name, sizeof(undecorated_name) / sizeof(*undecorated_name), UNDNAME_COMPLETE))
{
std::cout << "UnDecorateSymbolName returned error: " << GetLastError() << '
';
return EXIT_FAILURE;
}
std::cout << "Decorated name: " << decorated_name << '
'
<< "Undecorated name: " << undecorated_name << '
';
}
Output
Decorated name: ?AVFoo@?4?main@
Undecorated name: ?AVFoo@?4?main@
If i am doing it wrong?
I've heard somewhere about _unDName function, but i can't find any example with it. In which header file it is defined?
See Question&Answers more detail:os