Пример #1
0
        public static SourceInfo Read(string file)
        {
            var command = new CommandWrapper(new ProcessStartInfo()
            {
                Arguments = string.Format("-r -s:srcsrv -p:\"{0}\"", file),
                FileName = "pdbstr.exe",
            });
            command.Run();

            return SourceInfo.Read(command.Output);
        }
Пример #2
0
        /// <summary>
        /// Reads the original source files from the symbol.
        /// </summary>
        /// <returns>A list of full paths.</returns>
        /// <remarks>
        /// Requires dbh.exe on the path. See C:\Program Files (x86)\Windows Kits\8.1\Debuggers\x64
        /// when windows debugging toolkit is installed. This is separate from VS.
        /// </remarks>
        public static IList<string> GetOriginalSources(string file)
        {
            var command = new CommandWrapper(new ProcessStartInfo()
            {
                Arguments = string.Format("\"{0}\" src", file),
                FileName = "dbh.exe",
            });
            command.Run();

            return command.Output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
        }
Пример #3
0
        public static SymbolId GetSymbolId(string file)
        {
            var command = new CommandWrapper(new ProcessStartInfo()
            {
                Arguments = string.Format("\"{0}\" info", file),
                FileName = "dbh.exe",
            });
            command.Run();

            // This will be in a format like "PdbSig70 : 0x9cbfbdda, 0xff2b, 0x4d48, 0xaa, 0x7d, 0xa3, 0x3d, 0x26, 0x61, 0xbf, 0x46"
            var line = command.Output
                .Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                .Where(t => t.TrimStart().StartsWith("PdbSig70"))
                .Select(t => t.Substring(t.LastIndexOf(':') + 1))
                .Single()
                .Trim();

            var segments = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            // Despite what the documentation says, it doesn't handle the leading '0x'
            var guid = new Guid(
                UInt32.Parse(segments[0].Trim().Substring(2), NumberStyles.HexNumber),
                UInt16.Parse(segments[1].Trim().Substring(2), NumberStyles.HexNumber),
                UInt16.Parse(segments[2].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[3].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[4].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[5].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[6].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[7].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[8].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[9].Trim().Substring(2), NumberStyles.HexNumber),
                Byte.Parse(segments[10].Trim().Substring(2), NumberStyles.HexNumber));

            // This will be in a format like "PdbAge : 0x01"
            line = command.Output
                .Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                .Where(t => t.TrimStart().StartsWith("PdbAge"))
                .Select(t => t.Substring(t.LastIndexOf(':') + 1))
                .Single()
                .Trim();

            var age = Int32.Parse(line.Trim().Substring(2), NumberStyles.HexNumber);

            return new SymbolId() { Guid = guid, Age = age };
        }
Пример #4
0
        public static void WriteStream(string file, string stream)
        {
            var tempFile = Path.GetTempFileName();

            try
            {
                File.WriteAllText(tempFile, stream);

                var command = new CommandWrapper(new ProcessStartInfo()
                {
                    Arguments = string.Format("-w -s:srcsrv -p:\"{0}\" -i:\"{1}\"", file, tempFile),
                    FileName = "pdbstr.exe",
                });
                command.Run();
            }
            finally
            {
                File.Delete(tempFile);
            }
        }