2 // System.Diagnostics.SymbolStore/MonoSymbolTable.cs
5 // Martin Baulig (martin@gnome.org)
7 // (C) 2002 Ximian, Inc. http://www.ximian.com
11 using System.Reflection;
12 using System.Reflection.Emit;
13 using System.Collections;
17 namespace Mono.CSharp.Debugger
19 public struct OffsetTable
21 public const uint Version = 16;
22 public const long Magic = 0x45e82623fd7fa614;
24 public uint total_file_size;
25 public uint source_table_offset;
26 public uint source_table_size;
27 public uint method_table_offset;
28 public uint method_table_size;
29 public uint line_number_table_offset;
30 public uint line_number_table_size;
32 public OffsetTable (BinaryReader reader)
34 total_file_size = reader.ReadUInt32 ();
35 source_table_offset = reader.ReadUInt32 ();
36 source_table_size = reader.ReadUInt32 ();
37 method_table_offset = reader.ReadUInt32 ();
38 method_table_size = reader.ReadUInt32 ();
39 line_number_table_offset = reader.ReadUInt32 ();
40 line_number_table_size = reader.ReadUInt32 ();
43 public void Write (BinaryWriter bw)
45 bw.Write (total_file_size);
46 bw.Write (source_table_offset);
47 bw.Write (source_table_size);
48 bw.Write (method_table_offset);
49 bw.Write (method_table_size);
50 bw.Write (line_number_table_offset);
51 bw.Write (line_number_table_size);
55 public struct LineNumberEntry
61 public static LineNumberEntry Null = new LineNumberEntry (0, 0);
63 public LineNumberEntry (uint row, uint offset)
70 public LineNumberEntry (ISourceLine line)
71 : this ((uint) line.Row, (uint) line.Offset)
74 public LineNumberEntry (BinaryReader reader)
76 Row = reader.ReadUInt32 ();
77 Offset = reader.ReadUInt32 ();
78 Address = reader.ReadUInt32 ();
87 public void Write (BinaryWriter bw)
94 public override string ToString ()
96 return String.Format ("[Line {0}:{1}:{2}]", Row, Offset, Address);
100 public struct MethodEntry
103 public uint SourceFileOffset;
104 public uint LineNumberTableOffset;
105 public uint StartRow;
106 public long StartAddress;
107 public long EndAddress;
109 public readonly string SourceFile;
110 public readonly LineNumberEntry[] LineNumbers;
112 public MethodEntry (BinaryReader reader)
114 Token = reader.ReadUInt32 ();
115 SourceFileOffset = reader.ReadUInt32 ();
116 LineNumberTableOffset = reader.ReadUInt32 ();
117 StartRow = reader.ReadUInt32 ();
118 StartAddress = reader.ReadInt64 ();
119 EndAddress = reader.ReadInt64 ();
121 long old_pos = reader.BaseStream.Position;
122 reader.BaseStream.Position = LineNumberTableOffset;
124 ArrayList lines = new ArrayList ();
127 LineNumberEntry lne = new LineNumberEntry (reader);
133 reader.BaseStream.Position = SourceFileOffset;
134 SourceFile = reader.ReadString ();
135 reader.BaseStream.Position = old_pos;
137 LineNumbers = new LineNumberEntry [lines.Count];
138 lines.CopyTo (LineNumbers);
141 public MethodEntry (uint token, uint sf_offset, uint lnt_offset, uint row)
144 this.SourceFileOffset = sf_offset;
145 this.LineNumberTableOffset = lnt_offset;
147 this.StartAddress = 0;
149 this.SourceFile = null;
150 this.LineNumbers = new LineNumberEntry [0];
153 public void Write (BinaryWriter bw)
156 bw.Write (SourceFileOffset);
157 bw.Write (LineNumberTableOffset);
159 bw.Write (StartAddress);
160 bw.Write (EndAddress);
163 public override string ToString ()
165 return String.Format ("[Method {0}:{1}:{2}:{3}:{4}:{5}]",
166 Token, SourceFileOffset, LineNumberTableOffset,
167 StartRow, StartAddress, EndAddress);