Ejemplo n.º 1
0
 public virtual void show_debug_hunk(DebugHunk hunk)
 {
     var debug_type = hunk.debug_type;
     if (debug_type == "LINE")
     {
         this.print_extra_sub(String.Format("line for '{0}'", hunk.src_file));
         if (this.show_debug)
         {
             foreach (var src_off in hunk.src_map)
             {
                 uint addr = src_off.Value;
                 int line = src_off.Key;
                 this.print_symbol(addr, String.Format("line {0}", line), "");
             }
         }
     }
     else if (this.show_debug)
     {
         print_hex(hunk.Data, indent: 8);
     }
 }
Ejemplo n.º 2
0
 public void ParseDebug(Action<Hunk> h)
 {
     var hunk = new DebugHunk();
     var num_longs = this.read_long();
     if (num_longs < 0)
         throw new BadImageFormatException(string.Format("{0} has invalid size.", hunk.HunkType));
     var size = num_longs * 4;
     if (num_longs < 2)
     {
         f.Offset += (ulong)size;
         return;
     }
     var offset = (uint) this.read_long();
     hunk.debug_offset = offset;
     var tag = this.ReadTag();
     hunk.debug_type = tag;
     size -= 8;  //  skip offset and tag.
     if (tag == "LINE")
     {
         // LINE
         // parse LINE: source line -> code offset mapping
         var l = f.ReadBeInt32();
         size -= l * 4 + 4;
         var n = this.ReadSizedString(l);
         var src_map = new Dictionary<int, uint>();
         hunk.src_file = n;
         hunk.src_map = src_map;
         while (size > 0)
         {
             var line_no = this.read_long();
             offset = (uint) this.read_long();
             size -= 8;
             src_map.Add(line_no, offset);
         }
     }
     else
     {
         // read unknown DEBUG hunk
         hunk.Data = f.ReadBytes(size);
     }
 }