diff options
author | emaste <emaste@FreeBSD.org> | 2015-02-09 01:44:09 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2015-02-09 01:44:09 +0000 |
commit | d61b076ede88b56f3372a55e7d1eac6a9d717120 (patch) | |
tree | a8f4b3abea3e6937e60728991c736e6e3d322fc1 /source/Core/Mangled.cpp | |
parent | 0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531 (diff) | |
download | FreeBSD-src-d61b076ede88b56f3372a55e7d1eac6a9d717120.zip FreeBSD-src-d61b076ede88b56f3372a55e7d1eac6a9d717120.tar.gz |
Import LLDB as of upstream SVN 228549 (git 39760838)
Diffstat (limited to 'source/Core/Mangled.cpp')
-rw-r--r-- | source/Core/Mangled.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp index c0ab66c..e1598d3 100644 --- a/source/Core/Mangled.cpp +++ b/source/Core/Mangled.cpp @@ -10,8 +10,9 @@ // FreeBSD9-STABLE requires this to know about size_t in cxxabi.h #include <cstddef> -#if defined(_MSC_VER) -// Cannot enable the builtin demangler on msvc as it does not support the cpp11 within the implementation. +#if defined(_MSC_VER) +#include "lldb/Host/windows/windows.h" +#include <Dbghelp.h> #elif defined (__FreeBSD__) #define LLDB_USE_BUILTIN_DEMANGLER #else @@ -4998,7 +4999,11 @@ static inline bool cstring_is_mangled (const char *s) { if (s) - return s[0] == '_' && s[1] == 'Z'; +#if defined(_MSC_VER) + return (s[0] == '?'); +#else + return (s[0] == '_' && s[1] == 'Z'); +#endif return false; } @@ -5226,15 +5231,27 @@ Mangled::GetDemangledName () const if (!demangled_name) demangled_name = __cxa_demangle (mangled_cstr, NULL, NULL, NULL); #elif defined(_MSC_VER) - // Cannot demangle on msvc. - char *demangled_name = nullptr; + char *demangled_name = (char *)::malloc(1024); + ::ZeroMemory(demangled_name, 1024); + DWORD result = ::UnDecorateSymbolName(mangled_cstr, demangled_name, 1023, + UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected keywords + UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc keywords + UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications + UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers + UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords + ); + if (result == 0) + { + free (demangled_name); + demangled_name = nullptr; + } #else char *demangled_name = abi::__cxa_demangle (mangled_cstr, NULL, NULL, NULL); #endif if (demangled_name) { - m_demangled.SetCStringWithMangledCounterpart(demangled_name, m_mangled); + m_demangled.SetCStringWithMangledCounterpart(demangled_name, m_mangled); free (demangled_name); } } @@ -5335,6 +5352,21 @@ Mangled::MemorySize () const return m_mangled.MemorySize() + m_demangled.MemorySize(); } +lldb::LanguageType +Mangled::GetLanguage () +{ + ConstString mangled = GetMangledName(); + if (mangled) + { + if (GetDemangledName()) + { + if (cstring_is_mangled(mangled.GetCString())) + return lldb::eLanguageTypeC_plus_plus; + } + } + return lldb::eLanguageTypeUnknown; +} + //---------------------------------------------------------------------- // Dump OBJ to the supplied stream S. //---------------------------------------------------------------------- |