diff options
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&); - -} |