Ticket #15138: wx_trunk_msw_stacktrace_20130406.patch

File wx_trunk_msw_stacktrace_20130406.patch, 25.2 KB (added by suzumizaki, 7 years ago)

Patchs to trunk to resolve stack tracing problem with non-ASCII identifiers with wxMSW

  • include/wx/dynlib.h

     
    22// Name:        wx/dynlib.h
    33// Purpose:     Dynamic library loading classes
    44// Author:      Guilhem Lavaux, Vadim Zeitlin, Vaclav Slavik
    5 // Modified by:
     5// Modified by: Suzumizaki-kimitaka 2013-04-06
    66// Created:     20/07/98
    77// RCS-ID:      $Id$
    88// Copyright:   (c) 1998 Guilhem Lavaux
     
    359359    // the returned handle reference count is not incremented so it doesn't
    360360    // need to be freed using FreeLibrary() but it also means that it can
    361361    // become invalid if the DLL is unloaded
    362     static WXHMODULE MSWGetModuleHandle(const char *name, void *addr);
     362#ifdef UNICODE
     363    static WXHMODULE MSWGetModuleHandle(const wchar_t* name, void *addr);
     364#else
     365    static WXHMODULE MSWGetModuleHandle(const char* name, void *addr);
     366#endif
    363367#endif // __WINDOWS__
    364368
    365369protected:
  • include/wx/msw/debughlp.h

     
    22// Name:        wx/msw/debughlp.h
    33// Purpose:     wraps dbghelp.h standard file
    44// Author:      Vadim Zeitlin
    5 // Modified by:
     5// Modified by: Suzumizaki-kimitaka 2013-04-06
    66// Created:     2005-01-08 (extracted from msw/crashrpt.cpp)
    77// RCS-ID:      $Id$
    88// Copyright:   (c) 2003-2005 Vadim Zeitlin <vadim@wxwindows.org>
     
    4040
    4141#if wxUSE_DBGHELP
    4242
     43#ifdef UNICODE
     44#define wxPENUMLOADED_MODULES_CALLBACK64 PENUMLOADED_MODULES_CALLBACKW64
     45#define wxPSYMBOL_INFO PSYMBOL_INFOW
     46#define wxSYMBOL_INFO SYMBOL_INFOW
     47#define wxPIMAGEHLP_LINE PIMAGEHLP_LINEW64
     48#define wxIMAGEHLP_LINE IMAGEHLP_LINEW64
     49#define wxPSYM_ENUMERATESYMBOLS_CALLBACK PSYM_ENUMERATESYMBOLS_CALLBACKW
     50#else
     51#define wxPENUMLOADED_MODULES_CALLBACK64 PENUMLOADED_MODULES_CALLBACK64
     52#define wxPSYMBOL_INFO PSYMBOL_INFO
     53#define wxSYMBOL_INFO SYMBOL_INFO
     54#define wxPIMAGEHLP_LINE PIMAGEHLP_LINE64
     55#define wxIMAGEHLP_LINE IMAGEHLP_LINE64
     56#define wxPSYM_ENUMERATESYMBOLS_CALLBACK PSYM_ENUMERATESYMBOLS_CALLBACK
     57#endif
     58
    4359// ----------------------------------------------------------------------------
    4460// wxDbgHelpDLL: dynamically load dbghelp.dll functions
    4561// ----------------------------------------------------------------------------
     
    139155    // function types
    140156    typedef DWORD (WINAPI *SymGetOptions_t)();
    141157    typedef DWORD (WINAPI *SymSetOptions_t)(DWORD);
    142     typedef BOOL (WINAPI *SymInitialize_t)(HANDLE, LPSTR, BOOL);
     158    typedef BOOL (WINAPI *SymInitialize_t)(HANDLE, LPTSTR, BOOL);
    143159    typedef BOOL (WINAPI *StackWalk_t)(DWORD, HANDLE, HANDLE, LPSTACKFRAME,
    144160                                       LPVOID, PREAD_PROCESS_MEMORY_ROUTINE,
    145161                                       PFUNCTION_TABLE_ACCESS_ROUTINE,
    146162                                       PGET_MODULE_BASE_ROUTINE,
    147163                                       PTRANSLATE_ADDRESS_ROUTINE);
    148     typedef BOOL (WINAPI *SymFromAddr_t)(HANDLE, DWORD64, PDWORD64, PSYMBOL_INFO);
     164    typedef BOOL (WINAPI *SymFromAddr_t)(HANDLE, DWORD64, PDWORD64, wxPSYMBOL_INFO);
    149165    typedef LPVOID (WINAPI *SymFunctionTableAccess_t)(HANDLE, DWORD_PTR);
    150166    typedef DWORD_PTR (WINAPI *SymGetModuleBase_t)(HANDLE, DWORD_PTR);
    151     typedef BOOL (WINAPI *SymGetLineFromAddr_t)(HANDLE, DWORD_PTR,
    152                                                 PDWORD, PIMAGEHLP_LINE);
     167    typedef BOOL (WINAPI *SymGetLineFromAddr64_t)(HANDLE, DWORD_PTR,
     168                                                PDWORD, wxPIMAGEHLP_LINE);
    153169    typedef BOOL (WINAPI *SymSetContext_t)(HANDLE, PIMAGEHLP_STACK_FRAME,
    154170                                           PIMAGEHLP_CONTEXT);
    155     typedef BOOL (WINAPI *SymEnumSymbols_t)(HANDLE, ULONG64, PCSTR,
    156                                             PSYM_ENUMERATESYMBOLS_CALLBACK, PVOID);
     171    typedef BOOL (WINAPI *SymEnumSymbols_t)(HANDLE, ULONG64, PCTSTR,
     172                                            wxPSYM_ENUMERATESYMBOLS_CALLBACK, PVOID);
    157173    typedef BOOL (WINAPI *SymGetTypeInfo_t)(HANDLE, DWORD64, ULONG,
    158174                                            IMAGEHLP_SYMBOL_TYPE_INFO, PVOID);
    159175    typedef BOOL (WINAPI *SymCleanup_t)(HANDLE);
     
    164180                                               CONST PMINIDUMP_USER_STREAM_INFORMATION,
    165181                                               CONST PMINIDUMP_CALLBACK_INFORMATION);
    166182
     183    typedef BOOL (WINAPI *EnumerateLoadedModulesEx_t)(HANDLE, wxPENUMLOADED_MODULES_CALLBACK64, PVOID);
     184    typedef BOOL (WINAPI *EnumerateLoadedModules64_t)(HANDLE, wxPENUMLOADED_MODULES_CALLBACK64, PVOID);
     185    static BOOL EnumerateLoadedModulesExOr64(HANDLE, wxPENUMLOADED_MODULES_CALLBACK64, PVOID);
     186
    167187    // The macro called by wxDO_FOR_ALL_SYM_FUNCS() below takes 2 arguments:
    168188    // the name of the function in the program code, which never has "64"
    169189    // suffix, and the name of the function in the DLL which can have "64"
     
    172192    #define wxSYM_CALL(what, name)  what(name, name)
    173193#if defined(_M_AMD64)
    174194    #define wxSYM_CALL_64(what, name)  what(name, name ## 64)
    175 
    176195    // Also undo all the "helpful" definitions done by imagehlp.h that map 32
    177196    // bit functions to 64 bit ones, we don't need this as we do it ourselves.
    178197    #undef StackWalk
     
    184203    #define wxSYM_CALL_64(what, name)  what(name, name)
    185204#endif
    186205
     206#ifdef UNICODE
     207    #define wxSYM_CALL_T_ANYWAY64(what, name)  what(name ## 64, name ## W64)
     208    #define wxSYM_CALL_T(what, name)  what(name, name ## W)
     209#if defined(_M_AMD64)
     210    #define wxSYM_CALL_T_64(what, name)  what(name, name ## W64)
     211#else
     212    #define wxSYM_CALL_T_64(what, name)  what(name, name ## W)
     213#endif
     214#else
     215    #define wxSYM_CALL_T_ANYWAY64(what, name)  what(name ## 64, name ## 64)
     216    #define wxSYM_CALL_T(what, name)  what(name, name)
     217#if defined(_M_AMD64)
     218    #define wxSYM_CALL_T_64(what, name)  what(name, name ## 64)
     219#else
     220    #define wxSYM_CALL_T_64(what, name)  what(name, name)
     221#endif
     222#endif
     223
     224
    187225    #define wxDO_FOR_ALL_SYM_FUNCS(what)                                      \
    188226        wxSYM_CALL_64(what, StackWalk);                                       \
    189227        wxSYM_CALL_64(what, SymFunctionTableAccess);                          \
    190228        wxSYM_CALL_64(what, SymGetModuleBase);                                \
    191         wxSYM_CALL_64(what, SymGetLineFromAddr);                              \
     229        wxSYM_CALL_T_ANYWAY64(what, SymGetLineFromAddr);                      \
    192230        wxSYM_CALL_64(what, EnumerateLoadedModules);                          \
    193231                                                                              \
    194232        wxSYM_CALL(what, SymGetOptions);                                      \
    195233        wxSYM_CALL(what, SymSetOptions);                                      \
    196         wxSYM_CALL(what, SymInitialize);                                      \
    197         wxSYM_CALL(what, SymFromAddr);                                        \
     234        wxSYM_CALL_T(what, SymInitialize);                                    \
     235        wxSYM_CALL_T(what, SymFromAddr);                                      \
    198236        wxSYM_CALL(what, SymSetContext);                                      \
    199         wxSYM_CALL(what, SymEnumSymbols);                                     \
     237        wxSYM_CALL_T(what, SymEnumSymbols);                                   \
    200238        wxSYM_CALL(what, SymGetTypeInfo);                                     \
    201239        wxSYM_CALL(what, SymCleanup);                                         \
    202240        wxSYM_CALL(what, MiniDumpWriteDump)
    203241
    204242    #define wxDECLARE_SYM_FUNCTION(func, name) static func ## _t func
    205243
     244    // Alternation will work when the following 2 functions are not found,
     245    // therefore they are not included in wxDO_FOR_ALL_SYM_FUNCS.
     246    // see BindDbgHelpFunctions() in debughlp.cpp, and don't
     247    // forget to check another wxDO_FOR_ALL_SYM_FUNCS calls.
     248    wxSYM_CALL_T_ANYWAY64(wxDECLARE_SYM_FUNCTION, EnumerateLoadedModules);
     249    wxSYM_CALL_T(wxDECLARE_SYM_FUNCTION, EnumerateLoadedModulesEx);
     250   
    206251    wxDO_FOR_ALL_SYM_FUNCS(wxDECLARE_SYM_FUNCTION);
    207252
    208253    #undef wxDECLARE_SYM_FUNCTION
     
    217262    static void LogError(const wxChar *func);
    218263
    219264    // return textual representation of the value of given symbol
    220     static wxString DumpSymbol(PSYMBOL_INFO pSymInfo, void *pVariable);
     265    static wxString DumpSymbol(wxPSYMBOL_INFO pSymInfo, void *pVariable);
    221266
    222267    // return the name of the symbol with given type index
    223     static wxString GetSymbolName(PSYMBOL_INFO pSymInfo);
     268    static wxString GetSymbolName(wxPSYMBOL_INFO pSymInfo);
    224269
    225270private:
    226271    // dereference the given symbol, i.e. return symbol which is not a
     
    230275    // dereferenced the symbol
    231276    //
    232277    // return the tag of the dereferenced symbol
    233     static SymbolTag DereferenceSymbol(PSYMBOL_INFO pSymInfo, void **ppData);
     278    static SymbolTag DereferenceSymbol(wxPSYMBOL_INFO pSymInfo, void **ppData);
    234279
    235     static wxString DumpField(PSYMBOL_INFO pSymInfo,
     280    static wxString DumpField(wxPSYMBOL_INFO pSymInfo,
    236281                              void *pVariable,
    237282                              unsigned level);
    238283
    239284    static wxString DumpBaseType(BasicType bt, DWORD64 length, void *pVariable);
    240285
    241     static wxString DumpUDT(PSYMBOL_INFO pSymInfo,
     286    static wxString DumpUDT(wxPSYMBOL_INFO pSymInfo,
    242287                            void *pVariable,
    243288                            unsigned level = 0);
    244289};
  • include/wx/msw/stackwalk.h

     
    22// Name:        wx/msw/stackwalk.h
    33// Purpose:     wxStackWalker for MSW
    44// Author:      Vadim Zeitlin
    5 // Modified by:
     5// Modified by: Suzumizaki-kimitaka 2013-04-06
    66// Created:     2005-01-08
    77// RCS-ID:      $Id$
    88// Copyright:   (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
     
    2020
    2121// and these in dbghelp.h
    2222struct _SYMBOL_INFO;
     23struct _SYMBOL_INFOW;
    2324
    2425// ----------------------------------------------------------------------------
    2526// wxStackFrame
     
    5354    GetParam(size_t n, wxString *type, wxString *name, wxString *value) const;
    5455
    5556    // callback used by OnGetParam(), don't call directly
    56     void OnParam(_SYMBOL_INFO *pSymInfo);
     57#ifdef UNICODE
     58    void OnParam(_SYMBOL_INFOW * pSymInfo);
     59#else
     60    void OnParam(_SYMBOL_INFO * pSymInfo);
     61#endif
    5762
    5863protected:
    5964    virtual void OnGetName();
  • src/msw/debughlp.cpp

     
    22// Name:        src/msw/debughlp.cpp
    33// Purpose:     various Win32 debug helpers
    44// Author:      Vadim Zeitlin
    5 // Modified by:
     5// Modified by: Suzumizaki-kimitaka 2013-04-06
    66// Created:     2005-01-08 (extracted from crashrpt.cpp)
    77// RCS-ID:      $Id$
    88// Copyright:   (c) 2003-2005 Vadim Zeitlin <vadim@wxwindows.org>
     
    5454    wxDbgHelpDLL::func ## _t wxDbgHelpDLL::func = 0
    5555
    5656wxDO_FOR_ALL_SYM_FUNCS(DEFINE_SYM_FUNCTION);
     57wxSYM_CALL_T_ANYWAY64(DEFINE_SYM_FUNCTION, EnumerateLoadedModules);
     58wxSYM_CALL_T(DEFINE_SYM_FUNCTION, EnumerateLoadedModulesEx);
    5759
    5860#undef DEFINE_SYM_FUNCTION
    5961
     
    7880
    7981    #undef LOAD_SYM_FUNCTION
    8082
     83    #define LOAD_SYM_FUNCTION_CAN_FAIL(func, name)                            \
     84        wxDbgHelpDLL::func = (wxDbgHelpDLL::func ## _t)                       \
     85            dllDbgHelp.GetSymbol(wxT(#name));
     86
     87    wxSYM_CALL_T_ANYWAY64(LOAD_SYM_FUNCTION_CAN_FAIL, EnumerateLoadedModules);
     88    wxSYM_CALL_T(LOAD_SYM_FUNCTION_CAN_FAIL, EnumerateLoadedModulesEx);
     89
     90    #undef LOAD_SYM_FUNCTION_CAN_FAIL
     91
    8192    return true;
    8293}
    8394
     
    171182
    172183static inline
    173184bool
    174 DoGetTypeInfo(PSYMBOL_INFO pSym, IMAGEHLP_SYMBOL_TYPE_INFO type, void *rc)
     185DoGetTypeInfo(wxPSYMBOL_INFO pSym, IMAGEHLP_SYMBOL_TYPE_INFO type, void *rc)
    175186{
    176187    return DoGetTypeInfo(pSym->ModBase, pSym->TypeIndex, type, rc);
    177188}
    178189
    179190static inline
    180 wxDbgHelpDLL::BasicType GetBasicType(PSYMBOL_INFO pSym)
     191wxDbgHelpDLL::BasicType GetBasicType(wxPSYMBOL_INFO pSym)
    181192{
    182193    wxDbgHelpDLL::BasicType bt;
    183194    return DoGetTypeInfo(pSym, TI_GET_BASETYPE, &bt)
     
    186197}
    187198
    188199/* static */
    189 wxString wxDbgHelpDLL::GetSymbolName(PSYMBOL_INFO pSym)
     200wxString wxDbgHelpDLL::GetSymbolName(wxPSYMBOL_INFO pSym)
    190201{
    191202    wxString s;
    192203
     
    290301}
    291302
    292303wxString
    293 wxDbgHelpDLL::DumpField(PSYMBOL_INFO pSym, void *pVariable, unsigned level)
     304wxDbgHelpDLL::DumpField(wxPSYMBOL_INFO pSym, void *pVariable, unsigned level)
    294305{
    295306    wxString s;
    296307
     
    337348
    338349
    339350                // now pass to the type representing the type of this member
    340                 SYMBOL_INFO sym = *pSym;
     351                wxSYMBOL_INFO sym = *pSym;
    341352                if ( !DoGetTypeInfo(pSym, TI_GET_TYPEID, &sym.TypeIndex) )
    342353                    break;
    343354
     
    388399}
    389400
    390401/* static */ wxString
    391 wxDbgHelpDLL::DumpUDT(PSYMBOL_INFO pSym, void *pVariable, unsigned level)
     402wxDbgHelpDLL::DumpUDT(wxPSYMBOL_INFO pSym, void *pVariable, unsigned level)
    392403{
    393404    wxString s;
    394405
     
    455466        s << wxT(" {\n");
    456467
    457468        // Iterate through all children
    458         SYMBOL_INFO sym;
     469        wxSYMBOL_INFO sym;
    459470        wxZeroMemory(sym);
    460471        sym.ModBase = pSym->ModBase;
    461472        for ( unsigned i = 0; i < dwChildrenCount; i++ )
     
    487498
    488499/* static */
    489500wxDbgHelpDLL::SymbolTag
    490 wxDbgHelpDLL::DereferenceSymbol(PSYMBOL_INFO pSym, void **ppData)
     501wxDbgHelpDLL::DereferenceSymbol(wxPSYMBOL_INFO pSym, void **ppData)
    491502{
    492503    SymbolTag tag = SYMBOL_TAG_NULL;
    493504    for ( ;; )
     
    524535}
    525536
    526537/* static */ wxString
    527 wxDbgHelpDLL::DumpSymbol(PSYMBOL_INFO pSym, void *pVariable)
     538wxDbgHelpDLL::DumpSymbol(wxPSYMBOL_INFO pSym, void *pVariable)
    528539{
    529540    wxString s;
    530     SYMBOL_INFO symDeref = *pSym;
     541    wxSYMBOL_INFO symDeref = *pSym;
    531542    switch ( DereferenceSymbol(&symDeref, &pVariable) )
    532543    {
    533544        default:
     
    554565}
    555566
    556567// ----------------------------------------------------------------------------
     568// enumerating helper functions
     569// ----------------------------------------------------------------------------
     570
     571struct wxMswEnumLoadedModulesAlternate
     572{
     573public:
     574    wxMswEnumLoadedModulesAlternate(wxPENUMLOADED_MODULES_CALLBACK64 ptr, PVOID content)
     575        : m_pointer_to_callback(ptr), m_user_content(content)
     576    { }
     577    wxPENUMLOADED_MODULES_CALLBACK64 m_pointer_to_callback;
     578    PVOID m_user_content;
     579};
     580
     581static BOOL CALLBACK wxMswEnumLoadedModulesByPassFunction(
     582    PCSTR ModuleName, ULONG_PTR ModuleBase, ULONG ModuleSize, PVOID UserContext)
     583{
     584    wxMswEnumLoadedModulesAlternate& alternate =
     585        *(wxMswEnumLoadedModulesAlternate*)(UserContext);
     586    const int bufSize = MultiByteToWideChar(
     587        CP_ACP, MB_PRECOMPOSED, ModuleName, -1, 0, 0);
     588    if (bufSize <= 0)
     589    {
     590        static LPCWSTR errstr = L"[ConvertError1]";
     591        return (*alternate.m_pointer_to_callback)
     592            (errstr, ModuleBase, ModuleSize, alternate.m_user_content);
     593    }
     594    wxScopedPtr<WCHAR> buf(new WCHAR[bufSize]);
     595    if (! buf)
     596    {
     597        static LPCWSTR allocerrstr = L"[AllocateError]";
     598        return (*alternate.m_pointer_to_callback)
     599            (allocerrstr, ModuleBase, ModuleSize, alternate.m_user_content);
     600    }
     601    const int convertedSize = MultiByteToWideChar(
     602        CP_ACP, MB_PRECOMPOSED, ModuleName, -1, buf.get(), bufSize);
     603    if (convertedSize <= 0)
     604    {
     605        static LPCWSTR errstr2 = L"[ConvertError2]";
     606        return (*alternate.m_pointer_to_callback)
     607            (errstr2, ModuleBase, ModuleSize, alternate.m_user_content);
     608    }
     609    return (*alternate.m_pointer_to_callback)
     610        (buf.get(), ModuleBase, ModuleSize, alternate.m_user_content);
     611}
     612
     613/* static */
     614BOOL wxDbgHelpDLL::EnumerateLoadedModulesExOr64(
     615    HANDLE handle, wxPENUMLOADED_MODULES_CALLBACK64 callback, PVOID pvoid)
     616{
     617    if (EnumerateLoadedModulesEx)
     618    {
     619        return (*EnumerateLoadedModulesEx)(handle, callback, pvoid);
     620    }
     621    if (EnumerateLoadedModules64)
     622    {
     623        return (*EnumerateLoadedModules64)(handle, callback, pvoid);
     624    }
     625    if (EnumerateLoadedModules)
     626    {
     627        wxMswEnumLoadedModulesAlternate p(callback, pvoid);
     628        return (*EnumerateLoadedModules)
     629            (handle, wxMswEnumLoadedModulesByPassFunction, (PVOID)(&p));
     630    }
     631    return FALSE;
     632}
     633
     634// ----------------------------------------------------------------------------
    557635// debugging helpers
    558636// ----------------------------------------------------------------------------
    559637
  • src/msw/dlmsw.cpp

     
    22// Name:        src/msw/dlmsw.cpp
    33// Purpose:     Win32-specific part of wxDynamicLibrary and related classes
    44// Author:      Vadim Zeitlin
    5 // Modified by:
     5// Modified by: Suzumizaki-kimitaka 2013-04-06
    66// Created:     2005-01-10 (partly extracted from common/dynlib.cpp)
    77// RCS-ID:      $Id$
    88// Copyright:   (c) 1998-2005 Vadim Zeitlin <vadim@wxwindows.org>
     
    8080        wxVersionDLL *verDLL;
    8181    };
    8282
    83     // TODO: fix EnumerateLoadedModules() to use EnumerateLoadedModules64()
    84     #ifdef __WIN64__
    85         typedef DWORD64 DWORD_32_64;
    86     #else
    87         typedef DWORD DWORD_32_64;
    88     #endif
    89 
    9083    static BOOL CALLBACK
    91     EnumModulesProc(PCSTR name, DWORD_32_64 base, ULONG size, void *data);
     84    EnumModulesProc(PCTSTR name, DWORD64 base, ULONG size, PVOID data);
    9285};
    9386
    9487// ============================================================================
     
    116109        #endif // UNICODE/ANSI
    117110
    118111        #define LOAD_VER_FUNCTION(name)                                       \
    119             m_pfn ## name = (name ## _t)m_dll.GetSymbol(wxT(#name SUFFIX));    \
     112            m_pfn ## name = (name ## _t)m_dll.GetSymbol(wxT(#name SUFFIX));   \
    120113        if ( !m_pfn ## name )                                                 \
    121114        {                                                                     \
    122115            m_dll.Unload();                                                   \
     
    175168
    176169/* static */
    177170BOOL CALLBACK
    178 wxDynamicLibraryDetailsCreator::EnumModulesProc(PCSTR name,
    179                                                 DWORD_32_64 base,
     171wxDynamicLibraryDetailsCreator::EnumModulesProc(PCTSTR name,
     172                                                DWORD64 base,
    180173                                                ULONG size,
    181                                                 void *data)
     174                                                PVOID data)
    182175{
    183176    EnumModulesProcParams *params = (EnumModulesProcParams *)data;
    184177
    185178    wxDynamicLibraryDetails *details = new wxDynamicLibraryDetails;
    186179
    187180    // fill in simple properties
    188     details->m_name = wxString::FromAscii(name);
     181#ifdef UNICODE
     182    details->m_name = name;
     183#else
     184    details->m_name = wxString(name, wxConvLocal);
     185#endif
    189186    details->m_address = wxUIntToPtr(base);
    190187    details->m_length = size;
    191188
     
    320317        params.dlls = &dlls;
    321318        params.verDLL = &verDLL;
    322319
    323         // Note that the cast of EnumModulesProc is needed because the type of
    324         // PENUMLOADED_MODULES_CALLBACK changed: in old SDK versions its first
    325         // argument was non-const PSTR while now it's PCSTR. By explicitly
    326         // casting to whatever the currently used headers require we ensure
    327         // that the code compilers in any case.
    328         if ( !wxDbgHelpDLL::EnumerateLoadedModules
     320        if ( !wxDbgHelpDLL::EnumerateLoadedModulesExOr64
    329321                            (
    330322                                ::GetCurrentProcess(),
    331                                 (PENUMLOADED_MODULES_CALLBACK)
    332323                                wxDynamicLibraryDetailsCreator::EnumModulesProc,
    333324                                &params
    334325                            ) )
    335326        {
    336             wxLogLastError(wxT("EnumerateLoadedModules"));
     327            wxLogLastError(wxT("EnumerateLoadedModulesExOr64"));
    337328        }
    338329    }
    339330#endif // wxUSE_DBGHELP
     
    342333}
    343334
    344335/* static */
    345 WXHMODULE wxDynamicLibrary::MSWGetModuleHandle(const char *name, void *addr)
     336WXHMODULE wxDynamicLibrary::MSWGetModuleHandle(LPCTSTR name, void *addr)
    346337{
    347338    // we want to use GetModuleHandleEx() instead of usual GetModuleHandle()
    348339    // because the former works correctly for comctl32.dll while the latter
     
    350341    // GetModuleHandleEx() is only available under XP and later, coincidence?)
    351342
    352343    // check if we can use GetModuleHandleEx
    353     typedef BOOL (WINAPI *GetModuleHandleEx_t)(DWORD, LPCSTR, HMODULE *);
     344    typedef BOOL (WINAPI *GetModuleHandleEx_t)(DWORD, LPCTSTR, HMODULE *);
    354345
    355346    static const GetModuleHandleEx_t INVALID_FUNC_PTR = (GetModuleHandleEx_t)-1;
    356347
     
    359350    {
    360351        wxDynamicLibrary dll(wxT("kernel32.dll"), wxDL_VERBATIM);
    361352        s_pfnGetModuleHandleEx =
     353#ifdef UNICODE
     354            (GetModuleHandleEx_t)dll.RawGetSymbol(wxT("GetModuleHandleExW"));
     355#else
    362356            (GetModuleHandleEx_t)dll.RawGetSymbol(wxT("GetModuleHandleExA"));
    363 
     357#endif
    364358        // dll object can be destroyed, kernel32.dll won't be unloaded anyhow
    365359    }
    366360
     
    370364        // flags are GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
    371365        //           GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
    372366        HMODULE hmod;
    373         if ( s_pfnGetModuleHandleEx(6, (char *)addr, &hmod) && hmod )
     367        if ( s_pfnGetModuleHandleEx(6, (LPCTSTR)addr, &hmod) && hmod )
    374368            return hmod;
    375369    }
    376370
    377371    // Windows CE only has Unicode API, so even we have an ANSI string here, we
    378372    // still need to use GetModuleHandleW() there
    379373#ifdef __WXWINCE__
     374#ifdef UNICODE
     375    return ::GetModuleHandleW(name);
     376#else
    380377    return ::GetModuleHandleW(wxConvLibc.cMB2WC(name).data());
     378#endif
    381379#else
    382     return ::GetModuleHandleA((char *)name);
     380    return ::GetModuleHandle(name);
    383381#endif
    384382}
    385383
  • src/msw/stackwalk.cpp

     
    22// Name:        src/msw/stackwalk.cpp
    33// Purpose:     wxStackWalker implementation for Win32
    44// Author:      Vadim Zeitlin
    5 // Modified by: Artur Bac 2010-10-01 AMD64 Port
     5// Modified by: Artur Bac 2010-10-01 AMD64 Port, Suzumizaki-kimitaka 2013-04-06
    66// Created:     2005-01-08
    77// RCS-ID:      $Id$
    88// Copyright:   (c) 2003-2005 Vadim Zeitlin <vadim@wxwindows.org>
     
    5252
    5353    // get the name of the function for this stack frame entry
    5454    static const size_t MAX_NAME_LEN = 1024;
    55     BYTE symbolBuffer[sizeof(SYMBOL_INFO) + MAX_NAME_LEN];
     55    BYTE symbolBuffer[sizeof(wxSYMBOL_INFO) + MAX_NAME_LEN];
    5656    wxZeroMemory(symbolBuffer);
    5757
    58     PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)symbolBuffer;
    59     pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
     58    wxPSYMBOL_INFO pSymbol = (wxPSYMBOL_INFO)symbolBuffer;
     59    pSymbol->SizeOfStruct = sizeof(wxSYMBOL_INFO);
    6060    pSymbol->MaxNameLen = MAX_NAME_LEN;
    6161
    6262    DWORD64 symDisplacement = 0;
     
    7171        wxDbgHelpDLL::LogError(wxT("SymFromAddr"));
    7272        return;
    7373    }
    74 
    75     m_name = wxString::FromAscii(pSymbol->Name);
     74#ifdef UNICODE
     75    m_name = pSymbol->Name;
     76#else
     77    m_name = wxString(pSymbol->Name, wxConvLocal);
     78#endif
    7679    m_offset = symDisplacement;
    7780}
    7881
     
    8487    m_hasLocation = true;
    8588
    8689    // get the source line for this stack frame entry
    87     IMAGEHLP_LINE lineInfo = { sizeof(IMAGEHLP_LINE) };
     90    wxIMAGEHLP_LINE lineInfo = { sizeof(wxIMAGEHLP_LINE) };
    8891    DWORD dwLineDisplacement;
    89     if ( !wxDbgHelpDLL::SymGetLineFromAddr
     92    if ( !wxDbgHelpDLL::SymGetLineFromAddr64
    9093                        (
    9194                            ::GetCurrentProcess(),
    9295                            GetSymAddr(),
     
    9699    {
    97100        // it is normal that we don't have source info for some symbols,
    98101        // notably all the ones from the system DLLs...
    99         //wxDbgHelpDLL::LogError(wxT("SymGetLineFromAddr"));
     102        //wxDbgHelpDLL::LogError(wxT("SymGetLineFromAddr64"));
    100103        return;
    101104    }
    102 
    103     m_filename = wxString::FromAscii(lineInfo.FileName);
     105#ifdef UNICODE
     106    m_filename = lineInfo.FileName;
     107#else
     108    m_filename = wxString(lineInfo.FileName, wxConvLocal);
     109#endif
    104110    m_line = lineInfo.LineNumber;
    105111}
    106112
     
    126132    return true;
    127133}
    128134
    129 void wxStackFrame::OnParam(PSYMBOL_INFO pSymInfo)
     135void wxStackFrame::OnParam(wxPSYMBOL_INFO pSymInfo)
    130136{
    131137    m_paramTypes.Add(wxEmptyString);
    132138
    133     m_paramNames.Add(wxString::FromAscii(pSymInfo->Name));
     139#ifdef UNICODE
     140    m_paramNames.Add(pSymInfo->Name);
     141#else
     142    m_paramNames.Add(wxString(pSymInfo->Name, wxConvLocal));
     143#endif
    134144
    135145    // if symbol information is corrupted and we crash, the exception is going
    136146    // to be ignored when we're called from WalkFromException() because of the
     
    159169}
    160170
    161171BOOL CALLBACK
    162 EnumSymbolsProc(PSYMBOL_INFO pSymInfo, ULONG WXUNUSED(SymSize), PVOID data)
     172EnumSymbolsProc(wxPSYMBOL_INFO pSymInfo, ULONG WXUNUSED(SymSize), PVOID data)
    163173{
    164174    wxStackFrame *frame = static_cast<wxStackFrame *>(data);
    165175
     
    383393    return false;
    384394}
    385395
    386 void wxStackFrame::OnParam(_SYMBOL_INFO * WXUNUSED(pSymInfo))
     396void wxStackFrame::OnParam(wxPSYMBOL_INFO WXUNUSED(pSymInfo))
    387397{
    388398}
    389399