mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
AK: Make LEB128 decoding work with read_value
This commit is contained in:
parent
787f4d639a
commit
47531a42a9
9 changed files with 135 additions and 148 deletions
|
@ -44,17 +44,14 @@ ErrorOr<void> LineProgram::parse_path_entries(Function<void(PathEntry& entry)> c
|
|||
Vector<PathEntryFormat> format_descriptions;
|
||||
|
||||
for (u8 i = 0; i < path_entry_format_count; i++) {
|
||||
UnderlyingType<ContentType> content_type;
|
||||
TRY(LEB128::read_unsigned(m_stream, content_type));
|
||||
UnderlyingType<ContentType> content_type = TRY(m_stream.read_value<LEB128<UnderlyingType<ContentType>>>());
|
||||
|
||||
UnderlyingType<AttributeDataForm> data_form;
|
||||
TRY(LEB128::read_unsigned(m_stream, data_form));
|
||||
UnderlyingType<AttributeDataForm> data_form = TRY(m_stream.read_value<LEB128<UnderlyingType<AttributeDataForm>>>());
|
||||
|
||||
format_descriptions.empend(static_cast<ContentType>(content_type), static_cast<AttributeDataForm>(data_form));
|
||||
}
|
||||
|
||||
size_t paths_count = 0;
|
||||
TRY(LEB128::read_unsigned(m_stream, paths_count));
|
||||
size_t paths_count = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
|
||||
for (size_t i = 0; i < paths_count; i++) {
|
||||
PathEntry entry;
|
||||
|
@ -85,11 +82,9 @@ ErrorOr<void> LineProgram::parse_path_entries(Function<void(PathEntry& entry)> c
|
|||
PathEntry entry;
|
||||
entry.path = path;
|
||||
if (list_type == PathListType::Filenames) {
|
||||
size_t directory_index = 0;
|
||||
TRY(LEB128::read_unsigned(m_stream, directory_index));
|
||||
size_t _unused = 0;
|
||||
TRY(LEB128::read_unsigned(m_stream, _unused)); // skip modification time
|
||||
TRY(LEB128::read_unsigned(m_stream, _unused)); // skip file size
|
||||
size_t directory_index = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
TRY(m_stream.read_value<LEB128<size_t>>()); // skip modification time
|
||||
TRY(m_stream.read_value<LEB128<size_t>>()); // skip file size
|
||||
entry.directory_index = directory_index;
|
||||
dbgln_if(DWARF_DEBUG, "file: {}, directory index: {}", path, directory_index);
|
||||
}
|
||||
|
@ -157,8 +152,7 @@ void LineProgram::reset_registers()
|
|||
|
||||
ErrorOr<void> LineProgram::handle_extended_opcode()
|
||||
{
|
||||
size_t length = 0;
|
||||
TRY(LEB128::read_unsigned(m_stream, length));
|
||||
size_t length = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
|
||||
auto sub_opcode = TRY(m_stream.read_value<u8>());
|
||||
|
||||
|
@ -176,8 +170,7 @@ ErrorOr<void> LineProgram::handle_extended_opcode()
|
|||
}
|
||||
case ExtendedOpcodes::SetDiscriminator: {
|
||||
dbgln_if(DWARF_DEBUG, "SetDiscriminator");
|
||||
size_t discriminator;
|
||||
TRY(LEB128::read_unsigned(m_stream, discriminator));
|
||||
[[maybe_unused]] size_t discriminator = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -195,16 +188,14 @@ ErrorOr<void> LineProgram::handle_standard_opcode(u8 opcode)
|
|||
break;
|
||||
}
|
||||
case StandardOpcodes::AdvancePc: {
|
||||
size_t operand = 0;
|
||||
TRY(LEB128::read_unsigned(m_stream, operand));
|
||||
size_t operand = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
size_t delta = operand * m_unit_header.min_instruction_length();
|
||||
dbgln_if(DWARF_DEBUG, "AdvancePC by: {} to: {:p}", delta, m_address + delta);
|
||||
m_address += delta;
|
||||
break;
|
||||
}
|
||||
case StandardOpcodes::SetFile: {
|
||||
size_t new_file_index = 0;
|
||||
TRY(LEB128::read_unsigned(m_stream, new_file_index));
|
||||
size_t new_file_index = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
dbgln_if(DWARF_DEBUG, "SetFile: new file index: {}", new_file_index);
|
||||
m_file_index = new_file_index;
|
||||
break;
|
||||
|
@ -212,14 +203,12 @@ ErrorOr<void> LineProgram::handle_standard_opcode(u8 opcode)
|
|||
case StandardOpcodes::SetColumn: {
|
||||
// not implemented
|
||||
dbgln_if(DWARF_DEBUG, "SetColumn");
|
||||
size_t new_column;
|
||||
TRY(LEB128::read_unsigned(m_stream, new_column));
|
||||
[[maybe_unused]] size_t new_column = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
|
||||
break;
|
||||
}
|
||||
case StandardOpcodes::AdvanceLine: {
|
||||
ssize_t line_delta;
|
||||
TRY(LEB128::read_signed(m_stream, line_delta));
|
||||
ssize_t line_delta = TRY(m_stream.read_value<LEB128<ssize_t>>());
|
||||
VERIFY(line_delta >= 0 || m_line >= (size_t)(-line_delta));
|
||||
m_line += line_delta;
|
||||
dbgln_if(DWARF_DEBUG, "AdvanceLine: {}", m_line);
|
||||
|
@ -239,8 +228,7 @@ ErrorOr<void> LineProgram::handle_standard_opcode(u8 opcode)
|
|||
break;
|
||||
}
|
||||
case StandardOpcodes::SetIsa: {
|
||||
size_t isa;
|
||||
TRY(LEB128::read_unsigned(m_stream, isa));
|
||||
size_t isa = TRY(m_stream.read_value<LEB128<size_t>>());
|
||||
dbgln_if(DWARF_DEBUG, "SetIsa: {}", isa);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue