diff options
author | MacDue <macdue@dueutil.tech> | 2023-05-06 19:33:53 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-14 09:21:08 +0200 |
commit | cf79df0edb78abae8d8b7f77513b60af9a02c513 (patch) | |
tree | 5db78b3c5888bce994c969e4ba78c5a9c759674d /Userland/Libraries | |
parent | ce634957c1bd25fdcc39c4e0321bcdf1cc332d60 (diff) | |
download | serenity-cf79df0edb78abae8d8b7f77513b60af9a02c513.zip |
LibDebug: Stub out LocListX and remove stub expression evaluator
The expression evaluator is dead code that does nothing but crash on
all paths, as no opcodes are implemented.
Stubbing out the LocListX form fixes a crash while reading DWARF 5
debug data that contains location lists. These are just a new way
to store location expressions, and since we never implemented
expressions, we can just ignore these too.
As far as I can tell this is enough for DWARF 5 to work for us (since
we mainly just use the line tables).
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibDebug/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibDebug/DebugInfo.cpp | 18 | ||||
-rw-r--r-- | Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibDebug/Dwarf/Expression.cpp | 33 | ||||
-rw-r--r-- | Userland/Libraries/LibDebug/Dwarf/Expression.h | 37 |
5 files changed, 6 insertions, 84 deletions
diff --git a/Userland/Libraries/LibDebug/CMakeLists.txt b/Userland/Libraries/LibDebug/CMakeLists.txt index fbfc578171..b708019722 100644 --- a/Userland/Libraries/LibDebug/CMakeLists.txt +++ b/Userland/Libraries/LibDebug/CMakeLists.txt @@ -7,7 +7,6 @@ set(SOURCES Dwarf/CompilationUnit.cpp Dwarf/DIE.cpp Dwarf/DwarfInfo.cpp - Dwarf/Expression.cpp Dwarf/LineProgram.cpp ProcessInspector.cpp StackFrameUtils.cpp diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index b437a063f3..88eb5a7044 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -10,7 +10,6 @@ #include <AK/QuickSort.h> #include <LibDebug/Dwarf/CompilationUnit.h> #include <LibDebug/Dwarf/DwarfInfo.h> -#include <LibDebug/Dwarf/Expression.h> namespace Debug { @@ -207,7 +206,7 @@ static ErrorOr<Optional<Dwarf::DIE>> parse_variable_type_die(Dwarf::DIE const& v return type_die; } -static ErrorOr<void> parse_variable_location(Dwarf::DIE const& variable_die, DebugInfo::VariableInfo& variable_info, PtraceRegisters const& regs) +static ErrorOr<void> parse_variable_location(Dwarf::DIE const& variable_die, DebugInfo::VariableInfo& variable_info, PtraceRegisters const&) { auto location_info = TRY(variable_die.get_attribute(Dwarf::Attribute::Location)); if (!location_info.has_value()) { @@ -219,20 +218,13 @@ static ErrorOr<void> parse_variable_location(Dwarf::DIE const& variable_die, Deb switch (location_info.value().type()) { case Dwarf::AttributeValue::Type::UnsignedNumber: - variable_info.location_type = DebugInfo::VariableInfo::LocationType::Address; - variable_info.location_data.address = location_info.value().as_unsigned(); - break; - case Dwarf::AttributeValue::Type::DwarfExpression: { - auto expression_bytes = location_info.value().as_raw_bytes(); - auto value = TRY(Dwarf::Expression::evaluate(expression_bytes, regs)); - - if (value.type != Dwarf::Expression::Type::None) { - VERIFY(value.type == Dwarf::Expression::Type::UnsignedInteger); + if (location_info->form() != Dwarf::AttributeDataForm::LocListX) { variable_info.location_type = DebugInfo::VariableInfo::LocationType::Address; - variable_info.location_data.address = value.data.as_addr; + variable_info.location_data.address = location_info.value().as_unsigned(); + } else { + dbgln("Warning: unsupported Dwarf 5 loclist"); } break; - } default: dbgln("Warning: unhandled Dwarf location type: {}", to_underlying(location_info.value().type())); } diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp index 9f73930468..230ac015b7 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp @@ -272,6 +272,7 @@ ErrorOr<AttributeValue> DwarfInfo::get_attribute_value(AttributeDataForm form, s value.m_data.as_unsigned = index; break; } + case AttributeDataForm::LocListX: case AttributeDataForm::RngListX: { size_t index = TRY(debug_info_stream.read_value<LEB128<size_t>>()); value.m_type = AttributeValue::Type::UnsignedNumber; diff --git a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp b/Userland/Libraries/LibDebug/Dwarf/Expression.cpp deleted file mode 100644 index 30f45f6e4b..0000000000 --- a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include "Expression.h" - -#include <AK/Format.h> -#include <AK/MemoryStream.h> -#include <sys/arch/regs.h> - -namespace Debug::Dwarf::Expression { - -ErrorOr<Value> evaluate(ReadonlyBytes bytes, [[maybe_unused]] PtraceRegisters const& regs) -{ - FixedMemoryStream stream { bytes }; - - while (!stream.is_eof()) { - auto opcode = TRY(stream.read_value<u8>()); - - switch (static_cast<Operations>(opcode)) { - - default: - dbgln("DWARF expr addr: {:p}", bytes.data()); - dbgln("unsupported opcode: {}", opcode); - VERIFY_NOT_REACHED(); - } - } - VERIFY_NOT_REACHED(); -} - -} diff --git a/Userland/Libraries/LibDebug/Dwarf/Expression.h b/Userland/Libraries/LibDebug/Dwarf/Expression.h deleted file mode 100644 index 44652afa90..0000000000 --- a/Userland/Libraries/LibDebug/Dwarf/Expression.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include <AK/ByteBuffer.h> -#include <AK/Types.h> - -struct PtraceRegisters; - -namespace Debug::Dwarf::Expression { - -enum class Type { - None, - UnsignedInteger, - Register, -}; - -struct Value { - Type type; - union { - FlatPtr as_addr; - u32 as_u32; - } data { 0 }; -}; - -enum class Operations : u8 { - RegEbp = 0x75, - FbReg = 0x91, -}; - -ErrorOr<Value> evaluate(ReadonlyBytes, PtraceRegisters const&); - -} |