mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +00:00
LibDebug+LibCoredump: Replace remaining reinterpret_casts and C casts
You misused your toys and I'm now taking them away, reflect on what you did wrong for a bit.
This commit is contained in:
parent
da3c4e5df5
commit
e0db9cb876
10 changed files with 68 additions and 64 deletions
|
@ -80,7 +80,7 @@ void AddressRangesV5::for_each_range(Function<void(Range)> callback)
|
|||
case RangeListEntryType::EndOfList:
|
||||
return;
|
||||
default:
|
||||
dbgln("unsupported range list entry type: 0x{:x}", (int)entry_type);
|
||||
dbgln("unsupported range list entry type: 0x{:x}", entry_type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im
|
|||
value.m_compilation_unit = unit;
|
||||
|
||||
auto assign_raw_bytes_value = [&](size_t length) {
|
||||
value.m_data.as_raw_bytes = { reinterpret_cast<const u8*>(debug_info_data().data() + debug_info_stream.offset()), length };
|
||||
value.m_data.as_raw_bytes = { debug_info_data().offset_pointer(debug_info_stream.offset()), length };
|
||||
|
||||
debug_info_stream.discard_or_error(length);
|
||||
VERIFY(!debug_info_stream.has_any_error());
|
||||
|
@ -98,7 +98,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im
|
|||
value.m_type = AttributeValue::Type::String;
|
||||
|
||||
auto strings_data = debug_strings_data();
|
||||
value.m_data.as_string = reinterpret_cast<const char*>(strings_data.data() + offset);
|
||||
value.m_data.as_string = bit_cast<const char*>(strings_data.offset_pointer(offset));
|
||||
break;
|
||||
}
|
||||
case AttributeDataForm::Data1: {
|
||||
|
@ -199,7 +199,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im
|
|||
debug_info_stream >> str;
|
||||
VERIFY(!debug_info_stream.has_any_error());
|
||||
value.m_type = AttributeValue::Type::String;
|
||||
value.m_data.as_string = reinterpret_cast<const char*>(str_offset + debug_info_data().data());
|
||||
value.m_data.as_string = bit_cast<const char*>(debug_info_data().offset_pointer(str_offset));
|
||||
break;
|
||||
}
|
||||
case AttributeDataForm::Block1: {
|
||||
|
@ -241,7 +241,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im
|
|||
value.m_type = AttributeValue::Type::String;
|
||||
|
||||
auto strings_data = debug_line_strings_data();
|
||||
value.m_data.as_string = reinterpret_cast<const char*>(strings_data.data() + offset);
|
||||
value.m_data.as_string = bit_cast<const char*>(strings_data.offset_pointer(offset));
|
||||
break;
|
||||
}
|
||||
case AttributeDataForm::ImplicitConst: {
|
||||
|
@ -323,7 +323,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im
|
|||
break;
|
||||
}
|
||||
default:
|
||||
dbgln("Unimplemented AttributeDataForm: {}", (u32)form);
|
||||
dbgln("Unimplemented AttributeDataForm: {}", to_underlying(form));
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
return value;
|
||||
|
|
|
@ -47,7 +47,10 @@ struct [[gnu::packed]] CompilationUnitHeader {
|
|||
|
||||
u32 length() const { return common.length; }
|
||||
u16 version() const { return common.version; }
|
||||
CompilationUnitType unit_type() const { return (common.version <= 4) ? CompilationUnitType::Full : (CompilationUnitType)v5.unit_type; }
|
||||
CompilationUnitType unit_type() const
|
||||
{
|
||||
return (common.version <= 4) ? CompilationUnitType::Full : static_cast<CompilationUnitType>(v5.unit_type);
|
||||
}
|
||||
u32 abbrev_offset() const { return (common.version <= 4) ? v4.abbrev_offset : v5.abbrev_offset; }
|
||||
u8 address_size() const { return (common.version <= 4) ? v4.address_size : v5.address_size; }
|
||||
};
|
||||
|
|
|
@ -42,13 +42,13 @@ void LineProgram::parse_path_entries(Function<void(PathEntry& entry)> callback,
|
|||
Vector<PathEntryFormat> format_descriptions;
|
||||
|
||||
for (u8 i = 0; i < path_entry_format_count; i++) {
|
||||
size_t content_type = 0;
|
||||
UnderlyingType<ContentType> content_type;
|
||||
m_stream.read_LEB128_unsigned(content_type);
|
||||
|
||||
size_t data_form = 0;
|
||||
UnderlyingType<AttributeDataForm> data_form;
|
||||
m_stream.read_LEB128_unsigned(data_form);
|
||||
|
||||
format_descriptions.empend((ContentType)content_type, (AttributeDataForm)data_form);
|
||||
format_descriptions.empend(static_cast<ContentType>(content_type), static_cast<AttributeDataForm>(data_form));
|
||||
}
|
||||
|
||||
size_t paths_count = 0;
|
||||
|
@ -66,7 +66,7 @@ void LineProgram::parse_path_entries(Function<void(PathEntry& entry)> callback,
|
|||
entry.directory_index = value.as_unsigned();
|
||||
break;
|
||||
default:
|
||||
dbgln_if(DWARF_DEBUG, "Unhandled path list attribute: {}", (int)format_description.type);
|
||||
dbgln_if(DWARF_DEBUG, "Unhandled path list attribute: {}", to_underlying(format_description.type));
|
||||
}
|
||||
}
|
||||
callback(entry);
|
||||
|
@ -280,7 +280,7 @@ void LineProgram::run_program()
|
|||
{
|
||||
reset_registers();
|
||||
|
||||
while ((size_t)m_stream.offset() < m_unit_offset + sizeof(u32) + m_unit_header.length()) {
|
||||
while (m_stream.offset() < m_unit_offset + sizeof(u32) + m_unit_header.length()) {
|
||||
u8 opcode = 0;
|
||||
m_stream >> opcode;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue