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.
This commit is contained in:
baldurk
2017-03-13 13:09:56 +00:00
parent c160dcf049
commit 8b9dcbe519
18 changed files with 347 additions and 920 deletions
-2
View File
@@ -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
-170
View File
@@ -1,170 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Development32|Win32">
<Configuration>Development32</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Development64|Win32">
<Configuration>Development64</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release32|Win32">
<Configuration>Release32</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release64|Win32">
<Configuration>Release64</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6CCB39BA-AB6B-4589-B7C4-9DA879571713}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pdblocate</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Development32|Win32'">
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Development64|Win32'">
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release32|Win32'">
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release64|Win32'">
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release64|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(VSInstallDir)\DIA SDK\include;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)x64\Release\pdblocate\</OutDir>
<IntDir>$(SolutionDir)x64\Release\obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release32|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(VSInstallDir)\DIA SDK\include;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)Win32\Release\pdblocate\</OutDir>
<IntDir>$(SolutionDir)Win32\Release\obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Development64|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(VSInstallDir)\DIA SDK\include;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)x64\Development\pdblocate\</OutDir>
<IntDir>$(SolutionDir)x64\Development\obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Development32|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(VSInstallDir)\DIA SDK\include;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)Win32\Development\pdblocate\</OutDir>
<IntDir>$(SolutionDir)Win32\Development\obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release64|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release32|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Development64|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Development32|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="pdblocate.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target Name="AfterBuild" AfterTargets="Build">
<Copy SourceFiles="$(ProjectDir)x86\symsrv.dll" DestinationFolder="$(OutDir)x86">
</Copy>
<Copy SourceFiles="$(ProjectDir)x86\symsrv.yes" DestinationFolder="$(OutDir)x86">
</Copy>
<Copy SourceFiles="$(ProjectDir)x86\dbghelp.dll" DestinationFolder="$(OutDir)x86">
</Copy>
<Copy SourceFiles="$(ProjectDir)x64\symsrv.dll" DestinationFolder="$(OutDir)x64">
</Copy>
<Copy SourceFiles="$(ProjectDir)x64\symsrv.yes" DestinationFolder="$(OutDir)x64">
</Copy>
<Copy SourceFiles="$(ProjectDir)x64\dbghelp.dll" DestinationFolder="$(OutDir)x64">
</Copy>
</Target>
</Project>
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="pdblocate.cpp" />
</ItemGroup>
</Project>
+6 -19
View File
@@ -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
@@ -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 <assert.h>
#include <shlobj.h>
#include <stdint.h>
#include <stdio.h>
#include <tchar.h>
#include <wchar.h>
#include <windows.h>
#include <string>
#include <vector>
#include "dbghelp/dbghelp.h"
using std::vector;
using std::wstring;
#pragma once
// Inline the couple of necessary definitions from dia2.h below
//#include <dia2.h>
@@ -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<Module> 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", &params[0],
&params[1], &params[2], &params[3], &params[4], &params[5], &params[6], &params[7],
&params[8], &params[9], &params[10], &params[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", &params[0],
&params[1], &params[2], &params[3], &params[4], &params[5], &params[6], &params[7],
&params[8], &params[9], &params[10], &params[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;
+316 -184
View File
@@ -34,10 +34,309 @@
#include <algorithm>
#include <string>
#include <vector>
#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<Module> 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<wstring> pdbRememberedPaths;
vector<wstring> pdbIgnores;
vector<Module> 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)
+7
View File
@@ -283,6 +283,7 @@
<ClInclude Include="os\posix\posix_specific.h">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="os\win32\dia2_stubs.h" />
<ClInclude Include="os\win32\win32_hook.h" />
<ClInclude Include="os\win32\win32_specific.h" />
<ClInclude Include="replay\replay_driver.h" />
@@ -484,5 +485,11 @@
<Target Name="AfterBuild" AfterTargets="Build">
<Copy SourceFiles="$(ProjectDir)api\app\renderdoc_app.h" DestinationFolder="$(OutDir)">
</Copy>
<Copy SourceFiles="$(ProjectDir)3rdparty\dbghelp\$(Platform)\symsrv.dll" DestinationFolder="$(OutDir)">
</Copy>
<Copy SourceFiles="$(ProjectDir)3rdparty\dbghelp\$(Platform)\symsrv.yes" DestinationFolder="$(OutDir)">
</Copy>
<Copy SourceFiles="$(ProjectDir)3rdparty\dbghelp\$(Platform)\dbghelp.dll" DestinationFolder="$(OutDir)">
</Copy>
</Target>
</Project>
+3
View File
@@ -270,6 +270,9 @@
<ClInclude Include="3rdparty\tinyfiledialogs\tinyfiledialogs.h">
<Filter>3rdparty\tinyfiledialogs</Filter>
</ClInclude>
<ClInclude Include="os\win32\dia2_stubs.h">
<Filter>OS\Win32</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="maths\camera.cpp">
+2 -3
View File
@@ -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."
+3 -20
View File
@@ -85,6 +85,9 @@
<File Id='RenderDocJSON' Name='renderdoc.json' DiskId='1' Source='dist/Release32/renderdoc.json' />
<File Id='D3DCompiler47' Name='d3dcompiler_47.dll' DiskId='1' Source='dist/Release32/d3dcompiler_47.dll' />
<File Id='RenderDocSHIM' Name='renderdocshim32.dll' DiskId='1' Source='dist/Release32/renderdocshim32.dll' />
<File Id='dbghelpDLL' Name='dbghelp.dll' DiskId='1' Source='dist/Release32/dbghelp.dll' />
<File Id='symsrvDLL' Name='symsrv.dll' DiskId='1' Source='dist/Release32/symsrv.dll' />
<File Id='symsrvYES' Name='symsrv.yes' DiskId='1' Source='dist/Release32/symsrv.yes' />
<File Id='RenderDocAPIheader' Name='renderdoc_app.h' DiskId='1' Source='dist/Release32/renderdoc_app.h' />
@@ -137,23 +140,6 @@
</File>
</Component>
<Directory Id='pdblocate' Name='pdblocate'>
<Component Id='pdblocateEXE' Guid='733FCA6A-EC84-4E96-BFD2-F2A9A62DEAEB'>
<File Id='pdblocateEXE' Name='pdblocate.exe' DiskId='1' Source='dist/Release32/pdblocate/pdblocate.exe' KeyPath='yes' />
</Component>
<Directory Id='pdblocateDeps32' Name='x86'>
<Component Id='pdblocateDeps' Guid='CC83B1BB-8E47-4415-9308-5BEF2A7242A0'>
<File Id='dbghelpDLL' Name='dbghelp.dll' DiskId='1' Source='dist/Release32/pdblocate/x86/dbghelp.dll' KeyPath='yes' />
<File Id='symsrvDLL' Name='symsrv.dll' DiskId='1' Source='dist/Release32/pdblocate/x86/symsrv.dll' />
<File Id='symsrvYES' Name='symsrv.yes' DiskId='1' Source='dist/Release32/pdblocate/x86/symsrv.yes' />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
@@ -260,9 +246,6 @@
<ComponentRef Id='LICENSE' />
<ComponentRef Id='pdblocateEXE' />
<ComponentRef Id='pdblocateDeps' />
<ComponentRef Id='Scintilla' />
<ComponentRef Id='DockingUI' />
+6 -42
View File
@@ -75,6 +75,9 @@
<File Id='RenderDocJSON' Name='renderdoc.json' DiskId='1' Source='dist/Release64/renderdoc.json' />
<File Id='D3DCompiler47DLL64' Name='d3dcompiler_47.dll' DiskId='1' Source='dist/Release64/d3dcompiler_47.dll' />
<File Id='RenderDocSHIM' Name='renderdocshim64.dll' DiskId='1' Source='dist/Release64/renderdocshim64.dll' />
<File Id='dbghelpDLL' Name='dbghelp.dll' DiskId='1' Source='dist/Release64/dbghelp.dll' />
<File Id='symsrvDLL' Name='symsrv.dll' DiskId='1' Source='dist/Release64/symsrv.dll' />
<File Id='symsrvYES' Name='symsrv.yes' DiskId='1' Source='dist/Release64/symsrv.yes' />
<File Id='RenderDocAPIheader' Name='renderdoc_app.h' DiskId='1' Source='dist/Release32/renderdoc_app.h' />
@@ -126,34 +129,15 @@
</File>
</Component>
<Directory Id='pdblocate' Name='pdblocate'>
<Component Id='pdblocateEXE' Win64="yes" Guid='ED392DDC-7B3A-424D-A9F2-2F8DAA0C4AC3'>
<File Id='pdblocateEXE' Name='pdblocate.exe' DiskId='1' Source='dist/Release64/pdblocate/pdblocate.exe' KeyPath='yes' />
</Component>
<Directory Id='pdblocateDeps64' Name='x64'>
<Component Id='pdblocateDeps' Win64="yes" Guid='8AFD0EC4-04FE-4843-9DA3-9E23B806604A'>
<File Id='dbghelpDLL' Name='dbghelp.dll' DiskId='1' Source='dist/Release64/pdblocate/x64/dbghelp.dll' KeyPath='yes' />
<File Id='symsrvDLL' Name='symsrv.dll' DiskId='1' Source='dist/Release64/pdblocate/x64/symsrv.dll' />
<File Id='symsrvYES' Name='symsrv.yes' DiskId='1' Source='dist/Release64/pdblocate/x64/symsrv.yes' />
</Component>
</Directory>
<Directory Id='pdblocateDeps32bit' Name='x86'>
<Component Id='pdblocateDeps32' Win64="yes" Guid='15CE068A-56D9-4B9C-BA5E-DAC25E235E2E'>
<File Id='dbghelp32DLL' Name='dbghelp.dll' DiskId='1' Source='dist/Release64/pdblocate/x86/dbghelp.dll' KeyPath='yes' />
<File Id='symsrv32DLL' Name='symsrv.dll' DiskId='1' Source='dist/Release64/pdblocate/x86/symsrv.dll' />
<File Id='symsrv32YES' Name='symsrv.yes' DiskId='1' Source='dist/Release64/pdblocate/x86/symsrv.yes' />
</Component>
</Directory>
</Directory>
<Directory Id='renderdocX86' Name='x86'>
<Component Id='renderdocX86Bins' Win64="yes" Guid='EB58A048-899A-4239-B229-DA9781C431F8'>
<File Id='renderdocX86DLL' Name='renderdoc.dll' DiskId='1' Source='dist/Release64/x86/renderdoc.dll' KeyPath='yes' />
<File Id='renderdocX86JSON' Name='renderdoc.json' DiskId='1' Source='dist/Release64/x86/renderdoc.json' />
<File Id='renderdocshimX86DLL' Name='renderdocshim32.dll' DiskId='1' Source='dist/Release64/x86/renderdocshim32.dll' />
<File Id='renderdocX86CMD' Name='renderdoccmd.exe' DiskId='1' Source='dist/Release64/x86/renderdoccmd.exe' />
<File Id='dbghelp32DLL' Name='dbghelp.dll' DiskId='1' Source='dist/Release64/x86/dbghelp.dll' />
<File Id='symsrv32DLL' Name='symsrv.dll' DiskId='1' Source='dist/Release64/x86/symsrv.dll' />
<File Id='symsrv32YES' Name='symsrv.yes' DiskId='1' Source='dist/Release64/x86/symsrv.yes' />
<File Id='D3DCompiler47DLL32' Name='d3dcompiler_47.dll' DiskId='1' Source='dist/Release64/x86/d3dcompiler_47.dll' />
@@ -174,20 +158,6 @@
</Component>
<Directory Id='pdblocateX86' Name='pdblocate'>
<Component Id='pdblocateX86EXE' Win64="yes" Guid='1E7B3F86-D477-413F-9BAE-9C4BB96877C5'>
<File Id='pdblocateX86EXE' Name='pdblocate.exe' DiskId='1' Source='dist/Release64/x86/pdblocate/pdblocate.exe' KeyPath='yes' />
</Component>
<Directory Id='pdblocateX86Deps32' Name='x86'>
<Component Id='pdblocateX86Deps' Win64="yes" Guid='146A8E15-B6CC-4CA0-8CAA-BA8A76BC29B2'>
<File Id='dbghelpX86DLL' Name='dbghelp.dll' DiskId='1' Source='dist/Release64/x86/pdblocate/x86/dbghelp.dll' KeyPath='yes' />
<File Id='symsrvX86DLL' Name='symsrv.dll' DiskId='1' Source='dist/Release64/x86/pdblocate/x86/symsrv.dll' />
<File Id='symsrvX86YES' Name='symsrv.yes' DiskId='1' Source='dist/Release64/x86/pdblocate/x86/symsrv.yes' />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
@@ -294,13 +264,7 @@
<ComponentRef Id='LICENSE' />
<ComponentRef Id='pdblocateEXE' />
<ComponentRef Id='pdblocateDeps' />
<ComponentRef Id='pdblocateDeps32' />
<ComponentRef Id='renderdocX86Bins' />
<ComponentRef Id='pdblocateX86EXE' />
<ComponentRef Id='pdblocateX86Deps' />
<ComponentRef Id='Scintilla' />
<ComponentRef Id='DockingUI' />
+1 -1
View File
@@ -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