Exemple #1
0
        /// <exception cref="InvalidOperationException">Too late to add abbreviations, or too many abbreviations.</exception>
        public void AddAbbreviation(string str)
        {
            if (Frozen)
            {
                throw new InvalidOperationException("Too late to add abbreviations");
            }
            if (abbrevs.Count >= 96)
            {
                throw new InvalidOperationException("Too many abbreviations");
            }

            var entry = new AbbrevEntry(str, (byte)abbrevs.Count);
            var idx   = abbrevs.BinarySearch(entry, abbrevLengthComparer);

            abbrevs.Insert(idx < 0 ? ~idx : idx, entry);
        }
Exemple #2
0
            protected override Die CreateDie(DwarfBinaryReader reader, CompilationUnit comp_unit,
							  long offset, AbbrevEntry abbrev)
            {
                switch (abbrev.Tag) {
                case DwarfTag.formal_parameter:
                    return new DieFormalParameter (this, reader, comp_unit, abbrev);

                case DwarfTag.variable:
                    return new DieVariable (this, reader, comp_unit, abbrev);

                case DwarfTag.lexical_block:
                    return new DieLexicalBlock (this, reader, comp_unit, abbrev);

                default:
                    return base.CreateDie (reader, comp_unit, offset, abbrev);
                }
            }
Exemple #3
0
            public DieSubprogram(DwarfBinaryReader reader, CompilationUnit comp_unit,
					      long offset, AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
                this.real_offset = offset;
                if ((start_pc != 0) && (end_pc != 0))
                    is_continuous = true;

                comp_unit.AddSubprogram (offset, this);
            }
Exemple #4
0
            protected override Die CreateDie(DwarfBinaryReader reader, CompilationUnit comp_unit,
							  long offset, AbbrevEntry abbrev)
            {
                switch (abbrev.Tag) {
                case DwarfTag.inheritance:
                    return new DieInheritance (reader, comp_unit, abbrev);

                default:
                    return base.CreateDie (reader, comp_unit, offset, abbrev);
                }
            }
Exemple #5
0
            protected Die(DwarfBinaryReader reader, CompilationUnit comp_unit,
				       AbbrevEntry abbrev)
            {
                this.comp_unit = comp_unit;
                this.dwarf = comp_unit.DwarfReader;
                this.abbrev = abbrev;

                Offset = reader.Position;
                ChildrenOffset = Offset + ReadAttributes (reader);
                reader.Position = ChildrenOffset;

                debug ("NEW DIE: {0} {1} {2} {3}", GetType (),
                       abbrev, Offset, ChildrenOffset);
            }
Exemple #6
0
            public DieVariableBase(DwarfBinaryReader reader, CompilationUnit comp_unit,
						AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
            }
Exemple #7
0
            public DieVariable(DieSubprogram parent, DwarfBinaryReader reader,
					    CompilationUnit comp_unit, AbbrevEntry abbrev)
                : base(parent, reader, comp_unit, abbrev, null, true)
            {
            }
Exemple #8
0
            public DieType(DwarfBinaryReader reader, CompilationUnit comp_unit,
					long offset, AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
                this.offset = offset;
                this.language = reader.Bfd.NativeLanguage;
                comp_unit.AddType (offset, this);

                if (specification != null) {
                    if ((name == null) && (specification.name != null))
                        name = specification.Name;
                }

                if (name != null) {
                    if (comp_unit.CurrentNamespace != null)
                        name = comp_unit.CurrentNamespace + "::" + name;
                    comp_unit.DwarfReader.AddType (this);
                }
            }
Exemple #9
0
            protected override Die CreateDie(DwarfBinaryReader reader, CompilationUnit comp_unit,
							  long offset, AbbrevEntry abbrev)
            {
                switch (abbrev.Tag) {
                case DwarfTag.formal_parameter:
                    return new DieFormalParameter (subprog, reader, comp_unit, abbrev);

                case DwarfTag.variable:
                    return new DieVariable (subprog, reader, comp_unit, abbrev, this);

                case DwarfTag.lexical_block:
                    return new DieLexicalBlock (subprog, reader, comp_unit, abbrev);

                default:
                    debug ("LEXICAL BLOCK ({0}): unknown die: {1}", Offset, abbrev.Tag);
                    return base.CreateDie (reader, comp_unit, offset, abbrev);
                }
            }
Exemple #10
0
            public DieLexicalBlock(DieSubprogram subprog, DwarfBinaryReader reader,
						CompilationUnit comp_unit, AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
                this.subprog = subprog;
            }
Exemple #11
0
            public DieInheritance(DwarfBinaryReader reader,
					       CompilationUnit comp_unit,
					       AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
            }
Exemple #12
0
            public DieFormalParameter(DieSubprogram parent, DwarfBinaryReader reader,
						   CompilationUnit comp_unit, AbbrevEntry abbrev)
                : base(parent, reader, comp_unit, abbrev, null, false)
            {
            }
Exemple #13
0
            public DieEnumerator(DwarfBinaryReader reader, CompilationUnit comp_unit,
					      AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
            }
Exemple #14
0
            public DieCompileUnit(DwarfBinaryReader reader, CompilationUnit comp_unit,
					       AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
                if ((start_pc != null) && (end_pc != null))
                    is_continuous = true;

                string file_name;
                if (comp_dir != null)
                    file_name = String.Concat (
                        comp_dir, Path.DirectorySeparatorChar, name);
                else
                    file_name = name;
                file = dwarf.GetSourceFile (file_name);
            }
Exemple #15
0
            protected virtual Die CreateDie(DwarfBinaryReader reader, CompilationUnit comp_unit,
							 long offset, AbbrevEntry abbrev)
            {
                switch (abbrev.Tag) {
                case DwarfTag.compile_unit:
                    throw new InternalError ();

                case DwarfTag.subprogram:
                    return new DieSubprogram (reader, comp_unit, offset, abbrev);

                case DwarfTag.base_type:
                    return new DieBaseType (reader, comp_unit, offset, abbrev);

                case DwarfTag.const_type:
                    return new DieConstType (reader, comp_unit, offset, abbrev);

                case DwarfTag.pointer_type:
                    return new DiePointerType (reader, comp_unit, offset, abbrev);

                case DwarfTag.class_type: // for now just treat classes and structs the same.
                case DwarfTag.structure_type:
                    return new DieStructureType (reader, comp_unit, offset, abbrev, false);

                case DwarfTag.union_type:
                    return new DieStructureType (reader, comp_unit, offset, abbrev, true);

                case DwarfTag.array_type:
                    return new DieArrayType (reader, comp_unit, offset, abbrev);

                case DwarfTag.subrange_type:
                    return new DieSubrangeType (reader, comp_unit, abbrev);

                case DwarfTag.enumeration_type:
                    return new DieEnumerationType (reader, comp_unit, offset, abbrev);

                case DwarfTag.enumerator:
                    return new DieEnumerator (reader, comp_unit, abbrev);

                case DwarfTag.typedef:
                    return new DieTypedef (reader, comp_unit, offset, abbrev);

                case DwarfTag.subroutine_type:
                    return new DieSubroutineType (reader, comp_unit, offset, abbrev);

                case DwarfTag.member:
                    return new DieMember (reader, comp_unit, abbrev);

                case DwarfTag.inlined_subroutine:
                    debug ("INLINED SUBROUTINE!");
                    return new DieSubprogram (reader, comp_unit, offset, abbrev);

                case DwarfTag.dwarf3_namespace:
                    return new DieNamespace (reader, comp_unit, offset, abbrev);

                default:
                    return new Die (reader, comp_unit, abbrev);
                }
            }
Exemple #16
0
            public DieSubrangeType(DwarfBinaryReader reader, CompilationUnit comp_unit,
						AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
            }
Exemple #17
0
            protected override Die CreateDie(DwarfBinaryReader reader, CompilationUnit comp_unit,
							  long offset, AbbrevEntry abbrev)
            {
                switch (abbrev.Tag) {
                case DwarfTag.formal_parameter:
                    return new DieFormalParameter (null, reader, comp_unit, abbrev);

                default:
                    return base.CreateDie (reader, comp_unit, offset, abbrev);
                }
            }
Exemple #18
0
            public DieMember(DwarfBinaryReader reader, CompilationUnit comp_unit,
					  AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
                this.target_info = reader.TargetMemoryInfo;
            }
Exemple #19
0
            public DieTypedef(DwarfBinaryReader reader, CompilationUnit comp_unit,
					   long offset, AbbrevEntry abbrev)
                : base(reader, comp_unit, offset, abbrev)
            {
            }
Exemple #20
0
            public DieMethodVariable(DieSubprogram subprog, DwarfBinaryReader reader,
						  CompilationUnit comp_unit, AbbrevEntry abbrev,
						  DieLexicalBlock lexical_block, bool is_local)
                : base(reader, comp_unit, abbrev)
            {
                this.subprog = subprog;
                this.lexical_block = lexical_block;

                if (subprog != null) {
                    if (is_local)
                        subprog.AddLocal (this);
                    else
                        subprog.AddParameter (this);
                }
            }
Exemple #21
0
            public DieVariable(DieSubprogram parent, DwarfBinaryReader reader,
					    CompilationUnit comp_unit, AbbrevEntry abbrev,
					    DieLexicalBlock lexical)
                : base(parent, reader, comp_unit, abbrev, lexical, true)
            {
            }
Exemple #22
0
            public DieNamespace(DwarfBinaryReader reader, CompilationUnit comp_unit,
					     long offset, AbbrevEntry abbrev)
                : base(reader, comp_unit, abbrev)
            {
                this.offset = offset;
                comp_unit.AddNamespace (offset, this);

                if (extension != null) {
                    if (extension.name != null) {
                        if (name != null)
                            name = extension.name + "::" + name;
                        else
                            name = extension.name;
                    }
                }
            }
Exemple #23
0
            public DieStructureType(DwarfBinaryReader reader,
						 CompilationUnit comp_unit, long offset,
						 AbbrevEntry abbrev, bool is_union)
                : base(reader, comp_unit, offset, abbrev)
            {
                this.IsUnion = is_union;
            }
Exemple #24
0
            public CompilationUnit(DwarfReader dwarf, DwarfBinaryReader reader)
            {
                this.dwarf = dwarf;

                real_start_offset = reader.Position;
                unit_length = reader.ReadInitialLength ();
                start_offset = reader.Position;
                version = reader.ReadInt16 ();
                abbrev_offset = reader.ReadOffset ();
                address_size = reader.ReadByte ();

                if (version < 2)
                    throw new DwarfException (
                        dwarf.bfd, "Wrong DWARF version: {0}",
                        version);

                abbrevs = new Hashtable ();
                types = new Hashtable ();
                subprogs = new Hashtable ();
                namespaces = new Dictionary<long,DieNamespace> ();

                DwarfBinaryReader abbrev_reader = dwarf.DebugAbbrevReader;

                abbrev_reader.Position = abbrev_offset;
                while (abbrev_reader.PeekByte () != 0) {
                    AbbrevEntry entry = new AbbrevEntry (dwarf, abbrev_reader);
                    abbrevs.Add (entry.ID, entry);
                }

                comp_unit_die = Die.CreateDieCompileUnit (reader, this);

                reader.Position = start_offset + unit_length;
            }