public int Execute()
        {
            if (!_symbolsFile.ExistsFile)
            {
                Console.Error.WriteLine("PDB file {0} does not exist.", _symbolsFile);
                return(1);
            }

            try
            {
                var pdb = PdbReader.ReadPdb(_symbolsFile, PdbParseLevel.None, null);
                if (pdb == null)
                {
                    Console.Error.WriteLine("Invalid PDB file " + _symbolsFile);
                    return(1);
                }

                foreach (var sourceFile in GetSourceFiles(pdb))
                {
                    Console.Out.WriteLine(sourceFile);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Unable to read indexed sources from PDF file {0}: {1} ", _symbolsFile, e.Message);
                return(1);
            }

            return(0);
        }
Beispiel #2
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 #3
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);
            }

            return(pdb.DocumentNameToIndex.Keys
                   .Concat(
                       GetPdbSourceFiles(symbolsFile)
                       .SelectMany(x => x)));
        }