internal void RunTest(string name, out PdbFunction original, out PdbFunction rewritten) { int originalAge; Guid originalGuid; PdbFunction[] originalFunctions; using (var file = File.OpenRead(pdbFileName)) originalFunctions = PdbFile.LoadFunctions(file, true, out originalAge, out originalGuid); var method = GetMethod(name); original = originalFunctions.Single(f => f.token == method.MetadataToken.ToUInt32()); var pdb = ProgramDatabase.Read(pdbFileName); pdb.Write(pdbFileName, new CecilMetadataProvider(module)); int rewrittenAge; Guid rewrittenGuid; PdbFunction[] rewrittenFunctions; using (var file = File.OpenRead(pdbFileName)) rewrittenFunctions = PdbFile.LoadFunctions(file, true, out rewrittenAge, out rewrittenGuid); rewritten = rewrittenFunctions.Single(f => f.token == method.MetadataToken.ToUInt32()); Assert.AreEqual(originalAge, rewrittenAge); Assert.AreEqual(originalGuid, rewrittenGuid); }
public unsafe PdbInfo(IO.FileStream inputStream, Metadata.Reader reader) { this.reader = reader; this.pdbFunctionMap = PdbFile.LoadFunctionMap(inputStream, out tokenToSourceMapping, out sourceServerData, reader); //inputStream.Seek(0L, IO.SeekOrigin.Begin); //this.remapTable = PdbFile.LoadRemapTable(inputStream); }
void PopulateFunctions(string file) { using (Stream pdb = File.OpenRead(file)) { int age; Guid guid; PdbFunction [] funcs = PdbFile.LoadFunctions(pdb, true, out age, out guid); if (this.age != 0) { if (this.age != age) { throw new InvalidOperationException(); } if (this.guid != guid) { throw new InvalidOperationException(); } } foreach (PdbFunction function in funcs) { functions.Add(function.token, function); } } }
public static void Convert(string pdb, string windowsRootFolder, string linuxRootFolder) { string filenameWithoutExtension = Path.GetFileNameWithoutExtension(pdb); string filename = Path.Combine(Path.GetDirectoryName(pdb), $"{filenameWithoutExtension}.dll"); if (!File.Exists(filename)) { filename = Path.Combine(Path.GetDirectoryName(pdb), $"{filenameWithoutExtension}.exe"); } if (!File.Exists(filename)) { throw new FileNotFoundException("Assembly file doesn't exist: " + pdb); } using (var asm = AssemblyDefinition.ReadAssembly(filename)) { using (var stream = File.OpenRead(pdb)) { if (IsPortablePdb(stream)) { throw new PortablePdbNotSupportedException(); } var funcs = PdbFile.LoadFunctions(stream, true); Converter.Convert(asm, funcs, new MonoSymbolWriter(filename), windowsRootFolder, linuxRootFolder); } } }
public static Dictionary <string, string> VerifyPdbFiles(this Project project, IEnumerable <string> files, string pdbFileFullPath) { using (var pdb = new PdbFile(pdbFileFullPath)) { return(pdb.VerifyPdbFiles(files)); } }
internal static IReadOnlyDictionary <string, byte[]> GetFilesAndChecksums(this PdbFile pdbFile) { Argument.IsNotNull(() => pdbFile); // const int LastInterestingByte = 47; const string FileIndicator = "/src/files/"; var values = pdbFile.Info.NameToPdbName.Values; var results = new Dictionary <string, byte[]>(StringComparer.OrdinalIgnoreCase); foreach (var value in values) { if (!value.Name.StartsWith(FileIndicator)) { continue; } var num = value.Stream; var name = value.Name.Substring(FileIndicator.Length); // Get last bytes for checksum (it may be MD5 or SHA1) var bytes = pdbFile.ReadStreamBytes(num); int hashLength = bytes.Length - 72; var checksum = new byte[hashLength]; Array.Copy(bytes, bytes.Length - hashLength, checksum, 0, hashLength); results.Add(name, checksum); } return(results); }
public static Dictionary <string, string> VerifyPdbFiles(this PdbFile pdbFile, IEnumerable <string> files) { Argument.IsNotNull(() => pdbFile); var missing = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); var actualFileChecksums = (from x in files select new KeyValuePair <string, string>(Hex.Encode(Crypto.GetMd5HashForFiles(new[] { x }).First().Item1), x)).ToDictionary(x => x.Value, x => x.Key); foreach (var checksumInfo in pdbFile.GetChecksums()) { var file = checksumInfo.Key; var checksum = checksumInfo.Value; if (!actualFileChecksums.ContainsValue(checksum)) { if (file.EndsWith(".xaml")) { // #64 ignore xaml files, not important continue; } missing[file] = checksum; } } return(missing); }
bool PopulateFunctions() { using (pdb_file) { int age; Guid guid; var funcs = PdbFile.LoadFunctions(pdb_file, true, out age, out guid); if (this.age != 0 && this.guid != guid) { return(false); } { // foreach(var function in funcs) var __enumerator1 = (funcs).GetEnumerator(); while (__enumerator1.MoveNext()) { var function = (PdbFunction)__enumerator1.Current; functions.Add(function.token, function); } } } return(true); }
/* * uint Magic = 0x53445352; * Guid Signature; * uint Age; * string FileName; */ public bool ProcessDebugHeader(ImageDebugHeader header) { if (!header.HasEntries) { return(false); } using (pdb_file) { var info = PdbFile.LoadFunctions(pdb_file.value); foreach (var entry in header.Entries) { if (!IsMatchingEntry(info, entry)) { continue; } foreach (var function in info.Functions) { functions.Add(function.token, function); } return(true); } } return(false); }
bool PopulateFunctions() { using (pdb_file) { int age; Guid guid; var funcs = PdbFile.LoadFunctions(pdb_file, true, out age, out guid); if (this.age != 0) { if (this.age != age) { return(false); } if (this.guid != guid) { return(false); } } foreach (PdbFunction function in funcs) { functions.Add(function.token, function); } } return(true); }
public void Initialize(string assemblyFilePath) { using (var pdbFileStream = File.OpenRead(Path.ChangeExtension(assemblyFilePath, "pdb"))) { _pdbFunctions = PdbFile.LoadFunctions(pdbFileStream, true).ToDictionary(func => func.token, func => func); } }
/// <summary> /// Initializes a new instance of the <see cref="PdbModule"/> class. /// </summary> /// <param name="module">The XML module description.</param> /// <param name="pdbFile">Already opened PDB file.</param> public PdbModule(XmlModule module, PdbFile pdbFile) { PdbFile = pdbFile; Name = !string.IsNullOrEmpty(module.Name) ? module.Name : Path.GetFileNameWithoutExtension(module.SymbolsPath).ToLower(); Namespace = module.Namespace; globalScopeCache = SimpleCache.CreateStruct(() => new PdbGlobalScope(this)); builtinSymbolsCache = new DictionaryCache <TypeIndex, PdbSymbol>(CreateBuiltinSymbol); allSymbolsCache = new ArrayCache <PdbSymbol>(PdbFile.TpiStream.TypeRecordCount, CreateSymbol); definedSymbolsCache = new ArrayCache <PdbSymbol>(PdbFile.TpiStream.TypeRecordCount, true, GetDefinedSymbol); constantsCache = SimpleCache.CreateStruct(() => { Dictionary <string, ConstantSymbol> constants = new Dictionary <string, ConstantSymbol>(); foreach (SymbolRecordKind kind in ConstantSymbol.Kinds) { foreach (ConstantSymbol c in PdbFile.PdbSymbolStream[kind].OfType <ConstantSymbol>()) { if (!constants.ContainsKey(c.Name)) { constants.Add(c.Name, c); } } } return((IReadOnlyDictionary <string, ConstantSymbol>)constants); }); }
public static void Generate() { string pdbPath = Path.Combine(Program.Root, @"System\Kernel\Kernel.pdb"); string wrappersPath = Path.Combine(Program.Root, @"System\[Tools]\Debugger\Wrappers\Wrappers.cs"); PdbFile pdbFile = new PdbFile(pdbPath); PdbSession pdbSession = pdbFile.OpenSession(0x100000); using (StreamWriter output = File.CreateText(wrappersPath)) { output.WriteLine("using System;"); output.WriteLine("using System.Collections.Generic;"); output.WriteLine("using System.IO;"); output.WriteLine("using System.Linq;"); output.WriteLine(); output.WriteLine("namespace Debugger.Wrappers"); output.WriteLine("{"); /*foreach (PdbSymbol customType in pdbSession.Global.FindChildren(PdbSymbolTag.CustomType)) * { * output.WriteLine(" class _{0} : Object", customType.VirtualAddress); * output.WriteLine(" {"); * output.WriteLine(" }"); * }*/ output.Write("}"); } }
static void Convert(AssemblyDefinition assembly, Stream pdb, MonoSymbolWriter mdb) { try { Converter.Convert(assembly, PdbFile.LoadFunctions(pdb, true), mdb); } catch (Exception e) { Error(e); } }
/// <summary> /// Allocates an object that can map some kinds of ILocation objects to IPrimarySourceLocation objects. /// For example, a PDB reader that maps offsets in an IL stream to source locations. /// </summary> public PdbReader(Stream pdbStream, IMetadataHost host) { this.host = host; foreach (PdbFunction pdbFunction in PdbFile.LoadFunctions(pdbStream, true)) { this.pdbFunctionMap[pdbFunction.token] = pdbFunction; } }
public void ReadingAllData(string pdbFileName) { string pdbPath = Path.Combine(DumpInitialization.DefaultDumpPath, pdbFileName); using (PdbFile pdbFile = new PdbFile(pdbPath)) { Test(pdbFile); } }
private void Test(PdbFile pdbFile) { Assert.NotEmpty(pdbFile.FreePageMap); Assert.NotEmpty(pdbFile.Streams); Test(pdbFile.TpiStream); Test(pdbFile.IpiStream); Test(pdbFile.DbiStream); Test(pdbFile.PdbSymbolStream); }
private static IEnumerable <TypeRecord> GetFields(PdbFile pdb, TagRecord record) { foreach (TypeRecord field in EnumerateFieldList(pdb, record.FieldList)) { if (field is DataMemberRecord || field is StaticDataMemberRecord staticDataMember) { yield return(field); } } }
public void Open() { using (PdbFile pdb = OpenWindowsPdb(1)) { } using (PdbFile pdb = new PdbFile(new MemoryLoadedFile(GetPdbPath(1)))) { } }
public static Dictionary <string, string> VerifyPdbFiles(this Project project, IEnumerable <string> files) { Argument.IsNotNull(() => project); var pdbFile = GetOutputPdbFile(project); using (var pdb = new PdbFile(pdbFile)) { return(pdb.VerifyPdbFiles(files)); } }
public void Test1(int pdbIndex) { using (PdbFile pdb = OpenWindowsPdb(pdbIndex)) { Assert.NotNull(pdb.DbiStream); ReadDbiStream(pdb.DbiStream); Assert.NotNull(pdb.PdbSymbolStream); ReadSymbolStream(pdb.PdbSymbolStream); Assert.NotNull(pdb.TpiStream); ReadTpiStream(pdb.TpiStream); } }
/// <summary> /// Allocates an object that can map some kinds of ILocation objects to IPrimarySourceLocation objects. /// For example, a PDB reader that maps offsets in an IL stream to source locations. /// </summary> public PdbReader(Stream pdbStream, IMetadataHost host) { Contract.Requires(pdbStream != null); Contract.Requires(host != null); this.pdbStream = pdbStream; this.host = host; foreach (PdbFunction pdbFunction in PdbFile.LoadFunctions(pdbStream, out this.tokenToSourceMapping, out this.sourceServerData)) { this.pdbFunctionMap[pdbFunction.token] = pdbFunction; } }
public static Dictionary <string, string> GetChecksums(this PdbFile pdbFile) { Argument.IsNotNull(() => pdbFile); var checksums = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (var file in pdbFile.GetFiles()) { checksums.Add(file.Item1, Hex.Encode(file.Item2)); } return(checksums); }
public static void Convert(string filename) { var asm = AssemblyDefinition.ReadAssembly(filename); var pdb = asm.Name.Name + ".pdb"; pdb = Path.Combine(Path.GetDirectoryName(filename), pdb); using (var stream = File.OpenRead(pdb)) { var funcs = PdbFile.LoadFunctions(stream, true); Converter.Convert(asm, funcs, new MonoSymbolWriter(filename)); } }
private void LoadSymbols() { string pdbPath = Path.Combine(Bootstrap.Source, @"Kernel\Kernel.pdb"); if (!File.Exists(pdbPath)) { throw new Exception("Could not find kernel symbols"); } // Load and open PDB session PdbFile = new PdbFile(pdbPath); PdbSession = PdbFile.OpenSession(0x100000); }
public void Properties() { using (PdbFile pdb = OpenWindowsPdb(1)) { Assert.NotNull(pdb.FreePageMap); Assert.Equal(531U, pdb.FreePageMapBitLength); Assert.NotNull(pdb.DbiStream); Assert.NotNull(pdb.InfoStream); Assert.NotNull(pdb.PdbSymbolStream); Assert.NotNull(pdb.TpiStream); Assert.NotNull(pdb.IpiStream); Assert.NotNull(pdb.Streams); } }
bool PopulateFunctions() { using (pdb_file) { Dictionary <uint, PdbTokenLine> tokenToSourceMapping; string sourceServerData; var funcs = PdbFile.LoadFunctions(pdb_file, out tokenToSourceMapping, out sourceServerData); foreach (PdbFunction function in funcs) { functions.Add(function.token, function); } } return(true); }
/// <summary> /// Allocates an object that can map some kinds of ILocation objects to IPrimarySourceLocation objects. /// For example, a PDB reader that maps offsets in an IL stream to source locations. /// Uses the default host /// </summary> public PdbReader(string modulePath) { host = new PeReader.DefaultHost(); module = host.LoadUnitFrom(modulePath) as IModule; string pdbFile = Path.ChangeExtension(modulePath, "pdb"); using (Stream pdbStream = File.OpenRead(pdbFile)) { foreach (PdbFunction pdbFunction in PdbFile.LoadFunctions(pdbStream, out this.tokenToSourceMapping)) { this.pdbFunctionMap[pdbFunction.token] = pdbFunction; } } }
public override bool Execute() { LogManager.AddListener(new MSBuildListener(Log)); var options = new LinkOptions { Method = MethodEnum, SkipVerify = SkipVerify, GitRemoteUrl = GitRemoteUrl != null ? new Uri(GitRemoteUrl, UriKind.Absolute) : null, CommitId = GitCommitId, GitWorkingDirectory = GitWorkingDirectory, }; bool success = Linker.Link(PdbFile.GetMetadata("FullPath"), options); return(success && !Log.HasLoggedErrors); }
/// <summary> /// Read a pdb from a stream. /// </summary> /// <param name="stream">The stream containing the pdb.</param> /// <returns>A representation of the pdb.</returns> public static ProgramDatabase Read(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException("Can not read from stream", "stream"); } int age; Guid guid; return(new ProgramDatabase(PdbFile.LoadFunctions(stream, true, out age, out guid), age, guid)); }
public static Dictionary<string, string> VerifyPdbFiles(this Project project, IEnumerable<string> files) { Argument.IsNotNull(() => project); var pdbFile = GetOutputPdbFile(project); using (var pdb = new PdbFile(pdbFile)) { return pdb.VerifyPdbFiles(files); } }
public static Dictionary<string, string> VerifyPdbFiles(this Project project, IEnumerable<string> files, string pdbFileFullPath) { using(var pdb = new PdbFile(pdbFileFullPath)) { return pdb.VerifyPdbFiles(files); } }
private void LoadSymbols() { string pdbPath = Path.Combine(Program.Root, @"System\Kernel\Kernel.pdb"); if (!File.Exists(pdbPath)) throw new Exception("Could not find kernel symbols"); // Load and open PDB session PdbFile = new PdbFile(pdbPath); PdbSession = PdbFile.OpenSession(0x100000); }