Beispiel #1
0
        public SourceFileEntry DefineDocument(string url, byte[] guid, byte[] checksum)
        {
            SourceFileEntry entry = new SourceFileEntry(file, url, guid, checksum);

            sources.Add(entry);
            return(entry);
        }
 private void ReadData()
 {
     if (this.creating)
     {
         throw new InvalidOperationException();
     }
     lock (this.file)
     {
         if (this.namespaces == null)
         {
             MyBinaryReader reader  = this.file.BinaryReader;
             int            old_pos = (int)reader.BaseStream.Position;
             reader.BaseStream.Position = (long)this.DataOffset;
             int source_idx = reader.ReadLeb128();
             this.source = this.file.GetSourceFile(source_idx);
             int count_includes = reader.ReadLeb128();
             if (count_includes > 0)
             {
                 this.include_files = new List <SourceFileEntry>();
                 for (int i = 0; i < count_includes; i++)
                 {
                     this.include_files.Add(this.file.GetSourceFile(reader.ReadLeb128()));
                 }
             }
             int count_ns = reader.ReadLeb128();
             this.namespaces = new List <NamespaceEntry>();
             for (int i = 0; i < count_ns; i++)
             {
                 this.namespaces.Add(new NamespaceEntry(this.file, reader));
             }
             reader.BaseStream.Position = (long)old_pos;
         }
     }
 }
Beispiel #3
0
        public int FindSource(string file_name)
        {
            if (reader == null)
            {
                throw new InvalidOperationException();
            }

            lock (this) {
                if (source_name_hash == null)
                {
                    source_name_hash = new Hashtable();

                    for (int i = 0; i < ot.SourceCount; i++)
                    {
                        SourceFileEntry source = GetSourceFile(i + 1);
                        source_name_hash.Add(source.FileName, i);
                    }
                }

                object value = source_name_hash [file_name];
                if (value == null)
                {
                    return(-1);
                }
                return((int)value);
            }
        }
Beispiel #4
0
        public CompileUnitEntry DefineCompilationUnit(SourceFileEntry source)
        {
            CompileUnitEntry entry = new CompileUnitEntry(file, source);

            comp_units.Add(entry);
            return(entry);
        }
Beispiel #5
0
        public SourceFileEntry GetSourceFile(int index)
        {
            if ((index < 1) || (index > ot.SourceCount))
            {
                throw new ArgumentException();
            }
            if (reader == null)
            {
                throw new InvalidOperationException();
            }

            lock (this) {
                SourceFileEntry source = (SourceFileEntry)source_file_hash [index];
                if (source != null)
                {
                    return(source);
                }

                long old_pos = reader.BaseStream.Position;

                reader.BaseStream.Position = ot.SourceTableOffset +
                                             SourceFileEntry.Size * (index - 1);
                source = new SourceFileEntry(this, reader);
                source_file_hash.Add(index, source);

                reader.BaseStream.Position = old_pos;
                return(source);
            }
        }
Beispiel #6
0
        public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden)
        {
            int file_idx = file != null ? file.Index : 0;
            var lne      = new LineNumberEntry(file_idx, line, offset, is_hidden);

            if (method_lines.Count > 0)
            {
                var prev = method_lines[method_lines.Count - 1];

                //
                // Same offset cannot be used for multiple lines
                //
                if (prev.Offset == offset)
                {
                    //
                    // Use the new location because debugger will adjust
                    // the breakpoint to next line with sequence point
                    //
                    if (LineNumberEntry.LocationComparer.Default.Compare(lne, prev) > 0)
                    {
                        method_lines[method_lines.Count - 1] = lne;
                    }

                    return;
                }
            }

            method_lines.Add(lne);
        }
        public int FindSource(string file_name)
        {
            if (reader == null)
            {
                throw new InvalidOperationException();
            }

            lock (this) {
                if (source_name_hash == null)
                {
                    source_name_hash = new Dictionary <string, int> ();

                    for (int i = 0; i < ot.SourceCount; i++)
                    {
                        SourceFileEntry source = GetSourceFile(i + 1);
                        source_name_hash.Add(source.FileName, i);
                    }
                }

                int value;
                if (!source_name_hash.TryGetValue(file_name, out value))
                {
                    return(-1);
                }
                return(value);
            }
        }
Beispiel #8
0
		public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden)
		{
			int file_idx = file != null ? file.Index : 0;
			var lne = new LineNumberEntry (file_idx, line, column, offset, is_hidden);

			if (method_lines.Count > 0) {
				var prev = method_lines[method_lines.Count - 1];

				//
				// Same offset cannot be used for multiple lines
				// 
				if (prev.Offset == offset) {
					//
					// Use the new location because debugger will adjust
					// the breakpoint to next line with sequence point
					//
					if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0)
						method_lines[method_lines.Count - 1] = lne;

					return;
				}
			}

			method_lines.Add (lne);
		}
        public int FindSource(string file_name)
        {
            if (this.reader == null)
            {
                throw new InvalidOperationException();
            }
            int result;

            if (this.source_name_hash == null)
            {
                this.source_name_hash = new Dictionary <string, int>();
                for (int i = 0; i < this.ot.SourceCount; i++)
                {
                    SourceFileEntry source = this.GetSourceFile(i + 1);
                    this.source_name_hash.Add(source.FileName, i);
                }
            }
            int value;

            if (!this.source_name_hash.TryGetValue(file_name, out value))
            {
                result = -1;
            }
            else
            {
                result = value;
            }
            return(result);
        }
        public SourceFileEntry GetSourceFile(int index)
        {
            if (index < 1 || index > this.ot.SourceCount)
            {
                throw new ArgumentException();
            }
            if (this.reader == null)
            {
                throw new InvalidOperationException();
            }
            SourceFileEntry result;

            SourceFileEntry source;

            if (this.source_file_hash.TryGetValue(index, out source))
            {
                result = source;
            }
            else
            {
                long old_pos = this.reader.BaseStream.Position;
                this.reader.BaseStream.Position = (long)(this.ot.SourceTableOffset + SourceFileEntry.Size * (index - 1));
                source = new SourceFileEntry(this, this.reader);
                this.source_file_hash.Add(index, source);
                this.reader.BaseStream.Position = old_pos;
                result = source;
            }

            return(result);
        }
Beispiel #11
0
        public SourceFileEntry DefineDocument(string url)
        {
            SourceFileEntry entry = new SourceFileEntry(file, url);

            sources.Add(entry);
            return(entry);
        }
Beispiel #12
0
		public CompileUnitEntry(MonoSymbolFile file, SourceFileEntry source)
		{
			this.file = file;
			this.source = source;
			this.Index = file.AddCompileUnit(this);
			this.creating = true;
			this.namespaces = new List<NamespaceEntry>();
		}
 public CompileUnitEntry(MonoSymbolFile file, SourceFileEntry source)
 {
     this.file       = file;
     this.source     = source;
     this.Index      = file.AddCompileUnit(this);
     this.creating   = true;
     this.namespaces = new List <NamespaceEntry>();
 }
        public void MarkSequencePoint(int offset, SourceFileEntry file, int start_line, int end_line,
                                      int start_col, int end_col)
        {
            if (current_method == null)
            {
                return;
            }

            current_method.MarkSequencePoint(offset, file, start_line, end_line, start_col, end_col);
        }
Beispiel #15
0
        public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column,
                                      bool is_hidden)
        {
            if (current_method == null)
            {
                return;
            }

            current_method.MarkSequencePoint(offset, file, line, column, is_hidden);
        }
Beispiel #16
0
		public virtual void DefineSymbolInfo (MonoSymbolWriter symwriter)
		{
			if (guid != null)
				file = symwriter.DefineDocument (Path, guid, checksum);
			else {
				file = symwriter.DefineDocument (Path);
				if (AutoGenerated)
					file.SetAutoGenerated ();
			}
		}
Beispiel #17
0
		public void AddFile(SourceFileEntry file)
		{
			if (!this.creating)
			{
				throw new InvalidOperationException();
			}
			if (this.include_files == null)
			{
				this.include_files = new List<SourceFileEntry>();
			}
			this.include_files.Add(file);
		}
        public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden)
        {
            if (this.method_lines_pos == this.method_lines.Length)
            {
                LineNumberEntry[] tmp = this.method_lines;
                this.method_lines = new LineNumberEntry[this.method_lines.Length * 2];
                Array.Copy(tmp, this.method_lines, this.method_lines_pos);
            }
            int file_idx = (file != null) ? file.Index : 0;

            this.method_lines[this.method_lines_pos++] = new LineNumberEntry(file_idx, line, offset, is_hidden);
        }
 public void AddFile(SourceFileEntry file)
 {
     if (!this.creating)
     {
         throw new InvalidOperationException();
     }
     if (this.include_files == null)
     {
         this.include_files = new List <SourceFileEntry>();
     }
     this.include_files.Add(file);
 }
        public ISymUnmanagedDocumentWriter DefineDocument(string url, ref Guid language, ref Guid languageVendor, ref Guid documentType)
        {
            SymbolDocumentWriterImpl doc;

            if (!documents.TryGetValue(url, out doc))
            {
                SourceFileEntry  entry     = msw.DefineDocument(url);
                CompileUnitEntry comp_unit = msw.DefineCompilationUnit(entry);
                doc = new SymbolDocumentWriterImpl(comp_unit);
                documents.Add(url, doc);
            }
            return(doc);
        }
Beispiel #21
0
        public void AddFile(SourceFileEntry file)
        {
            if (!creating)
            {
                throw new InvalidOperationException();
            }

            if (include_files == null)
            {
                include_files = new ArrayList();
            }

            include_files.Add(file);
        }
        public void MarkSequencePoint(int offset, SourceFileEntry file, int start_line, int end_line,
                                      int start_col, int end_col)
        {
            if (method_lines_pos == method_lines.Length)
            {
                LineNumberEntry [] tmp = method_lines;
                method_lines = new LineNumberEntry [method_lines.Length * 2];
                Array.Copy(tmp, method_lines, method_lines_pos);
            }

            int file_idx = file != null ? file.Index : 0;

            method_lines [method_lines_pos++] = new LineNumberEntry(
                file_idx, offset, start_line, end_line, start_col, end_col);
        }
Beispiel #23
0
		private Document GetDocument(SourceFileEntry file)
		{
			string file_name = file.FileName;
			Document document;
			Document result;
			if (this.documents.TryGetValue(file_name, out document))
			{
				result = document;
			}
			else
			{
				document = new Document(file_name);
				this.documents.Add(file_name, document);
				result = document;
			}
			return result;
		}
        public ISymbolDocumentWriter DefineDocument(
            string url,
            Guid language,
            Guid languageVendor,
            Guid documentType)
        {
            SymbolDocumentWriterImpl doc = (SymbolDocumentWriterImpl)documents [url];

            if (doc == null)
            {
                SourceFileEntry  entry     = msw.DefineDocument(url);
                CompileUnitEntry comp_unit = msw.DefineCompilationUnit(entry);
                doc             = new SymbolDocumentWriterImpl(comp_unit);
                documents [url] = doc;
            }
            return(doc);
        }
Beispiel #25
0
        void ReadData()
        {
            if (creating)
            {
                throw new InvalidOperationException();
            }

            lock (file)
            {
                if (namespaces != null)
                {
                    return;
                }

                MyBinaryReader reader  = file.BinaryReader;
                int            old_pos = (int)reader.BaseStream.Position;

                reader.BaseStream.Position = DataOffset;

                int source_idx = reader.ReadLeb128();
                source = file.GetSourceFile(source_idx);

                int count_includes = reader.ReadLeb128();
                if (count_includes > 0)
                {
                    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 List <NamespaceEntry> ();
                for (int i = 0; i < count_ns; i++)
                {
                    namespaces.Add(new NamespaceEntry(file, reader));
                }

                reader.BaseStream.Position = old_pos;
            }
        }
        public void DefineSequencePoints(
            ISymbolDocumentWriter document,
            int[] offsets,
            int[] lines,
            int[] columns,
            int[] endLines,
            int[] endColumns)
        {
            SymbolDocumentWriterImpl doc  = (SymbolDocumentWriterImpl)document;
            SourceFileEntry          file = doc != null ? doc.Entry.SourceFile : null;

            for (int n = 0; n < offsets.Length; n++)
            {
                if (n > 0 && offsets[n] == offsets[n - 1] && lines[n] == lines[n - 1] && columns[n] == columns[n - 1])
                {
                    continue;
                }
                msw.MarkSequencePoint(offsets[n], file, lines[n], columns[n], false);
            }
        }
Beispiel #27
0
        public void MarkSequencePoint(int offset, SourceFileEntry file, int start_line, int end_line,
					       int start_col, int end_col)
        {
            if (method_lines_pos == method_lines.Length) {
                LineNumberEntry [] tmp = method_lines;
                method_lines = new LineNumberEntry [method_lines.Length * 2];
                Array.Copy (tmp, method_lines, method_lines_pos);
            }

            int file_idx = file != null ? file.Index : 0;
            method_lines [method_lines_pos++] = new LineNumberEntry (
                file_idx, offset, start_line, end_line, start_col, end_col);
        }
Beispiel #28
0
        public SourceFileEntry GetSourceFile(int index)
        {
            if (index < 1 || index > this.ot.SourceCount)
            {
                throw new ArgumentException();
            }
            if (this.reader == null)
            {
                throw new InvalidOperationException();
            }
            SourceFileEntry result;

            SourceFileEntry source;
            if (this.source_file_hash.TryGetValue(index, out source))
            {
                result = source;
            }
            else
            {
                long old_pos = this.reader.BaseStream.Position;
                this.reader.BaseStream.Position = (long)(this.ot.SourceTableOffset + SourceFileEntry.Size * (index - 1));
                source = new SourceFileEntry(this, this.reader);
                this.source_file_hash.Add(index, source);
                this.reader.BaseStream.Position = old_pos;
                result = source;
            }

            return result;
        }
		public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column,
					       bool is_hidden)
		{
			if (current_method == null)
				return;

			current_method.MarkSequencePoint (offset, file, line, column, is_hidden);
		}
		public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column,
					       bool is_hidden)
		{
			if (method_lines_pos == method_lines.Length) {
				LineNumberEntry [] tmp = method_lines;
				method_lines = new LineNumberEntry [method_lines.Length * 2];
				Array.Copy (tmp, method_lines, method_lines_pos);
			}

			int file_idx = file != null ? file.Index : 0;
			method_lines [method_lines_pos++] = new LineNumberEntry (
				file_idx, line, offset, is_hidden);
		}
Beispiel #31
0
 public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden)
 {
     MarkSequencePoint(offset, file, line, column, -1, -1, is_hidden);
 }
 internal int AddSource(SourceFileEntry source)
 {
     sources.Add(source);
     return(sources.Count);
 }
 public SourceFile(CompileUnitEntry comp_unit, SourceFileEntry entry)
 {
     this.compilation_unit = comp_unit;
     this.entry = entry;
 }
		void ReadData ()
		{
			if (creating)
				throw new InvalidOperationException ();

			lock (file) {
				if (namespaces != null)
					return;

				MyBinaryReader reader = file.BinaryReader;
				int old_pos = (int) reader.BaseStream.Position;

				reader.BaseStream.Position = DataOffset;

				int source_idx = reader.ReadLeb128 ();
				source = file.GetSourceFile (source_idx);

				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 ();
					}
				}

				int count_ns = reader.ReadLeb128 ();
				namespaces = new ArrayList ();
				for (int i = 0; i < count_ns; i ++)
					namespaces.Add (new NamespaceEntry (file, reader));

				reader.BaseStream.Position = old_pos;
			}
		}
		public void AddFile (SourceFileEntry file)
		{
			if (!creating)
				throw new InvalidOperationException ();

			if (include_files == null)
				include_files = new ArrayList ();

			include_files.Add (file);
		}
		public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden)
		{
			MarkSequencePoint (offset, file, line, column, -1, -1, is_hidden);
		}
		public CompileUnitEntry DefineCompilationUnit (SourceFileEntry source)
		{
			CompileUnitEntry entry = new CompileUnitEntry (file, source);
			comp_units.Add (entry);
			return entry;
		}
Beispiel #38
0
        public void MarkSequencePoint(int offset, SourceFileEntry file, int start_line, int end_line,
					       int start_col, int end_col)
        {
            if (current_method == null)
                return;

            current_method.MarkSequencePoint (offset, file, start_line, end_line, start_col, end_col);
        }
		public SourceFileEntry DefineDocument (string url, byte[] guid, byte[] checksum)
		{
			SourceFileEntry entry = new SourceFileEntry (file, url, guid, checksum);
			sources.Add (entry);
			return entry;
		}
Beispiel #40
0
            public MonoSourceFile(DebuggerSession session, Module module,
					       C.SourceFileEntry file, string path)
                : base(session, module, path)
            {
                this.file = file;
            }
		public SourceFileEntry DefineDocument (string url)
		{
			SourceFileEntry entry = new SourceFileEntry (file, url);
			sources.Add (entry);
			return entry;
		}
		Document GetDocument (SourceFileEntry file)
		{
			Document doc = m_documents [file.FileName] as Document;
			if (doc != null)
				return doc;

			doc = new Document (file.FileName);

			m_documents [file.FileName] = doc;
			return doc;
		}
Beispiel #43
0
		internal int AddSource (SourceFileEntry source)
		{
			sources.Add (source);
			return sources.Count;
		}
        void Write(MyBinaryWriter bw, Guid guid)
        {
            // Magic number and file version.
            bw.Write(OffsetTable.Magic);
            bw.Write(MajorVersion);
            bw.Write(MinorVersion);

            bw.Write(guid.ToByteArray());

            //
            // Offsets of file sections; we must write this after we're done
            // writing the whole file, so we just reserve the space for it here.
            //
            long offset_table_offset = bw.BaseStream.Position;

            ot.Write(bw, MajorVersion, MinorVersion);

            //
            // Sort the methods according to their tokens and update their index.
            //
            methods.Sort();
            for (int i = 0; i < methods.Count; i++)
            {
                ((MethodEntry)methods [i]).Index = i + 1;
            }

            //
            // Write data sections.
            //
            ot.DataSectionOffset = (int)bw.BaseStream.Position;
            foreach (SourceFileEntry source in sources)
            {
                source.WriteData(bw);
            }
            foreach (CompileUnitEntry comp_unit in comp_units)
            {
                comp_unit.WriteData(bw);
            }
            foreach (MethodEntry method in methods)
            {
                method.WriteData(this, bw);
            }
            ot.DataSectionSize = (int)bw.BaseStream.Position - ot.DataSectionOffset;

            //
            // Write the method index table.
            //
            ot.MethodTableOffset = (int)bw.BaseStream.Position;
            for (int i = 0; i < methods.Count; i++)
            {
                MethodEntry entry = (MethodEntry)methods [i];
                entry.Write(bw);
            }
            ot.MethodTableSize = (int)bw.BaseStream.Position - ot.MethodTableOffset;

            //
            // Write source table.
            //
            ot.SourceTableOffset = (int)bw.BaseStream.Position;
            for (int i = 0; i < sources.Count; i++)
            {
                SourceFileEntry source = (SourceFileEntry)sources [i];
                source.Write(bw);
            }
            ot.SourceTableSize = (int)bw.BaseStream.Position - ot.SourceTableOffset;

            //
            // Write compilation unit table.
            //
            ot.CompileUnitTableOffset = (int)bw.BaseStream.Position;
            for (int i = 0; i < comp_units.Count; i++)
            {
                CompileUnitEntry unit = (CompileUnitEntry)comp_units [i];
                unit.Write(bw);
            }
            ot.CompileUnitTableSize = (int)bw.BaseStream.Position - ot.CompileUnitTableOffset;

            //
            // Write anonymous scope table.
            //
            ot.AnonymousScopeCount       = anonymous_scopes != null ? anonymous_scopes.Count : 0;
            ot.AnonymousScopeTableOffset = (int)bw.BaseStream.Position;
            if (anonymous_scopes != null)
            {
                foreach (AnonymousScopeEntry scope in anonymous_scopes.Values)
                {
                    scope.Write(bw);
                }
            }
            ot.AnonymousScopeTableSize = (int)bw.BaseStream.Position - ot.AnonymousScopeTableOffset;

            //
            // Fixup offset table.
            //
            ot.TypeCount        = last_type_index;
            ot.MethodCount      = methods.Count;
            ot.SourceCount      = sources.Count;
            ot.CompileUnitCount = comp_units.Count;

            //
            // Write offset table.
            //
            ot.TotalFileSize = (int)bw.BaseStream.Position;
            bw.Seek((int)offset_table_offset, SeekOrigin.Begin);
            ot.Write(bw, MajorVersion, MinorVersion);
            bw.Seek(0, SeekOrigin.End);

#if false
            Console.WriteLine("TOTAL: {0} line numbes, {1} bytes, extended {2} bytes, " +
                              "{3} methods.", NumLineNumbers, LineNumberSize,
                              ExtendedLineNumberSize, methods.Count);
#endif
        }
Beispiel #45
0
		public SourceFileEntry GetSourceFile (int index)
		{
			if ((index < 1) || (index > ot.SourceCount))
				throw new ArgumentException ();
			if (reader == null)
				throw new InvalidOperationException ();

			lock (this) {
				SourceFileEntry source;
				if (source_file_hash.TryGetValue (index, out source))
					return source;

				long old_pos = reader.BaseStream.Position;

				reader.BaseStream.Position = ot.SourceTableOffset +
					SourceFileEntry.Size * (index - 1);
				source = new SourceFileEntry (this, reader);
				source_file_hash.Add (index, source);

				reader.BaseStream.Position = old_pos;
				return source;
			}
		}
Beispiel #46
0
		Document GetDocument (SourceFileEntry file)
		{
			var file_name = file.FileName;

			Document document;
			if (documents.TryGetValue (file_name, out document))
				return document;

			document = new Document (file_name);
			documents.Add (file_name, document);

			return document;
		}
Beispiel #47
0
		private void ReadData()
		{
			if (this.creating)
			{
				throw new InvalidOperationException();
			}
			lock (this.file)
			{
				if (this.namespaces == null)
				{
					MyBinaryReader reader = this.file.BinaryReader;
					int old_pos = (int)reader.BaseStream.Position;
					reader.BaseStream.Position = (long)this.DataOffset;
					int source_idx = reader.ReadLeb128();
					this.source = this.file.GetSourceFile(source_idx);
					int count_includes = reader.ReadLeb128();
					if (count_includes > 0)
					{
						this.include_files = new List<SourceFileEntry>();
						for (int i = 0; i < count_includes; i++)
						{
							this.include_files.Add(this.file.GetSourceFile(reader.ReadLeb128()));
						}
					}
					int count_ns = reader.ReadLeb128();
					this.namespaces = new List<NamespaceEntry>();
					for (int i = 0; i < count_ns; i++)
					{
						this.namespaces.Add(new NamespaceEntry(this.file, reader));
					}
					reader.BaseStream.Position = (long)old_pos;
				}
			}
		}