aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/windows/dump_syms/dump_syms.cc7
-rw-r--r--src/tools/windows/dump_syms/dump_syms.vcproj412
-rw-r--r--src/tools/windows/dump_syms/pdb_source_line_writer.cc313
-rw-r--r--src/tools/windows/dump_syms/pdb_source_line_writer.h96
-rw-r--r--src/tools/windows/symupload/symupload.cc180
-rwxr-xr-xsrc/tools/windows/symupload/symupload.vcproj215
6 files changed, 605 insertions, 618 deletions
diff --git a/src/tools/windows/dump_syms/dump_syms.cc b/src/tools/windows/dump_syms/dump_syms.cc
index c2fa90c2..ca63c2c4 100644
--- a/src/tools/windows/dump_syms/dump_syms.cc
+++ b/src/tools/windows/dump_syms/dump_syms.cc
@@ -32,9 +32,10 @@
#include <stdio.h>
#include <string>
-#include "pdb_source_line_writer.h"
+#include "common/windows/pdb_source_line_writer.h"
using std::wstring;
+using google_airbag::PDBSourceLineWriter;
int main(int argc, char **argv) {
if (argc < 2) {
@@ -48,8 +49,8 @@ int main(int argc, char **argv) {
return 1;
}
- google_airbag::PDBSourceLineWriter writer;
- if (!writer.Open(wstring(filename))) {
+ PDBSourceLineWriter writer;
+ if (!writer.Open(wstring(filename), PDBSourceLineWriter::PDB_FILE)) {
fprintf(stderr, "Open failed\n");
return 1;
}
diff --git a/src/tools/windows/dump_syms/dump_syms.vcproj b/src/tools/windows/dump_syms/dump_syms.vcproj
index 2b42adea..19682d6e 100644
--- a/src/tools/windows/dump_syms/dump_syms.vcproj
+++ b/src/tools/windows/dump_syms/dump_syms.vcproj
@@ -1,206 +1,206 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="dump_syms"
- ProjectGUID="{792E1530-E2C5-4289-992E-317BA30E9D9F}"
- RootNamespace="dumpsyms"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="Debug"
- IntermediateDirectory="Debug"
- ConfigurationType="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="&quot;$(VSInstallDir)\DIA SDK\include&quot;"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="&quot;$(VSInstallDir)\DIA SDK\lib\diaguids.lib&quot;"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
- ConfigurationType="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(VSInstallDir)\DIA SDK\include&quot;"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="&quot;$(VSInstallDir)\DIA SDK\lib\diaguids.lib&quot;"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath=".\pdb_source_line_writer.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\dump_syms.cc"
- >
- </File>
- <File
- RelativePath=".\pdb_source_line_writer.cc"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="dump_syms"
+ ProjectGUID="{792E1530-E2C5-4289-992E-317BA30E9D9F}"
+ RootNamespace="dumpsyms"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(VSInstallDir)\DIA SDK\include&quot;;..\..\.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="&quot;$(VSInstallDir)\DIA SDK\lib\diaguids.lib&quot;"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="&quot;$(VSInstallDir)\DIA SDK\include&quot;;..\..\.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="&quot;$(VSInstallDir)\DIA SDK\lib\diaguids.lib&quot;"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\common\windows\pdb_source_line_writer.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\dump_syms.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\common\windows\pdb_source_line_writer.cc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/src/tools/windows/dump_syms/pdb_source_line_writer.cc b/src/tools/windows/dump_syms/pdb_source_line_writer.cc
deleted file mode 100644
index 18b5d9ce..00000000
--- a/src/tools/windows/dump_syms/pdb_source_line_writer.cc
+++ /dev/null
@@ -1,313 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <stdio.h>
-#include <atlbase.h>
-#include <dia2.h>
-#include "pdb_source_line_writer.h"
-
-namespace google_airbag {
-
-PDBSourceLineWriter::PDBSourceLineWriter() : output_(NULL) {
-}
-
-PDBSourceLineWriter::~PDBSourceLineWriter() {
-}
-
-bool PDBSourceLineWriter::Open(const wstring &pdb_file) {
- Close();
-
- if (FAILED(CoInitialize(NULL))) {
- fprintf(stderr, "CoInitialize failed\n");
- return false;
- }
-
- CComPtr<IDiaDataSource> data_source;
- if (FAILED(data_source.CoCreateInstance(CLSID_DiaSource))) {
- fprintf(stderr, "CoCreateInstance CLSID_DiaSource failed "
- "(msdia80.dll unregistered?)\n");
- return false;
- }
-
- if (FAILED(data_source->loadDataFromPdb(pdb_file.c_str()))) {
- fprintf(stderr, "loadDataFromPdb failed\n");
- return false;
- }
-
- if (FAILED(data_source->openSession(&session_))) {
- fprintf(stderr, "openSession failed\n");
- }
-
- return true;
-}
-
-bool PDBSourceLineWriter::PrintLines(IDiaEnumLineNumbers *lines) {
- // The line number format is:
- // <rva> <line number> <source file id>
- CComPtr<IDiaLineNumber> line;
- ULONG count;
-
- while (SUCCEEDED(lines->Next(1, &line, &count)) && count == 1) {
- DWORD rva;
- if (FAILED(line->get_relativeVirtualAddress(&rva))) {
- fprintf(stderr, "failed to get line rva\n");
- return false;
- }
-
- DWORD length;
- if (FAILED(line->get_length(&length))) {
- fprintf(stderr, "failed to get line code length\n");
- return false;
- }
-
- DWORD source_id;
- if (FAILED(line->get_sourceFileId(&source_id))) {
- fprintf(stderr, "failed to get line source file id\n");
- return false;
- }
-
- DWORD line_num;
- if (FAILED(line->get_lineNumber(&line_num))) {
- fprintf(stderr, "failed to get line number\n");
- return false;
- }
-
- fprintf(output_, "%x %x %d %d\n", rva, length, line_num, source_id);
- line.Release();
- }
- return true;
-}
-
-bool PDBSourceLineWriter::PrintFunction(IDiaSymbol *function) {
- // The function format is:
- // FUNC <address> <function>
- CComBSTR name;
- if (FAILED(function->get_name(&name))) {
- fprintf(stderr, "failed to get function name\n");
- return false;
- }
- if (name.Length() == 0) {
- fprintf(stderr, "empty function name\n");
- return false;
- }
-
- ULONGLONG length;
- if (FAILED(function->get_length(&length))) {
- fprintf(stderr, "failed to get function length\n");
- return false;
- }
-
- DWORD rva;
- if (FAILED(function->get_relativeVirtualAddress(&rva))) {
- fprintf(stderr, "couldn't get rva\n");
- return false;
- }
-
- CComPtr<IDiaEnumLineNumbers> lines;
- if (FAILED(session_->findLinesByRVA(rva, DWORD(length), &lines))) {
- return false;
- }
-
- fwprintf(output_, L"FUNC %x %llx %s\n", rva, length, name);
- if (!PrintLines(lines)) {
- return false;
- }
- return true;
-}
-
-bool PDBSourceLineWriter::PrintSourceFiles() {
- CComPtr<IDiaSymbol> global;
- if (FAILED(session_->get_globalScope(&global))) {
- fprintf(stderr, "get_globalScope failed\n");
- return false;
- }
-
- CComPtr<IDiaEnumSymbols> compilands;
- if (FAILED(global->findChildren(SymTagCompiland, NULL,
- nsNone, &compilands))) {
- fprintf(stderr, "findChildren failed\n");
- return false;
- }
-
- CComPtr<IDiaSymbol> compiland;
- ULONG count;
- while (SUCCEEDED(compilands->Next(1, &compiland, &count)) && count == 1) {
- CComPtr<IDiaEnumSourceFiles> source_files;
- if (FAILED(session_->findFile(compiland, NULL, nsNone, &source_files))) {
- return false;
- }
- CComPtr<IDiaSourceFile> file;
- while (SUCCEEDED(source_files->Next(1, &file, &count)) && count == 1) {
- DWORD file_id;
- if (FAILED(file->get_uniqueId(&file_id))) {
- return false;
- }
-
- CComBSTR file_name;
- if (FAILED(file->get_fileName(&file_name))) {
- return false;
- }
-
- fwprintf(output_, L"FILE %d %s\n", file_id, file_name);
- file.Release();
- }
- compiland.Release();
- }
- return true;
-}
-
-bool PDBSourceLineWriter::PrintFunctions() {
- CComPtr<IDiaEnumSymbolsByAddr> symbols;
- if (FAILED(session_->getSymbolsByAddr(&symbols))) {
- fprintf(stderr, "failed to get symbol enumerator\n");
- return false;
- }
-
- CComPtr<IDiaSymbol> symbol;
- if (FAILED(symbols->symbolByAddr(1, 0, &symbol))) {
- fprintf(stderr, "failed to enumerate symbols\n");
- return false;
- }
-
- DWORD rva_last = 0;
- if (FAILED(symbol->get_relativeVirtualAddress(&rva_last))) {
- fprintf(stderr, "failed to get symbol rva\n");
- return false;
- }
-
- ULONG count;
- do {
- DWORD tag;
- if (FAILED(symbol->get_symTag(&tag))) {
- fprintf(stderr, "failed to get symbol tag\n");
- return false;
- }
- if (tag == SymTagFunction) {
- if (!PrintFunction(symbol)) {
- return false;
- }
- }
- symbol.Release();
- } while (SUCCEEDED(symbols->Next(1, &symbol, &count)) && count == 1);
-
- return true;
-}
-
-bool PDBSourceLineWriter::PrintFrameData() {
- // It would be nice if it were possible to output frame data alongside the
- // associated function, as is done with line numbers, but the DIA API
- // doesn't make it possible to get the frame data in that way.
-
- CComPtr<IDiaEnumTables> tables;
- if (FAILED(session_->getEnumTables(&tables)))
- return false;
-
- // Pick up the first table that supports IDiaEnumFrameData.
- CComPtr<IDiaEnumFrameData> frame_data_enum;
- CComPtr<IDiaTable> table;
- ULONG count;
- while (!frame_data_enum &&
- SUCCEEDED(tables->Next(1, &table, &count)) &&
- count == 1) {
- table->QueryInterface(_uuidof(IDiaEnumFrameData),
- reinterpret_cast<void**>(&frame_data_enum));
- table.Release();
- }
- if (!frame_data_enum)
- return false;
-
- CComPtr<IDiaFrameData> frame_data;
- while (SUCCEEDED(frame_data_enum->Next(1, &frame_data, &count)) &&
- count == 1) {
- DWORD type;
- if (FAILED(frame_data->get_type(&type)))
- return false;
-
- DWORD rva;
- if (FAILED(frame_data->get_relativeVirtualAddress(&rva)))
- return false;
-
- DWORD code_size;
- if (FAILED(frame_data->get_lengthBlock(&code_size)))
- return false;
-
- DWORD prolog_size;
- if (FAILED(frame_data->get_lengthProlog(&prolog_size)))
- return false;
-
- // epliog_size is always 0.
- DWORD epilog_size = 0;
-
- DWORD parameter_size;
- if (FAILED(frame_data->get_lengthParams(&parameter_size)))
- return false;
-
- DWORD saved_register_size;
- if (FAILED(frame_data->get_lengthSavedRegisters(&saved_register_size)))
- return false;
-
- DWORD local_size;
- if (FAILED(frame_data->get_lengthLocals(&local_size)))
- return false;
-
- DWORD max_stack_size;
- if (FAILED(frame_data->get_maxStack(&max_stack_size)))
- return false;
-
- BSTR program_string;
- if (FAILED(frame_data->get_program(&program_string)))
- return false;
-
- fprintf(output_, "STACK WIN %x %x %x %x %x %x %x %x %x %ws\n",
- type, rva, code_size, prolog_size, epilog_size,
- parameter_size, saved_register_size, local_size, max_stack_size,
- program_string);
-
- frame_data.Release();
- }
-
- return true;
-}
-
-bool PDBSourceLineWriter::WriteMap(FILE *map_file) {
- bool ret = false;
- output_ = map_file;
- if (PrintSourceFiles() && PrintFunctions() && PrintFrameData()) {
- ret = true;
- }
-
- output_ = NULL;
- return ret;
-}
-
-void PDBSourceLineWriter::Close() {
- session_.Release();
-}
-
-} // namespace google_airbag
diff --git a/src/tools/windows/dump_syms/pdb_source_line_writer.h b/src/tools/windows/dump_syms/pdb_source_line_writer.h
deleted file mode 100644
index c6c6563a..00000000
--- a/src/tools/windows/dump_syms/pdb_source_line_writer.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// PDBSourceLineWriter uses a pdb file produced by Visual C++ to output
-// a line/address map for use with SourceLineResolver.
-
-#ifndef _PDB_SOURCE_LINE_WRITER_H__
-#define _PDB_SOURCE_LINE_WRITER_H__
-
-#include <string>
-#include <atlcomcli.h>
-
-struct IDiaEnumLineNumbers;
-struct IDiaSession;
-struct IDiaSymbol;
-
-namespace google_airbag {
-
-using std::wstring;
-
-class PDBSourceLineWriter {
- public:
- explicit PDBSourceLineWriter();
- ~PDBSourceLineWriter();
-
- // Opens the given pdb file. If there is already a pdb file open,
- // it is automatically closed. Returns true on success.
- bool Open(const wstring &pdb_file);
-
- // Writes a map file from the current pdb file to the given file stream.
- // Returns true on success.
- bool WriteMap(FILE *map_file);
-
- // Closes the current pdb file and its associated resources.
- void Close();
-
- private:
- // Outputs the line/address pairs for each line in the enumerator.
- // Returns true on success.
- bool PrintLines(IDiaEnumLineNumbers *lines);
-
- // Outputs a function address and name, followed by its source line list.
- // Returns true on success.
- bool PrintFunction(IDiaSymbol *function);
-
- // Outputs all functions as described above. Returns true on success.
- bool PrintFunctions();
-
- // Outputs all of the source files in the session's pdb file.
- // Returns true on success.
- bool PrintSourceFiles();
-
- // Outputs all of the frame information necessary to construct stack
- // backtraces in the absence of frame pointers. Returns true on success.
- bool PrintFrameData();
-
- // The session for the currently-open pdb file.
- CComPtr<IDiaSession> session_;
-
- // The current output file for this WriteMap invocation.
- FILE *output_;
-
- // Disallow copy ctor and operator=
- PDBSourceLineWriter(const PDBSourceLineWriter&);
- void operator=(const PDBSourceLineWriter&);
-};
-
-} // namespace google_airbag
-
-#endif // _PDB_SOURCE_LINE_WRITER_H__
diff --git a/src/tools/windows/symupload/symupload.cc b/src/tools/windows/symupload/symupload.cc
new file mode 100644
index 00000000..7b530d0f
--- /dev/null
+++ b/src/tools/windows/symupload/symupload.cc
@@ -0,0 +1,180 @@
+// Copyright (c) 2006, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Tool to upload an exe/dll and its associated symbols to an HTTP server.
+// The PDB file is located automatically, using the path embedded in the
+// executable. The upload is sent as a multipart/form-data POST request,
+// with the following parameters:
+// module: the name of the module, e.g. app.exe
+// ver: the file version of the module, e.g. 1.2.3.4
+// guid: the GUID string embedded in the module pdb,
+// e.g. 11111111-2222-3333-4444-555555555555
+// symbol_file: the airbag-format symbol file
+
+#include <windows.h>
+#include <wininet.h>
+#include <dbghelp.h>
+
+#include <cstdio>
+#include <vector>
+#include <string>
+#include <map>
+
+#include "common/windows/pdb_source_line_writer.h"
+#include "common/windows/http_upload.h"
+
+using std::string;
+using std::wstring;
+using std::vector;
+using std::map;
+using google_airbag::HTTPUpload;
+using google_airbag::PDBSourceLineWriter;
+
+// Extracts the file version information for the given filename,
+// as a string, for example, "1.2.3.4". Returns true on success.
+static bool GetFileVersionString(const wchar_t *filename, wstring *version) {
+ DWORD handle;
+ DWORD version_size = GetFileVersionInfoSize(filename, &handle);
+ if (version_size < sizeof(VS_FIXEDFILEINFO)) {
+ return false;
+ }
+
+ vector<char> version_info(version_size);
+ if (!GetFileVersionInfo(filename, handle, version_size, &version_info[0])) {
+ return false;
+ }
+
+ void *file_info_buffer = NULL;
+ unsigned int file_info_length;
+ if (!VerQueryValue(&version_info[0], L"\\",
+ &file_info_buffer, &file_info_length)) {
+ return false;
+ }
+
+ // The maximum value of each version component is 65535 (0xffff),
+ // so the max length is 24, including the terminating null.
+ wchar_t ver_string[24];
+ VS_FIXEDFILEINFO *file_info =
+ reinterpret_cast<VS_FIXEDFILEINFO*>(file_info_buffer);
+ _snwprintf_s(ver_string, sizeof(ver_string) / sizeof(wchar_t), _TRUNCATE,
+ L"%d.%d.%d.%d",
+ file_info->dwFileVersionMS >> 16,
+ file_info->dwFileVersionMS & 0xffff,
+ file_info->dwFileVersionLS >> 16,
+ file_info->dwFileVersionLS & 0xffff);
+ *version = ver_string;
+ return true;
+}
+
+// Creates a new temporary file and writes the symbol data from the given
+// exe/dll file to it. Returns the path to the temp file in temp_file_path,
+// and the unique identifier (GUID) for the pdb in module_guid.
+static bool DumpSymbolsToTempFile(const wchar_t *exe_file,
+ wstring *temp_file_path,
+ wstring *module_guid) {
+ google_airbag::PDBSourceLineWriter writer;
+ if (!writer.Open(exe_file, PDBSourceLineWriter::EXE_FILE)) {
+ return false;
+ }
+
+ wchar_t temp_path[_MAX_PATH];
+ if (GetTempPath(_MAX_PATH, temp_path) == 0) {
+ return false;
+ }
+
+ wchar_t temp_filename[_MAX_PATH];
+ if (GetTempFileName(temp_path, L"sym", 0, temp_filename) == 0) {
+ return false;
+ }
+
+ FILE *temp_file = NULL;
+ if (_wfopen_s(&temp_file, temp_filename, L"w") != 0) {
+ return false;
+ }
+
+ bool success = writer.WriteMap(temp_file);
+ fclose(temp_file);
+ if (!success) {
+ _wunlink(temp_filename);
+ return false;
+ }
+
+ *temp_file_path = temp_filename;
+ *module_guid = writer.GetModuleGUID();
+ return true;
+}
+
+// Returns the base name of a file, e.g. strips off the path.
+static wstring GetBaseName(const wstring &filename) {
+ wstring base_name(filename);
+ size_t slash_pos = base_name.find_last_of(L"/\\");
+ if (slash_pos != string::npos) {
+ base_name.erase(0, slash_pos + 1);
+ }
+ return base_name;
+}
+
+int wmain(int argc, wchar_t *argv[]) {
+ if (argc < 3) {
+ wprintf(L"Usage: %s file.[exe|dll] <symbol upload URL>\n", argv[0]);
+ return 0;
+ }
+ const wchar_t *module = argv[1], *url = argv[2];
+ wstring module_basename = GetBaseName(module);
+
+ wstring file_version;
+ if (!GetFileVersionString(module, &file_version)) {
+ fwprintf(stderr, L"Could not get file version for %s\n", module);
+ return 1;
+ }
+
+ wstring symbol_file, module_guid;
+ if (!DumpSymbolsToTempFile(module, &symbol_file, &module_guid)) {
+ fwprintf(stderr, L"Could not get symbol data from %s\n", module);
+ return 1;
+ }
+
+ map<wstring, wstring> parameters;
+ parameters[L"module"] = module_basename;
+ parameters[L"version"] = file_version;
+ parameters[L"guid"] = module_guid;
+
+ bool success = HTTPUpload::SendRequest(url, parameters,
+ symbol_file, L"symbol_file");
+ _wunlink(symbol_file.c_str());
+
+ if (!success) {
+ fwprintf(stderr, L"Symbol file upload failed\n");
+ return 1;
+ }
+
+ wprintf(L"Uploaded symbols for %s/%s/%s\n",
+ module_basename.c_str(), file_version.c_str(), module_guid.c_str());
+ return 0;
+}
diff --git a/src/tools/windows/symupload/symupload.vcproj b/src/tools/windows/symupload/symupload.vcproj
new file mode 100755
index 00000000..63b731c1
--- /dev/null
+++ b/src/tools/windows/symupload/symupload.vcproj
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="symupload"
+ ProjectGUID="{E156ED87-9DE9-47C8-94EC-A5A9CDD65E18}"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(VSInstallDir)\DIA SDK\include&quot;;..\..\.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="&quot;$(VSInstallDir)\DIA SDK\lib\diaguids.lib&quot; wininet.lib version.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="&quot;$(VSInstallDir)\DIA SDK\include&quot;;..\..\.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="&quot;$(VSInstallDir)\DIA SDK\lib\diaguids.lib&quot; wininet.lib version.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\common\windows\http_upload.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\common\windows\pdb_source_line_writer.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\..\common\windows\http_upload.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\common\windows\pdb_source_line_writer.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\symupload.cc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>