Mercurial > hg > tc-symbol-server
changeset 102:0e927b14ccf1
restored jet-symbols native tool sources
author | Evgeniy.Koshkin@unit-519.Labs.IntelliJ.Net |
---|---|
date | Mon, 16 May 2016 19:40:51 +0300 |
parents | 52fc27842bc1 |
children | 9ff982a9213e |
files | jet-symbols/jet-symbols.sln jet-symbols/lib/JetBrains.Platform.Symbols.Metadata.dll jet-symbols/lib/JetBrains.Platform.Symbols.Util.dll jet-symbols/src/JetBrains.CommandLine.Symbols/DumpBinaryFileSignCommand.cs jet-symbols/src/JetBrains.CommandLine.Symbols/DumpFilesSignCommandBase.cs jet-symbols/src/JetBrains.CommandLine.Symbols/DumpSymbolsFileSignCommand.cs jet-symbols/src/JetBrains.CommandLine.Symbols/ICommand.cs jet-symbols/src/JetBrains.CommandLine.Symbols/JetBrains.CommandLine.Symbols.csproj jet-symbols/src/JetBrains.CommandLine.Symbols/Program.cs jet-symbols/src/JetBrains.CommandLine.Symbols/Properties/AssemblyInfo.cs |
diffstat | 10 files changed, 337 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/jet-symbols.sln Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JetBrains.CommandLine.Symbols", "src\JetBrains.CommandLine.Symbols\JetBrains.CommandLine.Symbols.csproj", "{66E56E2A-5CFC-455E-A0AF-0CC8DCBFD528}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {66E56E2A-5CFC-455E-A0AF-0CC8DCBFD528}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66E56E2A-5CFC-455E-A0AF-0CC8DCBFD528}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66E56E2A-5CFC-455E-A0AF-0CC8DCBFD528}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66E56E2A-5CFC-455E-A0AF-0CC8DCBFD528}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/DumpBinaryFileSignCommand.cs Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,42 @@ +// Decompiled with JetBrains decompiler +// Type: JetBrains.CommandLine.Symbols.DumpBinaryFileSignCommand +// Assembly: JetBrains.CommandLine.Symbols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325 +// MVID: EF046BF6-60AC-48EA-9121-8AF3D8D08853 +// Assembly location: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe + +using JetBrains.Metadata.Utils; +using JetBrains.Metadata.Utils.PE; +using JetBrains.Util; +using System; +using System.Collections.Generic; +using System.IO; + +namespace JetBrains.CommandLine.Symbols +{ + public class DumpBinaryFileSignCommand : DumpFilesSignCommandBase + { + public const string CMD_NAME = "dumpBinSign"; + + public DumpBinaryFileSignCommand(FileSystemPath outputFilePath, IEnumerable<FileSystemPath> targetFilePaths) + : base(outputFilePath, targetFilePaths) + { + } + + protected override string GetFileSignature(FileSystemPath targetFilePath) + { + try + { + using (Stream stream = targetFilePath.OpenFileForReading()) + { + PEFile peFile = new PEFile((IBinaryReader) new StreamBinaryReader(stream)); + return string.Format("{0:X}{1:X}", (object) peFile.COFFheader.TimeStamp, (object) peFile.NTHeader.ImageSize); + } + } + catch (Exception ex) + { + Console.Error.WriteLine(ex.Message); + return (string) null; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/DumpFilesSignCommandBase.cs Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,71 @@ +// Decompiled with JetBrains decompiler +// Type: JetBrains.CommandLine.Symbols.DumpFilesSignCommandBase +// Assembly: JetBrains.CommandLine.Symbols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325 +// MVID: EF046BF6-60AC-48EA-9121-8AF3D8D08853 +// Assembly location: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe + +using JetBrains.Util; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml; + +namespace JetBrains.CommandLine.Symbols +{ + public abstract class DumpFilesSignCommandBase : ICommand + { + private FileSystemPath myOutputFilePath; + private IEnumerable<FileSystemPath> myTargetFilePaths; + + protected DumpFilesSignCommandBase(FileSystemPath outputFilePath, IEnumerable<FileSystemPath> targetFilePaths) + { + this.myOutputFilePath = outputFilePath; + this.myTargetFilePaths = targetFilePaths; + } + + public int Execute() + { + try + { + if (this.myOutputFilePath.IsEmpty) + { + Console.Error.WriteLine("Output file path is empty."); + return 1; + } + Dictionary<FileSystemPath, string> dictionary = this.myTargetFilePaths.ToDictionary<FileSystemPath, FileSystemPath, string>((Func<FileSystemPath, FileSystemPath>) (targetFilePath => targetFilePath), new Func<FileSystemPath, string>(this.GetFileSignature)); + if (!dictionary.IsEmpty<KeyValuePair<FileSystemPath, string>>()) + { + DumpFilesSignCommandBase.WriteToFile(this.myOutputFilePath, dictionary); + Console.Out.WriteLine("Dumped {0} signature entries to the file {1}", (object) dictionary.Count, (object) this.myOutputFilePath); + return 0; + } + Console.Error.WriteLine("Nothing to dump."); + return 1; + } + catch (Exception ex) + { + Console.Error.WriteLine((object) ex); + return 1; + } + } + + private static void WriteToFile(FileSystemPath outputFilePath, Dictionary<FileSystemPath, string> signatures) + { + XmlDocument xmlDocument = new XmlDocument(); + XmlNode node = xmlDocument.CreateNode(XmlNodeType.Element, "file-signs", ""); + foreach (KeyValuePair<FileSystemPath, string> signature in signatures) + { + XmlElement element = node.CreateElement("file-sign-entry"); + element.CreateAttributeWithNonEmptyValue("file", signature.Key.Name); + string str = signature.Value; + if (str != null) + element.CreateAttributeWithNonEmptyValue("sign", str); + } + xmlDocument.AppendChild(node); + using (XmlWriter w = XmlWriter.Create(outputFilePath.FullPath)) + xmlDocument.WriteContentTo(w); + } + + protected abstract string GetFileSignature(FileSystemPath targetFilePath); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/DumpSymbolsFileSignCommand.cs Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,41 @@ +// Decompiled with JetBrains decompiler +// Type: JetBrains.CommandLine.Symbols.DumpSymbolsFileSignCommand +// Assembly: JetBrains.CommandLine.Symbols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325 +// MVID: EF046BF6-60AC-48EA-9121-8AF3D8D08853 +// Assembly location: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe + +using JetBrains.Metadata.Utils.Pdb; +using JetBrains.Util; +using System; +using System.Collections.Generic; +using System.IO; + +namespace JetBrains.CommandLine.Symbols +{ + public class DumpSymbolsFileSignCommand : DumpFilesSignCommandBase + { + public const string CMD_NAME = "dumpSymbolSign"; + + public DumpSymbolsFileSignCommand(FileSystemPath outputFilePath, IEnumerable<FileSystemPath> targetFilePaths) + : base(outputFilePath, targetFilePaths) + { + } + + protected override string GetFileSignature(FileSystemPath targetFilePath) + { + try + { + using (Stream pdbStream = targetFilePath.OpenFileForReading()) + { + PdbRootRecord root = new PdbFile(pdbStream).GetRoot(); + return string.Format("{0}{1:X}", (object) root.SymId.ToString("N").ToUpperInvariant(), (object) root.Age); + } + } + catch (Exception ex) + { + Console.Error.WriteLine((object) ex); + return (string) null; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/ICommand.cs Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,13 @@ +// Decompiled with JetBrains decompiler +// Type: JetBrains.CommandLine.Symbols.ICommand +// Assembly: JetBrains.CommandLine.Symbols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325 +// MVID: EF046BF6-60AC-48EA-9121-8AF3D8D08853 +// Assembly location: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe + +namespace JetBrains.CommandLine.Symbols +{ + internal interface ICommand + { + int Execute(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/JetBrains.CommandLine.Symbols.csproj Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <!--Project was exported from assembly: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe--> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{66E56E2A-5CFC-455E-A0AF-0CC8DCBFD528}</ProjectGuid> + <OutputType>Exe</OutputType> + <AssemblyName>JetBrains.CommandLine.Symbols</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <ApplicationVersion>1.0.0.0</ApplicationVersion> + <FileAlignment>512</FileAlignment> + <RootNamespace>JetBrains.CommandLine.Symbols</RootNamespace> + <FileUpgradeFlags> + </FileUpgradeFlags> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + <OldToolsVersion>3.5</OldToolsVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="JetBrains.Platform.Symbols.Util"> + <HintPath>..\..\lib\JetBrains.Platform.Symbols.Util.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml" /> + <Reference Include="JetBrains.Platform.Symbols.Metadata"> + <HintPath>..\..\lib\JetBrains.Platform.Symbols.Metadata.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="ICommand.cs" /> + <Compile Include="DumpFilesSignCommandBase.cs" /> + <Compile Include="DumpBinaryFileSignCommand.cs" /> + <Compile Include="DumpSymbolsFileSignCommand.cs" /> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/Program.cs Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,78 @@ +// Decompiled with JetBrains decompiler +// Type: JetBrains.CommandLine.Symbols.Program +// Assembly: JetBrains.CommandLine.Symbols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325 +// MVID: EF046BF6-60AC-48EA-9121-8AF3D8D08853 +// Assembly location: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe + +using JetBrains.Util; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace JetBrains.CommandLine.Symbols +{ + internal static class Program + { + private const int ERROR_EXIT_CODE = 1; + + public static int Main(string[] args) + { + try + { + string error; + ICommand commandToExecute = Program.GetCommandToExecute(args, out error); + if (commandToExecute != null) + return commandToExecute.Execute(); + Program.PrintIncorrectUsageMessage(error); + return 1; + } + catch (Exception ex) + { + Console.Error.WriteLine((object) ex); + return 1; + } + } + + private static ICommand GetCommandToExecute(string[] args, out string error) + { + error = string.Empty; + string str = ((IEnumerable<string>) args).First<string>(); + FileSystemPath inputFilePath = FileSystemPath.TryParse(args[2].Substring(3)); + FileSystemPath outputFilePath = FileSystemPath.TryParse(args[1].Substring(3)); + IEnumerable<FileSystemPath> targetFilePaths = Program.LoadPathsFromFile(inputFilePath); + switch (str) + { + case "dumpSymbolSign": + return (ICommand) new DumpSymbolsFileSignCommand(outputFilePath, targetFilePaths); + case "dumpBinSign": + return (ICommand) new DumpBinaryFileSignCommand(outputFilePath, targetFilePaths); + default: + error = string.Format("{0} command is unknown.", (object) str); + return (ICommand) null; + } + } + + private static IEnumerable<FileSystemPath> LoadPathsFromFile(FileSystemPath inputFilePath) + { + ICollection<FileSystemPath> result = (ICollection<FileSystemPath>) new HashSet<FileSystemPath>(); + inputFilePath.ReadTextStream((Action<StreamReader>) (streamReader => + { + while (!streamReader.EndOfStream) + { + FileSystemPath fileSystemPath = FileSystemPath.TryParse(streamReader.ReadLine()); + if (!fileSystemPath.IsEmpty) + result.Add(fileSystemPath); + } + }), (Encoding) null); + return (IEnumerable<FileSystemPath>) result; + } + + private static void PrintIncorrectUsageMessage(string error) + { + Console.Error.WriteLine(error); + Console.Error.WriteLine("Usage: Symbols /<command_name> <command_parameters>"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jet-symbols/src/JetBrains.CommandLine.Symbols/Properties/AssemblyInfo.cs Mon May 16 19:40:51 2016 +0300 @@ -0,0 +1,12 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Permissions; + +[assembly: AssemblyCopyright("Copyright ©2014 JetBrains s.r.o. All rights reserved.")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyCompany("JetBrains s.r.o.")] +[assembly: AssemblyProduct("Symbols")] +[assembly: ComVisible(false)] +[assembly: AssemblyTitle("Symbols")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]