Ejemplo n.º 1
0
        public CompileUnitEntry DefineCompilationUnit(SourceFileEntry source)
        {
            CompileUnitEntry entry = new CompileUnitEntry(file, source);

            comp_units.Add(entry);
            return(entry);
        }
Ejemplo n.º 2
0
        public SourceFileEntry DefineDocument(string url)
        {
            SourceFileEntry entry = new SourceFileEntry(file, url);

            sources.Add(entry);
            return(entry);
        }
Ejemplo n.º 3
0
        public SourceFileEntry DefineDocument(string url, byte[] guid, byte[] checksum)
        {
            SourceFileEntry entry = new SourceFileEntry(file, url, guid, checksum);

            sources.Add(entry);
            return(entry);
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, int end_line, int end_column, bool is_hidden)
        {
            int file_idx = file != null ? file.Index : 0;
            var lne      = new LineNumberEntry(file_idx, line, column, end_line, end_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);
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        public CompileUnitEntry(MonoSymbolFile file, SourceFileEntry source)
        {
            this.file   = file;
            this.source = source;

            this.Index = file.AddCompileUnit(this);

            creating   = true;
            namespaces = new List <NamespaceEntry> ();
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        public void AddFile(SourceFileEntry file)
        {
            if (!creating)
            {
                throw new InvalidOperationException();
            }

            if (include_files == null)
            {
                include_files = new List <SourceFileEntry> ();
            }

            include_files.Add(file);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
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;
            }
        }
Ejemplo n.º 13
0
        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++)
            {
                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 = 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 = 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 = 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
        }
Ejemplo n.º 14
0
 public int AddSource(SourceFileEntry source)
 {
     sources.Add(source);
     return(sources.Count);
 }
Ejemplo n.º 15
0
 public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden)
 {
     MarkSequencePoint(offset, file, line, column, -1, -1, is_hidden);
 }