mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
LibDebug: Add support for the various DW_FORM_block types
This fixes #2885.
This commit is contained in:
parent
52ab2cead4
commit
240eb3242a
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) {
|
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);
|
auto value = Dwarf::Expression::evaluate(expression_bytes, regs);
|
||||||
|
|
||||||
if (value.type != Dwarf::Expression::Type::None) {
|
if (value.type != Dwarf::Expression::Type::None) {
|
||||||
|
|
|
@ -63,6 +63,15 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
|
||||||
BufferStream& debug_info_stream) const
|
BufferStream& debug_info_stream) const
|
||||||
{
|
{
|
||||||
AttributeValue value;
|
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) {
|
switch (form) {
|
||||||
case AttributeDataForm::StringPointer: {
|
case AttributeDataForm::StringPointer: {
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
|
@ -124,11 +133,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
debug_info_stream.read_LEB128_unsigned(length);
|
debug_info_stream.read_LEB128_unsigned(length);
|
||||||
value.type = AttributeValue::Type::DwarfExpression;
|
value.type = AttributeValue::Type::DwarfExpression;
|
||||||
|
assign_raw_bytes_value(length);
|
||||||
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);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AttributeDataForm::String: {
|
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());
|
value.data.as_string = reinterpret_cast<const char*>(str_offset + m_compilation_unit.dwarf_info().debug_info_data().data());
|
||||||
break;
|
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:
|
default:
|
||||||
dbg() << "Unimplemented AttributeDataForm: " << (u32)form;
|
dbg() << "Unimplemented AttributeDataForm: " << (u32)form;
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
Boolean,
|
Boolean,
|
||||||
DwarfExpression,
|
DwarfExpression,
|
||||||
SecOffset,
|
SecOffset,
|
||||||
|
RawBytes,
|
||||||
} type;
|
} type;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
@ -62,7 +63,7 @@ public:
|
||||||
struct {
|
struct {
|
||||||
u32 length;
|
u32 length;
|
||||||
const u8* bytes; // points to bytes in the memory mapped elf image
|
const u8* bytes; // points to bytes in the memory mapped elf image
|
||||||
} as_dwarf_expression;
|
} as_raw_bytes;
|
||||||
} data {};
|
} data {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue