diff options
author | sagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8> | 2010-03-12 11:59:48 (GMT) |
---|---|---|
committer | sagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8> | 2010-03-12 11:59:48 (GMT) |
commit | b5b9076d2370cb7a5d9fe30c7ffee38e19def0c7 (patch) | |
tree | 0bbbff37a578e45219e595888e388ed8cb526ff3 /src/managed | |
parent | ca2d69f4a43f7209113ceee6773bd04bbe6bd317 (diff) | |
download | cv2pdb-b5b9076d2370cb7a5d9fe30c7ffee38e19def0c7.zip cv2pdb-b5b9076d2370cb7a5d9fe30c7ffee38e19def0c7.tar.gz cv2pdb-b5b9076d2370cb7a5d9fe30c7ffee38e19def0c7.tar.bz2 |
* names of local function are now demangled
* added managed C++ project to integrate cv2pdb with CLR
Diffstat (limited to 'src/managed')
-rw-r--r-- | src/managed/cv2pdb.vcproj | 237 | ||||
-rw-r--r-- | src/managed/main.cpp | 89 |
2 files changed, 326 insertions, 0 deletions
diff --git a/src/managed/cv2pdb.vcproj b/src/managed/cv2pdb.vcproj new file mode 100644 index 0000000..121e29e --- /dev/null +++ b/src/managed/cv2pdb.vcproj @@ -0,0 +1,237 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="cv2pdb"
+ ProjectGUID="{5E2BD27D-446A-4C99-9829-135F7C000D91}"
+ RootNamespace="cv2pdb"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\bin"
+ IntermediateDirectory=".\bin\$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2"
+ ManagedExtensions="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4996"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="false"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="false"
+ UsePrecompiledHeader="0"
+ GenerateXMLDocumentationFiles="true"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="dbghelp.lib"
+ OutputFile="$(OutDir)\$(ProjectName).dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ AssemblyDebug="1"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\bin\$(ConfigurationName)"
+ IntermediateDirectory=".\bin\$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ ManagedExtensions="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4996"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ TreatWChar_tAsBuiltInType="false"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ 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="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\cv2pdb.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\demangle.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\demangle.h"
+ >
+ </File>
+ <File
+ RelativePath="..\LastError.h"
+ >
+ </File>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\mscvpdb.h"
+ >
+ </File>
+ <File
+ RelativePath="..\mspdb.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\mspdb.h"
+ >
+ </File>
+ <File
+ RelativePath="..\PEImage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\PEImage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\symutil.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\symutil.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/src/managed/main.cpp b/src/managed/main.cpp new file mode 100644 index 0000000..3f2ac5b --- /dev/null +++ b/src/managed/main.cpp @@ -0,0 +1,89 @@ +// Convert DMD CodeView debug information to PDB files
+// Copyright (c) 2009 by Rainer Schuetze, All Rights Reserved
+//
+// License for redistribution is given by the Artistic License 2.0
+// see file LICENSE for further details
+
+// CLR interface to cv2pdb created by Alexander Bothe
+ +#include "../PEImage.h" +#include "../cv2pdb.h" +#include "vcclr.h" +
+using namespace System;
+using namespace System::IO;
+using namespace System::Text;
+
+namespace CodeViewToPDB
+{
+ ///<summary>Exports DMD CodeView debug information from an executable file to a separate .pdb file</summary>
+ public ref class CodeViewToPDBConverter
+ {
+ public:
+ delegate void MsgHandler(String^ Message);
+ ///<summary>If an error occurs it will be reported via this event</summary>
+ static event MsgHandler^ Message;
+
+ ///<summary>Exports DMD CodeView debug information from an executable file to a separate .pdb file</summary>
+ static bool DoConvert(String^ InputExe,String^ OutputExe,String^ OutputPDBFile,bool IsD2)
+ {
+ if(!File::Exists(InputExe))
+ {
+ Message("Input file doesn't exist!");
+ return false;
+ }
+
+ if(String::IsNullOrEmpty(OutputPDBFile) || String::IsNullOrEmpty(OutputExe))
+ {
+ Message("Empty arguments not allowed!");
+ return false;
+ }
+
+ char* input=(char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(InputExe).ToPointer();
+ char* outname=(char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(OutputExe).ToPointer();
+ char* pdbname=(char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(OutputPDBFile).ToPointer();
+
+ PEImage img(input);
+
+ if (img.countCVEntries() == 0)
+ {
+ Message("No codeview debug entries found");
+ return false;
+ }
+
+ CV2PDB cv2pdb(img);
+ cv2pdb.initLibraries();
+ cv2pdb.Dversion = IsD2?2:1;
+
+ File::Delete(OutputPDBFile);
+
+ if(cv2pdb.openPDB(pdbname)
+ && cv2pdb.initSegMap()
+ && cv2pdb.initGlobalTypes()
+ && cv2pdb.createModules()
+ && cv2pdb.addTypes()
+ && cv2pdb.addSymbols()
+ && cv2pdb.addSrcLines()
+ && cv2pdb.addPublics()
+ && cv2pdb.writeImage(outname))
+ { }
+ else
+ {
+ Message(gcnew String(cv2pdb.getLastError()));
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool DoConvert(String^ Exe,String^ OutputPDBFile)
+ {
+ return DoConvert(Exe,Exe,OutputPDBFile,true);
+ }
+
+ static bool DoConvert(String^ Exe)
+ {
+ return DoConvert(Exe,Exe,Path::ChangeExtension(Exe,".pdb"),true);
+ }
+ };
+}
|