mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibDebug: Propagate errors throughout DWARF parsing
Splitting this into a separate commit was an afterthought, so this does not yet feature any fallible operations.
This commit is contained in:
parent
e235c42e4d
commit
e62269650a
17 changed files with 243 additions and 204 deletions
|
@ -40,27 +40,27 @@ LineProgram const& CompilationUnit::line_program() const
|
|||
return *m_line_program;
|
||||
}
|
||||
|
||||
Optional<FlatPtr> CompilationUnit::base_address() const
|
||||
ErrorOr<Optional<FlatPtr>> CompilationUnit::base_address() const
|
||||
{
|
||||
if (m_has_cached_base_address)
|
||||
return m_cached_base_address;
|
||||
|
||||
auto die = root_die();
|
||||
auto res = die.get_attribute(Attribute::LowPc);
|
||||
auto res = TRY(die.get_attribute(Attribute::LowPc));
|
||||
if (res.has_value()) {
|
||||
m_cached_base_address = res->as_addr();
|
||||
m_cached_base_address = TRY(res->as_addr());
|
||||
}
|
||||
m_has_cached_base_address = true;
|
||||
return m_cached_base_address;
|
||||
}
|
||||
|
||||
u64 CompilationUnit::address_table_base() const
|
||||
ErrorOr<u64> CompilationUnit::address_table_base() const
|
||||
{
|
||||
if (m_has_cached_address_table_base)
|
||||
return m_cached_address_table_base;
|
||||
|
||||
auto die = root_die();
|
||||
auto res = die.get_attribute(Attribute::AddrBase);
|
||||
auto res = TRY(die.get_attribute(Attribute::AddrBase));
|
||||
if (res.has_value()) {
|
||||
VERIFY(res->form() == AttributeDataForm::SecOffset);
|
||||
m_cached_address_table_base = res->as_unsigned();
|
||||
|
@ -69,13 +69,13 @@ u64 CompilationUnit::address_table_base() const
|
|||
return m_cached_address_table_base;
|
||||
}
|
||||
|
||||
u64 CompilationUnit::string_offsets_base() const
|
||||
ErrorOr<u64> CompilationUnit::string_offsets_base() const
|
||||
{
|
||||
if (m_has_cached_string_offsets_base)
|
||||
return m_cached_string_offsets_base;
|
||||
|
||||
auto die = root_die();
|
||||
auto res = die.get_attribute(Attribute::StrOffsetsBase);
|
||||
auto res = TRY(die.get_attribute(Attribute::StrOffsetsBase));
|
||||
if (res.has_value()) {
|
||||
VERIFY(res->form() == AttributeDataForm::SecOffset);
|
||||
m_cached_string_offsets_base = res->as_unsigned();
|
||||
|
@ -84,13 +84,13 @@ u64 CompilationUnit::string_offsets_base() const
|
|||
return m_cached_string_offsets_base;
|
||||
}
|
||||
|
||||
u64 CompilationUnit::range_lists_base() const
|
||||
ErrorOr<u64> CompilationUnit::range_lists_base() const
|
||||
{
|
||||
if (m_has_cached_range_lists_base)
|
||||
return m_cached_range_lists_base;
|
||||
|
||||
auto die = root_die();
|
||||
auto res = die.get_attribute(Attribute::RngListsBase);
|
||||
auto res = TRY(die.get_attribute(Attribute::RngListsBase));
|
||||
if (res.has_value()) {
|
||||
VERIFY(res->form() == AttributeDataForm::SecOffset);
|
||||
m_cached_range_lists_base = res->as_unsigned();
|
||||
|
@ -99,9 +99,9 @@ u64 CompilationUnit::range_lists_base() const
|
|||
return m_cached_range_lists_base;
|
||||
}
|
||||
|
||||
FlatPtr CompilationUnit::get_address(size_t index) const
|
||||
ErrorOr<FlatPtr> CompilationUnit::get_address(size_t index) const
|
||||
{
|
||||
auto base = address_table_base();
|
||||
auto base = TRY(address_table_base());
|
||||
auto debug_addr_data = dwarf_info().debug_addr_data();
|
||||
VERIFY(base < debug_addr_data.size());
|
||||
auto addresses = debug_addr_data.slice(base);
|
||||
|
@ -111,9 +111,9 @@ FlatPtr CompilationUnit::get_address(size_t index) const
|
|||
return value;
|
||||
}
|
||||
|
||||
char const* CompilationUnit::get_string(size_t index) const
|
||||
ErrorOr<char const*> CompilationUnit::get_string(size_t index) const
|
||||
{
|
||||
auto base = string_offsets_base();
|
||||
auto base = TRY(string_offsets_base());
|
||||
auto debug_str_offsets_data = dwarf_info().debug_str_offsets_data();
|
||||
VERIFY(base < debug_str_offsets_data.size());
|
||||
// FIXME: This assumes DWARF32
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue