diff --git a/premake4.lua b/premake4.lua index ef9f966d1..c4f613a30 100644 --- a/premake4.lua +++ b/premake4.lua @@ -1738,6 +1738,7 @@ solution "eepp" linkoptions { "../../bin/assets/icon/ecode.res" } end buildoptions{ "-Wa,-mbig-obj" } + linkoptions { "-Wl,--export-all-symbols" } end build_link_configuration( "ecode", false ) configuration { "release", "windows" } diff --git a/premake5.lua b/premake5.lua index 38a5aef5b..299450704 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1593,6 +1593,7 @@ workspace "eepp" build_link_configuration( "ecode", false ) filter { "system:windows", "action:not vs*" } buildoptions{ "-Wa,-mbig-obj" } + linkoptions { "-Wl,--export-all-symbols" } filter { "system:windows", "action:vs*" } files { "bin/assets/icon/ecode.rc", "bin/assets/icon/ecode.ico" } vpaths { ['Resources/*'] = { "ecode.rc", "ecode.ico" } } diff --git a/src/eepp/system/fileinfo.cpp b/src/eepp/system/fileinfo.cpp index 4bca0d75c..ac3aa255d 100644 --- a/src/eepp/system/fileinfo.cpp +++ b/src/eepp/system/fileinfo.cpp @@ -115,8 +115,11 @@ void FileInfo::getInfo() { struct stat st; int res = stat( mFilepath.c_str(), &st ); #else - struct _stat st; - int res = _wstat( String::fromUtf8( mFilepath ).toWideString().c_str(), &st ); + std::string_view fp( mFilepath ); + if ( fp.size() > 3 && ( fp.back() == '/' || fp.back() == '\\' ) ) + fp.remove_suffix( 1 ); + struct __stat64 st; + int res = _wstat64( String( fp ).toWideString().c_str(), &st ); #endif if ( 0 == res ) { @@ -261,8 +264,11 @@ bool FileInfo::exists() const { struct stat st; int res = stat( mFilepath.c_str(), &st ); #else - struct _stat st; - int res = _wstat( String::fromUtf8( mFilepath ).toWideString().c_str(), &st ); + std::string_view fp( mFilepath ); + if ( fp.size() > 3 && ( fp.back() == '/' || fp.back() == '\\' ) ) + fp.remove_suffix( 1 ); + struct __stat64 st; + int res = _wstat64( String( fp ).toWideString().c_str(), &st ); #endif if ( isDirectory() ) diff --git a/src/eepp/system/filesystem.cpp b/src/eepp/system/filesystem.cpp index fb62844f4..8b2f348b5 100644 --- a/src/eepp/system/filesystem.cpp +++ b/src/eepp/system/filesystem.cpp @@ -211,8 +211,11 @@ bool FileSystem::fileHide( const std::string& filepath ) { Uint32 FileSystem::fileGetModificationDate( const std::string& filepath ) { #if EE_PLATFORM == EE_PLATFORM_WIN - struct _stat st; - int res = _wstat( String( filepath ).toWideString().c_str(), &st ); + std::string_view fp( filepath ); + if ( fp.size() > 3 && ( fp.back() == '/' || fp.back() == '\\' ) ) + fp.remove_suffix( 1 ); + struct __stat64 st; + int res = _wstat64( String( fp ).toWideString().c_str(), &st ); #else struct stat st; int res = stat( filepath.c_str(), &st ); @@ -540,8 +543,11 @@ std::vector FileSystem::filesGetInPath( const std::string& path, Uint64 FileSystem::fileSize( const std::string& Filepath ) { #if EE_PLATFORM == EE_PLATFORM_WIN - struct _stat st; - int res = _wstat( String( Filepath ).toWideString().c_str(), &st ); + std::string_view fp( Filepath ); + if ( fp.size() > 3 && ( fp.back() == '/' || fp.back() == '\\' ) ) + fp.remove_suffix( 1 ); + struct __stat64 st; + int res = _wstat64( String( fp ).toWideString().c_str(), &st ); #else struct stat st; int res = stat( Filepath.c_str(), &st ); @@ -555,8 +561,11 @@ Uint64 FileSystem::fileSize( const std::string& Filepath ) { bool FileSystem::fileExists( const std::string& Filepath ) { #if EE_PLATFORM == EE_PLATFORM_WIN - struct _stat st; - return ( _wstat( String( Filepath ).toWideString().c_str(), &st ) == 0 ); + std::string_view fp( Filepath ); + if ( fp.size() > 3 && ( fp.back() == '/' || fp.back() == '\\' ) ) + fp.remove_suffix( 1 ); + struct __stat64 st; + return ( _wstat64( String( fp ).toWideString().c_str(), &st ) == 0 ); #else struct stat st; return ( stat( Filepath.c_str(), &st ) == 0 ); diff --git a/src/eepp/system/sys.cpp b/src/eepp/system/sys.cpp index f64295856..6f7f96500 100644 --- a/src/eepp/system/sys.cpp +++ b/src/eepp/system/sys.cpp @@ -643,7 +643,7 @@ static std::string sGetProcessPath() { _splitpath_s( dllstrName.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFilename, _MAX_DIR, szExt, _MAX_DIR ); #else - _splitpath( szDllName, szDrive, szDir, szFilename, szExt ); + _splitpath( dllstrName.c_str(), szDrive, szDir, szFilename, szExt ); #endif return std::string( szDrive ) + std::string( szDir ); diff --git a/src/thirdparty/backward-cpp/backward.hpp b/src/thirdparty/backward-cpp/backward.hpp index 8c44d657d..f92637426 100644 --- a/src/thirdparty/backward-cpp/backward.hpp +++ b/src/thirdparty/backward-cpp/backward.hpp @@ -332,6 +332,10 @@ #if defined(BACKWARD_SYSTEM_WINDOWS) +#ifdef __GNUC__ +#include +#endif + #include #include #include @@ -612,14 +616,20 @@ template struct demangler_impl { static std::string demangle(const char *funcname) { return funcname; } }; -#if defined(BACKWARD_SYSTEM_LINUX) || defined(BACKWARD_SYSTEM_DARWIN) +#if defined(BACKWARD_SYSTEM_LINUX) || defined(BACKWARD_SYSTEM_DARWIN) || (defined(BACKWARD_SYSTEM_WINDOWS) && defined(__GNUC__)) template <> struct demangler_impl { demangler_impl() : _demangle_buffer_length(0) {} std::string demangle(const char *funcname) { using namespace details; - char *result = abi::__cxa_demangle(funcname, _demangle_buffer.get(), + const char* target = funcname; + std::string mangled; + if (target && target[0] == 'Z') { + mangled = "_" + std::string(target); + target = mangled.c_str(); + } + char *result = abi::__cxa_demangle(target, _demangle_buffer.get(), &_demangle_buffer_length, nullptr); if (result) { _demangle_buffer.update(result); @@ -3674,41 +3684,38 @@ public: ResolvedTrace resolve(ResolvedTrace t) override { HANDLE process = GetCurrentProcess(); - char name[256]; - memset(&sym, 0, sizeof(sym)); sym.sym.SizeOfStruct = sizeof(SYMBOL_INFO); sym.sym.MaxNameLen = max_sym_len; if (!SymFromAddr(process, (ULONG64)t.addr, &displacement, &sym.sym)) { - // TODO: error handling everywhere - char* lpMsgBuf; - DWORD dw = GetLastError(); - - if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (char*)&lpMsgBuf, 0, NULL)) { - std::fprintf(stderr, "%s\n", lpMsgBuf); - LocalFree(lpMsgBuf); - } - - // abort(); + t.object_function = "??"; + return t; + } + std::string name = demangle(sym.sym.Name); + if (name == sym.sym.Name) { + char undecorated[256]; + if (UnDecorateSymbolName(sym.sym.Name, undecorated, 256, UNDNAME_COMPLETE)) { + name = undecorated; + } } - UnDecorateSymbolName(sym.sym.Name, (PSTR)name, 256, UNDNAME_COMPLETE); DWORD offset = 0; IMAGEHLP_LINE line; if (SymGetLineFromAddr(process, (ULONG64)t.addr, &offset, &line)) { - t.object_filename = line.FileName; t.source.filename = line.FileName; t.source.line = line.LineNumber; t.source.col = offset; } + IMAGEHLP_MODULE64 module; + memset(&module, 0, sizeof(module)); + module.SizeOfStruct = sizeof(module); + if (SymGetModuleInfo64(process, (ULONG64)t.addr, &module)) { + t.object_filename = module.ModuleName; + } + t.source.function = name; - t.object_filename = ""; t.object_function = name; return t;