1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:18:11 +00:00

LibDebug: Add support for the various DW_FORM_block types

This fixes #2885.
This commit is contained in:
Itamar 2020-07-26 21:19:02 +03:00 committed by Andreas Kling
parent 52ab2cead4
commit 240eb3242a
3 changed files with 41 additions and 7 deletions

View file

@ -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();