X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FMono.CSharp.Debugger%2FMonoSymbolTable.cs;h=7692f6579fd5eea62e79b31c55d3cba860cba552;hb=81d4cdd307eecba8dfad32b9f91ab9a0d8ea1a54;hp=71cd1c0f6d010e71c2c44005ab1ee0d181ff1bff;hpb=afd46500d47b2ad0e7c498d239a683bc3a6e1d0f;p=mono.git diff --git a/mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs b/mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs index 71cd1c0f6d0..7692f6579fd 100644 --- a/mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs +++ b/mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs @@ -18,7 +18,7 @@ namespace Mono.CSharp.Debugger { public struct OffsetTable { - public const int Version = 23; + public const int Version = 28; public const long Magic = 0x45e82623fd7fa614; public int total_file_size; @@ -29,7 +29,14 @@ namespace Mono.CSharp.Debugger public int method_table_size; public int line_number_table_offset; public int line_number_table_size; - public int address_table_size; + public int local_variable_table_offset; + public int local_variable_table_size; + public int source_file_table_offset; + public int source_file_table_size; + public int source_file_count; + public int type_count; + public int type_index_table_offset; + public int type_index_table_size; public OffsetTable (IMonoBinaryReader reader) { @@ -41,7 +48,14 @@ namespace Mono.CSharp.Debugger method_table_size = reader.ReadInt32 (); line_number_table_offset = reader.ReadInt32 (); line_number_table_size = reader.ReadInt32 (); - address_table_size = reader.ReadInt32 (); + local_variable_table_offset = reader.ReadInt32 (); + local_variable_table_size = reader.ReadInt32 (); + source_file_table_offset = reader.ReadInt32 (); + source_file_table_size = reader.ReadInt32 (); + source_file_count = reader.ReadInt32 (); + type_count = reader.ReadInt32 (); + type_index_table_offset = reader.ReadInt32 (); + type_index_table_size = reader.ReadInt32 (); } public void Write (BinaryWriter bw) @@ -54,7 +68,14 @@ namespace Mono.CSharp.Debugger bw.Write (method_table_size); bw.Write (line_number_table_offset); bw.Write (line_number_table_size); - bw.Write (address_table_size); + bw.Write (local_variable_table_offset); + bw.Write (local_variable_table_size); + bw.Write (source_file_table_offset); + bw.Write (source_file_table_size); + bw.Write (source_file_count); + bw.Write (type_count); + bw.Write (type_index_table_offset); + bw.Write (type_index_table_size); } } @@ -91,76 +112,172 @@ namespace Mono.CSharp.Debugger } } - public class VariableInfo + public struct LocalVariableEntry { - public readonly int Index; - public readonly int Offset; - public readonly int Size; - public readonly AddressMode Mode; - public readonly int BeginScope; - public readonly int EndScope; + public readonly string Name; + public readonly FieldAttributes Attributes; + public readonly byte[] Signature; + + public LocalVariableEntry (string Name, FieldAttributes Attributes, byte[] Signature) + { + this.Name = Name; + this.Attributes = Attributes; + this.Signature = Signature; + } + + public LocalVariableEntry (IMonoBinaryReader reader) + { + int name_length = reader.ReadInt32 (); + byte[] name = reader.ReadBuffer (name_length); + Name = Encoding.UTF8.GetString (name); + Attributes = (FieldAttributes) reader.ReadInt32 (); + int sig_length = reader.ReadInt32 (); + Signature = reader.ReadBuffer (sig_length); + } + + internal void Write (BinaryWriter bw) + { + byte[] name = Encoding.UTF8.GetBytes (Name); + bw.Write ((int) name.Length); + bw.Write (name); + bw.Write ((int) Attributes); + bw.Write ((int) Signature.Length); + bw.Write (Signature); + } - public enum AddressMode : long + public override string ToString () { - Stack = 0, - Register = 0x10000000, - TwoRegisters = 0x20000000 + return String.Format ("[LocalVariable {0}:{1}]", Name, Attributes); } + } - const long AddressModeFlags = 0xf0000000; + public class SourceFileEntry + { + public readonly string SourceFile; + + IMonoBinaryReader reader; + long method_position; + ArrayList methods; + int count; - public static int StructSize { + internal SourceFileEntry (string source_file) + { + this.SourceFile = source_file; + this.methods = new ArrayList (); + this.count = 0; + } + + internal void AddMethod (MethodSourceEntry method) + { + methods.Add (method); + count++; + } + + internal void Write (BinaryWriter bw) + { + byte[] name = Encoding.UTF8.GetBytes (SourceFile); + bw.Write ((int) name.Length); + bw.Write (name); + + methods.Sort (); + bw.Write (methods.Count); + foreach (MethodSourceEntry method in methods) + method.Write (bw); + } + + public SourceFileEntry (IMonoBinaryReader reader) + { + int name_length = reader.ReadInt32 (); + byte[] name = reader.ReadBuffer (name_length); + SourceFile = Encoding.UTF8.GetString (name); + + count = reader.ReadInt32 (); + this.reader = reader; + this.method_position = reader.Position; + + reader.Position += count * MethodSourceEntry.Size; + } + + public MethodSourceEntry[] Methods { get { - return 20; + read_methods (); + MethodSourceEntry[] retval = new MethodSourceEntry [methods.Count]; + methods.CopyTo (retval, 0); + return retval; } } - public VariableInfo (IMonoBinaryReader reader) + void read_methods () { - Index = reader.ReadInt32 (); - Offset = reader.ReadInt32 (); - Size = reader.ReadInt32 (); - BeginScope = reader.ReadInt32 (); - EndScope = reader.ReadInt32 (); - - Mode = (AddressMode) (Index & AddressModeFlags); - Index = (int) ((long) Index & ~AddressModeFlags); + if (methods != null) + return; - Console.WriteLine (this); + reader.Position = method_position; + methods = new ArrayList (); + for (int i = 0; i < count; i++) + methods.Add (new MethodSourceEntry (reader)); } public override string ToString () { - return String.Format ("[VariableInfo {0}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}]", - Mode, Index, Offset, Size, BeginScope, EndScope); + return String.Format ("SourceFileEntry ({0}:{1})", SourceFile, count); } } - public class MethodAddress + public struct MethodSourceEntry : IComparable { - public readonly long StartAddress; - public readonly long EndAddress; - public readonly int[] LineAddresses; + public readonly int Index; + public readonly int FileOffset; + public readonly int StartRow; + public readonly int EndRow; - public static int Size { + public MethodSourceEntry (int index, int file_offset, int start, int end) + { + this.Index = index; + this.FileOffset = file_offset; + this.StartRow = start; + this.EndRow = end; + } + + public MethodSourceEntry (IMonoBinaryReader reader) + { + Index = reader.ReadInt32 (); + FileOffset = reader.ReadInt32 (); + StartRow = reader.ReadInt32 (); + EndRow = reader.ReadInt32 (); + } + + public static int Size + { get { - return 20; + return 16; } } - public MethodAddress (MethodEntry entry, IMonoBinaryReader reader) + internal void Write (BinaryWriter bw) + { + bw.Write (Index); + bw.Write (FileOffset); + bw.Write (StartRow); + bw.Write (EndRow); + } + + public int CompareTo (object obj) { - StartAddress = reader.ReadInt64 (); - EndAddress = reader.ReadInt64 (); - LineAddresses = new int [entry.NumLineNumbers]; - for (int i = 0; i < entry.NumLineNumbers; i++) - LineAddresses [i] = reader.ReadInt32 (); + MethodSourceEntry method = (MethodSourceEntry) obj; + + if (method.StartRow < StartRow) + return -1; + else if (method.StartRow > StartRow) + return 1; + else + return 0; } public override string ToString () { - return String.Format ("[Address {0:x}:{1:x}]", - StartAddress, EndAddress); + return String.Format ("MethodSourceEntry ({0}:{1}:{2}:{3})", + Index, FileOffset, StartRow, EndRow); } } @@ -170,45 +287,41 @@ namespace Mono.CSharp.Debugger public readonly int StartRow; public readonly int EndRow; public readonly int NumLineNumbers; - public readonly int HasThis; + public readonly int ThisTypeIndex; public readonly int NumParameters; public readonly int NumLocals; + public int TypeIndexTableOffset; + public int LocalVariableTableOffset; public readonly int SourceFileOffset; public readonly int LineNumberTableOffset; - public readonly int AddressTableOffset; - public readonly int VariableTableOffset; - public readonly int AddressTableSize; public readonly string SourceFile = null; public readonly LineNumberEntry[] LineNumbers = null; - public readonly MethodAddress Address = null; - public readonly VariableInfo ThisVariable = null; - public readonly VariableInfo[] Parameters = null; - public readonly VariableInfo[] Locals = null; + public readonly int[] ParamTypeIndices = null; + public readonly int[] LocalTypeIndices = null; + public readonly LocalVariableEntry[] Locals = null; public static int Size { get { - return 48; + return 44; } } - public MethodEntry (IMonoBinaryReader reader, IMonoBinaryReader address_reader) + public MethodEntry (IMonoBinaryReader reader) { Token = reader.ReadInt32 (); StartRow = reader.ReadInt32 (); EndRow = reader.ReadInt32 (); - HasThis = reader.ReadInt32 (); + ThisTypeIndex = reader.ReadInt32 (); NumParameters = reader.ReadInt32 (); NumLocals = reader.ReadInt32 (); - NumLineNumbers = reader.ReadInt32 (); + TypeIndexTableOffset = reader.ReadInt32 (); + LocalVariableTableOffset = reader.ReadInt32 (); SourceFileOffset = reader.ReadInt32 (); LineNumberTableOffset = reader.ReadInt32 (); - AddressTableOffset = reader.ReadInt32 (); - VariableTableOffset = reader.ReadInt32 (); - AddressTableSize = reader.ReadInt32 (); if (SourceFileOffset != 0) { long old_pos = reader.Position; @@ -231,43 +344,52 @@ namespace Mono.CSharp.Debugger reader.Position = old_pos; } - if (AddressTableSize != 0) { - long old_pos = address_reader.Position; - address_reader.Position = AddressTableOffset; - int is_valid = address_reader.ReadInt32 (); - if (is_valid != 0) - Address = new MethodAddress (this, address_reader); - address_reader.Position = VariableTableOffset; - if (HasThis != 0) - ThisVariable = new VariableInfo (address_reader); - Parameters = new VariableInfo [NumParameters]; + if (LocalVariableTableOffset != 0) { + long old_pos = reader.Position; + reader.Position = LocalVariableTableOffset; + + Locals = new LocalVariableEntry [NumLocals]; + + for (int i = 0; i < NumLocals; i++) + Locals [i] = new LocalVariableEntry (reader); + + reader.Position = old_pos; + } + + if (TypeIndexTableOffset != 0) { + long old_pos = reader.Position; + reader.Position = TypeIndexTableOffset; + + ParamTypeIndices = new int [NumParameters]; + LocalTypeIndices = new int [NumLocals]; + for (int i = 0; i < NumParameters; i++) - Parameters [i] = new VariableInfo (address_reader); - Locals = new VariableInfo [NumLocals]; + ParamTypeIndices [i] = reader.ReadInt32 (); for (int i = 0; i < NumLocals; i++) - Locals [i] = new VariableInfo (address_reader); - address_reader.Position = old_pos; + LocalTypeIndices [i] = reader.ReadInt32 (); + + reader.Position = old_pos; } } internal MethodEntry (int token, int sf_offset, string source_file, - bool has_this, int num_params, int num_locals, + int this_type_index, int[] param_type_indices, + int[] local_type_indices, LocalVariableEntry[] locals, LineNumberEntry[] lines, int lnt_offset, - int addrtab_offset, int vartab_offset, int addrtab_size, int start_row, int end_row) { this.Token = token; this.StartRow = start_row; this.EndRow = end_row; this.NumLineNumbers = lines.Length; - this.HasThis = has_this ? 1 : 0; - this.NumParameters = num_params; - this.NumLocals = num_locals; + this.ThisTypeIndex = this_type_index; + this.NumParameters = param_type_indices.Length; + this.NumLocals = local_type_indices.Length; + this.ParamTypeIndices = param_type_indices; + this.LocalTypeIndices = local_type_indices; + this.Locals = locals; this.SourceFileOffset = sf_offset; this.LineNumberTableOffset = lnt_offset; - this.AddressTableOffset = addrtab_offset; - this.VariableTableOffset = vartab_offset; - this.AddressTableSize = addrtab_size; this.SourceFile = source_file; this.LineNumbers = lines; } @@ -277,23 +399,21 @@ namespace Mono.CSharp.Debugger bw.Write (Token); bw.Write (StartRow); bw.Write (EndRow); - bw.Write (HasThis); + bw.Write (ThisTypeIndex); bw.Write (NumParameters); bw.Write (NumLocals); bw.Write (NumLineNumbers); + bw.Write (TypeIndexTableOffset); + bw.Write (LocalVariableTableOffset); bw.Write (SourceFileOffset); bw.Write (LineNumberTableOffset); - bw.Write (AddressTableOffset); - bw.Write (VariableTableOffset); - bw.Write (AddressTableSize); } public override string ToString () { - return String.Format ("[Method {0}:{1}:{2}:{3}:{4} - {5}:{6}:{7}:{8}]", - Token, SourceFile, StartRow, EndRow, NumLineNumbers, - SourceFileOffset, LineNumberTableOffset, AddressTableOffset, - AddressTableSize); + return String.Format ("[Method {0}:{1}:{2}:{3}:{4} - {5}:{6}]", + Token, SourceFile, StartRow, EndRow, + NumLineNumbers, SourceFileOffset, LineNumberTableOffset); } } }