{
#region This is actually written to the symbol file
public readonly int Row;
+ public int Column;
+ public int EndRow, EndColumn;
public readonly int File;
public readonly int Offset;
public readonly bool IsHidden; // Obsolete is never used
public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
return l1.Row == l2.Row ?
- l1.Offset.CompareTo (l2.Offset) :
+ l1.Column.CompareTo (l2.Column) :
l1.Row.CompareTo (l2.Row);
}
}
- public static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
+ public static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0, 0);
+
+ public LineNumberEntry (int file, int row, int column, int offset)
+ : this (file, row, column, offset, false)
+ {
+ }
public LineNumberEntry (int file, int row, int offset)
- : this (file, row, offset, false)
- { }
+ : this (file, row, -1, offset, false)
+ {
+ }
- public LineNumberEntry (int file, int row, int offset, bool is_hidden)
+ public LineNumberEntry (int file, int row, int column, int offset, bool is_hidden)
+ : this (file, row, column, -1, -1, offset, is_hidden)
+ {
+ }
+
+ public LineNumberEntry (int file, int row, int column, int end_row, int end_column, int offset, bool is_hidden)
{
this.File = file;
this.Row = row;
+ this.Column = column;
+ this.EndRow = end_row;
+ this.EndColumn = end_column;
this.Offset = offset;
this.IsHidden = is_hidden;
}
public override string ToString ()
{
- return String.Format ("[Line {0}:{1}:{2}]", File, Row, Offset);
+ return String.Format ("[Line {0}:{1,2}-{3,4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset);
}
}
DataOffset = reader.ReadInt32 ();
}
+ public void ReadAll ()
+ {
+ ReadData ();
+ }
+
void ReadData ()
{
if (creating)
byte[] hash;
bool creating;
bool auto_generated;
+ readonly string sourceFile;
public static int Size {
get { return 8; }
creating = true;
}
- public SourceFileEntry (MonoSymbolFile file, string file_name,
- byte[] guid, byte[] checksum)
- : this (file, file_name)
+ public SourceFileEntry (MonoSymbolFile file, string sourceFile, byte [] guid, byte [] checksum)
+ : this (file, sourceFile, sourceFile, guid, checksum)
+ {
+ }
+
+ public SourceFileEntry (MonoSymbolFile file, string fileName, string sourceFile, byte[] guid, byte[] checksum)
+ : this (file, fileName)
{
this.guid = guid;
this.hash = checksum;
+ this.sourceFile = sourceFile;
}
public byte[] Checksum {
DataOffset = (int) bw.BaseStream.Position;
bw.Write (file_name);
- if (guid == null) {
- guid = Guid.NewGuid ().ToByteArray ();
+ if (guid == null)
+ guid = new byte[16];
+
+ if (hash == null) {
try {
- using (FileStream fs = new FileStream (file_name, FileMode.Open, FileAccess.Read)) {
- MD5 md5 = MD5.Create ();
- hash = md5.ComputeHash (fs);
- }
+ using (FileStream fs = new FileStream (sourceFile, FileMode.Open, FileAccess.Read)) {
+ MD5 md5 = MD5.Create ();
+ hash = md5.ComputeHash (fs);
+ }
} catch {
hash = new byte [16];
}
int old_pos = (int) reader.BaseStream.Position;
reader.BaseStream.Position = DataOffset;
- file_name = reader.ReadString ();
+ sourceFile = file_name = reader.ReadString ();
guid = reader.ReadBytes (16);
hash = reader.ReadBytes (16);
auto_generated = reader.ReadByte () == 1;
public string FileName {
get { return file_name; }
+ set { file_name = value; }
}
public bool AutoGenerated {
public bool CheckChecksum ()
{
try {
- using (FileStream fs = new FileStream (file_name, FileMode.Open)) {
+ using (FileStream fs = new FileStream (sourceFile, FileMode.Open)) {
MD5 md5 = MD5.Create ();
byte[] data = md5.ComputeHash (fs);
for (int i = 0; i < 16; i++)
public const int Default_LineRange = 8;
public const byte Default_OpcodeBase = 9;
- public const bool SuppressDuplicates = true;
#endregion
public const byte DW_LNS_copy = 1;
this._line_numbers = lines;
}
- internal void Write (MonoSymbolFile file, MyBinaryWriter bw)
+ internal void Write (MonoSymbolFile file, MyBinaryWriter bw, bool hasColumnsInfo, bool hasEndInfo)
{
int start = (int) bw.BaseStream.Position;
int line_inc = LineNumbers [i].Row - last_line;
int offset_inc = LineNumbers [i].Offset - last_offset;
- if (SuppressDuplicates && (i+1 < LineNumbers.Length)) {
- if (LineNumbers [i+1].Equals (LineNumbers [i]))
- continue;
- }
-
if (LineNumbers [i].File != last_file) {
bw.Write (DW_LNS_set_file);
bw.WriteLeb128 (LineNumbers [i].File);
bw.Write ((byte) 1);
bw.Write (DW_LNE_end_sequence);
+ if (hasColumnsInfo) {
+ for (int i = 0; i < LineNumbers.Length; i++) {
+ var ln = LineNumbers [i];
+ if (ln.Row >= 0)
+ bw.WriteLeb128 (ln.Column);
+ }
+ }
+
+ if (hasEndInfo) {
+ for (int i = 0; i < LineNumbers.Length; i++) {
+ var ln = LineNumbers [i];
+ if (ln.EndRow == -1 || ln.EndColumn == -1 || ln.Row > ln.EndRow) {
+ bw.WriteLeb128 (0xffffff);
+ } else {
+ bw.WriteLeb128 (ln.EndRow - ln.Row);
+ bw.WriteLeb128 (ln.EndColumn);
+ }
+ }
+ }
+
file.ExtendedLineNumberSize += (int) bw.BaseStream.Position - start;
}
- internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br)
+ internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br, bool readColumnsInfo, bool readEndInfo)
{
LineNumberTable lnt = new LineNumberTable (file);
- lnt.DoRead (file, br);
+ lnt.DoRead (file, br, readColumnsInfo, readEndInfo);
return lnt;
}
- void DoRead (MonoSymbolFile file, MyBinaryReader br)
+ void DoRead (MonoSymbolFile file, MyBinaryReader br, bool includesColumns, bool includesEnds)
{
var lines = new List<LineNumberEntry> ();
if (opcode == DW_LNE_end_sequence) {
if (modified)
lines.Add (new LineNumberEntry (
- stm_file, stm_line, stm_offset, is_hidden));
+ stm_file, stm_line, -1, stm_offset, is_hidden));
break;
} else if (opcode == DW_LNE_MONO_negate_is_hidden) {
is_hidden = !is_hidden;
switch (opcode) {
case DW_LNS_copy:
lines.Add (new LineNumberEntry (
- stm_file, stm_line, stm_offset, is_hidden));
+ stm_file, stm_line, -1, stm_offset, is_hidden));
modified = false;
break;
case DW_LNS_advance_pc:
stm_offset += opcode / LineRange;
stm_line += LineBase + (opcode % LineRange);
lines.Add (new LineNumberEntry (
- stm_file, stm_line, stm_offset, is_hidden));
+ stm_file, stm_line, -1, stm_offset, is_hidden));
modified = false;
}
}
- _line_numbers = new LineNumberEntry [lines.Count];
- lines.CopyTo (_line_numbers, 0);
+ _line_numbers = lines.ToArray ();
+
+ if (includesColumns) {
+ for (int i = 0; i < _line_numbers.Length; ++i) {
+ var ln = _line_numbers[i];
+ if (ln.Row >= 0)
+ ln.Column = br.ReadLeb128 ();
+ }
+ }
+ if (includesEnds) {
+ for (int i = 0; i < _line_numbers.Length; ++i) {
+ var ln = _line_numbers[i];
+
+ int row = br.ReadLeb128 ();
+ if (row == 0xffffff) {
+ ln.EndRow = -1;
+ ln.EndColumn = -1;
+ } else {
+ ln.EndRow = ln.Row + row;
+ ln.EndColumn = br.ReadLeb128 ();
+ }
+ }
+ }
}
public bool GetMethodBounds (out LineNumberEntry start, out LineNumberEntry end)
[Flags]
public enum Flags
{
- LocalNamesAmbiguous = 1
+ LocalNamesAmbiguous = 1,
+ ColumnsInfoIncluded = 1 << 1,
+ EndInfoIncluded = 1 << 2
}
public const int Size = 12;
bw.Write (real_name);
}
+ foreach (var lne in lnt.LineNumbers) {
+ if (lne.EndRow != -1 || lne.EndColumn != -1)
+ flags |= Flags.EndInfoIncluded;
+ }
+
LineNumberTableOffset = (int) bw.BaseStream.Position;
- lnt.Write (file, bw);
+ lnt.Write (file, bw, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
DataOffset = (int) bw.BaseStream.Position;
bw.WriteLeb128 ((int) flags);
}
+ public void ReadAll ()
+ {
+ GetLineNumberTable ();
+ GetLocals ();
+ GetCodeBlocks ();
+ GetScopeVariables ();
+ GetRealName ();
+ }
+
public LineNumberTable GetLineNumberTable ()
{
lock (SymbolFile) {
long old_pos = reader.BaseStream.Position;
reader.BaseStream.Position = LineNumberTableOffset;
- lnt = LineNumberTable.Read (SymbolFile, reader);
+ lnt = LineNumberTable.Read (SymbolFile, reader, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
reader.BaseStream.Position = old_pos;
return lnt;