summaryrefslogtreecommitdiff
path: root/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibDebug/Dwarf/DwarfInfo.cpp')
-rw-r--r--Libraries/LibDebug/Dwarf/DwarfInfo.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/Libraries/LibDebug/Dwarf/DwarfInfo.cpp b/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
index e105099b4c..2c81e3e059 100644
--- a/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
+++ b/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
@@ -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);
}
}