diff --git a/README.md b/README.md index c50410ed6..fc58fc94a 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ The steps are much like the ones above. # Revision History +## v1.8.631 + +* Symbols produced by Visual Studio 2019 are now correctly read by using redistributable dbghelp.dll. + ## v1.8.629 * Major UI rework: statistic lists are now entirely custom, performance (although not measured precisely) significantly improved (meaning, less CPU is busy displaying stats - more available to the profiled app); diff --git a/build-vsix.cmd b/build-vsix.cmd index 819ccd1ee..8363f27ad 100644 --- a/build-vsix.cmd +++ b/build-vsix.cmd @@ -38,6 +38,12 @@ popd pushd "%~dp0_build.android.arm\_bin" call sha256 hashandroidarm libmicro-profiler_arm.so popd +pushd "%~dp0redist\dbghelp" + call sha256 hashkernel32downlevelapix64 windows7+\x64\api-ms-win-downlevel-kernel32-l2-1-0.dll + call sha256 hashdbghelpx64 windows7+\x64\dbghelp.dll + call sha256 hashkernel32downlevelapix86 windows7+\x86\api-ms-win-downlevel-kernel32-l2-1-0.dll + call sha256 hashdbghelpx86 windows7+\x86\dbghelp.dll +popd pushd "%~dp0legacy" call mkzip micro-profiler.initializer.cpp "%OUTPUT%" @@ -72,6 +78,9 @@ popd pushd "%~dp0_build.android.arm\_bin" call mkzip libmicro-profiler_arm.so "%OUTPUT%" popd +pushd "%~dp0redist\dbghelp" + call mkzip * "%OUTPUT%" +popd pushd "%~dp0_setup" call replace.cmd "%~dp0deployment\vsix\catalog.json" > catalog.json diff --git a/common/src/image_info_win32.cpp b/common/src/image_info_win32.cpp index 10f3742e4..c410bcf10 100644 --- a/common/src/image_info_win32.cpp +++ b/common/src/image_info_win32.cpp @@ -34,6 +34,8 @@ #include #include +#define GET_PROC_ADDRESS(hmodule, symbol) reinterpret_cast(::GetProcAddress(hmodule, #symbol)) + using namespace std; using namespace std::placeholders; @@ -42,10 +44,15 @@ namespace micro_profiler namespace { #ifdef _M_IX86 - const string c_own_dbghelp_filename = "dbghelp_x86.dll"; + const string c_bitness_directory = "x86"; #elif _M_X64 - const string c_own_dbghelp_filename = "dbghelp_x64.dll"; + const string c_bitness_directory = "x64"; #endif + const string c_dbghelps[] = { + ~get_module_info(&c_bitness_directory).path & "windows7+" & c_bitness_directory & "dbghelp.dll", + ~get_module_info(&c_bitness_directory).path & "windowsxp+" & c_bitness_directory & "dbghelp.dll", + "dbghelp.dll", + }; class dbghelp : noncopyable { @@ -90,23 +97,24 @@ namespace micro_profiler dbghelp::dbghelp() { - const auto local_directory = ~get_module_info(&c_own_dbghelp_filename).path; + auto path_env = _wgetenv(L"PATH"); - _module.reset(::LoadLibraryW(unicode(local_directory & c_own_dbghelp_filename).c_str()), &FreeLibrary); - if (!_module) - _module.reset(::LoadLibraryW(L"dbghelp.dll"), &FreeLibrary); + path_env = path_env ? path_env : L""; + for (auto i = begin(c_dbghelps); !_module && i != end(c_dbghelps); ++i) + { + ::SetEnvironmentVariableW(L"PATH", (wstring(path_env) + L";" + unicode(~*i)).c_str()); + _module.reset(::LoadLibraryW(unicode(*i).c_str()), &FreeLibrary); + } + ::SetEnvironmentVariableW(L"PATH", path_env); const auto hmodule = static_cast(_module.get()); - SymEnumSymbols = reinterpret_cast(::GetProcAddress(hmodule, "SymEnumSymbols")); - SymGetLineFromAddr64 = reinterpret_cast(::GetProcAddress(hmodule, - "SymGetLineFromAddr64")); - _SymInitialize = reinterpret_cast(::GetProcAddress(hmodule, "SymInitialize")); - _SymCleanup = reinterpret_cast(::GetProcAddress(hmodule, "SymCleanup")); - _SymLoadModuleExW = reinterpret_cast(::GetProcAddress(hmodule, - "SymLoadModuleExW")); - _SymLoadModule64 = reinterpret_cast(::GetProcAddress(hmodule, - "SymLoadModule64")); + SymEnumSymbols = GET_PROC_ADDRESS(hmodule, SymEnumSymbols); + SymGetLineFromAddr64 = GET_PROC_ADDRESS(hmodule, SymGetLineFromAddr64); + _SymInitialize = GET_PROC_ADDRESS(hmodule, SymInitialize); + _SymCleanup = GET_PROC_ADDRESS(hmodule, SymCleanup); + _SymLoadModuleExW = GET_PROC_ADDRESS(hmodule, SymLoadModuleExW); + _SymLoadModule64 = GET_PROC_ADDRESS(hmodule, SymLoadModule64); if (!_SymInitialize(this, NULL, FALSE)) throw 0; diff --git a/deployment/vsix/manifest.json b/deployment/vsix/manifest.json index 155f2b00e..ea2edaccb 100644 --- a/deployment/vsix/manifest.json +++ b/deployment/vsix/manifest.json @@ -19,7 +19,12 @@ {"fileName":"/logo.ico","sha256":"!hashappicon!"}, {"fileName":"/libmicro-profiler_x86.so","sha256":"!hashlinuxmpx86!"}, {"fileName":"/libmicro-profiler_x64.so","sha256":"!hashlinuxmpx64!"}, - {"fileName":"/libmicro-profiler_arm.so","sha256":"!hashandroidarm!"} + {"fileName":"/libmicro-profiler_arm.so","sha256":"!hashandroidarm!"}, + + {"fileName":"/windows7+/x64/api-ms-win-downlevel-kernel32-l2-1-0.dll","sha256":"!hashkernel32downlevelapix64!"}, + {"fileName":"/windows7+/x64/dbghelp.dll","sha256":"!hashdbghelpx64!"}, + {"fileName":"/windows7+/x86/api-ms-win-downlevel-kernel32-l2-1-0.dll","sha256":"!hashkernel32downlevelapix86!"}, + {"fileName":"/windows7+/x86/dbghelp.dll","sha256":"!hashdbghelpx86!"} ], "dependencies":{"Microsoft.VisualStudio.Component.CoreEditor":"[11.0,17.0)"} }