Example #1
0
            public void Read(DwarfBinaryReader reader, long end_pos)
            {
                while (reader.Position < end_pos) {
                    byte first = reader.ReadByte ();
                    int opcode = first >> 6;
                    int low = first & 0x3f;

                    if (opcode == (int) DW_CFA.offset) {
                        int offset = reader.ReadLeb128 ();
                        offset *= cie.DataAlignment;

                        columns [low + 1].State = State.Offset;
                        columns [low + 1].Register = 0;
                        columns [low + 1].Offset = offset;
                        continue;
                    } else if (opcode == (int) DW_CFA.advance_loc) {
                        current_address += low;
                        if (current_address > address)
                            return;
                        continue;
                    } else if (opcode != 0) {
                        continue;
                    }

                    switch ((DW_CFA) low) {
                    case DW_CFA.nop:
                        break;
                    case DW_CFA.def_cfa:
                        columns [0].State = State.Register;
                        columns [0].Register = reader.ReadLeb128 ();
                        columns [0].Offset = reader.ReadLeb128 ();
                        break;
                    case DW_CFA.def_cfa_register:
                        columns [0].State = State.Register;
                        columns [0].Register = reader.ReadLeb128 ();
                        break;
                    case DW_CFA.def_cfa_offset:
                        columns [0].Offset = reader.ReadLeb128 ();
                        break;
                    case DW_CFA.gnu_args_size:
                        // Ignored.
                        reader.ReadLeb128 ();
                        break;
                    default:
                        break;
                    }
                }
            }
Example #2
0
            void read_cie(DwarfBinaryReader reader)
            {
                long length = reader.ReadInitialLength ();
                long end_pos = reader.Position + length;
                int id = reader.ReadInt32 ();

                bool is_cie;
                if (frame.is_ehframe)
                    is_cie = id == 0;
                else
                    is_cie = id == -1;
                if (!is_cie)
                    throw new InvalidOperationException ();

                int version = reader.ReadByte ();
                if (version != 1)
                    throw new DwarfException (
                        reader.Bfd, "Unknown version {0} in CIE",
                        version);

                string augmentation = reader.ReadString ();

                if (augmentation.StartsWith ("eh")) {
                    reader.ReadAddress ();
                    augmentation = augmentation.Substring (2);
                }

                code_alignment = reader.ReadLeb128 ();
                data_alignment = reader.ReadSLeb128 ();
                return_register = reader.ReadByte ();

                for (int pos = 0; pos < augmentation.Length; pos++) {
                    if (augmentation [pos] == 'z') {
                        reader.ReadLeb128 ();
                        // has_z_augmentation = true;
                        continue;
                    }

                    if (augmentation [pos] == 'L')
                        continue;
                    else if (augmentation [pos] == 'R') {
                        encoding = reader.ReadByte ();
                        continue;
                    }
                    else if (augmentation [pos] == 'P') {
                        continue;
                    }

                    throw new DwarfException (
                        reader.Bfd, "Unknown augmentation `{0}' in CIE",
                        augmentation[pos]);
                }

                columns = new Column [return_register + 2];
                for (int i = 0; i < columns.Length; i++)
                    columns [i] = new Column (State.Undefined);

                Entry entry = new Entry (this);
                entry.Read (reader, end_pos);

                reader.Position = end_pos;
            }
Example #3
0
            public AbbrevEntry(DwarfReader dwarf, DwarfBinaryReader reader)
            {
                abbrev_id = reader.ReadLeb128 ();
                tag = (DwarfTag) reader.ReadLeb128 ();
                has_children = reader.ReadByte () != 0;

                Attributes = new ArrayList ();

                do {
                    int attr = reader.ReadLeb128 ();
                    int form = reader.ReadLeb128 ();

                    if ((attr == 0) && (form == 0))
                        break;

                    Attributes.Add (new AttributeEntry (
                        dwarf, (DwarfAttribute) attr, (DwarfForm) form));
                } while (true);
            }
Example #4
0
                public FileEntry(LineNumberEngine engine, DwarfBinaryReader reader)
                {
                    FileName = reader.ReadString ();
                    Directory = reader.ReadLeb128 ();
                    LastModificationTime = reader.ReadLeb128 ();
                    Length = reader.ReadLeb128 ();

                    string dir_name;
                    if (Directory > 0)
                        dir_name = (string) engine.include_dirs [Directory - 1];
                    else
                        dir_name = engine.compilation_dir;

                    string full_name;
                    if (dir_name != null)
                        full_name = Path.Combine (dir_name, FileName);
                    else
                        full_name = FileName;

                    File = engine.comp_unit.dwarf.GetSourceFile (full_name);
                }
Example #5
0
            public Die CreateDie(DwarfBinaryReader reader, CompilationUnit comp_unit)
            {
                long offset = reader.Position;
                int abbrev_id = reader.ReadLeb128 ();
                AbbrevEntry abbrev = comp_unit [abbrev_id];

                return CreateDie (reader, comp_unit, offset, abbrev);
            }
Example #6
0
            public static DieCompileUnit CreateDieCompileUnit(DwarfBinaryReader reader,
									   CompilationUnit comp_unit)
            {
                int abbrev_id = reader.ReadLeb128 ();
                AbbrevEntry abbrev = comp_unit [abbrev_id];

                return new DieCompileUnit (reader, comp_unit, abbrev);
            }