diff options
author | Bernard Normier <bernard@zeroc.com> | 2012-10-18 16:59:16 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2012-10-18 16:59:16 -0400 |
commit | f2a736953f5462f8fc5db9c86a5e7daba86f2e5e (patch) | |
tree | 87a387cbb248a3c7b54af900dae44b86b5adef1e /cpp/src/IceUtil/Exception.cpp | |
parent | VC9 build changes (diff) | |
download | ice-f2a736953f5462f8fc5db9c86a5e7daba86f2e5e.tar.bz2 ice-f2a736953f5462f8fc5db9c86a5e7daba86f2e5e.tar.xz ice-f2a736953f5462f8fc5db9c86a5e7daba86f2e5e.zip |
Fixed bug ICE-4892: no longer use DbgHelp unicode functions with VS <=2010, as they are not available in the Windows XP DbgHelp.
Diffstat (limited to 'cpp/src/IceUtil/Exception.cpp')
-rw-r--r-- | cpp/src/IceUtil/Exception.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 6b932274198..eda8311b19f 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -7,6 +7,16 @@ // // ********************************************************************** +#if !defined(ICE_OS_WINRT) && defined(_MSC_VER) && _MSC_VER >= 1700 +// +// DbgHelp.dll on Windows XP does not contain Unicode functions, so we +// "switch on" Unicode only with VS2012 and up +// +# define UNICODE +# define DBGHELP_TRANSLATE_TCHAR +# include <IceUtil/Unicode.h> +#endif + #include <IceUtil/Exception.h> #include <IceUtil/MutexPtrLock.h> #include <IceUtil/Mutex.h> @@ -24,14 +34,11 @@ #endif #if defined(_WIN32) && !defined(__MINGW32__) && !defined(ICE_OS_WINRT) -# include <IceUtil/Unicode.h> -# define DBGHELP_TRANSLATE_TCHAR # include <DbgHelp.h> # define ICE_STACK_TRACES # define ICE_WIN32_STACK_TRACES #endif - using namespace std; namespace IceUtilInternal @@ -116,11 +123,20 @@ getStackTrace() if(frames > 0) { +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +# if defined(DBGHELP_TRANSLATE_TCHAR) + static_assert(sizeof(TCHAR) == sizeof(wchar_t), "Bad TCHAR - should be wchar_t"); +# else + static_assert(sizeof(TCHAR) == sizeof(char), "Bad TCHAR - should be char"); +# endif +#endif + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(buffer); symbol->SizeOfStruct = sizeof(SYMBOL_INFO); symbol->MaxNameLen = MAX_SYM_NAME; - + IMAGEHLP_LINE64 line = {}; line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); DWORD displacement = 0; @@ -141,12 +157,20 @@ getStackTrace() BOOL ok = SymFromAddr(process, address, 0, symbol); if(ok) { +#ifdef DBGHELP_TRANSLATE_TCHAR s << IceUtil::wstringToString(symbol->Name); - +#else + s << symbol->Name; +#endif ok = SymGetLineFromAddr64(process, address, &displacement, &line); if(ok) { - s << " at line " << line.LineNumber << " in " << IceUtil::wstringToString(line.FileName); + s << " at line " << line.LineNumber << " in " +#ifdef DBGHELP_TRANSLATE_TCHAR + << IceUtil::wstringToString(line.FileName); +#else + << line.FileName; +#endif } } else |