summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibDebug
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibDebug')
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp18
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/AddressRanges.h1
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/DIE.cpp18
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp22
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/Expression.cpp6
5 files changed, 33 insertions, 32 deletions
diff --git a/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp b/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp
index e8c263ffa6..67f926a43e 100644
--- a/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp
@@ -21,19 +21,19 @@ AbbreviationsMap::AbbreviationsMap(DwarfInfo const& dwarf_info, u32 offset)
ErrorOr<void> AbbreviationsMap::populate_map()
{
- auto abbreviation_stream = TRY(FixedMemoryStream::construct(m_dwarf_info.abbreviation_data()));
- TRY(abbreviation_stream->discard(m_offset));
+ FixedMemoryStream abbreviation_stream { m_dwarf_info.abbreviation_data() };
+ TRY(abbreviation_stream.discard(m_offset));
- while (!abbreviation_stream->is_eof()) {
- size_t abbreviation_code = TRY(abbreviation_stream->read_value<LEB128<size_t>>());
+ while (!abbreviation_stream.is_eof()) {
+ size_t abbreviation_code = TRY(abbreviation_stream.read_value<LEB128<size_t>>());
// An abbreviation code of 0 marks the end of the
// abbreviations for a given compilation unit
if (abbreviation_code == 0)
break;
- size_t tag = TRY(abbreviation_stream->read_value<LEB128<size_t>>());
+ size_t tag = TRY(abbreviation_stream.read_value<LEB128<size_t>>());
- auto has_children = TRY(abbreviation_stream->read_value<u8>());
+ auto has_children = TRY(abbreviation_stream.read_value<u8>());
AbbreviationEntry abbreviation_entry {};
abbreviation_entry.tag = static_cast<EntryTag>(tag);
@@ -41,14 +41,14 @@ ErrorOr<void> AbbreviationsMap::populate_map()
AttributeSpecification current_attribute_specification {};
do {
- size_t attribute_value = TRY(abbreviation_stream->read_value<LEB128<size_t>>());
- size_t form_value = TRY(abbreviation_stream->read_value<LEB128<size_t>>());
+ size_t attribute_value = TRY(abbreviation_stream.read_value<LEB128<size_t>>());
+ size_t form_value = TRY(abbreviation_stream.read_value<LEB128<size_t>>());
current_attribute_specification.attribute = static_cast<Attribute>(attribute_value);
current_attribute_specification.form = static_cast<AttributeDataForm>(form_value);
if (current_attribute_specification.form == AttributeDataForm::ImplicitConst) {
- ssize_t data_value = TRY(abbreviation_stream->read_value<LEB128<ssize_t>>());
+ ssize_t data_value = TRY(abbreviation_stream.read_value<LEB128<ssize_t>>());
current_attribute_specification.value = data_value;
}
diff --git a/Userland/Libraries/LibDebug/Dwarf/AddressRanges.h b/Userland/Libraries/LibDebug/Dwarf/AddressRanges.h
index 4f4a82985f..7849b9778d 100644
--- a/Userland/Libraries/LibDebug/Dwarf/AddressRanges.h
+++ b/Userland/Libraries/LibDebug/Dwarf/AddressRanges.h
@@ -24,6 +24,7 @@ class AddressRangesV5 {
AK_MAKE_NONMOVABLE(AddressRangesV5);
public:
+ // FIXME: This should be fine with using a non-owned stream.
AddressRangesV5(NonnullOwnPtr<AK::Stream> range_lists_stream, CompilationUnit const& compilation_unit);
ErrorOr<void> for_each_range(Function<void(Range)>);
diff --git a/Userland/Libraries/LibDebug/Dwarf/DIE.cpp b/Userland/Libraries/LibDebug/Dwarf/DIE.cpp
index a9e0cef979..2d2c5154c1 100644
--- a/Userland/Libraries/LibDebug/Dwarf/DIE.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/DIE.cpp
@@ -23,11 +23,11 @@ ErrorOr<void> DIE::rehydrate_from(u32 offset, Optional<u32> parent_offset)
{
m_offset = offset;
- auto stream = TRY(FixedMemoryStream::construct(m_compilation_unit.dwarf_info().debug_info_data()));
+ FixedMemoryStream stream { m_compilation_unit.dwarf_info().debug_info_data() };
// Note: We can't just slice away from the input data here, since get_attribute_value will try to recover the original offset using seek().
- TRY(stream->seek(m_offset));
- m_abbreviation_code = TRY(stream->read_value<LEB128<size_t>>());
- m_data_offset = TRY(stream->tell());
+ TRY(stream.seek(m_offset));
+ m_abbreviation_code = TRY(stream.read_value<LEB128<size_t>>());
+ m_data_offset = TRY(stream.tell());
if (m_abbreviation_code == 0) {
// An abbreviation code of 0 ( = null DIE entry) means the end of a chain of siblings
@@ -41,25 +41,25 @@ ErrorOr<void> DIE::rehydrate_from(u32 offset, Optional<u32> parent_offset)
// We iterate the attributes data only to calculate this DIE's size
for (auto& attribute_spec : abbreviation_info->attribute_specifications) {
- TRY(m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, *stream, &m_compilation_unit));
+ TRY(m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, stream, &m_compilation_unit));
}
}
- m_size = TRY(stream->tell()) - m_offset;
+ m_size = TRY(stream.tell()) - m_offset;
m_parent_offset = parent_offset;
return {};
}
ErrorOr<Optional<AttributeValue>> DIE::get_attribute(Attribute const& attribute) const
{
- auto stream = TRY(FixedMemoryStream::construct(m_compilation_unit.dwarf_info().debug_info_data()));
+ FixedMemoryStream stream { m_compilation_unit.dwarf_info().debug_info_data() };
// Note: We can't just slice away from the input data here, since get_attribute_value will try to recover the original offset using seek().
- TRY(stream->seek(m_data_offset));
+ TRY(stream.seek(m_data_offset));
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
VERIFY(abbreviation_info);
for (auto const& attribute_spec : abbreviation_info->attribute_specifications) {
- auto value = TRY(m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, *stream, &m_compilation_unit));
+ auto value = TRY(m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, stream, &m_compilation_unit));
if (attribute_spec.attribute == attribute) {
return value;
}
diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
index b4b519cdaf..6d52ecf8b7 100644
--- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp
@@ -47,35 +47,35 @@ ErrorOr<void> DwarfInfo::populate_compilation_units()
if (!m_debug_info_data.data())
return {};
- auto debug_info_stream = TRY(FixedMemoryStream::construct(m_debug_info_data));
- auto line_info_stream = TRY(FixedMemoryStream::construct(m_debug_line_data));
+ FixedMemoryStream debug_info_stream { m_debug_info_data };
+ FixedMemoryStream line_info_stream { m_debug_line_data };
- while (!debug_info_stream->is_eof()) {
- auto unit_offset = TRY(debug_info_stream->tell());
+ while (!debug_info_stream.is_eof()) {
+ auto unit_offset = TRY(debug_info_stream.tell());
- auto compilation_unit_header = TRY(debug_info_stream->read_value<CompilationUnitHeader>());
+ auto compilation_unit_header = TRY(debug_info_stream.read_value<CompilationUnitHeader>());
VERIFY(compilation_unit_header.common.version <= 5);
VERIFY(compilation_unit_header.address_size() == sizeof(FlatPtr));
u32 length_after_header = compilation_unit_header.length() - (compilation_unit_header.header_size() - offsetof(CompilationUnitHeader, common.version));
- auto line_program = make<LineProgram>(*this, *line_info_stream);
+ auto line_program = make<LineProgram>(*this, line_info_stream);
// HACK: Clang generates line programs for embedded resource assembly files, but not compile units.
// Meaning that for graphical applications, some line info data would be unread, triggering the assertion below.
// As a fix, we don't create compilation units for line programs that come from resource files.
#if defined(AK_COMPILER_CLANG)
if (line_program->looks_like_embedded_resource()) {
- TRY(debug_info_stream->seek(unit_offset));
+ TRY(debug_info_stream.seek(unit_offset));
} else
#endif
{
m_compilation_units.append(make<CompilationUnit>(*this, unit_offset, compilation_unit_header, move(line_program)));
- TRY(debug_info_stream->discard(length_after_header));
+ TRY(debug_info_stream.discard(length_after_header));
}
}
- VERIFY(line_info_stream->is_eof());
+ VERIFY(line_info_stream.is_eof());
return {};
}
@@ -300,14 +300,14 @@ ErrorOr<void> DwarfInfo::build_cached_dies() const
Vector<DIERange> entries;
if (die.compilation_unit().dwarf_version() == 5) {
- auto range_lists_stream = TRY(FixedMemoryStream::construct(debug_range_lists_data()));
+ auto range_lists_stream = TRY(try_make<FixedMemoryStream>(debug_range_lists_data()));
TRY(range_lists_stream->seek(offset));
AddressRangesV5 address_ranges(move(range_lists_stream), die.compilation_unit());
TRY(address_ranges.for_each_range([&entries](auto range) {
entries.empend(range.start, range.end);
}));
} else {
- auto ranges_stream = TRY(FixedMemoryStream::construct(debug_ranges_data()));
+ auto ranges_stream = TRY(try_make<FixedMemoryStream>(debug_ranges_data()));
TRY(ranges_stream->seek(offset));
AddressRangesV4 address_ranges(move(ranges_stream), die.compilation_unit());
TRY(address_ranges.for_each_range([&entries](auto range) {
diff --git a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp b/Userland/Libraries/LibDebug/Dwarf/Expression.cpp
index 373bf26940..30f45f6e4b 100644
--- a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/Expression.cpp
@@ -14,10 +14,10 @@ namespace Debug::Dwarf::Expression {
ErrorOr<Value> evaluate(ReadonlyBytes bytes, [[maybe_unused]] PtraceRegisters const& regs)
{
- auto stream = TRY(FixedMemoryStream::construct(bytes));
+ FixedMemoryStream stream { bytes };
- while (!stream->is_eof()) {
- auto opcode = TRY(stream->read_value<u8>());
+ while (!stream.is_eof()) {
+ auto opcode = TRY(stream.read_value<u8>());
switch (static_cast<Operations>(opcode)) {