Exemple #1
0
        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);
        }
Exemple #2
0
 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;
 }
Exemple #3
0
        private void renderDebugFunction(SmxDebugSymbolsTable syms, TreeNode root, DebugSymbolEntry fun)
        {
            root.Tag = new NodeData(delegate()
            {
                renderSymbolDetail(fun);
            }, null);

            var args = new List<DebugSymbolEntry>();
            var locals = new List<DebugSymbolEntry>();
            foreach (var sym_ in syms.Entries)
            {
                var sym = sym_;
                if (sym.Scope == SymScope.Global)
                    continue;
                if (sym.CodeStart < fun.CodeStart || sym.CodeEnd > fun.CodeEnd)
                    continue;
                if (sym.Address < 0)
                    locals.Add(sym);
                else
                    args.Add(sym);
            }

            args.Sort(delegate (DebugSymbolEntry e1, DebugSymbolEntry e2)
            {
                return e1.Address.CompareTo(e2.Address);
            });
            foreach (var sym_ in args)
            {
                var sym = sym_;
                var node = root.Nodes.Add(sym.Name);
                node.Tag = new NodeData(delegate()
                {
                    renderSymbolDetail(sym);
                }, null);
            }

            locals.Sort(delegate (DebugSymbolEntry e1, DebugSymbolEntry e2)
            {
                return e1.CodeStart.CompareTo(e2.CodeStart);
            });
            foreach (var sym_ in locals)
            {
                var sym = sym_;
                var node = root.Nodes.Add(sym.Name);
                node.Tag = new NodeData(delegate()
                {
                    renderSymbolDetail(sym);
                }, null);
            }
        }
Exemple #4
0
        private void renderSymbolDetail(DebugSymbolEntry entry)
        {
            Tag tag = null;
            if (file_.Tags != null)
                tag = file_.Tags.FindTag(entry.TagId);

            startDetail("; {0}", entry.Name);
            if (entry.Address < 0)
                addDetailLine("address = -0x{0:x}", -entry.Address);
            else
                addDetailLine("address = 0x{0:x}", entry.Address);
            if (tag == null)
                addDetailLine("tagid = 0x{0:x}", entry.TagId);
            else
                addDetailLine("tagid = 0x{0:x} ; {1}", entry.TagId, tag.Name);
            addDetailLine("codestart = 0x{0:x}", entry.CodeStart);
            addDetailLine("codeend = 0x{0:x}", entry.CodeEnd);
            addDetailLine("nameoffs = 0x{0:x} ; {1}", entry.nameoffs, entry.Name);
            addDetailLine("kind = {0:d} ; {1}", entry.Ident, entry.Ident.ToString());
            addDetailLine("scope = {0:d} ; {1}", entry.Scope, entry.Scope.ToString());

            if (entry.Dims != null)
            {
                addDetailLine("dims = {0}", dimsToString(tag, entry.Dims));
            }

            string file = null;
            if (file_.DebugFiles != null)
                file = file_.DebugFiles.FindFile(entry.CodeStart);
            if (file != null)
                addDetailLine("file: \"{0}\"", (string)file);

            uint? line = null;
            if (file_.DebugLines != null)
                line = file_.DebugLines.FindLine(entry.CodeStart);
            if (line != null)
                addDetailLine("line: \"{0}\"", (uint)line);
            endDetailUpdate();
        }
Exemple #5
0
 public SmxDebugSymbolsTable(FileHeader file, SectionEntry header, SmxDebugInfoSection info, SmxNameTable names)
     : base(file, header)
 {
     entries_ = DebugSymbolEntry.From(file, file.SectionReader(header), info, names);
 }