mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibDebug: Add support for the various DW_FORM_block types
This fixes #2885.
This commit is contained in:
parent
52ab2cead4
commit
240eb3242a
Notes:
sideshowbarker
2024-07-19 04:35:30 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/240eb3242a9 Pull-request: https://github.com/SerenityOS/serenity/pull/2890 Issue: https://github.com/SerenityOS/serenity/issues/2885
3 changed files with 41 additions and 7 deletions
|
@ -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) {
|
||||
|
|
|
@ -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<const u8*>(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<const u8*>(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<const char*>(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();
|
||||
|
|
|
@ -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 {};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue