using System;
using System.Security.Cryptography;
-using System.Collections;
+using System.Collections.Generic;
using System.Text;
using System.IO;
{
public class OffsetTable
{
- public const int MajorVersion = 42;
- public const int MinorVersion = 6;
+ public const int MajorVersion = 50;
+ public const int MinorVersion = 0;
public const long Magic = 0x45e82623fd7fa614;
#region This is actually written to the symbol file
public int AnonymousScopeTableOffset;
public int AnonymousScopeTableSize;
- public bool IsAspxSource;
+ [Flags]
+ public enum Flags
+ {
+ IsAspxSource = 1,
+ WindowsFileNames = 2
+ }
+
+ public Flags FileFlags;
public int LineNumberTable_LineBase = LineNumberTable.Default_LineBase;
public int LineNumberTable_LineRange = LineNumberTable.Default_LineRange;
#endregion
internal OffsetTable ()
- { }
+ {
+ int platform = (int) Environment.OSVersion.Platform;
+ if ((platform != 4) && (platform != 128))
+ FileFlags |= Flags.WindowsFileNames;
+ }
internal OffsetTable (BinaryReader reader, int major_version, int minor_version)
{
LineNumberTable_LineRange = reader.ReadInt32 ();
LineNumberTable_OpcodeBase = reader.ReadInt32 ();
- IsAspxSource = reader.ReadInt32 () != 0;
+ FileFlags = (Flags) reader.ReadInt32 ();
}
internal void Write (BinaryWriter bw, int major_version, int minor_version)
bw.Write (LineNumberTable_LineRange);
bw.Write (LineNumberTable_OpcodeBase);
- bw.Write ((int) (IsAspxSource ? 1 : 0));
+ bw.Write ((int) FileFlags);
}
public override string ToString ()
}
}
- public struct LineNumberEntry
+ public class LineNumberEntry
{
#region This is actually written to the symbol file
public readonly int Row;
public static LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
- private class OffsetComparerClass : IComparer
+ private class OffsetComparerClass : IComparer<LineNumberEntry>
{
- public int Compare (object a, object b)
+ public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
- LineNumberEntry l1 = (LineNumberEntry) a;
- LineNumberEntry l2 = (LineNumberEntry) b;
-
if (l1.Offset < l2.Offset)
return -1;
else if (l1.Offset > l2.Offset)
}
}
- private class RowComparerClass : IComparer
+ private class RowComparerClass : IComparer<LineNumberEntry>
{
- public int Compare (object a, object b)
+ public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
- LineNumberEntry l1 = (LineNumberEntry) a;
- LineNumberEntry l2 = (LineNumberEntry) b;
-
if (l1.Row < l2.Row)
return -1;
else if (l1.Row > l2.Row)
}
}
- public static readonly IComparer OffsetComparer = new OffsetComparerClass ();
- public static readonly IComparer RowComparer = new RowComparerClass ();
+ public static readonly IComparer<LineNumberEntry> OffsetComparer = new OffsetComparerClass ();
+ public static readonly IComparer<LineNumberEntry> RowComparer = new RowComparerClass ();
public override string ToString ()
{
public override string ToString ()
{
return String.Format ("[LocalVariable {0}:{1}:{2}]",
- Name, Index, BlockIndex);
+ Name, Index, BlockIndex - 1);
}
}
public readonly int ID;
#endregion
- ArrayList captured_vars = new ArrayList ();
- ArrayList captured_scopes = new ArrayList ();
+ List<CapturedVariable> captured_vars = new List<CapturedVariable> ();
+ List<CapturedScope> captured_scopes = new List<CapturedScope> ();
public AnonymousScopeEntry (int id)
{
MonoSymbolFile file;
SourceFileEntry source;
- ArrayList include_files;
- ArrayList namespaces;
+ List<SourceFileEntry> include_files;
+ List<NamespaceEntry> namespaces;
bool creating;
this.Index = file.AddCompileUnit (this);
creating = true;
- namespaces = new ArrayList ();
+ namespaces = new List<NamespaceEntry> ();
}
public void AddFile (SourceFileEntry file)
throw new InvalidOperationException ();
if (include_files == null)
- include_files = new ArrayList ();
+ include_files = new List<SourceFileEntry> ();
include_files.Add (file);
}
int count_includes = reader.ReadLeb128 ();
if (count_includes > 0) {
- include_files = new ArrayList ();
- for (int i = 0; i < count_includes; i++) {
- // FIXME: The debugger will need this later on.
- reader.ReadLeb128 ();
- }
+ include_files = new List<SourceFileEntry> ();
+ for (int i = 0; i < count_includes; i++)
+ include_files.Add (file.GetSourceFile (reader.ReadLeb128 ()));
}
int count_ns = reader.ReadLeb128 ();
- namespaces = new ArrayList ();
+ namespaces = new List<NamespaceEntry> ();
for (int i = 0; i < count_ns; i ++)
namespaces.Add (new NamespaceEntry (file, reader));
return retval;
}
}
+
+ public SourceFileEntry[] IncludeFiles {
+ get {
+ ReadData ();
+ if (include_files == null)
+ return new SourceFileEntry [0];
+
+ SourceFileEntry[] retval = new SourceFileEntry [include_files.Count];
+ include_files.CopyTo (retval, 0);
+ return retval;
+ }
+ }
}
public class SourceFileEntry
throw new InvalidOperationException ();
auto_generated = true;
- file.OffsetTable.IsAspxSource = true;
+ file.OffsetTable.FileFlags |= OffsetTable.Flags.IsAspxSource;
}
public bool CheckChecksum ()
// MONO extensions.
public const byte DW_LNE_MONO_negate_is_hidden = 0x40;
+ internal const byte DW_LNE_MONO__extensions_start = 0x40;
+ internal const byte DW_LNE_MONO__extensions_end = 0x7f;
+
protected LineNumberTable (MonoSymbolFile file)
{
this.LineBase = file.OffsetTable.LineNumberTable_LineBase;
void DoRead (MonoSymbolFile file, MyBinaryReader br)
{
- ArrayList lines = new ArrayList ();
+ var lines = new List<LineNumberEntry> ();
bool is_hidden = false, modified = false;
int stm_line = 1, stm_offset = 0, stm_file = 1;
} else if (opcode == DW_LNE_MONO_negate_is_hidden) {
is_hidden = !is_hidden;
modified = true;
- } else
+ } else if ((opcode >= DW_LNE_MONO__extensions_start) &&
+ (opcode <= DW_LNE_MONO__extensions_end)) {
+ ; // reserved for future extensions
+ } else {
throw new MonoSymbolFileException (
"Unknown extended opcode {0:x} in LNT ({1})",
opcode, file.FileName);
+ }
br.BaseStream.Position = end_pos;
continue;
[Flags]
public enum Flags
{
- LocalNamesAmbiguous = 1,
- IsCompilerGenerated = 2
+ LocalNamesAmbiguous = 1
}
public const int Size = 12;
locals_check_done :
;
} else {
- Hashtable local_names = new Hashtable ();
+ var local_names = new Dictionary<string, LocalVariableEntry> ();
foreach (LocalVariableEntry local in locals) {
- if (local_names.Contains (local.Name)) {
+ if (local_names.ContainsKey (local.Name)) {
flags |= Flags.LocalNamesAmbiguous;
break;
}