Exemplo n.º 1
0
 //internal void WriteData(MyBinaryWriter bw)
 //{
 //    this.DataOffset = (int)bw.BaseStream.Position;
 //    bw.Write(this.file_name);
 //    if (this.guid == null)
 //    {
 //        this.guid = Guid.NewGuid().ToByteArray();
 //        try
 //        {
 //            using (FileStream fs = new FileStream(this.file_name, FileMode.Open, FileAccess.Read))
 //            {
 //                MD5 md5 = MD5.Create();
 //                this.hash = md5.ComputeHash(fs);
 //            }
 //        }
 //        catch
 //        {
 //            this.hash = new byte[16];
 //        }
 //    }
 //    bw.Write(this.guid);
 //    bw.Write(this.hash);
 //    bw.Write(this.auto_generated ? 1 : 0);
 //}
 //internal void Write(BinaryWriter bw)
 //{
 //    bw.Write(this.Index);
 //    bw.Write(this.DataOffset);
 //}
 internal SourceFileEntry(MonoSymbolFile file, MyBinaryReader reader)
 {
     this.file = file;
     this.Index = reader.ReadInt32();
     this.DataOffset = reader.ReadInt32();
     int old_pos = (int)reader.BaseStream.Position;
     reader.BaseStream.Position = (long)this.DataOffset;
     this.file_name = reader.ReadString();
     //??this.guid = reader.ReadBytes(16);
     this.hash = reader.ReadBytes(16);
     this.auto_generated = (reader.ReadByte() == 1);
     reader.BaseStream.Position = (long)old_pos;
 }
Exemplo n.º 2
0
        //internal void WriteData(MyBinaryWriter bw)
        //{
        //    this.DataOffset = (int)bw.BaseStream.Position;
        //    bw.Write(this.file_name);
        //    if (this.guid == null)
        //    {
        //        this.guid = Guid.NewGuid().ToByteArray();
        //        try
        //        {
        //            using (FileStream fs = new FileStream(this.file_name, FileMode.Open, FileAccess.Read))
        //            {
        //                MD5 md5 = MD5.Create();
        //                this.hash = md5.ComputeHash(fs);
        //            }
        //        }
        //        catch
        //        {
        //            this.hash = new byte[16];
        //        }
        //    }
        //    bw.Write(this.guid);
        //    bw.Write(this.hash);
        //    bw.Write(this.auto_generated ? 1 : 0);
        //}
        //internal void Write(BinaryWriter bw)
        //{
        //    bw.Write(this.Index);
        //    bw.Write(this.DataOffset);
        //}
        internal SourceFileEntry(MonoSymbolFile file, MyBinaryReader reader)
        {
            this.file       = file;
            this.Index      = reader.ReadInt32();
            this.DataOffset = reader.ReadInt32();
            int old_pos = (int)reader.BaseStream.Position;

            reader.BaseStream.Position = (long)this.DataOffset;
            this.file_name             = reader.ReadString();
            this.guid                  = reader.ReadBytes(16);
            this.hash                  = reader.ReadBytes(16);
            this.auto_generated        = (reader.ReadByte() == 1);
            reader.BaseStream.Position = (long)old_pos;
        }
Exemplo n.º 3
0
        internal SourceFileEntry(MonoSymbolFile file, MyBinaryReader reader)
        {
            this.file = file;

            Index      = reader.ReadInt32();
            DataOffset = reader.ReadInt32();

            int old_pos = (int)reader.BaseStream.Position;

            reader.BaseStream.Position = DataOffset;

            file_name      = reader.ReadString();
            guid           = reader.ReadBytes(16);
            hash           = reader.ReadBytes(16);
            auto_generated = reader.ReadByte() == 1;

            reader.BaseStream.Position = old_pos;
        }
Exemplo n.º 4
0
 internal CapturedVariable(MyBinaryReader reader)
 {
     Name         = reader.ReadString();
     CapturedName = reader.ReadString();
     Kind         = (CapturedKind)reader.ReadByte();
 }
Exemplo n.º 5
0
        void DoRead(MonoSymbolFile file, MyBinaryReader br, bool includesColumns, bool includesEnds)
        {
            var lines = new List <LineNumberEntry> ();

            bool is_hidden = false, modified = false;
            int  stm_line = 1, stm_offset = 0, stm_file = 1;

            while (true)
            {
                byte opcode = br.ReadByte();

                if (opcode == 0)
                {
                    byte size    = br.ReadByte();
                    long end_pos = br.BaseStream.Position + size;
                    opcode = br.ReadByte();

                    if (opcode == DW_LNE_end_sequence)
                    {
                        if (modified)
                        {
                            lines.Add(new LineNumberEntry(
                                          stm_file, stm_line, -1, stm_offset, is_hidden));
                        }
                        break;
                    }
                    else if (opcode == DW_LNE_MONO_negate_is_hidden)
                    {
                        is_hidden = !is_hidden;
                        modified  = true;
                    }
                    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}", opcode);
                    }

                    br.BaseStream.Position = end_pos;
                    continue;
                }
                else if (opcode < OpcodeBase)
                {
                    switch (opcode)
                    {
                    case DW_LNS_copy:
                        lines.Add(new LineNumberEntry(
                                      stm_file, stm_line, -1, stm_offset, is_hidden));
                        modified = false;
                        break;

                    case DW_LNS_advance_pc:
                        stm_offset += br.ReadLeb128();
                        modified    = true;
                        break;

                    case DW_LNS_advance_line:
                        stm_line += br.ReadLeb128();
                        modified  = true;
                        break;

                    case DW_LNS_set_file:
                        stm_file = br.ReadLeb128();
                        modified = true;
                        break;

                    case DW_LNS_const_add_pc:
                        stm_offset += MaxAddressIncrement;
                        modified    = true;
                        break;

                    default:
                        throw new MonoSymbolFileException(
                                  "Unknown standard opcode {0:x} in LNT",
                                  opcode);
                    }
                }
                else
                {
                    opcode -= OpcodeBase;

                    stm_offset += opcode / LineRange;
                    stm_line   += LineBase + (opcode % LineRange);
                    lines.Add(new LineNumberEntry(
                                  stm_file, stm_line, -1, stm_offset, is_hidden));
                    modified = false;
                }
            }

            _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();
                    }
                }
            }
        }
Exemplo n.º 6
0
        void DoRead(MonoSymbolFile file, MyBinaryReader br)
        {
            var lines = new List <LineNumberEntry> ();

            bool is_hidden = false, modified = false;
            int  stm_line = 1, stm_offset = 0, stm_file = 1;

            while (true)
            {
                byte opcode = br.ReadByte();

                if (opcode == 0)
                {
                    byte size    = br.ReadByte();
                    long end_pos = br.BaseStream.Position + size;
                    opcode = br.ReadByte();

                    if (opcode == DW_LNE_end_sequence)
                    {
                        if (modified)
                        {
                            lines.Add(new LineNumberEntry(
                                          stm_file, stm_line, stm_offset, is_hidden));
                        }
                        break;
                    }
                    else if (opcode == DW_LNE_MONO_negate_is_hidden)
                    {
                        is_hidden = !is_hidden;
                        modified  = true;
                    }
                    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}", opcode);
                    }

                    br.BaseStream.Position = end_pos;
                    continue;
                }
                else if (opcode < OpcodeBase)
                {
                    switch (opcode)
                    {
                    case DW_LNS_copy:
                        lines.Add(new LineNumberEntry(
                                      stm_file, stm_line, stm_offset, is_hidden));
                        modified = false;
                        break;

                    case DW_LNS_advance_pc:
                        stm_offset += br.ReadLeb128();
                        modified    = true;
                        break;

                    case DW_LNS_advance_line:
                        stm_line += br.ReadLeb128();
                        modified  = true;
                        break;

                    case DW_LNS_set_file:
                        stm_file = br.ReadLeb128();
                        modified = true;
                        break;

                    case DW_LNS_const_add_pc:
                        stm_offset += MaxAddressIncrement;
                        modified    = true;
                        break;

                    default:
                        throw new MonoSymbolFileException(
                                  "Unknown standard opcode {0:x} in LNT",
                                  opcode);
                    }
                }
                else
                {
                    opcode -= OpcodeBase;

                    stm_offset += opcode / LineRange;
                    stm_line   += LineBase + (opcode % LineRange);
                    lines.Add(new LineNumberEntry(
                                  stm_file, stm_line, stm_offset, is_hidden));
                    modified = false;
                }
            }

            _line_numbers = new LineNumberEntry [lines.Count];
            lines.CopyTo(_line_numbers, 0);
        }
Exemplo n.º 7
0
        private void DoRead(MonoSymbolFile file, MyBinaryReader br)
        {
            List <LineNumberEntry> lines = new List <LineNumberEntry>();
            bool is_hidden  = false;
            bool modified   = false;
            int  stm_line   = 1;
            int  stm_offset = 0;
            int  stm_file   = 1;
            byte opcode;

            while (true)
            {
                opcode = br.ReadByte();
                if (opcode == 0)
                {
                    byte size    = br.ReadByte();
                    long end_pos = br.BaseStream.Position + (long)((ulong)size);
                    opcode = br.ReadByte();
                    if (opcode == 1)
                    {
                        break;
                    }
                    if (opcode == 64)
                    {
                        is_hidden = !is_hidden;
                        modified  = true;
                    }
                    else
                    {
                        if (opcode < 64 || opcode > 127)
                        {
                            goto IL_B8;
                        }
                    }
                    br.BaseStream.Position = end_pos;
                }
                else
                {
                    if (opcode < this.OpcodeBase)
                    {
                        switch (opcode)
                        {
                        case 1:
                            lines.Add(new LineNumberEntry(stm_file, stm_line, stm_offset, is_hidden));
                            modified = false;
                            continue;

                        case 2:
                            stm_offset += br.ReadLeb128();
                            modified    = true;
                            continue;

                        case 3:
                            stm_line += br.ReadLeb128();
                            modified  = true;
                            continue;

                        case 4:
                            stm_file = br.ReadLeb128();
                            modified = true;
                            continue;

                        case 8:
                            stm_offset += this.MaxAddressIncrement;
                            modified    = true;
                            continue;
                        }
                        goto Block_8;
                    }
                    opcode     -= this.OpcodeBase;
                    stm_offset += (int)opcode / this.LineRange;
                    stm_line   += this.LineBase + (int)opcode % this.LineRange;
                    lines.Add(new LineNumberEntry(stm_file, stm_line, stm_offset, is_hidden));
                    modified = false;
                }
            }
            if (modified)
            {
                lines.Add(new LineNumberEntry(stm_file, stm_line, stm_offset, is_hidden));
            }
            this._line_numbers = new LineNumberEntry[lines.Count];
            lines.CopyTo(this._line_numbers, 0);
            return;

IL_B8:
            throw new MonoSymbolFileException("Unknown extended opcode {0:x} in LNT ({1})", new object[]
            {
                opcode,
                file.FileName
            });
Block_8:
            throw new MonoSymbolFileException("Unknown standard opcode {0:x} in LNT", new object[]
            {
                opcode
            });
        }
 internal CapturedVariable(MyBinaryReader reader)
 {
     this.Name         = reader.ReadString();
     this.CapturedName = reader.ReadString();
     this.Kind         = (CapturedVariable.CapturedKind)reader.ReadByte();
 }
		void DoRead (MonoSymbolFile file, MyBinaryReader br)
		{
			ArrayList lines = new ArrayList ();

			bool is_hidden = false, modified = false;
			int stm_line = 1, stm_offset = 0, stm_file = 1;
			while (true) {
				byte opcode = br.ReadByte ();

				if (opcode == 0) {
					byte size = br.ReadByte ();
					long end_pos = br.BaseStream.Position + size;
					opcode = br.ReadByte ();

					if (opcode == DW_LNE_end_sequence) {
						if (modified)
							lines.Add (new LineNumberEntry (
								stm_file, stm_line, stm_offset, is_hidden));
						break;
					} else if (opcode == DW_LNE_MONO_negate_is_hidden) {
						is_hidden = !is_hidden;
						modified = true;
					} else
						throw new MonoSymbolFileException (
							"Unknown extended opcode {0:x} in LNT ({1})",
							opcode, file.FileName);

					br.BaseStream.Position = end_pos;
					continue;
				} else if (opcode < OpcodeBase) {
					switch (opcode) {
					case DW_LNS_copy:
						lines.Add (new LineNumberEntry (
							stm_file, stm_line, stm_offset, is_hidden));
						modified = false;
						break;
					case DW_LNS_advance_pc:
						stm_offset += br.ReadLeb128 ();
						modified = true;
						break;
					case DW_LNS_advance_line:
						stm_line += br.ReadLeb128 ();
						modified = true;
						break;
					case DW_LNS_set_file:
						stm_file = br.ReadLeb128 ();
						modified = true;
						break;
					case DW_LNS_const_add_pc:
						stm_offset += MaxAddressIncrement;
						modified = true;
						break;
					default:
						throw new MonoSymbolFileException (
							"Unknown standard opcode {0:x} in LNT",
							opcode);
					}
				} else {
					opcode -= OpcodeBase;

					stm_offset += opcode / LineRange;
					stm_line += LineBase + (opcode % LineRange);
					lines.Add (new LineNumberEntry (
						stm_file, stm_line, stm_offset, is_hidden));
					modified = false;
				}
			}

			_line_numbers = new LineNumberEntry [lines.Count];
			lines.CopyTo (_line_numbers, 0);
		}
		internal SourceFileEntry (MonoSymbolFile file, MyBinaryReader reader)
		{
			this.file = file;

			Index = reader.ReadInt32 ();
			DataOffset = reader.ReadInt32 ();

			int old_pos = (int) reader.BaseStream.Position;
			reader.BaseStream.Position = DataOffset;

			file_name = reader.ReadString ();
			guid = reader.ReadBytes (16);
			hash = reader.ReadBytes (16);
			auto_generated = reader.ReadByte () == 1;

			reader.BaseStream.Position = old_pos;
		}
		internal CapturedVariable (MyBinaryReader reader)
		{
			Name = reader.ReadString ();
			CapturedName = reader.ReadString ();
			Kind = (CapturedKind) reader.ReadByte ();
		}
Exemplo n.º 12
0
		private void DoRead(MonoSymbolFile file, MyBinaryReader br)
		{
			List<LineNumberEntry> lines = new List<LineNumberEntry>();
			bool is_hidden = false;
			bool modified = false;
			int stm_line = 1;
			int stm_offset = 0;
			int stm_file = 1;
			byte opcode;
			while (true)
			{
				opcode = br.ReadByte();
				if (opcode == 0)
				{
					byte size = br.ReadByte();
					long end_pos = br.BaseStream.Position + (long)((ulong)size);
					opcode = br.ReadByte();
					if (opcode == 1)
					{
						break;
					}
					if (opcode == 64)
					{
						is_hidden = !is_hidden;
						modified = true;
					}
					else
					{
						if (opcode < 64 || opcode > 127)
						{
							goto IL_B8;
						}
					}
					br.BaseStream.Position = end_pos;
				}
				else
				{
					if (opcode < this.OpcodeBase)
					{
						switch (opcode)
						{
						case 1:
							lines.Add(new LineNumberEntry(stm_file, stm_line, stm_offset, is_hidden));
							modified = false;
							continue;
						case 2:
							stm_offset += br.ReadLeb128();
							modified = true;
							continue;
						case 3:
							stm_line += br.ReadLeb128();
							modified = true;
							continue;
						case 4:
							stm_file = br.ReadLeb128();
							modified = true;
							continue;
						case 8:
							stm_offset += this.MaxAddressIncrement;
							modified = true;
							continue;
						}
						goto Block_8;
					}
					opcode -= this.OpcodeBase;
					stm_offset += (int)opcode / this.LineRange;
					stm_line += this.LineBase + (int)opcode % this.LineRange;
					lines.Add(new LineNumberEntry(stm_file, stm_line, stm_offset, is_hidden));
					modified = false;
				}
			}
			if (modified)
			{
				lines.Add(new LineNumberEntry(stm_file, stm_line, stm_offset, is_hidden));
			}
			this._line_numbers = new LineNumberEntry[lines.Count];
			lines.CopyTo(this._line_numbers, 0);
			return;
			IL_B8:
			throw new MonoSymbolFileException("Unknown extended opcode {0:x} in LNT ({1})", new object[]
			{
				opcode,
				file.FileName
			});
			Block_8:
			throw new MonoSymbolFileException("Unknown standard opcode {0:x} in LNT", new object[]
			{
				opcode
			});
		}
Exemplo n.º 13
0
        void DoRead(MonoSymbolFile file, MyBinaryReader br)
        {
            ArrayList lines = new ArrayList ();

            bool is_hidden = false, modified = false;
            int stm_line = 1, stm_offset = 0, stm_file = 1;
            #if DEBUGGER_SOURCE
            SourceRangeEntry source_range = null;
            #endif
            while (true) {
                byte opcode = br.ReadByte ();

                if (opcode == 0) {
                    byte size = br.ReadByte ();
                    long end_pos = br.BaseStream.Position + size;
                    opcode = br.ReadByte ();

                    if (opcode == DW_LNE_end_sequence) {
                        if (modified)
            #if DEBUGGER_SOURCE
                            lines.Add (new LineNumberEntry (
                                stm_file, stm_line, stm_offset, is_hidden, source_range));
            #else
                            lines.Add (new LineNumberEntry (
                                stm_file, stm_line, stm_offset, is_hidden));
            #endif
                        break;
                    } else if (opcode == DW_LNE_MONO_negate_is_hidden) {
                        is_hidden = !is_hidden;
                        modified = true;
            #if DEBUGGER_SOURCE
                    } else if (opcode == DW_LNE_MONO_set_source_range) {
                        int start_line = stm_line + br.ReadLeb128 ();
                        int end_line = start_line + br.ReadLeb128 ();
                        int start_col = br.ReadLeb128 ();
                        int end_col = br.ReadLeb128 ();

                        source_range = new SourceRangeEntry (
                            start_line, end_line, start_col, end_col);
            #endif
                    } 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;
                } else if (opcode < OpcodeBase) {
                    switch (opcode) {
                    case DW_LNS_copy:
            #if DEBUGGER_SOURCE
                        lines.Add (new LineNumberEntry (
                            stm_file, stm_line, stm_offset, is_hidden, source_range));
                        source_range = null;
            #else
                        lines.Add (new LineNumberEntry (
                            stm_file, stm_line, stm_offset, is_hidden));
            #endif
                        modified = false;
                        break;
                    case DW_LNS_advance_pc:
                        stm_offset += br.ReadLeb128 ();
                        modified = true;
                        break;
                    case DW_LNS_advance_line:
                        stm_line += br.ReadLeb128 ();
                        modified = true;
                        break;
                    case DW_LNS_set_file:
                        stm_file = br.ReadLeb128 ();
                        modified = true;
                        break;
                    case DW_LNS_const_add_pc:
                        stm_offset += MaxAddressIncrement;
                        modified = true;
                        break;
                    default:
                        throw new MonoSymbolFileException (
                            "Unknown standard opcode {0:x} in LNT",
                            opcode);
                    }
                } else {
                    opcode -= OpcodeBase;

                    stm_offset += opcode / LineRange;
                    stm_line += LineBase + (opcode % LineRange);
            #if DEBUGGER_SOURCE
                    lines.Add (new LineNumberEntry (
                        stm_file, stm_line, stm_offset, is_hidden, source_range));
                    source_range = null;
            #else
                    lines.Add (new LineNumberEntry (
                        stm_file, stm_line, stm_offset, is_hidden));
            #endif
                    modified = false;
                }
            }

            _line_numbers = new LineNumberEntry [lines.Count];
            lines.CopyTo (_line_numbers, 0);
        }
Exemplo n.º 14
0
		internal CapturedVariable(MyBinaryReader reader)
		{
			this.Name = reader.ReadString();
			this.CapturedName = reader.ReadString();
			this.Kind = (CapturedVariable.CapturedKind)reader.ReadByte();
		}