From ab19941650b210691df002ee3278130c65be503b Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 10 Mar 2022 11:13:02 +0000 Subject: [PATCH] Use _NT_SYMBOL_PATH where available as search path for callstacks --- renderdoc/os/win32/win32_callstack.cpp | 33 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/renderdoc/os/win32/win32_callstack.cpp b/renderdoc/os/win32/win32_callstack.cpp index bb5ffa47c..942528f20 100644 --- a/renderdoc/os/win32/win32_callstack.cpp +++ b/renderdoc/os/win32/win32_callstack.cpp @@ -83,18 +83,31 @@ rdcarray modules; rdcwstr GetSymSearchPath() { - PWSTR appDataPath; - SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL, - &appDataPath); - rdcwstr appdata = appDataPath; - CoTaskMemFree(appDataPath); + std::wstring sympath; - std::wstring sympath = L".;"; - sympath += appdata.c_str(); - sympath += L"\\renderdoc\\symbols;SRV*"; - sympath += appdata.c_str(); - sympath += L"\\renderdoc\\symbols\\symsrv*http://msdl.microsoft.com/download/symbols"; + DWORD len = GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", NULL, 0); + if(len == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) + { + // set up a default sympath to look up MS's symbol servers and cache them locally in RenderDoc's + // appdata folder. + PWSTR appDataPath; + SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, + NULL, &appDataPath); + rdcwstr appdata = appDataPath; + CoTaskMemFree(appDataPath); + + sympath = L".;"; + sympath += appdata.c_str(); + sympath += L"\\renderdoc\\symbols;SRV*"; + sympath += appdata.c_str(); + sympath += L"\\renderdoc\\symbols\\symsrv*http://msdl.microsoft.com/download/symbols"; + + return sympath.c_str(); + } + + sympath.resize(len + 1); + GetEnvironmentVariableW(L"_NT_SYMBOL_PATH", &sympath[0], len); return sympath.c_str(); }