mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-26 20:23:09 +00:00
LibDebug: Use InputMemoryStream instead of BufferStream.
This removes another call to ByteBuffer::wrap(const void*, size_t).
This commit is contained in:
parent
5bfa7749c3
commit
ac9f6fd1f8
Notes:
sideshowbarker
2024-07-19 04:14:19 +09:00
Author: https://github.com/asynts
Commit: ac9f6fd1f8
Pull-request: https://github.com/SerenityOS/serenity/pull/3007
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/nico
12 changed files with 125 additions and 106 deletions
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "DwarfInfo.h"
|
||||
|
||||
#include <AK/Stream.h>
|
||||
|
||||
namespace Dwarf {
|
||||
|
||||
DwarfInfo::DwarfInfo(NonnullRefPtr<const ELF::Loader> elf)
|
||||
|
@ -50,22 +52,19 @@ void DwarfInfo::populate_compilation_units()
|
|||
{
|
||||
if (m_debug_info_data.is_null())
|
||||
return;
|
||||
// We have to const_cast here because there isn't a version of
|
||||
// BufferStream that accepts a const ByteStream
|
||||
// We take care not to use BufferStream operations that modify the underlying buffer
|
||||
// TOOD: Add a variant of BufferStream that operates on a const ByteBuffer to AK
|
||||
BufferStream stream(const_cast<ByteBuffer&>(m_debug_info_data));
|
||||
while (!stream.at_end()) {
|
||||
|
||||
InputMemoryStream stream(m_debug_info_data.span());
|
||||
while (!stream.eof()) {
|
||||
auto unit_offset = stream.offset();
|
||||
CompilationUnitHeader compilation_unit_header {};
|
||||
|
||||
stream.read_raw(reinterpret_cast<u8*>(&compilation_unit_header), sizeof(CompilationUnitHeader));
|
||||
stream >> Bytes { &compilation_unit_header, sizeof(compilation_unit_header) };
|
||||
ASSERT(compilation_unit_header.address_size == sizeof(u32));
|
||||
ASSERT(compilation_unit_header.version == 4);
|
||||
|
||||
u32 length_after_header = compilation_unit_header.length - (sizeof(CompilationUnitHeader) - offsetof(CompilationUnitHeader, version));
|
||||
m_compilation_units.empend(*this, unit_offset, compilation_unit_header);
|
||||
stream.advance(length_after_header);
|
||||
stream.discard_or_error(length_after_header);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue