#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 static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0, 0);
public LineNumberEntry (int file, int row, int column, int offset)
- : this (file, row, offset, column, false)
+ : this (file, row, column, offset, false)
{
}
}
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}:{3}]", File, Row, Column, Offset);
+ return String.Format ("[Line {0}:{1,2}-{3,4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset);
}
}
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 {
if (hash == null) {
try {
- using (FileStream fs = new FileStream (file_name, FileMode.Open, FileAccess.Read)) {
+ using (FileStream fs = new FileStream (sourceFile, FileMode.Open, FileAccess.Read)) {
MD5 md5 = MD5.Create ();
hash = md5.ComputeHash (fs);
}
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 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++)
this._line_numbers = lines;
}
- internal void Write (MonoSymbolFile file, MyBinaryWriter bw, bool readColumnsInfo)
+ internal void Write (MonoSymbolFile file, MyBinaryWriter bw, bool hasColumnsInfo, bool hasEndInfo)
{
int start = (int) bw.BaseStream.Position;
bw.Write ((byte) 1);
bw.Write (DW_LNE_end_sequence);
- for (int i = 0; i < LineNumbers.Length; i++) {
- var ln = LineNumbers [i];
- if (ln.Row >= 0)
- bw.WriteLeb128 (ln.Column);
+ 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, bool readColumnsInfo)
+ internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br, bool readColumnsInfo, bool readEndInfo)
{
LineNumberTable lnt = new LineNumberTable (file);
- lnt.DoRead (file, br, readColumnsInfo);
+ lnt.DoRead (file, br, readColumnsInfo, readEndInfo);
return lnt;
}
- void DoRead (MonoSymbolFile file, MyBinaryReader br, bool includesColumns)
+ void DoRead (MonoSymbolFile file, MyBinaryReader br, bool includesColumns, bool includesEnds)
{
var lines = new List<LineNumberEntry> ();
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)
public enum Flags
{
LocalNamesAmbiguous = 1,
- ColumnsInfoIncluded = 1 << 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, (flags & Flags.ColumnsInfoIncluded) != 0);
+ lnt.Write (file, bw, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
DataOffset = (int) bw.BaseStream.Position;
long old_pos = reader.BaseStream.Position;
reader.BaseStream.Position = LineNumberTableOffset;
- lnt = LineNumberTable.Read (SymbolFile, reader, (flags & Flags.ColumnsInfoIncluded) != 0);
+ lnt = LineNumberTable.Read (SymbolFile, reader, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0);
reader.BaseStream.Position = old_pos;
return lnt;