mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:37:34 +00:00
LibDebug: Convert LibDebug to east-const style
This commit is contained in:
parent
03ef2a479a
commit
3a4017b419
17 changed files with 68 additions and 68 deletions
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
AbbreviationsMap::AbbreviationsMap(const DwarfInfo& dwarf_info, u32 offset)
|
||||
AbbreviationsMap::AbbreviationsMap(DwarfInfo const& dwarf_info, u32 offset)
|
||||
: m_dwarf_info(dwarf_info)
|
||||
, m_offset(offset)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ class DwarfInfo;
|
|||
|
||||
class AbbreviationsMap {
|
||||
public:
|
||||
AbbreviationsMap(const DwarfInfo& dwarf_info, u32 offset);
|
||||
AbbreviationsMap(DwarfInfo const& dwarf_info, u32 offset);
|
||||
|
||||
struct AbbreviationEntry {
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
private:
|
||||
void populate_map();
|
||||
|
||||
const DwarfInfo& m_dwarf_info;
|
||||
DwarfInfo const& m_dwarf_info;
|
||||
u32 m_offset { 0 };
|
||||
HashMap<u32, AbbreviationEntry> m_entries;
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
CompilationUnit::CompilationUnit(const DwarfInfo& dwarf_info, u32 offset, const CompilationUnitHeader& header, NonnullOwnPtr<LineProgram>&& line_program)
|
||||
CompilationUnit::CompilationUnit(DwarfInfo const& dwarf_info, u32 offset, CompilationUnitHeader const& header, NonnullOwnPtr<LineProgram>&& line_program)
|
||||
: m_dwarf_info(dwarf_info)
|
||||
, m_offset(offset)
|
||||
, m_header(header)
|
||||
|
|
|
@ -23,7 +23,7 @@ class CompilationUnit {
|
|||
AK_MAKE_NONMOVABLE(CompilationUnit);
|
||||
|
||||
public:
|
||||
CompilationUnit(const DwarfInfo& dwarf_info, u32 offset, const CompilationUnitHeader&, NonnullOwnPtr<LineProgram>&& line_program);
|
||||
CompilationUnit(DwarfInfo const& dwarf_info, u32 offset, CompilationUnitHeader const&, NonnullOwnPtr<LineProgram>&& line_program);
|
||||
|
||||
u32 offset() const { return m_offset; }
|
||||
u32 size() const { return m_header.length() + sizeof(u32); }
|
||||
|
@ -31,12 +31,12 @@ public:
|
|||
DIE root_die() const;
|
||||
DIE get_die_at_offset(u32 offset) const;
|
||||
|
||||
const DwarfInfo& dwarf_info() const { return m_dwarf_info; }
|
||||
const AbbreviationsMap& abbreviations_map() const { return m_abbreviations; }
|
||||
const LineProgram& line_program() const { return *m_line_program; }
|
||||
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; }
|
||||
|
||||
private:
|
||||
const DwarfInfo& m_dwarf_info;
|
||||
DwarfInfo const& m_dwarf_info;
|
||||
u32 m_offset { 0 };
|
||||
CompilationUnitHeader m_header;
|
||||
AbbreviationsMap m_abbreviations;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
DIE::DIE(const CompilationUnit& unit, u32 offset, Optional<u32> parent_offset)
|
||||
DIE::DIE(CompilationUnit const& unit, u32 offset, Optional<u32> parent_offset)
|
||||
: m_compilation_unit(unit)
|
||||
, m_offset(offset)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ DIE::DIE(const CompilationUnit& unit, u32 offset, Optional<u32> parent_offset)
|
|||
m_parent_offset = parent_offset;
|
||||
}
|
||||
|
||||
Optional<AttributeValue> DIE::get_attribute(const Attribute& attribute) const
|
||||
Optional<AttributeValue> DIE::get_attribute(Attribute const& attribute) const
|
||||
{
|
||||
InputMemoryStream stream { m_compilation_unit.dwarf_info().debug_info_data() };
|
||||
stream.discard_or_error(m_data_offset);
|
||||
|
@ -57,7 +57,7 @@ Optional<AttributeValue> DIE::get_attribute(const Attribute& attribute) const
|
|||
return {};
|
||||
}
|
||||
|
||||
void DIE::for_each_child(Function<void(const DIE& child)> callback) const
|
||||
void DIE::for_each_child(Function<void(DIE const& child)> callback) const
|
||||
{
|
||||
if (!m_has_children)
|
||||
return;
|
||||
|
@ -81,7 +81,7 @@ void DIE::for_each_child(Function<void(const DIE& child)> callback) const
|
|||
if (!sibling.has_value()) {
|
||||
// NOTE: According to the spec, the compiler doesn't have to supply the sibling information.
|
||||
// When it doesn't, we have to recursively iterate the current child's children to find where they end
|
||||
current_child->for_each_child([&](const DIE& sub_child) {
|
||||
current_child->for_each_child([&](DIE const& sub_child) {
|
||||
sibling_offset = sub_child.offset() + sub_child.size();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,23 +20,23 @@ class CompilationUnit;
|
|||
// DIE = Debugging Information Entry
|
||||
class DIE {
|
||||
public:
|
||||
DIE(const CompilationUnit&, u32 offset, Optional<u32> parent_offset = {});
|
||||
DIE(CompilationUnit const&, u32 offset, Optional<u32> parent_offset = {});
|
||||
|
||||
u32 offset() const { return m_offset; }
|
||||
u32 size() const { return m_size; }
|
||||
bool has_children() const { return m_has_children; }
|
||||
EntryTag tag() const { return m_tag; }
|
||||
|
||||
Optional<AttributeValue> get_attribute(const Attribute&) const;
|
||||
Optional<AttributeValue> get_attribute(Attribute const&) const;
|
||||
|
||||
void for_each_child(Function<void(const DIE& child)> callback) const;
|
||||
void for_each_child(Function<void(DIE const& child)> callback) const;
|
||||
|
||||
bool is_null() const { return m_tag == EntryTag::None; }
|
||||
const CompilationUnit& compilation_unit() const { return m_compilation_unit; }
|
||||
CompilationUnit const& compilation_unit() const { return m_compilation_unit; }
|
||||
Optional<u32> parent_offset() const { return m_parent_offset; }
|
||||
|
||||
private:
|
||||
const CompilationUnit& m_compilation_unit;
|
||||
CompilationUnit const& m_compilation_unit;
|
||||
u32 m_offset { 0 };
|
||||
u32 m_data_offset { 0 };
|
||||
size_t m_abbreviation_code { 0 };
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace Debug::Dwarf {
|
||||
|
||||
DwarfInfo::DwarfInfo(const ELF::Image& elf)
|
||||
DwarfInfo::DwarfInfo(ELF::Image const& elf)
|
||||
: m_elf(elf)
|
||||
{
|
||||
m_debug_info_data = section_data(".debug_info"sv);
|
||||
|
@ -25,7 +25,7 @@ DwarfInfo::DwarfInfo(const ELF::Image& elf)
|
|||
populate_compilation_units();
|
||||
}
|
||||
|
||||
ReadonlyBytes DwarfInfo::section_data(const StringView& section_name) const
|
||||
ReadonlyBytes DwarfInfo::section_data(StringView const& section_name) const
|
||||
{
|
||||
auto section = m_elf.lookup_section(section_name);
|
||||
if (!section.has_value())
|
||||
|
@ -237,11 +237,11 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im
|
|||
|
||||
void DwarfInfo::build_cached_dies() const
|
||||
{
|
||||
auto insert_to_cache = [this](const DIE& die, DIERange& range) {
|
||||
auto insert_to_cache = [this](DIE const& die, DIERange const& range) {
|
||||
m_cached_dies_by_range.insert(range.start_address, DIEAndRange { die, range });
|
||||
m_cached_dies_by_offset.insert(die.offset(), die);
|
||||
};
|
||||
auto get_ranges_of_die = [this](const DIE& die) -> Vector<DIERange> {
|
||||
auto get_ranges_of_die = [this](DIE const& die) -> Vector<DIERange> {
|
||||
// TODO support DW_AT_ranges (appears when range is non-contiguous)
|
||||
|
||||
auto start = die.get_attribute(Attribute::LowPc);
|
||||
|
@ -266,22 +266,22 @@ void DwarfInfo::build_cached_dies() const
|
|||
};
|
||||
|
||||
// If we simply use a lambda, type deduction fails because it's used recursively.
|
||||
Function<void(const DIE& die)> insert_to_cache_recursively;
|
||||
insert_to_cache_recursively = [&](const DIE& die) {
|
||||
Function<void(DIE const& die)> insert_to_cache_recursively;
|
||||
insert_to_cache_recursively = [&](DIE const& die) {
|
||||
if (die.offset() == 0 || die.parent_offset().has_value()) {
|
||||
auto ranges = get_ranges_of_die(die);
|
||||
for (auto& range : ranges) {
|
||||
insert_to_cache(die, range);
|
||||
}
|
||||
}
|
||||
die.for_each_child([&](const DIE& child) {
|
||||
die.for_each_child([&](DIE const& child) {
|
||||
if (!child.is_null()) {
|
||||
insert_to_cache_recursively(child);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
for_each_compilation_unit([&](const CompilationUnit& compilation_unit) {
|
||||
for_each_compilation_unit([&](CompilationUnit const& compilation_unit) {
|
||||
insert_to_cache_recursively(compilation_unit.root_die());
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class DwarfInfo {
|
|||
AK_MAKE_NONMOVABLE(DwarfInfo);
|
||||
|
||||
public:
|
||||
explicit DwarfInfo(const ELF::Image&);
|
||||
explicit DwarfInfo(ELF::Image const&);
|
||||
|
||||
ReadonlyBytes debug_info_data() const { return m_debug_info_data; }
|
||||
ReadonlyBytes abbreviation_data() const { return m_abbreviation_data; }
|
||||
|
@ -50,9 +50,9 @@ private:
|
|||
void populate_compilation_units();
|
||||
void build_cached_dies() const;
|
||||
|
||||
ReadonlyBytes section_data(const StringView& section_name) const;
|
||||
ReadonlyBytes section_data(StringView const& section_name) const;
|
||||
|
||||
const ELF::Image& m_elf;
|
||||
ELF::Image const& m_elf;
|
||||
ReadonlyBytes m_debug_info_data;
|
||||
ReadonlyBytes m_abbreviation_data;
|
||||
ReadonlyBytes m_debug_strings_data;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Debug::Dwarf::Expression {
|
||||
|
||||
Value evaluate(ReadonlyBytes bytes, const PtraceRegisters& regs)
|
||||
Value evaluate(ReadonlyBytes bytes, PtraceRegisters const& regs)
|
||||
{
|
||||
InputMemoryStream stream(bytes);
|
||||
|
||||
|
|
|
@ -31,6 +31,6 @@ enum class Operations : u8 {
|
|||
FbReg = 0x91,
|
||||
};
|
||||
|
||||
Value evaluate(ReadonlyBytes, const PtraceRegisters&);
|
||||
Value evaluate(ReadonlyBytes, PtraceRegisters const&);
|
||||
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
size_t line { 0 };
|
||||
};
|
||||
|
||||
const Vector<LineInfo>& lines() const { return m_lines; }
|
||||
Vector<LineInfo> const& lines() const { return m_lines; }
|
||||
|
||||
struct DirectoryAndFile {
|
||||
FlyString directory;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue