# HG changeset patch # User Evgeniy.Koshkin@unit-519.Labs.IntelliJ.Net # Date 1463416851 -10800 # Node ID 0e927b14ccf191706a70270320744c870aca6eb8 # Parent 52fc27842bc162ba31e9dd398eeca7f21a2a3f12 restored jet-symbols native tool sources diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/jet-symbols.sln --- /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 diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/lib/JetBrains.Platform.Symbols.Metadata.dll Binary file jet-symbols/lib/JetBrains.Platform.Symbols.Metadata.dll has changed diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/lib/JetBrains.Platform.Symbols.Util.dll Binary file jet-symbols/lib/JetBrains.Platform.Symbols.Util.dll has changed diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/src/JetBrains.CommandLine.Symbols/DumpBinaryFileSignCommand.cs --- /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 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; + } + } + } +} diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/src/JetBrains.CommandLine.Symbols/DumpFilesSignCommandBase.cs --- /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 myTargetFilePaths; + + protected DumpFilesSignCommandBase(FileSystemPath outputFilePath, IEnumerable 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 dictionary = this.myTargetFilePaths.ToDictionary((Func) (targetFilePath => targetFilePath), new Func(this.GetFileSignature)); + if (!dictionary.IsEmpty>()) + { + 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 signatures) + { + XmlDocument xmlDocument = new XmlDocument(); + XmlNode node = xmlDocument.CreateNode(XmlNodeType.Element, "file-signs", ""); + foreach (KeyValuePair 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); + } +} diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/src/JetBrains.CommandLine.Symbols/DumpSymbolsFileSignCommand.cs --- /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 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; + } + } + } +} diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/src/JetBrains.CommandLine.Symbols/ICommand.cs --- /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(); + } +} diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/src/JetBrains.CommandLine.Symbols/JetBrains.CommandLine.Symbols.csproj --- /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 @@ + + + + + Debug + AnyCPU + {66E56E2A-5CFC-455E-A0AF-0CC8DCBFD528} + Exe + JetBrains.CommandLine.Symbols + v3.5 + 1.0.0.0 + 512 + JetBrains.CommandLine.Symbols + + + + + 3.5 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\lib\JetBrains.Platform.Symbols.Util.dll + + + + + + ..\..\lib\JetBrains.Platform.Symbols.Metadata.dll + + + + + + + + + + + + \ No newline at end of file diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/src/JetBrains.CommandLine.Symbols/Program.cs --- /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) args).First(); + FileSystemPath inputFilePath = FileSystemPath.TryParse(args[2].Substring(3)); + FileSystemPath outputFilePath = FileSystemPath.TryParse(args[1].Substring(3)); + IEnumerable 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 LoadPathsFromFile(FileSystemPath inputFilePath) + { + ICollection result = (ICollection) new HashSet(); + inputFilePath.ReadTextStream((Action) (streamReader => + { + while (!streamReader.EndOfStream) + { + FileSystemPath fileSystemPath = FileSystemPath.TryParse(streamReader.ReadLine()); + if (!fileSystemPath.IsEmpty) + result.Add(fileSystemPath); + } + }), (Encoding) null); + return (IEnumerable) result; + } + + private static void PrintIncorrectUsageMessage(string error) + { + Console.Error.WriteLine(error); + Console.Error.WriteLine("Usage: Symbols / "); + } + } +} diff -r 52fc27842bc1 -r 0e927b14ccf1 jet-symbols/src/JetBrains.CommandLine.Symbols/Properties/AssemblyInfo.cs --- /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)]