Exemplo n.º 1
0
        protected override void Read(DwarfReader reader)
        {
            var itemTag = new DwarfTagEx(reader.ReadULEB128AsU32());

            Tag = itemTag;
            var  hasChildrenRaw = reader.ReadU8();
            bool hasChildren    = false;

            if (hasChildrenRaw == DwarfNative.DW_CHILDREN_yes)
            {
                hasChildren = true;
            }
            else if (hasChildrenRaw != DwarfNative.DW_CHILDREN_no)
            {
                reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"Invalid children {hasChildrenRaw}. Must be either {DwarfNative.DW_CHILDREN_yes} or {DwarfNative.DW_CHILDREN_no}");
                return;
            }

            HasChildren = hasChildren;

            List <DwarfAttributeDescriptor> descriptors = null;

            while (true)
            {
                var attributeName = new DwarfAttributeKindEx(reader.ReadULEB128AsU32());
                var attributeForm = new DwarfAttributeFormEx(reader.ReadULEB128AsU32());

                if (attributeForm.Value == 0 && attributeForm.Value == 0)
                {
                    break;
                }

                if (descriptors == null)
                {
                    descriptors = new List <DwarfAttributeDescriptor>(1);
                }
                descriptors.Add(new DwarfAttributeDescriptor(attributeName, attributeForm));
            }

            Descriptors = descriptors != null ? new DwarfAttributeDescriptors(descriptors.ToArray()) : new DwarfAttributeDescriptors();

            Size = reader.Offset - Offset;
        }
Exemplo n.º 2
0
 public DwarfAttributeDescriptor(DwarfAttributeKindEx kind, DwarfAttributeFormEx form)
 {
     Kind = kind;
     Form = form;
 }