mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibDebug: Add Dwarf::CompilationUnit::base_address()
The base address of the compilation unit is used in some range lists entry types.
This commit is contained in:
parent
01417c82c5
commit
2b04a86d4d
2 changed files with 17 additions and 0 deletions
|
@ -30,4 +30,18 @@ DIE CompilationUnit::get_die_at_offset(u32 die_offset) const
|
|||
return DIE(*this, die_offset);
|
||||
}
|
||||
|
||||
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);
|
||||
if (res.has_value()) {
|
||||
m_cached_base_address = res->data.as_addr;
|
||||
}
|
||||
m_has_cached_base_address = true;
|
||||
return m_cached_base_address;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
DwarfInfo const& dwarf_info() const { return m_dwarf_info; }
|
||||
AbbreviationsMap const& abbreviations_map() const { return m_abbreviations; }
|
||||
LineProgram const& line_program() const { return *m_line_program; }
|
||||
Optional<FlatPtr> base_address() const;
|
||||
|
||||
private:
|
||||
DwarfInfo const& m_dwarf_info;
|
||||
|
@ -41,6 +42,8 @@ private:
|
|||
CompilationUnitHeader m_header;
|
||||
AbbreviationsMap m_abbreviations;
|
||||
NonnullOwnPtr<LineProgram> m_line_program;
|
||||
mutable bool m_has_cached_base_address { false };
|
||||
mutable Optional<FlatPtr> m_cached_base_address;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue