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); } } } }
public int Execute() { if (!_symbolsFile.ExistsFile) { Console.Error.WriteLine("PDB file {0} does not exist.", _symbolsFile); return(1); } try { DebugInfoType debugInfo; if (!PdbUtils.TryGetPdbType(_symbolsFile, out debugInfo)) { throw new Exception("Invalid PDB file " + _symbolsFile); } Console.Out.WriteLine(FormatDebugInfoType(debugInfo)); } catch (Exception e) { Console.Error.WriteLine("Unable to read PDB type from PDF file {0}: {1} ", _symbolsFile, e.Message); return(1); } return(0); }
WindowsPdbWriter(PdbState pdbState, Metadata metadata) { this.pdbState = pdbState; this.metadata = metadata; module = metadata.Module; instrToOffset = new Dictionary <Instruction, uint>(); customDebugInfoWriterContext = new PdbCustomDebugInfoWriterContext(); localsEndScopeIncValue = PdbUtils.IsEndInclusive(PdbFileKind.WindowsPDB, pdbState.Compiler) ? 1 : 0; }
public int Execute() { if (!_symbolsFile.ExistsFile) { Console.Error.WriteLine("PDB file {0} does not exist.", _symbolsFile); return(1); } if (!_sourceDescriptorFile.ExistsFile) { Console.Error.WriteLine("Source descriptor file {0} does not exist.", _sourceDescriptorFile); return(1); } try { DebugInfoType debugInfoType; if (!PdbUtils.TryGetPdbType(_symbolsFile, out debugInfoType)) { throw new Exception("Invalid PDB file " + _symbolsFile); } if (debugInfoType != DebugInfoType.Portable) { throw new Exception(string.Format("Cannot update PDB file ${0}. PDB Type {1} is not supported", _symbolsFile, debugInfoType)); } var sourceDescriptor = ReadSourceDescriptor(_sourceDescriptorFile); if (sourceDescriptor.Documents == null) { throw new Exception(string.Format("Source Link file ${0} is empty", _sourceDescriptorFile)); } var symbolsFile = _symbolsFile.AddSuffix(".original"); _symbolsFile.MoveFile(symbolsFile, true); if (!PortablePdbModifier.AddSourceLink(symbolsFile, _sourceDescriptorFile, _symbolsFile)) { throw new Exception(string.Format("Cannot update PDB file ${0}. Internal error", symbolsFile)); } } catch (Exception e) { Console.Error.WriteLine("Unable to update PDF file {0}: {1} ", _symbolsFile, e.Message); return(1); } return(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)); }
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; } } }
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); } 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)); }