diff options
author | ASOU Masato <asou@cvs.openbsd.org> | 2024-10-21 05:18:18 +0000 |
---|---|---|
committer | ASOU Masato <asou@cvs.openbsd.org> | 2024-10-21 05:18:18 +0000 |
commit | 353f631852ec376273a9448b445132aa87dbb07b (patch) | |
tree | 2374545b0d5a30d2f1be5d612166c24bf14fe617 /gnu | |
parent | 6734e62f0eb49acea4733dead8eb6fd9702ac78d (diff) |
Fix lldb doesn't analyze process core correctly.
ok kettenis@
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/llvm/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/gnu/llvm/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp b/gnu/llvm/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp index 7729e58f858..0900ff10091 100644 --- a/gnu/llvm/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp +++ b/gnu/llvm/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp @@ -26,10 +26,12 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" +#include <optional> #include <vector> using namespace lldb; @@ -93,6 +95,7 @@ ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) case llvm::Triple::OSType::Linux: case llvm::Triple::OSType::MacOSX: case llvm::Triple::OSType::NetBSD: + case llvm::Triple::OSType::OpenBSD: case llvm::Triple::OSType::Solaris: case llvm::Triple::OSType::UnknownOS: return ABISP( @@ -107,7 +110,7 @@ ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) bool ABISysV_x86_64::PrepareTrivialCall(Thread &thread, addr_t sp, addr_t func_addr, addr_t return_addr, llvm::ArrayRef<addr_t> args) const { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); + Log *log = GetLog(LLDBLog::Expressions); if (log) { StreamString s; @@ -266,7 +269,7 @@ bool ABISysV_x86_64::GetArgumentValues(Thread &thread, // We currently only support extracting values with Clang QualTypes. Do we // care about others? CompilerType compiler_type = value->GetCompilerType(); - llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread); + std::optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread); if (!bit_size) return false; bool is_signed; @@ -336,7 +339,7 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, error.SetErrorString( "We don't support returning complex values at present"); else { - llvm::Optional<uint64_t> bit_width = + std::optional<uint64_t> bit_width = compiler_type.GetBitSize(frame_sp.get()); if (!bit_width) { error.SetErrorString("can't get type size"); @@ -399,14 +402,14 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( const uint32_t type_flags = return_compiler_type.GetTypeInfo(); if (type_flags & eTypeIsScalar) { - value.SetValueType(Value::eValueTypeScalar); + value.SetValueType(Value::ValueType::Scalar); bool success = false; if (type_flags & eTypeIsInteger) { // Extract the register context so we can read arguments from registers - llvm::Optional<uint64_t> byte_size = - return_compiler_type.GetByteSize(nullptr); + std::optional<uint64_t> byte_size = + return_compiler_type.GetByteSize(&thread); if (!byte_size) return return_valobj_sp; uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( @@ -452,8 +455,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( if (type_flags & eTypeIsComplex) { // Don't handle complex yet. } else { - llvm::Optional<uint64_t> byte_size = - return_compiler_type.GetByteSize(nullptr); + std::optional<uint64_t> byte_size = + return_compiler_type.GetByteSize(&thread); if (byte_size && *byte_size <= sizeof(long double)) { const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0); @@ -487,12 +490,12 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( value.GetScalar() = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, 0); - value.SetValueType(Value::eValueTypeScalar); + value.SetValueType(Value::ValueType::Scalar); return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); } else if (type_flags & eTypeIsVector) { - llvm::Optional<uint64_t> byte_size = - return_compiler_type.GetByteSize(nullptr); + std::optional<uint64_t> byte_size = + return_compiler_type.GetByteSize(&thread); if (byte_size && *byte_size > 0) { const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); @@ -510,7 +513,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( if (reg_ctx->ReadRegister(altivec_reg, reg_value)) { Status error; if (reg_value.GetAsMemoryData( - altivec_reg, heap_data_up->GetBytes(), + *altivec_reg, heap_data_up->GetBytes(), heap_data_up->GetByteSize(), byte_order, error)) { DataExtractor data(DataBufferSP(heap_data_up.release()), byte_order, @@ -538,10 +541,10 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( Status error; if (reg_value.GetAsMemoryData( - altivec_reg, heap_data_up->GetBytes(), + *altivec_reg, heap_data_up->GetBytes(), altivec_reg->byte_size, byte_order, error) && reg_value2.GetAsMemoryData( - altivec_reg2, + *altivec_reg2, heap_data_up->GetBytes() + altivec_reg->byte_size, heap_data_up->GetByteSize() - altivec_reg->byte_size, byte_order, error)) { @@ -586,8 +589,8 @@ static bool FlattenAggregateType( uint64_t field_bit_offset = 0; CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); - llvm::Optional<uint64_t> field_bit_width = - field_compiler_type.GetBitSize(&thread); + std::optional<uint64_t> field_bit_width = + field_compiler_type.GetBitSize(&thread); // if we don't know the size of the field (e.g. invalid type), exit if (!field_bit_width || *field_bit_width == 0) { @@ -629,7 +632,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( if (!reg_ctx_sp) return return_valobj_sp; - llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread); + std::optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread); if (!bit_width) return return_valobj_sp; if (return_compiler_type.IsAggregateType()) { @@ -637,14 +640,14 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( bool is_memory = true; std::vector<uint32_t> aggregate_field_offsets; std::vector<CompilerType> aggregate_compiler_types; - if (return_compiler_type.GetTypeSystem()->CanPassInRegisters( - return_compiler_type) && - *bit_width <= 128 && - FlattenAggregateType(thread, exe_ctx, return_compiler_type, - 0, aggregate_field_offsets, - aggregate_compiler_types)) { + auto ts = return_compiler_type.GetTypeSystem(); + if (ts && ts->CanPassInRegisters(return_compiler_type) && + *bit_width <= 128 && + FlattenAggregateType(thread, exe_ctx, return_compiler_type, 0, + aggregate_field_offsets, + aggregate_compiler_types)) { ByteOrder byte_order = target->GetArchitecture().GetByteOrder(); - DataBufferSP data_sp(new DataBufferHeap(16, 0)); + WritableDataBufferSP data_sp(new DataBufferHeap(16, 0)); DataExtractor return_ext(data_sp, byte_order, target->GetArchitecture().GetAddressByteSize()); @@ -887,6 +890,7 @@ bool ABISysV_x86_64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { const int32_t ptr_size = 8; row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_rbp, 2 * ptr_size); row->SetOffset(0); + row->SetUnspecifiedRegistersAreUndefined(true); row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); @@ -932,6 +936,8 @@ uint32_t ABISysV_x86_64::GetGenericNum(llvm::StringRef name) { .Case("rsp", LLDB_REGNUM_GENERIC_SP) .Case("rbp", LLDB_REGNUM_GENERIC_FP) .Case("rflags", LLDB_REGNUM_GENERIC_FLAGS) + // gdbserver uses eflags + .Case("eflags", LLDB_REGNUM_GENERIC_FLAGS) .Case("rdi", LLDB_REGNUM_GENERIC_ARG1) .Case("rsi", LLDB_REGNUM_GENERIC_ARG2) .Case("rdx", LLDB_REGNUM_GENERIC_ARG3) @@ -949,16 +955,3 @@ void ABISysV_x86_64::Initialize() { void ABISysV_x86_64::Terminate() { PluginManager::UnregisterPlugin(CreateInstance); } - -lldb_private::ConstString ABISysV_x86_64::GetPluginNameStatic() { - static ConstString g_name("sysv-x86_64"); - return g_name; -} - -// PluginInterface protocol - -lldb_private::ConstString ABISysV_x86_64::GetPluginName() { - return GetPluginNameStatic(); -} - -uint32_t ABISysV_x86_64::GetPluginVersion() { return 1; } |