Beispiel #1
0
        private IEnumerable <string> GetSourceFiles(FileSystemPath symbolsFile)
        {
            var pdb = PdbReader.ReadPdb(_symbolsFile, PdbParseLevel.None, null);

            if (pdb == null)
            {
                throw new Exception("Invalid PDB file " + _symbolsFile);
            }

            foreach (var sourceFile in GetGenericPdbSourceFiles(pdb))
            {
                yield return(sourceFile);
            }

            // Windows PDB files could not contains proper section with C++ file references,
            // they reference generated files instead, so we need to iterate values from /name stream.
            DebugInfoType debugInfoType;

            if (PdbUtils.TryGetPdbType(_symbolsFile, out debugInfoType) && debugInfoType == DebugInfoType.Windows)
            {
                using (Stream pdbStream = _symbolsFile.OpenFileForReading())
                {
                    var windowsPdbFile = new WindowsPdbFile(pdbStream);
                    foreach (var sourceName in windowsPdbFile.NameStream.Values)
                    {
                        yield return(sourceName);
                    }
                }
            }
        }
Beispiel #2
0
        protected override string GetFileSignature(FileSystemPath targetFilePath)
        {
            if (!targetFilePath.ExistsFile)
            {
                Console.Error.WriteLine("PDB file does not exists " + targetFilePath);
                return(null);
            }

            if (targetFilePath.GetFileLength() == 0)
            {
                Console.Error.WriteLine("Empty PDB file " + targetFilePath);
                return(null);
            }

            if (PdbUtils.GetPdbType(targetFilePath) == DebugInfoType.Windows)
            {
                using (var pdbStream = targetFilePath.OpenFileForReading())
                {
                    var pdbFile    = new WindowsPdbFile(pdbStream);
                    var dbiStream  = pdbFile.GetDbiStream();
                    var ageFromDbi = 1;
                    if (dbiStream.Length > 0)
                    {
                        var binaryStream = new StreamBinaryReader(dbiStream);
                        var dbiHeader    = new DbiHeader(binaryStream);
                        ageFromDbi = dbiHeader.PdbAge;
                    }
                    var root      = pdbFile.GetRoot();
                    var signature = root.PdbSignature;
                    return(string.Format("{0}{1:X}", signature.ToString("N").ToUpperInvariant(), ageFromDbi));
                }
            }

            var debugInfo = PdbUtils.TryGetPdbDebugInfo(targetFilePath);

            if (debugInfo == null)
            {
                Console.Error.WriteLine("Unsupport PDB file " + targetFilePath);
                return(null);
            }

            return(string.Format("{0}{1:X}", debugInfo.Signature.ToString("N").ToUpperInvariant(), debugInfo.AgeOrTimestamp));
        }
Beispiel #3
0
        private IEnumerable <IEnumerable <string> > GetPdbSourceFiles(FileSystemPath symbolsFile)
        {
            DebugInfoType debugInfoType;

            if (!PdbUtils.TryGetPdbType(_symbolsFile, out debugInfoType))
            {
                yield break;
            }

            switch (debugInfoType)
            {
            case DebugInfoType.Windows:
            {
                using (var fileStream = symbolsFile.OpenFileForReading())
                {
                    var windowsPdbFile = new WindowsPdbFile(fileStream);
                    // Windows PDB files could not contains proper section with C++ file references,
                    // they reference generated files instead, so we need to iterate values from /name stream.
                    yield return(windowsPdbFile.NameStream.Values);

                    yield return(PdbUtils.GetTypeToFilesMapping(windowsPdbFile, null).AllValues);
                }

                break;
            }

            case DebugInfoType.Portable:
            case DebugInfoType.EmbeddedPortable:
            {
                using (var cookie = PortablePdbFileCookie.Create(symbolsFile, debugInfoType, null))
                {
                    yield return(cookie.Pdb?.Type2Files?.AllValues ?? Enumerable.Empty <string>());
                }

                break;
            }
            }
        }