diff --git a/Libraries/LibDebug/DebugInfo.cpp b/Libraries/LibDebug/DebugInfo.cpp index 250b6902a4..bd6755f66e 100644 --- a/Libraries/LibDebug/DebugInfo.cpp +++ b/Libraries/LibDebug/DebugInfo.cpp @@ -204,7 +204,7 @@ static void parse_variable_location(const Dwarf::DIE& variable_die, DebugInfo::V } if (location_info.value().type == Dwarf::DIE::AttributeValue::Type::DwarfExpression) { - auto expression_bytes = ByteBuffer::wrap(location_info.value().data.as_dwarf_expression.bytes, location_info.value().data.as_dwarf_expression.length); + auto expression_bytes = ByteBuffer::wrap(location_info.value().data.as_raw_bytes.bytes, location_info.value().data.as_raw_bytes.length); auto value = Dwarf::Expression::evaluate(expression_bytes, regs); if (value.type != Dwarf::Expression::Type::None) { diff --git a/Libraries/LibDebug/Dwarf/DIE.cpp b/Libraries/LibDebug/Dwarf/DIE.cpp index e8f957d432..2afab92920 100644 --- a/Libraries/LibDebug/Dwarf/DIE.cpp +++ b/Libraries/LibDebug/Dwarf/DIE.cpp @@ -63,6 +63,15 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form, BufferStream& debug_info_stream) const { AttributeValue value; + + auto assign_raw_bytes_value = [&](size_t length) { + value.data.as_raw_bytes.length = length; + value.data.as_raw_bytes.bytes = reinterpret_cast(m_compilation_unit.dwarf_info().debug_info_data().data() + + debug_info_stream.offset()); + + debug_info_stream.advance(length); + }; + switch (form) { case AttributeDataForm::StringPointer: { u32 offset = 0; @@ -124,11 +133,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form, size_t length = 0; debug_info_stream.read_LEB128_unsigned(length); value.type = AttributeValue::Type::DwarfExpression; - - value.data.as_dwarf_expression.length = length; - value.data.as_dwarf_expression.bytes = reinterpret_cast(m_compilation_unit.dwarf_info().debug_info_data().data() + debug_info_stream.offset()); - - debug_info_stream.advance(length); + assign_raw_bytes_value(length); break; } case AttributeDataForm::String: { @@ -139,6 +144,34 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form, value.data.as_string = reinterpret_cast(str_offset + m_compilation_unit.dwarf_info().debug_info_data().data()); break; } + case AttributeDataForm::Block1: { + value.type = AttributeValue::Type::RawBytes; + u8 length = 0; + debug_info_stream >> length; + assign_raw_bytes_value(length); + break; + } + case AttributeDataForm::Block2: { + value.type = AttributeValue::Type::RawBytes; + u16 length = 0; + debug_info_stream >> length; + assign_raw_bytes_value(length); + break; + } + case AttributeDataForm::Block4: { + value.type = AttributeValue::Type::RawBytes; + u32 length = 0; + debug_info_stream >> length; + assign_raw_bytes_value(length); + break; + } + case AttributeDataForm::Block: { + value.type = AttributeValue::Type::RawBytes; + size_t length = 0; + debug_info_stream.read_LEB128_unsigned(length); + assign_raw_bytes_value(length); + break; + } default: dbg() << "Unimplemented AttributeDataForm: " << (u32)form; ASSERT_NOT_REACHED(); diff --git a/Libraries/LibDebug/Dwarf/DIE.h b/Libraries/LibDebug/Dwarf/DIE.h index 2cb081cb88..85ac01a67c 100644 --- a/Libraries/LibDebug/Dwarf/DIE.h +++ b/Libraries/LibDebug/Dwarf/DIE.h @@ -52,6 +52,7 @@ public: Boolean, DwarfExpression, SecOffset, + RawBytes, } type; union { @@ -62,7 +63,7 @@ public: struct { u32 length; const u8* bytes; // points to bytes in the memory mapped elf image - } as_dwarf_expression; + } as_raw_bytes; } data {}; };