LibELF+LibDebug: Remove use of ByteBuffer::wrap()
This commit is contained in:
parent
685d5f4e25
commit
7c94856c12
Notes:
sideshowbarker
2024-07-19 00:44:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7c94856c12d
4 changed files with 12 additions and 13 deletions
|
@ -106,8 +106,7 @@ void DebugInfo::prepare_lines()
|
|||
if (section.is_undefined())
|
||||
return;
|
||||
|
||||
auto buffer = section.wrapping_byte_buffer();
|
||||
InputMemoryStream stream { buffer };
|
||||
InputMemoryStream stream { section.bytes() };
|
||||
|
||||
Vector<Dwarf::LineProgram::LineInfo> all_lines;
|
||||
while (!stream.eof()) {
|
||||
|
|
|
@ -40,17 +40,17 @@ DwarfInfo::DwarfInfo(NonnullRefPtr<const ELF::Loader> elf)
|
|||
populate_compilation_units();
|
||||
}
|
||||
|
||||
ByteBuffer DwarfInfo::section_data(const String& section_name)
|
||||
ReadonlyBytes DwarfInfo::section_data(const String& section_name) const
|
||||
{
|
||||
auto section = m_elf->image().lookup_section(section_name);
|
||||
if (section.is_undefined())
|
||||
return {};
|
||||
return section.wrapping_byte_buffer();
|
||||
return section.bytes();
|
||||
}
|
||||
|
||||
void DwarfInfo::populate_compilation_units()
|
||||
{
|
||||
if (m_debug_info_data.is_null())
|
||||
if (!m_debug_info_data.data())
|
||||
return;
|
||||
|
||||
InputMemoryStream stream { m_debug_info_data };
|
||||
|
|
|
@ -40,9 +40,9 @@ class DwarfInfo : public RefCounted<DwarfInfo> {
|
|||
public:
|
||||
static NonnullRefPtr<DwarfInfo> create(NonnullRefPtr<const ELF::Loader> elf) { return adopt(*new DwarfInfo(move(elf))); }
|
||||
|
||||
const ByteBuffer& debug_info_data() const { return m_debug_info_data; }
|
||||
const ByteBuffer& abbreviation_data() const { return m_abbreviation_data; }
|
||||
const ByteBuffer& debug_strings_data() const { return m_debug_strings_data; }
|
||||
ReadonlyBytes debug_info_data() const { return m_debug_info_data; }
|
||||
ReadonlyBytes abbreviation_data() const { return m_abbreviation_data; }
|
||||
ReadonlyBytes debug_strings_data() const { return m_debug_strings_data; }
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_compilation_unit(Callback) const;
|
||||
|
@ -51,12 +51,12 @@ private:
|
|||
explicit DwarfInfo(NonnullRefPtr<const ELF::Loader> elf);
|
||||
void populate_compilation_units();
|
||||
|
||||
ByteBuffer section_data(const String& section_name);
|
||||
ReadonlyBytes section_data(const String& section_name) const;
|
||||
|
||||
NonnullRefPtr<const ELF::Loader> m_elf;
|
||||
ByteBuffer m_debug_info_data;
|
||||
ByteBuffer m_abbreviation_data;
|
||||
ByteBuffer m_debug_strings_data;
|
||||
ReadonlyBytes m_debug_info_data;
|
||||
ReadonlyBytes m_abbreviation_data;
|
||||
ReadonlyBytes m_debug_strings_data;
|
||||
|
||||
Vector<Dwarf::CompilationUnit> m_compilation_units;
|
||||
};
|
||||
|
|
|
@ -132,7 +132,7 @@ public:
|
|||
unsigned entry_count() const { return !entry_size() ? 0 : size() / entry_size(); }
|
||||
u32 address() const { return m_section_header.sh_addr; }
|
||||
const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); }
|
||||
ByteBuffer wrapping_byte_buffer() { return ByteBuffer::wrap(const_cast<char*>(raw_data()), size()); }
|
||||
ReadonlyBytes bytes() const { return { raw_data(), size() }; }
|
||||
bool is_undefined() const { return m_section_index == SHN_UNDEF; }
|
||||
const RelocationSection relocations() const;
|
||||
u32 flags() const { return m_section_header.sh_flags; }
|
||||
|
|
Loading…
Add table
Reference in a new issue