public static DebugSymbolEntry[] From(FileHeader hdr, BinaryReader rd, SmxDebugInfoSection info, SmxNameTable names) { var entries = new DebugSymbolEntry[info.NumSymbols]; for (var i = 0; i < info.NumSymbols; i++) { var entry = new DebugSymbolEntry(); entry.Address = rd.ReadInt32(); entry.TagId = rd.ReadUInt16(); // There's a padding of 2 bytes after this short. if (hdr.debugUnpacked) { rd.ReadBytes(2); } entry.CodeStart = rd.ReadUInt32(); entry.CodeEnd = rd.ReadUInt32(); entry.Ident = (SymKind)rd.ReadByte(); entry.Scope = (SymScope)rd.ReadByte(); entry.dimcount = rd.ReadUInt16(); entry.nameoffs = rd.ReadInt32(); entry.Name = names.StringAt(entry.nameoffs); if (entry.dimcount > 0) { entry.Dims = DebugSymbolDimEntry.From(hdr, rd, entry.dimcount); } entries[i] = entry; } return(entries); }
public SmxDebugSymbolsTable(FileHeader file, SectionEntry header, SmxDebugInfoSection info, SmxNameTable names) : base(file, header) { entries_ = DebugSymbolEntry.From(file, file.SectionReader(header), info, names); }
public static DebugSymbolEntry[] From(FileHeader hdr, BinaryReader rd, SmxDebugInfoSection info, SmxNameTable names) { var entries = new DebugSymbolEntry[info.NumSymbols]; for (var i = 0; i < info.NumSymbols; i++) { var entry = new DebugSymbolEntry(); entry.Address = rd.ReadInt32(); entry.TagId = rd.ReadUInt16(); // There's a padding of 2 bytes after this short. if (hdr.debugUnpacked) rd.ReadBytes(2); entry.CodeStart = rd.ReadUInt32(); entry.CodeEnd = rd.ReadUInt32(); entry.Ident = (SymKind)rd.ReadByte(); entry.Scope = (SymScope)rd.ReadByte(); entry.dimcount = rd.ReadUInt16(); entry.nameoffs = rd.ReadInt32(); entry.Name = names.StringAt(entry.nameoffs); if (entry.dimcount > 0) entry.Dims = DebugSymbolDimEntry.From(hdr, rd, entry.dimcount); entries[i] = entry; } return entries; }
public SmxFile(BinaryReader br) { Header = FileHeader.From(br); // Parse precursor sections. foreach (var section in Header.Sections) { if (section.Name == ".names") { Names = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.strings") { DebugNames = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.info") { DebugInfo = new SmxDebugInfoSection(Header, section); } } CalledFunctions = new SmxCalledFunctionsTable(); // .dbg.names was removed when RTTI was added. if (DebugNames == null) { DebugNames = Names; } // Parse out other sections. var unknown = new List <SectionEntry>(); foreach (var section in Header.Sections) { try { switch (section.Name) { case ".names": case ".dbg.strings": case ".dbg.info": break; case ".natives": Natives = new SmxNativeTable(Header, section, Names); break; case ".publics": Publics = new SmxPublicTable(Header, section, Names); break; case ".pubvars": Pubvars = new SmxPubvarTable(Header, section, Names); break; case ".tags": Tags = new SmxTagTable(Header, section, Names); break; case ".data": Data = new SmxDataSection(Header, section); break; case ".code": CodeV1 = new SmxCodeV1Section(Header, section); break; case ".dbg.files": DebugFiles = new SmxDebugFilesTable(Header, section, DebugNames); break; case ".dbg.lines": DebugLines = new SmxDebugLinesTable(Header, section); break; case ".dbg.natives": DebugNatives = new SmxDebugNativesTable(Header, section, DebugNames); break; case ".dbg.symbols": DebugSymbols = new SmxDebugSymbolsTable(Header, section, DebugInfo, DebugNames); break; case ".dbg.methods": DebugMethods = new SmxDebugMethods(Header, section, Names); break; case ".dbg.globals": DebugGlobals = new SmxDebugGlobals(Header, section, Names); break; case ".dbg.locals": DebugLocals = new SmxDebugLocals(this, Header, section, Names); break; case "rtti.data": RttiData = new SmxRttiData(this, Header, section); break; case "rtti.classdefs": RttiClassDefs = new SmxRttiClassDefTable(Header, section, Names); break; case "rtti.fields": RttiFields = new SmxRttiFieldTable(Header, section, Names); break; case "rtti.methods": RttiMethods = new SmxRttiMethodTable(Header, section, Names); break; case "rtti.natives": RttiNatives = new SmxRttiNativeTable(Header, section, Names); break; case "rtti.enums": RttiEnums = new SmxRttiEnumTable(Header, section, Names); break; case "rtti.typedefs": RttiTypedefs = new SmxRttiTypedefTable(Header, section, Names); break; case "rtti.typesets": RttiTypesets = new SmxRttiTypesetTable(Header, section, Names); break; default: unknown.Add(section); break; } } catch { // Set a breakpoint here to see why the section failed to be parsed. unknown.Add(section); } } UnknownSections = unknown.ToArray(); // Disassemble all functions right away to find all called functions. if (DebugSymbols != null) { foreach (var entry in DebugSymbols.Entries) { if (entry.Ident != SymKind.Function) { continue; } V1Disassembler.TryDisassemble(this, CodeV1, entry.Address); } } if (Publics != null) { foreach (var pubfun in Publics.Entries) { V1Disassembler.TryDisassemble(this, CodeV1, (int)pubfun.Address); } } if (CalledFunctions != null) { foreach (var fun in CalledFunctions.Entries) { V1Disassembler.TryDisassemble(this, CodeV1, (int)fun.Address); } } }
private void renderDebugInfo(TreeNode root, SmxDebugInfoSection info) { root.Tag = new NodeData(delegate() { renderSectionHeaderDetail(info.SectionHeader); addDetailLine("num_files = {0}", info.NumFiles); addDetailLine("num_lines = {0}", info.NumLines); addDetailLine("num_symbols = {0}", info.NumSymbols); addDetailLine("num_arrays = {0}", info.NumArrays); endDetailUpdate(); }, null); }
public SmxFile(BinaryReader br) { Header = FileHeader.From(br); // Parse precursor sections. foreach (var section in Header.Sections) { if (section.Name == ".names") { Names = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.strings") { DebugNames = new SmxNameTable(Header, section); } else if (section.Name == ".dbg.info") { DebugInfo = new SmxDebugInfoSection(Header, section); } } // Parse out other sections. var unknown = new List <SectionEntry>(); foreach (var section in Header.Sections) { switch (section.Name) { case ".names": case ".dbg.strings": case ".dbg.info": break; case ".natives": Natives = new SmxNativeTable(Header, section, Names); break; case ".publics": Publics = new SmxPublicTable(Header, section, Names); break; case ".pubvars": Pubvars = new SmxPubvarTable(Header, section, Names); break; case ".tags": Tags = new SmxTagTable(Header, section, Names); break; case ".data": Data = new SmxDataSection(Header, section); break; case ".code": CodeV1 = new SmxCodeV1Section(Header, section); break; case ".dbg.files": DebugFiles = new SmxDebugFilesTable(Header, section, DebugNames); break; case ".dbg.lines": DebugLines = new SmxDebugLinesTable(Header, section); break; case ".dbg.natives": DebugNatives = new SmxDebugNativesTable(Header, section, DebugNames); break; case ".dbg.symbols": DebugSymbols = new SmxDebugSymbolsTable(Header, section, DebugInfo, DebugNames); break; default: unknown.Add(section); break; } } UnknownSections = unknown.ToArray(); }
public SmxFile(BinaryReader br) { Header = FileHeader.From(br); // Parse precursor sections. foreach (var section in Header.Sections) { if (section.Name == ".names") Names = new SmxNameTable(Header, section); else if (section.Name == ".dbg.strings") DebugNames = new SmxNameTable(Header, section); else if (section.Name == ".dbg.info") DebugInfo = new SmxDebugInfoSection(Header, section); } // Parse out other sections. var unknown = new List<SectionEntry>(); foreach (var section in Header.Sections) { switch (section.Name) { case ".names": case ".dbg.strings": case ".dbg.info": break; case ".natives": Natives = new SmxNativeTable(Header, section, Names); break; case ".publics": Publics = new SmxPublicTable(Header, section, Names); break; case ".pubvars": Pubvars = new SmxPubvarTable(Header, section, Names); break; case ".tags": Tags = new SmxTagTable(Header, section, Names); break; case ".data": Data = new SmxDataSection(Header, section); break; case ".code": CodeV1 = new SmxCodeV1Section(Header, section); break; case ".dbg.files": DebugFiles = new SmxDebugFilesTable(Header, section, DebugNames); break; case ".dbg.lines": DebugLines = new SmxDebugLinesTable(Header, section); break; case ".dbg.natives": DebugNatives = new SmxDebugNativesTable(Header, section, DebugNames); break; case ".dbg.symbols": DebugSymbols = new SmxDebugSymbolsTable(Header, section, DebugInfo, DebugNames); break; default: unknown.Add(section); break; } } UnknownSections = unknown.ToArray(); }