From 8b9dcbe519df972f6e0f3f96f4acc00135ee15f3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 13 Mar 2017 13:09:56 +0000 Subject: [PATCH] Remove pdblocate, move DIA2 usage into win32_callstack.cpp * Previously on VS2010, the DIA2 library wasn't properly supported on 64-bit, so it needed a separate program that always ran 32-bit and proxied operations over a named pipe. * Now DIA2 will load correctly in 32-bit and 64-bit, so we can do the work in-process without needing the separate exe. * We still need to distribute dbghelp.dll and symsrv.dll, so these now live alongside renderdoc.dll in the build/install folder with matching bitness. * At the same time fixed a bug I noticed where the 0-based module index would return 0 for the first valid module and be treated as invalid. --- CONTRIBUTING.md | 2 - pdblocate/pdblocate.vcxproj | 170 ------ pdblocate/pdblocate.vcxproj.filters | 6 - renderdoc.sln | 25 +- .../3rdparty/dbghelp/Win32}/dbghelp.dll | Bin .../3rdparty/dbghelp/Win32}/symsrv.dll | Bin .../3rdparty/dbghelp/Win32}/symsrv.yes | 0 .../3rdparty/dbghelp}/x64/dbghelp.dll | Bin .../3rdparty/dbghelp}/x64/symsrv.dll | Bin .../3rdparty/dbghelp}/x64/symsrv.yes | 0 .../os/win32/dia2_stubs.h | 476 +---------------- renderdoc/os/win32/win32_callstack.cpp | 500 +++++++++++------- renderdoc/renderdoc.vcxproj | 7 + renderdoc/renderdoc.vcxproj.filters | 3 + scripts/dist.sh | 5 +- scripts/installer/Installer32.wxs | 23 +- scripts/installer/Installer64.wxs | 48 +- scripts/travis/linux_setup.sh | 2 +- 18 files changed, 347 insertions(+), 920 deletions(-) delete mode 100644 pdblocate/pdblocate.vcxproj delete mode 100644 pdblocate/pdblocate.vcxproj.filters rename {pdblocate/x86 => renderdoc/3rdparty/dbghelp/Win32}/dbghelp.dll (100%) rename {pdblocate/x86 => renderdoc/3rdparty/dbghelp/Win32}/symsrv.dll (100%) rename {pdblocate/x86 => renderdoc/3rdparty/dbghelp/Win32}/symsrv.yes (100%) rename {pdblocate => renderdoc/3rdparty/dbghelp}/x64/dbghelp.dll (100%) rename {pdblocate => renderdoc/3rdparty/dbghelp}/x64/symsrv.dll (100%) rename {pdblocate => renderdoc/3rdparty/dbghelp}/x64/symsrv.yes (100%) rename pdblocate/pdblocate.cpp => renderdoc/os/win32/dia2_stubs.h (66%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 569c9984b..eae5f4437 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -167,8 +167,6 @@ There are [several pages](https://github.com/baldurk/renderdoc/wiki/Code-Dives) renderdocui/ ; The .NET UI layer built on top of renderdoc/ 3rdparty/ ; third party utilities & libraries included qrenderdoc/ ; The Qt UI layer built on top of renderdoc/ - pdblocate/ ; a simple stub program to invoke DIA to look up symbols/pdbs - ; for callstack resolution on windows docs/ ; source documentation for the .chm file or http://docs.renderdoc.org/ ; in the Sandcastle help file builder scripts/ ; folder for small scripts - e.g. for CI, installers, distribution diff --git a/pdblocate/pdblocate.vcxproj b/pdblocate/pdblocate.vcxproj deleted file mode 100644 index a971295cf..000000000 --- a/pdblocate/pdblocate.vcxproj +++ /dev/null @@ -1,170 +0,0 @@ - - - - - Development32 - Win32 - - - Development64 - Win32 - - - Release32 - Win32 - - - Release64 - Win32 - - - - {6CCB39BA-AB6B-4589-B7C4-9DA879571713} - Win32Proj - pdblocate - - - - v140 - - - v140 - - - v140 - - - v140 - - - Application - false - true - Unicode - - - - - - - - - - - - false - $(VSInstallDir)\DIA SDK\include;$(IncludePath) - $(SolutionDir)x64\Release\pdblocate\ - $(SolutionDir)x64\Release\obj\$(ProjectName)\ - - - false - $(VSInstallDir)\DIA SDK\include;$(IncludePath) - $(SolutionDir)Win32\Release\pdblocate\ - $(SolutionDir)Win32\Release\obj\$(ProjectName)\ - - - false - $(VSInstallDir)\DIA SDK\include;$(IncludePath) - $(SolutionDir)x64\Development\pdblocate\ - $(SolutionDir)x64\Development\obj\$(ProjectName)\ - - - false - $(VSInstallDir)\DIA SDK\include;$(IncludePath) - $(SolutionDir)Win32\Development\pdblocate\ - $(SolutionDir)Win32\Development\obj\$(ProjectName)\ - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(SolutionDir)renderdoc\3rdparty\ - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(SolutionDir)renderdoc\3rdparty\ - - - Windows - true - true - true - - - - - Level3 - - - Disabled - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(SolutionDir)renderdoc\3rdparty\ - - - Windows - true - true - true - - - - - Level3 - - - Disabled - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(SolutionDir)renderdoc\3rdparty\ - - - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pdblocate/pdblocate.vcxproj.filters b/pdblocate/pdblocate.vcxproj.filters deleted file mode 100644 index 212e4ea22..000000000 --- a/pdblocate/pdblocate.vcxproj.filters +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/renderdoc.sln b/renderdoc.sln index 33fca3597..482b3fc1a 100644 --- a/renderdoc.sln +++ b/renderdoc.sln @@ -10,7 +10,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderdoc", "renderdoc\rend {EC847717-119A-2391-0477-212E1140082C} = {EC847717-119A-2391-0477-212E1140082C} {B7399F39-300F-450E-F471-9490F959D2A7} = {B7399F39-300F-450E-F471-9490F959D2A7} {2A793574-BD3C-46D4-9788-C339D9550CE1} = {2A793574-BD3C-46D4-9788-C339D9550CE1} - {6CCB39BA-AB6B-4589-B7C4-9DA879571713} = {6CCB39BA-AB6B-4589-B7C4-9DA879571713} {EA1242CF-BB42-B1AC-9B6A-A508D96D1CB7} = {EA1242CF-BB42-B1AC-9B6A-A508D96D1CB7} EndProjectSection EndProject @@ -18,11 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "renderdocui", "renderdocui\ ProjectSection(ProjectDependencies) = postProject {6DEE3F12-F2F8-42CA-865A-578D0FD11387} = {6DEE3F12-F2F8-42CA-865A-578D0FD11387} {E2B46D67-90E2-40B6-9597-72930E7845E5} = {E2B46D67-90E2-40B6-9597-72930E7845E5} - {6CCB39BA-AB6B-4589-B7C4-9DA879571713} = {6CCB39BA-AB6B-4589-B7C4-9DA879571713} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pdblocate", "pdblocate\pdblocate.vcxproj", "{6CCB39BA-AB6B-4589-B7C4-9DA879571713}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "renderdocui\3rdparty\WinFormsUI\WinFormsUI.csproj", "{C75532C4-765B-418E-B09B-46D36B2ABDB1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLL", "DLL", "{B1FB29A4-9C48-4D47-BAEF-CF14CB2A40A3}" @@ -99,14 +95,6 @@ Global {5504BAC8-287E-4083-A57F-5EE172EDDAEB}.Release|Win32.Build.0 = Release|x86 {5504BAC8-287E-4083-A57F-5EE172EDDAEB}.Release|x64.ActiveCfg = Release|x64 {5504BAC8-287E-4083-A57F-5EE172EDDAEB}.Release|x64.Build.0 = Release|x64 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Development|Win32.ActiveCfg = Development32|Win32 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Development|Win32.Build.0 = Development32|Win32 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Development|x64.ActiveCfg = Development64|Win32 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Development|x64.Build.0 = Development64|Win32 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Release|Win32.ActiveCfg = Release32|Win32 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Release|Win32.Build.0 = Release32|Win32 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Release|x64.ActiveCfg = Release64|Win32 - {6CCB39BA-AB6B-4589-B7C4-9DA879571713}.Release|x64.Build.0 = Release64|Win32 {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Development|Win32.ActiveCfg = Development|Any CPU {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Development|Win32.Build.0 = Development|Any CPU {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Development|x64.ActiveCfg = Development|Any CPU @@ -225,25 +213,24 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {E2B46D67-90E2-40B6-9597-72930E7845E5} = {B1FB29A4-9C48-4D47-BAEF-CF14CB2A40A3} - {9B86ABCF-0A48-41CE-B109-FFA08D80F345} = {B1FB29A4-9C48-4D47-BAEF-CF14CB2A40A3} - {864A44B0-5612-451A-857F-41E3EF785EF6} = {B1FB29A4-9C48-4D47-BAEF-CF14CB2A40A3} - {C75532C4-765B-418E-B09B-46D36B2ABDB1} = {89059266-9C4E-4637-AB1D-BFF1DC15096B} {5504BAC8-287E-4083-A57F-5EE172EDDAEB} = {89059266-9C4E-4637-AB1D-BFF1DC15096B} + {C75532C4-765B-418E-B09B-46D36B2ABDB1} = {89059266-9C4E-4637-AB1D-BFF1DC15096B} {D03DF2F9-513C-4084-BBDD-1DEE8D9250D7} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C} - {6CCB39BA-AB6B-4589-B7C4-9DA879571713} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C} - {6DEE3F12-F2F8-42CA-865A-578D0FD11387} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C} + {9B86ABCF-0A48-41CE-B109-FFA08D80F345} = {B1FB29A4-9C48-4D47-BAEF-CF14CB2A40A3} {EA1242CF-BB42-B1AC-9B6A-A508D96D1CB7} = {9B86ABCF-0A48-41CE-B109-FFA08D80F345} {EC847717-119A-2391-0477-212E1140082C} = {9B86ABCF-0A48-41CE-B109-FFA08D80F345} {7893E300-3ED0-7F4C-158F-67EA63934C57} = {9B86ABCF-0A48-41CE-B109-FFA08D80F345} {B7399F39-300F-450E-F471-9490F959D2A7} = {9B86ABCF-0A48-41CE-B109-FFA08D80F345} + {6DEE3F12-F2F8-42CA-865A-578D0FD11387} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C} + {864A44B0-5612-451A-857F-41E3EF785EF6} = {B1FB29A4-9C48-4D47-BAEF-CF14CB2A40A3} {F1E59A05-60D4-4927-9E57-DD191EAE90EF} = {864A44B0-5612-451A-857F-41E3EF785EF6} {2A793574-BD3C-46D4-9788-C339D9550CE1} = {864A44B0-5612-451A-857F-41E3EF785EF6} {F92FCDA6-A261-4EEC-9CD0-73A11FBCC459} = {864A44B0-5612-451A-857F-41E3EF785EF6} {DB2DDA74-A668-4AC7-A1D5-198C9F0BD242} = {864A44B0-5612-451A-857F-41E3EF785EF6} + {C43FF27E-A155-4852-88EC-5CE9334C07A8} = {DB2DDA74-A668-4AC7-A1D5-198C9F0BD242} + {0AAE0AD1-371B-4A36-9ED1-80E10E960605} = {DB2DDA74-A668-4AC7-A1D5-198C9F0BD242} {88C5DAC6-30A0-4CFD-AF51-540A977D1F3F} = {864A44B0-5612-451A-857F-41E3EF785EF6} {9E6B10A2-84B4-434D-ABDB-43BE4EA650F4} = {864A44B0-5612-451A-857F-41E3EF785EF6} {44044776-9469-4079-B587-ABFFF6574AA4} = {864A44B0-5612-451A-857F-41E3EF785EF6} - {C43FF27E-A155-4852-88EC-5CE9334C07A8} = {DB2DDA74-A668-4AC7-A1D5-198C9F0BD242} - {0AAE0AD1-371B-4A36-9ED1-80E10E960605} = {DB2DDA74-A668-4AC7-A1D5-198C9F0BD242} EndGlobalSection EndGlobal diff --git a/pdblocate/x86/dbghelp.dll b/renderdoc/3rdparty/dbghelp/Win32/dbghelp.dll similarity index 100% rename from pdblocate/x86/dbghelp.dll rename to renderdoc/3rdparty/dbghelp/Win32/dbghelp.dll diff --git a/pdblocate/x86/symsrv.dll b/renderdoc/3rdparty/dbghelp/Win32/symsrv.dll similarity index 100% rename from pdblocate/x86/symsrv.dll rename to renderdoc/3rdparty/dbghelp/Win32/symsrv.dll diff --git a/pdblocate/x86/symsrv.yes b/renderdoc/3rdparty/dbghelp/Win32/symsrv.yes similarity index 100% rename from pdblocate/x86/symsrv.yes rename to renderdoc/3rdparty/dbghelp/Win32/symsrv.yes diff --git a/pdblocate/x64/dbghelp.dll b/renderdoc/3rdparty/dbghelp/x64/dbghelp.dll similarity index 100% rename from pdblocate/x64/dbghelp.dll rename to renderdoc/3rdparty/dbghelp/x64/dbghelp.dll diff --git a/pdblocate/x64/symsrv.dll b/renderdoc/3rdparty/dbghelp/x64/symsrv.dll similarity index 100% rename from pdblocate/x64/symsrv.dll rename to renderdoc/3rdparty/dbghelp/x64/symsrv.dll diff --git a/pdblocate/x64/symsrv.yes b/renderdoc/3rdparty/dbghelp/x64/symsrv.yes similarity index 100% rename from pdblocate/x64/symsrv.yes rename to renderdoc/3rdparty/dbghelp/x64/symsrv.yes diff --git a/pdblocate/pdblocate.cpp b/renderdoc/os/win32/dia2_stubs.h similarity index 66% rename from pdblocate/pdblocate.cpp rename to renderdoc/os/win32/dia2_stubs.h index 79d0b7737..e063b426a 100644 --- a/pdblocate/pdblocate.cpp +++ b/renderdoc/os/win32/dia2_stubs.h @@ -1,8 +1,7 @@ /****************************************************************************** * The MIT License (MIT) * - * Copyright (c) 2015-2017 Baldur Karlsson - * Copyright (c) 2014 Crytek + * Copyright (c) 2017 Baldur Karlsson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,19 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dbghelp/dbghelp.h" - -using std::vector; -using std::wstring; +#pragma once // Inline the couple of necessary definitions from dia2.h below //#include @@ -332,461 +319,4 @@ IDiaDataSource : public IUnknown virtual HRESULT STDMETHODCALLTYPE openSession(IDiaSession * *ppSession) = 0; }; -class DECLSPEC_UUID("B86AE24D-BF2F-4ac9-B5A2-34B14E4CE11D") DiaSource; - -// must match definition in callstack.h -struct AddrInfo -{ - wchar_t funcName[127]; - wchar_t fileName[127]; - unsigned long lineNum; -}; - -struct Module -{ - Module(IDiaDataSource *src, IDiaSession *sess) : pSource(src), pSession(sess) {} - IDiaDataSource *pSource; - IDiaSession *pSession; -}; - -vector modules; - -typedef BOOL(WINAPI *PSYMINITIALIZEW)(__in HANDLE hProcess, __in_opt PCWSTR UserSearchPath, - __in BOOL fInvadeProcess); -typedef BOOL(WINAPI *PSYMFINDFILEINPATHW)(__in HANDLE hprocess, __in_opt PCWSTR SearchPath, - __in PCWSTR FileName, __in_opt PVOID id, __in DWORD two, - __in DWORD three, __in DWORD flags, - __out_ecount(MAX_PATH + 1) PWSTR FoundFile, - __in_opt PFINDFILEINPATHCALLBACKW callback, - __in_opt PVOID context); - -PSYMINITIALIZEW dynSymInitializeW = NULL; -PSYMFINDFILEINPATHW dynSymFindFileInPathW = NULL; - -wstring GetSymSearchPath() -{ - PWSTR appDataPath; - SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL, - &appDataPath); - wstring appdata = appDataPath; - CoTaskMemFree(appDataPath); - - wstring sympath = L".;"; - sympath += appdata; - sympath += L"\\renderdoc\\symbols;SRV*"; - sympath += appdata; - sympath += L"\\renderdoc\\symbols\\symsrv*http://msdl.microsoft.com/download/symbols"; - - return sympath; -} - -wstring LookupModule(wstring moduleDetails) -{ - uint32_t params[12]; - int charsRead = 0; - swscanf_s(moduleDetails.c_str(), L"%d %d %d %d %d %d %d %d %d %d %d %d%n", ¶ms[0], - ¶ms[1], ¶ms[2], ¶ms[3], ¶ms[4], ¶ms[5], ¶ms[6], ¶ms[7], - ¶ms[8], ¶ms[9], ¶ms[10], ¶ms[11], &charsRead); - - wchar_t *modName = (wchar_t *)moduleDetails.c_str() + charsRead + 1; - - while(*modName != L'\0' && iswspace(*modName)) - modName++; - - DWORD age = params[0]; - GUID guid; - guid.Data1 = params[1]; - guid.Data2 = params[2]; - guid.Data3 = params[3]; - guid.Data4[0] = params[4]; - guid.Data4[1] = params[5]; - guid.Data4[2] = params[6]; - guid.Data4[3] = params[7]; - guid.Data4[4] = params[8]; - guid.Data4[5] = params[9]; - guid.Data4[6] = params[10]; - guid.Data4[7] = params[11]; - - wchar_t *pdbName = modName; - - if(wcsrchr(pdbName, L'\\')) - pdbName = wcsrchr(pdbName, L'\\') + 1; - - if(wcsrchr(pdbName, L'/')) - pdbName = wcsrchr(pdbName, L'/') + 1; - - if(wcsstr(pdbName, L".pdb") == NULL && wcsstr(pdbName, L".PDB") == NULL) - { - wchar_t *ext = wcsrchr(pdbName, L'.'); - - if(ext) - { - ext[1] = L'p'; - ext[2] = L'd'; - ext[3] = L'b'; - } - } - - wstring ret = modName; - - if(dynSymFindFileInPathW != NULL) - { - wstring sympath = GetSymSearchPath(); - - wchar_t path[MAX_PATH + 1] = {0}; - BOOL found = dynSymFindFileInPathW(GetCurrentProcess(), sympath.c_str(), pdbName, &guid, age, 0, - SSRVOPT_GUIDPTR, path, NULL, NULL); - DWORD err = GetLastError(); - - if(found == TRUE && path[0] != 0) - ret = path; - } - - return ret; -} - -uint32_t GetModule(wstring moduleDetails) -{ - uint32_t params[12]; - int charsRead = 0; - swscanf_s(moduleDetails.c_str(), L"%d %d %d %d %d %d %d %d %d %d %d %d%n", ¶ms[0], - ¶ms[1], ¶ms[2], ¶ms[3], ¶ms[4], ¶ms[5], ¶ms[6], ¶ms[7], - ¶ms[8], ¶ms[9], ¶ms[10], ¶ms[11], &charsRead); - - wchar_t *pdbName = (wchar_t *)moduleDetails.c_str() + charsRead + 1; - - while(*pdbName != L'\0' && iswspace(*pdbName)) - pdbName++; - - DWORD age = params[0]; - GUID guid; - guid.Data1 = params[1]; - guid.Data2 = params[2]; - guid.Data3 = params[3]; - guid.Data4[0] = params[4]; - guid.Data4[1] = params[5]; - guid.Data4[2] = params[6]; - guid.Data4[3] = params[7]; - guid.Data4[4] = params[8]; - guid.Data4[5] = params[9]; - guid.Data4[6] = params[10]; - guid.Data4[7] = params[11]; - - Module m(NULL, NULL); - - CoCreateInstance(__uuidof(DiaSource), NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiaDataSource), - (void **)&m.pSource); - - HRESULT hr = S_OK; - - // check this pdb is the one we expected from our chunk - if(guid.Data1 == 0 && guid.Data2 == 0) - { - hr = m.pSource->loadDataFromPdb(pdbName); - } - else - { - hr = m.pSource->loadAndValidateDataFromPdb(pdbName, &guid, 0, age); - } - - if(SUCCEEDED(hr)) - { - // open the session - hr = m.pSource->openSession(&m.pSession); - if(FAILED(hr)) - { - m.pSource->Release(); - return 0; - } - - modules.push_back(m); - - return modules.size() - 1; - } - - m.pSource->Release(); - - return 0; -} - -void SetBaseAddress(wstring req) -{ - uint32_t module; - uint64_t addr; - int charsRead = swscanf_s(req.c_str(), L"%d %llu", &module, &addr); - - if(module > 0 && module < modules.size()) - modules[module].pSession->put_loadAddress(addr); -} - -AddrInfo GetAddr(wstring req) -{ - uint32_t module; - uint64_t addr; - int charsRead = swscanf_s(req.c_str(), L"%d %llu", &module, &addr); - - AddrInfo ret; - ZeroMemory(&ret, sizeof(ret)); - - if(module > 0 && module < modules.size()) - { - SymTagEnum tag = SymTagFunction; - IDiaSymbol *pFunc = NULL; - HRESULT hr = modules[module].pSession->findSymbolByVA(addr, tag, &pFunc); - - if(hr != S_OK) - { - if(pFunc) - pFunc->Release(); - - // try again looking for public symbols - tag = SymTagPublicSymbol; - hr = modules[module].pSession->findSymbolByVA(addr, tag, &pFunc); - - if(hr != S_OK) - { - if(pFunc) - pFunc->Release(); - return ret; - } - } - - DWORD opts = 0; - opts |= UNDNAME_NO_LEADING_UNDERSCORES; - opts |= UNDNAME_NO_MS_KEYWORDS; - opts |= UNDNAME_NO_FUNCTION_RETURNS; - opts |= UNDNAME_NO_ALLOCATION_MODEL; - opts |= UNDNAME_NO_ALLOCATION_LANGUAGE; - opts |= UNDNAME_NO_THISTYPE; - opts |= UNDNAME_NO_ACCESS_SPECIFIERS; - opts |= UNDNAME_NO_THROW_SIGNATURES; - opts |= UNDNAME_NO_MEMBER_TYPE; - opts |= UNDNAME_NO_RETURN_UDT_MODEL; - opts |= UNDNAME_32_BIT_DECODE; - opts |= UNDNAME_NO_LEADING_UNDERSCORES; - - // first try undecorated name - BSTR file; - hr = pFunc->get_undecoratedNameEx(opts, &file); - - // if not, just try name - if(hr != S_OK) - { - hr = pFunc->get_name(&file); - - if(hr != S_OK) - { - pFunc->Release(); - SysFreeString(file); - return ret; - } - - wcsncpy_s(ret.funcName, file, 126); - } - else - { - wcsncpy_s(ret.funcName, file, 126); - - wchar_t *voidparam = wcsstr(ret.funcName, L"(void)"); - - // remove stupid (void) for empty parameters - if(voidparam != NULL) - { - *(voidparam + 1) = L')'; - *(voidparam + 2) = 0; - } - } - - pFunc->Release(); - pFunc = NULL; - - SysFreeString(file); - - // find the line numbers touched by this address. - IDiaEnumLineNumbers *lines = NULL; - hr = modules[module].pSession->findLinesByVA(addr, DWORD(4), &lines); - if(FAILED(hr)) - { - if(lines) - lines->Release(); - return ret; - } - - IDiaLineNumber *line = NULL; - ULONG count = 0; - - // just take the first one - if(SUCCEEDED(lines->Next(1, &line, &count)) && count == 1) - { - IDiaSourceFile *dia_source = NULL; - hr = line->get_sourceFile(&dia_source); - if(FAILED(hr)) - { - line->Release(); - lines->Release(); - if(dia_source) - dia_source->Release(); - return ret; - } - - hr = dia_source->get_fileName(&file); - if(FAILED(hr)) - { - line->Release(); - lines->Release(); - dia_source->Release(); - return ret; - } - - wcsncpy_s(ret.fileName, file, 126); - - SysFreeString(file); - - dia_source->Release(); - dia_source = NULL; - - DWORD line_num = 0; - hr = line->get_lineNumber(&line_num); - if(FAILED(hr)) - { - line->Release(); - lines->Release(); - return ret; - } - - ret.lineNum = line_num; - - line->Release(); - } - - lines->Release(); - } - - return ret; -} - -wstring HandleRequest(wstring req) -{ - size_t idx = req.find(L' '); - - if(idx == wstring::npos) - return L"."; - - wstring type = req.substr(0, idx); - wstring payload = req.substr(idx + 1); - - if(type == L"lookup") - return LookupModule(payload); - - if(type == L"baseaddr") - { - SetBaseAddress(payload); - return L"."; - } - - if(type == L"getmodule") - { - wstring ret; - ret.resize(4); - - uint32_t *output = (uint32_t *)&ret[0]; - - *output = GetModule(payload); - - return ret; - } - - if(type == L"getaddr") - { - wstring ret; - ret.resize(sizeof(AddrInfo) / sizeof(wchar_t)); - - AddrInfo info = GetAddr(payload); - - memcpy(&ret[0], &info, sizeof(AddrInfo)); - - return ret; - } - - return L"."; -} - -int WINAPI wWinMain(__in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, - __in LPWSTR lpCmdLine, __in int nShowCmd) -{ - modules.push_back(Module(NULL, NULL)); - - // CreatePipe - HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\RenderDoc.pdblocate", PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, 1024, - 1024, 0, NULL); - - if(pipe == INVALID_HANDLE_VALUE) - return 1; - - BOOL connected = ConnectNamedPipe(pipe, NULL); - if(!connected && GetLastError() == ERROR_PIPE_CONNECTED) - connected = true; - - if(!connected) - { - CloseHandle(pipe); - return 1; - } - - CoInitialize(NULL); - - HMODULE mod = LoadLibraryW(L"x86/dbghelp.dll"); - - if(mod != NULL) - { - dynSymInitializeW = (PSYMINITIALIZEW)GetProcAddress(mod, "SymInitializeW"); - dynSymFindFileInPathW = (PSYMFINDFILEINPATHW)GetProcAddress(mod, "SymFindFileInPathW"); - - wstring sympath = GetSymSearchPath(); - - if(dynSymInitializeW != NULL) - { - dynSymInitializeW(GetCurrentProcess(), sympath.c_str(), TRUE); - } - } - - wchar_t buf[1024]; - - while(true) - { - DWORD read = 0; - BOOL success = ReadFile(pipe, buf, 1024, &read, NULL); - - if(!success || read == 0) - { - DWORD err = GetLastError(); - break; - } - - wstring request(buf, buf + read / sizeof(wchar_t)); - if(request.back() != L'\0') - request.push_back(L'\0'); - - wstring reply = HandleRequest(request); - - reply.push_back(L'\0'); - - DWORD msglen = reply.length() * sizeof(wchar_t); - - DWORD written = 0; - success = WriteFile(pipe, reply.c_str(), msglen, &written, NULL); - - if(!success || written != msglen) - { - DWORD err = GetLastError(); - break; - } - } - - if(mod != NULL) - FreeLibrary(mod); - - CloseHandle(pipe); - return 0; -} +class DECLSPEC_UUID("e6756135-1e65-4d17-8576-610761398c3c") DiaSource; diff --git a/renderdoc/os/win32/win32_callstack.cpp b/renderdoc/os/win32/win32_callstack.cpp index 56de82b28..5ac331693 100644 --- a/renderdoc/os/win32/win32_callstack.cpp +++ b/renderdoc/os/win32/win32_callstack.cpp @@ -34,10 +34,309 @@ #include #include #include +#include "core/core.h" #include "dbghelp/dbghelp.h" #include "os/os_specific.h" #include "serialise/string_utils.h" +#include "dia2_stubs.h" + +struct AddrInfo +{ + wchar_t funcName[127]; + wchar_t fileName[127]; + unsigned long lineNum; +}; + +typedef BOOL(CALLBACK *PSYM_ENUMMODULES_CALLBACK64W)(__in PCWSTR ModuleName, __in DWORD64 BaseOfDll, + __in_opt PVOID UserContext); + +typedef BOOL(WINAPI *PSYMINITIALIZEW)(HANDLE, PCTSTR, BOOL); +typedef BOOL(WINAPI *PSYMREFRESHMODULELIST)(HANDLE); +typedef BOOL(WINAPI *PSYMENUMERATEMODULES64W)(HANDLE, PSYM_ENUMMODULES_CALLBACK64W, PVOID); +typedef BOOL(WINAPI *PSYMGETMODULEINFO64W)(HANDLE, DWORD64, PIMAGEHLP_MODULEW64); +typedef BOOL(WINAPI *PSYMFINDFILEINPATHW)(__in HANDLE hprocess, __in_opt PCWSTR SearchPath, + __in PCWSTR FileName, __in_opt PVOID id, __in DWORD two, + __in DWORD three, __in DWORD flags, + __out_ecount(MAX_PATH + 1) PWSTR FoundFile, + __in_opt PFINDFILEINPATHCALLBACKW callback, + __in_opt PVOID context); + +PSYMINITIALIZEW dynSymInitializeW = NULL; +PSYMREFRESHMODULELIST dynSymRefreshModuleList = NULL; +PSYMENUMERATEMODULES64W dynSymEnumerateModules64W = NULL; +PSYMGETMODULEINFO64W dynSymGetModuleInfo64W = NULL; +PSYMFINDFILEINPATHW dynSymFindFileInPathW = NULL; + +namespace DIA2 +{ +struct Module +{ + Module(IDiaDataSource *src, IDiaSession *sess) : pSource(src), pSession(sess) {} + IDiaDataSource *pSource; + IDiaSession *pSession; +}; + +vector modules; + +wstring GetSymSearchPath() +{ + PWSTR appDataPath; + SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL, + &appDataPath); + wstring appdata = appDataPath; + CoTaskMemFree(appDataPath); + + wstring sympath = L".;"; + sympath += appdata; + sympath += L"\\renderdoc\\symbols;SRV*"; + sympath += appdata; + sympath += L"\\renderdoc\\symbols\\symsrv*http://msdl.microsoft.com/download/symbols"; + + return sympath; +} + +wstring LookupModule(const wchar_t *modName, GUID guid, DWORD age) +{ + wstring ret = modName; + + wchar_t *pdbName = &ret[0]; + + if(wcsrchr(pdbName, L'\\')) + pdbName = wcsrchr(pdbName, L'\\') + 1; + + if(wcsrchr(pdbName, L'/')) + pdbName = wcsrchr(pdbName, L'/') + 1; + + if(wcsstr(pdbName, L".pdb") == NULL && wcsstr(pdbName, L".PDB") == NULL) + { + wchar_t *ext = wcsrchr(pdbName, L'.'); + + if(ext) + { + ext[1] = L'p'; + ext[2] = L'd'; + ext[3] = L'b'; + } + } + + if(dynSymFindFileInPathW != NULL) + { + wstring sympath = GetSymSearchPath(); + + wchar_t path[MAX_PATH + 1] = {0}; + BOOL found = dynSymFindFileInPathW(GetCurrentProcess(), sympath.c_str(), pdbName, &guid, age, 0, + SSRVOPT_GUIDPTR, path, NULL, NULL); + DWORD err = GetLastError(); + (void)err; // for debugging only + + if(found == TRUE && path[0] != 0) + ret = path; + } + + return ret; +} + +uint32_t GetModule(const wchar_t *pdbName, GUID guid, DWORD age) +{ + Module m(NULL, NULL); + + HRESULT hr = CoCreateInstance(__uuidof(DiaSource), NULL, CLSCTX_INPROC_SERVER, + __uuidof(IDiaDataSource), (void **)&m.pSource); + + if(FAILED(hr)) + { + return 0; + } + + // check this pdb is the one we expected from our chunk + if(guid.Data1 == 0 && guid.Data2 == 0) + { + hr = m.pSource->loadDataFromPdb(pdbName); + } + else + { + hr = m.pSource->loadAndValidateDataFromPdb(pdbName, &guid, 0, age); + } + + if(SUCCEEDED(hr)) + { + // open the session + hr = m.pSource->openSession(&m.pSession); + if(FAILED(hr)) + { + m.pSource->Release(); + return 0; + } + + modules.push_back(m); + + return uint32_t(modules.size()); + } + + m.pSource->Release(); + + return 0; +} + +void SetBaseAddress(uint32_t module, uint64_t addr) +{ + if(module > 0 && module <= modules.size()) + modules[module - 1].pSession->put_loadAddress(addr); +} + +AddrInfo GetAddr(uint32_t module, uint64_t addr) +{ + AddrInfo ret; + ZeroMemory(&ret, sizeof(ret)); + + if(module > 0 && module <= modules.size()) + { + SymTagEnum tag = SymTagFunction; + IDiaSymbol *pFunc = NULL; + HRESULT hr = modules[module - 1].pSession->findSymbolByVA(addr, tag, &pFunc); + + if(hr != S_OK) + { + if(pFunc) + pFunc->Release(); + + // try again looking for public symbols + tag = SymTagPublicSymbol; + hr = modules[module - 1].pSession->findSymbolByVA(addr, tag, &pFunc); + + if(hr != S_OK) + { + if(pFunc) + pFunc->Release(); + return ret; + } + } + + DWORD opts = 0; + opts |= UNDNAME_NO_LEADING_UNDERSCORES; + opts |= UNDNAME_NO_MS_KEYWORDS; + opts |= UNDNAME_NO_FUNCTION_RETURNS; + opts |= UNDNAME_NO_ALLOCATION_MODEL; + opts |= UNDNAME_NO_ALLOCATION_LANGUAGE; + opts |= UNDNAME_NO_THISTYPE; + opts |= UNDNAME_NO_ACCESS_SPECIFIERS; + opts |= UNDNAME_NO_THROW_SIGNATURES; + opts |= UNDNAME_NO_MEMBER_TYPE; + opts |= UNDNAME_NO_RETURN_UDT_MODEL; + opts |= UNDNAME_32_BIT_DECODE; + opts |= UNDNAME_NO_LEADING_UNDERSCORES; + + // first try undecorated name + BSTR file; + hr = pFunc->get_undecoratedNameEx(opts, &file); + + // if not, just try name + if(hr != S_OK) + { + hr = pFunc->get_name(&file); + + if(hr != S_OK) + { + pFunc->Release(); + SysFreeString(file); + return ret; + } + + wcsncpy_s(ret.funcName, file, 126); + } + else + { + wcsncpy_s(ret.funcName, file, 126); + + wchar_t *voidparam = wcsstr(ret.funcName, L"(void)"); + + // remove stupid (void) for empty parameters + if(voidparam != NULL) + { + *(voidparam + 1) = L')'; + *(voidparam + 2) = 0; + } + } + + pFunc->Release(); + pFunc = NULL; + + SysFreeString(file); + + // find the line numbers touched by this address. + IDiaEnumLineNumbers *lines = NULL; + hr = modules[module - 1].pSession->findLinesByVA(addr, DWORD(4), &lines); + if(FAILED(hr)) + { + if(lines) + lines->Release(); + return ret; + } + + IDiaLineNumber *line = NULL; + ULONG count = 0; + + // just take the first one + if(SUCCEEDED(lines->Next(1, &line, &count)) && count == 1) + { + IDiaSourceFile *dia_source = NULL; + hr = line->get_sourceFile(&dia_source); + if(FAILED(hr)) + { + line->Release(); + lines->Release(); + if(dia_source) + dia_source->Release(); + return ret; + } + + hr = dia_source->get_fileName(&file); + if(FAILED(hr)) + { + line->Release(); + lines->Release(); + dia_source->Release(); + return ret; + } + + wcsncpy_s(ret.fileName, file, 126); + + SysFreeString(file); + + dia_source->Release(); + dia_source = NULL; + + DWORD line_num = 0; + hr = line->get_lineNumber(&line_num); + if(FAILED(hr)) + { + line->Release(); + lines->Release(); + return ret; + } + + ret.lineNum = line_num; + + line->Release(); + } + + lines->Release(); + } + + return ret; +} + +void Init() +{ + CoInitialize(NULL); + + if(dynSymInitializeW) + dynSymInitializeW(GetCurrentProcess(), GetSymSearchPath().c_str(), TRUE); +} + +}; // namespace DIA2 + class Win32Callstack : public Callstack::Stackwalk { public: @@ -67,25 +366,7 @@ public: Callstack::AddressDetails GetAddr(uint64_t addr); private: - // must match definition in pdblocate.cpp - struct AddrInfo - { - wchar_t funcName[127]; - wchar_t fileName[127]; - unsigned long lineNum; - - wchar_t *formattedString(const char *commonPath = NULL); - }; - wstring pdbBrowse(wstring startingPoint); - wstring LookupModule(wchar_t *modName, GUID guid, DWORD age); - - void *SendRecvPipeMessage(wstring message); - - void OpenPdblocateHandle(); - uint32_t GetModuleID(wstring pdbName, GUID guid, DWORD age); - void SetModuleBaseAddress(uint32_t moduleId, DWORD64 base); - AddrInfo GetAddrInfoForModule(uint32_t moduleId, DWORD64 addr); struct Module { @@ -96,9 +377,6 @@ private: uint32_t moduleId; }; - HANDLE pdblocateProcess; - HANDLE pdblocatePipe; - vector pdbRememberedPaths; vector pdbIgnores; vector modules; @@ -108,19 +386,6 @@ private: /////////////////////////////////////////////////// -typedef BOOL(CALLBACK *PSYM_ENUMMODULES_CALLBACK64W)(__in PCWSTR ModuleName, __in DWORD64 BaseOfDll, - __in_opt PVOID UserContext); - -typedef BOOL(WINAPI *PSYMINITIALIZEW)(HANDLE, PCTSTR, BOOL); -typedef BOOL(WINAPI *PSYMREFRESHMODULELIST)(HANDLE); -typedef BOOL(WINAPI *PSYMENUMERATEMODULES64W)(HANDLE, PSYM_ENUMMODULES_CALLBACK64W, PVOID); -typedef BOOL(WINAPI *PSYMGETMODULEINFO64W)(HANDLE, DWORD64, PIMAGEHLP_MODULEW64); - -PSYMINITIALIZEW dynSymInitializeW = NULL; -PSYMREFRESHMODULELIST dynSymRefreshModuleList = NULL; -PSYMENUMERATEMODULES64W dynSymEnumerateModules64W = NULL; -PSYMGETMODULEINFO64W dynSymGetModuleInfo64W = NULL; - void *renderdocBase = NULL; uint32_t renderdocSize = 0; @@ -173,9 +438,9 @@ static bool InitDbgHelp() } #if ENABLED(RDOC_X64) - wcscat_s(path, L"/pdblocate/x64/dbghelp.dll"); + wcscat_s(path, L"/dbghelp.dll"); #else - wcscat_s(path, L"/pdblocate/x86/dbghelp.dll"); + wcscat_s(path, L"/dbghelp.dll"); #endif module = LoadLibraryW(path); @@ -193,6 +458,7 @@ static bool InitDbgHelp() (PSYMENUMERATEMODULES64W)GetProcAddress(module, "SymEnumerateModulesW64"); dynSymRefreshModuleList = (PSYMREFRESHMODULELIST)GetProcAddress(module, "SymRefreshModuleList"); dynSymGetModuleInfo64W = (PSYMGETMODULEINFO64W)GetProcAddress(module, "SymGetModuleInfoW64"); + dynSymFindFileInPathW = (PSYMFINDFILEINPATHW)GetProcAddress(module, "SymFindFileInPathW"); if(!dynSymInitializeW || !dynSymRefreshModuleList || !dynSymEnumerateModules64W || !dynSymGetModuleInfo64W) @@ -222,6 +488,11 @@ static bool InitDbgHelp() } } + if(RenderDoc::Inst().IsReplayApp()) + { + DIA2::Init(); + } + ret = true; return ret; } @@ -395,135 +666,6 @@ wstring Win32CallstackResolver::pdbBrowse(wstring startingPoint) return outBuf; } -void Win32CallstackResolver::OpenPdblocateHandle() -{ - STARTUPINFOW si; - RDCEraseEl(si); - - PROCESS_INFORMATION pi; - RDCEraseEl(pi); - - wchar_t locateCmd[128] = {0}; - - wcscpy_s(locateCmd, L"\".\\pdblocate\\pdblocate.exe\""); - - BOOL success = CreateProcessW(NULL, locateCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); - - if(!success) - return; - - Sleep(100); - - CloseHandle(pi.hThread); - - pdblocateProcess = pi.hProcess; - - pdblocatePipe = CreateFileW(L"\\\\.\\pipe\\RenderDoc.pdblocate", GENERIC_READ | GENERIC_WRITE, 0, - NULL, OPEN_EXISTING, 0, NULL); - - if(pdblocatePipe == INVALID_HANDLE_VALUE) - { - RDCERR("Couldn't open pdblocate pipe"); - CloseHandle(pdblocatePipe); - pdblocatePipe = NULL; - return; - } - - DWORD mode = PIPE_READMODE_MESSAGE; - success = SetNamedPipeHandleState(pdblocatePipe, &mode, NULL, NULL); - - if(!success) - { - RDCERR("Couldn't set pdblocate pipe to message mode"); - CloseHandle(pdblocatePipe); - pdblocatePipe = NULL; - return; - } -} - -void *Win32CallstackResolver::SendRecvPipeMessage(wstring message) -{ - if(pdblocatePipe == NULL) - return NULL; - - DWORD written = 0; - DWORD msgLen = (DWORD)message.length() * sizeof(wchar_t); - BOOL success = WriteFile(pdblocatePipe, message.c_str(), msgLen, &written, NULL); - - if(!success || written != msgLen) - return NULL; - - byte *bufPtr = (byte *)pipeMessageBuf; - DWORD bufSize = sizeof(pipeMessageBuf); - - do - { - DWORD read = 0; - success = ReadFile(pdblocatePipe, bufPtr, bufSize, &read, NULL); - - RDCDEBUG("'%ls' -> %lu", message.c_str(), read); - - DWORD err = GetLastError(); - if(!success && err != ERROR_MORE_DATA) - { - break; - } - - bufPtr += read; - bufSize -= read; - } while(!success); - - RDCDEBUG("buf: %02x %02x %02x %02x", bufPtr[0], bufPtr[1], bufPtr[2], bufPtr[3]); - - return pipeMessageBuf; -} - -std::wstring Win32CallstackResolver::LookupModule(wchar_t *modName, GUID guid, DWORD age) -{ - wchar_t msg[1024] = {0}; - swprintf_s(msg, L"lookup %d %d %d %d %d %d %d %d %d %d %d %d %ls", age, guid.Data1, guid.Data2, - guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], - guid.Data4[5], guid.Data4[6], guid.Data4[7], modName); - - wchar_t *ret = (wchar_t *)SendRecvPipeMessage(msg); - - wstring result = (ret == NULL ? L"" : ret); - - if(result == L"Not Found") - result = L""; - - return result; -} - -void Win32CallstackResolver::SetModuleBaseAddress(uint32_t moduleId, DWORD64 base) -{ - wchar_t msg[1024]; - swprintf_s(msg, L"baseaddr %d %llu", moduleId, base); - SendRecvPipeMessage(msg); -} - -uint32_t Win32CallstackResolver::GetModuleID(wstring pdbName, GUID guid, DWORD age) -{ - wchar_t msg[1024] = {0}; - swprintf_s(msg, L"getmodule %d %d %d %d %d %d %d %d %d %d %d %d %ls", age, guid.Data1, - guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], - guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7], pdbName.c_str()); - - uint32_t *modID = (uint32_t *)SendRecvPipeMessage(msg); - - return modID == NULL ? 0 : *modID; -} - -Win32CallstackResolver::AddrInfo Win32CallstackResolver::GetAddrInfoForModule(uint32_t moduleId, - DWORD64 addr) -{ - wchar_t msg[1024]; - swprintf_s(msg, L"getaddr %d %llu", moduleId, addr); - - AddrInfo *info = (AddrInfo *)SendRecvPipeMessage(msg); - return info == NULL ? AddrInfo() : *info; -} - Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, string pdbSearchPaths, volatile bool *killSignal) { @@ -563,11 +705,6 @@ Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, st split(widepdbsearch, pdbRememberedPaths, L';'); - pdblocateProcess = NULL; - pdblocatePipe = NULL; - - OpenPdblocateHandle(); - if(memcmp(moduleDB, "WN32CALL", 8)) { RDCWARN("Can't load callstack resolve for this log. Possibly from another platform?"); @@ -580,9 +717,6 @@ Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, st EnumModChunk *chunk = (EnumModChunk *)(chunks); WCHAR *modName = (WCHAR *)(chunks + sizeof(EnumModChunk)); - if(pdblocatePipe == NULL) - return; - // loop over all our modules for(; chunks < end; chunks += sizeof(EnumModChunk) + (chunk->imageNameLen) * sizeof(WCHAR)) { @@ -608,8 +742,8 @@ Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, st } // get default pdb (this also looks up symbol server etc) - // relies on pdblocate. Always done in unicode - std::wstring defaultPdb = LookupModule(modName, chunk->guid, chunk->age); + // Always done in unicode + std::wstring defaultPdb = DIA2::LookupModule(modName, chunk->guid, chunk->age); // strip newline if(defaultPdb != L"" && defaultPdb[defaultPdb.length() - 1] == '\n') @@ -674,7 +808,7 @@ Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, st failed = false; } - m.moduleId = GetModuleID(pdbName, chunk->guid, chunk->age); + m.moduleId = DIA2::GetModule(pdbName.c_str(), chunk->guid, chunk->age); if(m.moduleId == 0) { @@ -701,8 +835,10 @@ Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, st RDCWARN("Couldn't get symbols for %ls", m.name.c_str()); - // silently ignore renderdoc.dll and dbghelp.dll without asking to permanently ignore - if(m.name.find(L"renderdoc") != wstring::npos || m.name.find(L"dbghelp") != wstring::npos) + // silently ignore renderdoc.dll, dbghelp.dll, and symsrv.dll without asking to permanently + // ignore + if(m.name.find(L"renderdoc.") != wstring::npos || m.name.find(L"dbghelp.") != wstring::npos || + m.name.find(L"symsrv.") != wstring::npos) continue; wchar_t text[1024]; @@ -716,7 +852,7 @@ Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, st continue; } - SetModuleBaseAddress(m.moduleId, chunk->base); + DIA2::SetBaseAddress(m.moduleId, chunk->base); RDCLOG("Loaded Symbols for %ls", m.name.c_str()); @@ -731,10 +867,6 @@ Win32CallstackResolver::Win32CallstackResolver(char *moduleDB, size_t DBSize, st Win32CallstackResolver::~Win32CallstackResolver() { - if(pdblocatePipe != NULL) - CloseHandle(pdblocatePipe); - if(pdblocateProcess != NULL) - TerminateProcess(pdblocateProcess, 0); } Callstack::AddressDetails Win32CallstackResolver::GetAddr(DWORD64 addr) @@ -755,7 +887,7 @@ Callstack::AddressDetails Win32CallstackResolver::GetAddr(DWORD64 addr) if(addr > base && addr < base + size) { if(modules[i].moduleId != 0) - info = GetAddrInfoForModule(modules[i].moduleId, addr); + info = DIA2::GetAddr(modules[i].moduleId, addr); // if we didn't get a filename, default to the module name if(modules[i].moduleId == 0 || info.fileName[0] == 0) diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj index 60c00d076..782bab62a 100644 --- a/renderdoc/renderdoc.vcxproj +++ b/renderdoc/renderdoc.vcxproj @@ -283,6 +283,7 @@ true + @@ -484,5 +485,11 @@ + + + + + + \ No newline at end of file diff --git a/renderdoc/renderdoc.vcxproj.filters b/renderdoc/renderdoc.vcxproj.filters index 600ffd034..906dfd8c3 100644 --- a/renderdoc/renderdoc.vcxproj.filters +++ b/renderdoc/renderdoc.vcxproj.filters @@ -270,6 +270,9 @@ 3rdparty\tinyfiledialogs + + OS\Win32 + diff --git a/scripts/dist.sh b/scripts/dist.sh index 3746090bc..a1eced6c9 100644 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -91,10 +91,9 @@ rm -f dist/ReleasePDBs{32,64}/*.{exp,lib,metagen} dist/Release{32,64}/*.vshost.* # In the 64bit release folder, make an x86 subfolder and copy in renderdoc 32bit mkdir -p dist/Release64/x86 -rm -rf dist/Release32/pdblocate/x64 dist/ReleasePDBs32/pdblocate/x64 -cp -R dist/Release32/{d3dcompiler_47.dll,renderdoc.dll,renderdoc.json,renderdocshim32.dll,renderdoccmd.exe,pdblocate} dist/Release64/x86/ +cp -R dist/Release32/{d3dcompiler_47.dll,renderdoc.dll,renderdoc.json,renderdocshim32.dll,renderdoccmd.exe,dbghelp.dll,symsrv.dll,symsrv.yes} dist/Release64/x86/ mkdir -p dist/ReleasePDBs64/x86 -cp -R dist/ReleasePDBs32/{d3dcompiler_47.dll,renderdoc.dll,renderdoc.json,renderdoc.pdb,renderdocshim32.dll,renderdocshim32.pdb,renderdoccmd.exe,renderdoccmd.pdb,pdblocate} dist/ReleasePDBs64/x86/ +cp -R dist/ReleasePDBs32/{d3dcompiler_47.dll,renderdoc.dll,renderdoc.json,renderdoc.pdb,renderdocshim32.dll,renderdocshim32.pdb,renderdoccmd.exe,renderdoccmd.pdb,dbghelp.dll,symsrv.dll,symsrv.yes} dist/ReleasePDBs64/x86/ if [[ $AUTOBUILD -eq 0 ]]; then echo "=== Folders built. Ready to make installer MSIs." diff --git a/scripts/installer/Installer32.wxs b/scripts/installer/Installer32.wxs index 46de7c70b..655a8fe4e 100644 --- a/scripts/installer/Installer32.wxs +++ b/scripts/installer/Installer32.wxs @@ -85,6 +85,9 @@ + + + @@ -137,23 +140,6 @@ - - - - - - - - - - - - - - - - - @@ -260,9 +246,6 @@ - - - diff --git a/scripts/installer/Installer64.wxs b/scripts/installer/Installer64.wxs index 51fea0fba..97c9d7b06 100644 --- a/scripts/installer/Installer64.wxs +++ b/scripts/installer/Installer64.wxs @@ -75,6 +75,9 @@ + + + @@ -126,34 +129,15 @@ - - - - - - - - - - - - - - - - - - - - - - + + + @@ -174,20 +158,6 @@ - - - - - - - - - - - - - - @@ -294,13 +264,7 @@ - - - - - - diff --git a/scripts/travis/linux_setup.sh b/scripts/travis/linux_setup.sh index 24281aac6..76bf97fb4 100644 --- a/scripts/travis/linux_setup.sh +++ b/scripts/travis/linux_setup.sh @@ -12,7 +12,7 @@ sudo apt-get install --allow-unauthenticated -y -qq libx11-dev mesa-common-dev l # changes in formatting even without any rule changes, we have to fix on a # single version. -clang-format-3.8 -i -style=file $(find pdblocate/ qrenderdoc/ renderdoc/ renderdoccmd/ renderdocshim/ -type f -regex '.*\(/3rdparty/\|/official/\|resource.h\).*' -prune -o -regex '.*\.\(c\|cpp\|h\)$' -print) +clang-format-3.8 -i -style=file $(find qrenderdoc/ renderdoc/ renderdoccmd/ renderdocshim/ -type f -regex '.*\(/3rdparty/\|/official/\|resource.h\).*' -prune -o -regex '.*\.\(c\|cpp\|h\)$' -print) git clean -f