Index: lldb/lldb.xcodeproj/project.pbxproj =================================================================== --- lldb/lldb.xcodeproj/project.pbxproj +++ lldb/lldb.xcodeproj/project.pbxproj @@ -655,7 +655,6 @@ 267F68531CC02E920086832B /* RegisterContextLinux_s390x.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267F68511CC02E920086832B /* RegisterContextLinux_s390x.cpp */; }; 267F68541CC02E920086832B /* RegisterContextLinux_s390x.h in Headers */ = {isa = PBXBuildFile; fileRef = 267F68521CC02E920086832B /* RegisterContextLinux_s390x.h */; }; 26474CB418D0CB180073DEBA /* RegisterContextLinux_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CB018D0CB180073DEBA /* RegisterContextLinux_x86_64.cpp */; }; - 268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */; }; 26474CBC18D0CB2D0073DEBA /* RegisterContextMach_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CB618D0CB2D0073DEBA /* RegisterContextMach_arm.cpp */; }; 26474CBE18D0CB2D0073DEBA /* RegisterContextMach_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CB818D0CB2D0073DEBA /* RegisterContextMach_i386.cpp */; }; 26474CC018D0CB2D0073DEBA /* RegisterContextMach_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CBA18D0CB2D0073DEBA /* RegisterContextMach_x86_64.cpp */; }; @@ -980,7 +979,6 @@ 264D8D5013661BD7003A368F /* UnwindAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264D8D4F13661BD7003A368F /* UnwindAssembly.cpp */; }; 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; }; 268900AF13353E5000698AC0 /* UnwindLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */; }; - 268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */; }; 268900E413353E6F00698AC0 /* UnwindPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */; }; 268900E513353E6F00698AC0 /* UnwindTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */; }; AF2BA6EC1A707E3400C5248A /* UriParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33064C991A5C7A330033D415 /* UriParser.cpp */; }; @@ -2520,9 +2518,6 @@ 267F68521CC02E920086832B /* RegisterContextLinux_s390x.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextLinux_s390x.h; path = Utility/RegisterContextLinux_s390x.h; sourceTree = ""; }; 26474CB018D0CB180073DEBA /* RegisterContextLinux_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextLinux_x86_64.cpp; path = Utility/RegisterContextLinux_x86_64.cpp; sourceTree = ""; }; 26474CB118D0CB180073DEBA /* RegisterContextLinux_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextLinux_x86_64.h; path = Utility/RegisterContextLinux_x86_64.h; sourceTree = ""; }; - 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMacOSXFrameBackchain.cpp; path = Utility/RegisterContextMacOSXFrameBackchain.cpp; sourceTree = ""; }; - AF77E09C1A033D360096C0EA /* RegisterContextMacOSXFrameBackchain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMacOSXFrameBackchain.cpp; path = Utility/RegisterContextMacOSXFrameBackchain.cpp; sourceTree = ""; }; - 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMacOSXFrameBackchain.h; path = Utility/RegisterContextMacOSXFrameBackchain.h; sourceTree = ""; }; 26474CB618D0CB2D0073DEBA /* RegisterContextMach_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMach_arm.cpp; path = Utility/RegisterContextMach_arm.cpp; sourceTree = ""; }; 26474CB718D0CB2D0073DEBA /* RegisterContextMach_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMach_arm.h; path = Utility/RegisterContextMach_arm.h; sourceTree = ""; }; 26474CB818D0CB2D0073DEBA /* RegisterContextMach_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMach_i386.cpp; path = Utility/RegisterContextMach_i386.cpp; sourceTree = ""; }; @@ -3094,8 +3089,6 @@ 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyInstEmulation.h; sourceTree = ""; }; AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindLLDB.cpp; path = Utility/UnwindLLDB.cpp; sourceTree = ""; }; AF68D3301255A110002FF25B /* UnwindLLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindLLDB.h; path = Utility/UnwindLLDB.h; sourceTree = ""; }; - 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindMacOSXFrameBackchain.cpp; path = Utility/UnwindMacOSXFrameBackchain.cpp; sourceTree = ""; }; - 26E3EEE411A9901300FBADB6 /* UnwindMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindMacOSXFrameBackchain.h; path = Utility/UnwindMacOSXFrameBackchain.h; sourceTree = ""; }; 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindPlan.cpp; path = source/Symbol/UnwindPlan.cpp; sourceTree = ""; }; 269FF07F12494F8E00225026 /* UnwindPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindPlan.h; path = include/lldb/Symbol/UnwindPlan.h; sourceTree = ""; }; 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindTable.cpp; path = source/Symbol/UnwindTable.cpp; sourceTree = ""; }; @@ -4866,8 +4859,6 @@ 26474CB918D0CB2D0073DEBA /* RegisterContextMach_i386.h */, 26474CBA18D0CB2D0073DEBA /* RegisterContextMach_x86_64.cpp */, 26474CBB18D0CB2D0073DEBA /* RegisterContextMach_x86_64.h */, - AF77E09C1A033D360096C0EA /* RegisterContextMacOSXFrameBackchain.cpp */, - 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */, 262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */, 262D24E513FB8710002D1960 /* RegisterContextMemory.h */, 4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */, @@ -4908,9 +4899,6 @@ 26F4A21B13FBA31A0064B613 /* ThreadMemory.h */, AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */, AF68D3301255A110002FF25B /* UnwindLLDB.h */, - 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */, - 26E3EEE411A9901300FBADB6 /* UnwindMacOSXFrameBackchain.h */, - 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */, 26474CC218D0CB5B0073DEBA /* RegisterContextMemory.cpp */, 26474CC318D0CB5B0073DEBA /* RegisterContextMemory.h */, ); @@ -7838,14 +7826,12 @@ AF33B4BE1C1FA441001B28D9 /* NetBSDSignals.cpp in Sources */, 949EEDA31BA76577008C63CF /* Cocoa.cpp in Sources */, 3FDFE56C19AF9C44009756A7 /* HostProcessPosix.cpp in Sources */, - 268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */, AE44FB321BB07EBC0033EB62 /* GoParser.cpp in Sources */, 6B74D89B200696BB0074051B /* Environment.cpp in Sources */, 3F8169311ABB7A6D001DA9DF /* SystemInitializer.cpp in Sources */, 949EEDB21BA76731008C63CF /* NSIndexPath.cpp in Sources */, 3FDFED2D19C257A0009756A7 /* HostProcess.cpp in Sources */, 268900B513353E5000698AC0 /* StopInfoMachException.cpp in Sources */, - 268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */, 4CE4EFB41E899A4000A80C06 /* RegisterContextOpenBSD_x86_64.cpp in Sources */, 268900B713353E5F00698AC0 /* DWARFAbbreviationDeclaration.cpp in Sources */, 268900B813353E5F00698AC0 /* DWARFCompileUnit.cpp in Sources */, Index: lldb/source/Plugins/Process/Utility/CMakeLists.txt =================================================================== --- lldb/source/Plugins/Process/Utility/CMakeLists.txt +++ lldb/source/Plugins/Process/Utility/CMakeLists.txt @@ -25,7 +25,6 @@ RegisterContextLinux_mips.cpp RegisterContextLinux_s390x.cpp RegisterContextLLDB.cpp - RegisterContextMacOSXFrameBackchain.cpp RegisterContextMach_arm.cpp RegisterContextMach_i386.cpp RegisterContextMach_x86_64.cpp @@ -47,7 +46,6 @@ StopInfoMachException.cpp ThreadMemory.cpp UnwindLLDB.cpp - UnwindMacOSXFrameBackchain.cpp LINK_LIBS lldbBreakpoint Index: lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h +++ /dev/null @@ -1,61 +0,0 @@ -//===-- RegisterContextMacOSXFrameBackchain.h -------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_RegisterContextMacOSXFrameBackchain_h_ -#define lldb_RegisterContextMacOSXFrameBackchain_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Target/RegisterContext.h" -#include "lldb/lldb-private.h" - -#include "UnwindMacOSXFrameBackchain.h" - -class RegisterContextMacOSXFrameBackchain - : public lldb_private::RegisterContext { -public: - RegisterContextMacOSXFrameBackchain( - lldb_private::Thread &thread, uint32_t concrete_frame_idx, - const UnwindMacOSXFrameBackchain::Cursor &cursor); - - ~RegisterContextMacOSXFrameBackchain() override; - - void InvalidateAllRegisters() override; - - size_t GetRegisterCount() override; - - const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; - - size_t GetRegisterSetCount() override; - - const lldb_private::RegisterSet *GetRegisterSet(size_t reg_set) override; - - bool ReadRegister(const lldb_private::RegisterInfo *reg_info, - lldb_private::RegisterValue &value) override; - - bool WriteRegister(const lldb_private::RegisterInfo *reg_info, - const lldb_private::RegisterValue &value) override; - - bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; - - bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; - - uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, - uint32_t num) override; - -private: - UnwindMacOSXFrameBackchain::Cursor m_cursor; - bool m_cursor_is_valid; - - DISALLOW_COPY_AND_ASSIGN(RegisterContextMacOSXFrameBackchain); -}; - -#endif // lldb_RegisterContextMacOSXFrameBackchain_h_ Index: lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp +++ /dev/null @@ -1,169 +0,0 @@ -//===-- RegisterContextMacOSXFrameBackchain.cpp -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "RegisterContextMacOSXFrameBackchain.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" -#include "lldb/Target/Thread.h" -#include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/StreamString.h" -// Project includes -#include "lldb/Utility/StringExtractorGDBRemote.h" - -using namespace lldb; -using namespace lldb_private; - -//---------------------------------------------------------------------- -// RegisterContextMacOSXFrameBackchain constructor -//---------------------------------------------------------------------- -RegisterContextMacOSXFrameBackchain::RegisterContextMacOSXFrameBackchain( - Thread &thread, uint32_t concrete_frame_idx, - const UnwindMacOSXFrameBackchain::Cursor &cursor) - : RegisterContext(thread, concrete_frame_idx), m_cursor(cursor), - m_cursor_is_valid(true) {} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -RegisterContextMacOSXFrameBackchain::~RegisterContextMacOSXFrameBackchain() {} - -void RegisterContextMacOSXFrameBackchain::InvalidateAllRegisters() { - m_cursor_is_valid = false; -} - -size_t RegisterContextMacOSXFrameBackchain::GetRegisterCount() { - return m_thread.GetRegisterContext()->GetRegisterCount(); -} - -const RegisterInfo * -RegisterContextMacOSXFrameBackchain::GetRegisterInfoAtIndex(size_t reg) { - return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg); -} - -size_t RegisterContextMacOSXFrameBackchain::GetRegisterSetCount() { - return m_thread.GetRegisterContext()->GetRegisterSetCount(); -} - -const RegisterSet * -RegisterContextMacOSXFrameBackchain::GetRegisterSet(size_t reg_set) { - return m_thread.GetRegisterContext()->GetRegisterSet(reg_set); -} - -bool RegisterContextMacOSXFrameBackchain::ReadRegister( - const RegisterInfo *reg_info, RegisterValue &value) { - if (!m_cursor_is_valid) - return false; - - uint64_t reg_value = LLDB_INVALID_ADDRESS; - - switch (reg_info->kinds[eRegisterKindGeneric]) { - case LLDB_REGNUM_GENERIC_PC: - if (m_cursor.pc == LLDB_INVALID_ADDRESS) - return false; - reg_value = m_cursor.pc; - break; - - case LLDB_REGNUM_GENERIC_FP: - if (m_cursor.fp == LLDB_INVALID_ADDRESS) - return false; - reg_value = m_cursor.fp; - break; - - default: - return false; - } - - switch (reg_info->encoding) { - case eEncodingInvalid: - case eEncodingVector: - break; - - case eEncodingUint: - case eEncodingSint: - value.SetUInt(reg_value, reg_info->byte_size); - return true; - - case eEncodingIEEE754: - switch (reg_info->byte_size) { - case sizeof(float): - if (sizeof(float) == sizeof(uint32_t)) { - value.SetUInt32(reg_value, RegisterValue::eTypeFloat); - return true; - } else if (sizeof(float) == sizeof(uint64_t)) { - value.SetUInt64(reg_value, RegisterValue::eTypeFloat); - return true; - } - break; - - case sizeof(double): - if (sizeof(double) == sizeof(uint32_t)) { - value.SetUInt32(reg_value, RegisterValue::eTypeDouble); - return true; - } else if (sizeof(double) == sizeof(uint64_t)) { - value.SetUInt64(reg_value, RegisterValue::eTypeDouble); - return true; - } - break; - -// TOOD: need a better way to detect when "long double" types are -// the same bytes size as "double" -#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__) && \ - !defined(_MSC_VER) && !defined(__mips__) && !defined(__powerpc__) && \ - !defined(__ANDROID__) - case sizeof(long double): - if (sizeof(long double) == sizeof(uint32_t)) { - value.SetUInt32(reg_value, RegisterValue::eTypeLongDouble); - return true; - } else if (sizeof(long double) == sizeof(uint64_t)) { - value.SetUInt64(reg_value, RegisterValue::eTypeLongDouble); - return true; - } - break; -#endif - } - break; - } - return false; -} - -bool RegisterContextMacOSXFrameBackchain::WriteRegister( - const RegisterInfo *reg_info, const RegisterValue &value) { - // Not supported yet. We could easily add support for this by remembering the - // address of each entry (it would need to be part of the cursor) - return false; -} - -bool RegisterContextMacOSXFrameBackchain::ReadAllRegisterValues( - lldb::DataBufferSP &data_sp) { - // libunwind frames can't handle this it doesn't always have all register - // values. This call should only be called on frame zero anyway so there - // shouldn't be any problem - return false; -} - -bool RegisterContextMacOSXFrameBackchain::WriteAllRegisterValues( - const lldb::DataBufferSP &data_sp) { - // Since this class doesn't respond to "ReadAllRegisterValues()", it must not - // have been the one that saved all the register values. So we just let the - // thread's register context (the register context for frame zero) do the - // writing. - return m_thread.GetRegisterContext()->WriteAllRegisterValues(data_sp); -} - -uint32_t -RegisterContextMacOSXFrameBackchain::ConvertRegisterKindToRegisterNumber( - lldb::RegisterKind kind, uint32_t num) { - return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber( - kind, num); -} Index: lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h =================================================================== --- lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h +++ /dev/null @@ -1,60 +0,0 @@ -//===-- UnwindMacOSXFrameBackchain.h ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_UnwindMacOSXFrameBackchain_h_ -#define lldb_UnwindMacOSXFrameBackchain_h_ - -// C Includes -// C++ Includes -#include - -// Other libraries and framework includes -// Project includes -#include "lldb/Target/Unwind.h" -#include "lldb/lldb-private.h" - -class UnwindMacOSXFrameBackchain : public lldb_private::Unwind { -public: - UnwindMacOSXFrameBackchain(lldb_private::Thread &thread); - - ~UnwindMacOSXFrameBackchain() override = default; - -protected: - void DoClear() override { m_cursors.clear(); } - - uint32_t DoGetFrameCount() override; - - bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, - lldb::addr_t &pc) override; - - lldb::RegisterContextSP - DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override; - - friend class RegisterContextMacOSXFrameBackchain; - - struct Cursor { - lldb::addr_t pc; // Program counter - lldb::addr_t fp; // Frame pointer for us with backchain - }; - -private: - std::vector m_cursors; - - size_t GetStackFrameData_i386(const lldb_private::ExecutionContext &exe_ctx); - - size_t - GetStackFrameData_x86_64(const lldb_private::ExecutionContext &exe_ctx); - - //------------------------------------------------------------------ - // For UnwindMacOSXFrameBackchain only - //------------------------------------------------------------------ - DISALLOW_COPY_AND_ASSIGN(UnwindMacOSXFrameBackchain); -}; - -#endif // lldb_UnwindMacOSXFrameBackchain_h_ Index: lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp =================================================================== --- lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp +++ /dev/null @@ -1,246 +0,0 @@ -//===-- UnwindMacOSXFrameBackchain.cpp --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Symbol/Function.h" -#include "lldb/Symbol/ObjectFile.h" -#include "lldb/Symbol/Symbol.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Thread.h" -#include "lldb/Utility/ArchSpec.h" - -#include "RegisterContextMacOSXFrameBackchain.h" - -using namespace lldb; -using namespace lldb_private; - -UnwindMacOSXFrameBackchain::UnwindMacOSXFrameBackchain(Thread &thread) - : Unwind(thread), m_cursors() {} - -uint32_t UnwindMacOSXFrameBackchain::DoGetFrameCount() { - if (m_cursors.empty()) { - ExecutionContext exe_ctx(m_thread.shared_from_this()); - Target *target = exe_ctx.GetTargetPtr(); - if (target) { - const ArchSpec &target_arch = target->GetArchitecture(); - // Frame zero should always be supplied by the thread... - exe_ctx.SetFrameSP(m_thread.GetStackFrameAtIndex(0)); - - if (target_arch.GetAddressByteSize() == 8) - GetStackFrameData_x86_64(exe_ctx); - else - GetStackFrameData_i386(exe_ctx); - } - } - return m_cursors.size(); -} - -bool UnwindMacOSXFrameBackchain::DoGetFrameInfoAtIndex(uint32_t idx, - addr_t &cfa, - addr_t &pc) { - const uint32_t frame_count = GetFrameCount(); - if (idx < frame_count) { - if (m_cursors[idx].pc == LLDB_INVALID_ADDRESS) - return false; - if (m_cursors[idx].fp == LLDB_INVALID_ADDRESS) - return false; - - pc = m_cursors[idx].pc; - cfa = m_cursors[idx].fp; - - return true; - } - return false; -} - -lldb::RegisterContextSP -UnwindMacOSXFrameBackchain::DoCreateRegisterContextForFrame(StackFrame *frame) { - lldb::RegisterContextSP reg_ctx_sp; - uint32_t concrete_idx = frame->GetConcreteFrameIndex(); - const uint32_t frame_count = GetFrameCount(); - if (concrete_idx < frame_count) - reg_ctx_sp.reset(new RegisterContextMacOSXFrameBackchain( - m_thread, concrete_idx, m_cursors[concrete_idx])); - return reg_ctx_sp; -} - -size_t UnwindMacOSXFrameBackchain::GetStackFrameData_i386( - const ExecutionContext &exe_ctx) { - m_cursors.clear(); - - StackFrame *first_frame = exe_ctx.GetFramePtr(); - - Process *process = exe_ctx.GetProcessPtr(); - if (process == NULL) - return 0; - - struct Frame_i386 { - uint32_t fp; - uint32_t pc; - }; - - RegisterContext *reg_ctx = m_thread.GetRegisterContext().get(); - assert(reg_ctx); - - Cursor cursor; - cursor.pc = reg_ctx->GetPC(LLDB_INVALID_ADDRESS); - cursor.fp = reg_ctx->GetFP(0); - - Frame_i386 frame = {static_cast(cursor.fp), - static_cast(cursor.pc)}; - - m_cursors.push_back(cursor); - - const size_t k_frame_size = sizeof(frame); - Status error; - while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0)) { - // Read both the FP and PC (8 bytes) - if (process->ReadMemory(frame.fp, &frame.fp, k_frame_size, error) != - k_frame_size) - break; - if (frame.pc >= 0x1000) { - cursor.pc = frame.pc; - cursor.fp = frame.fp; - m_cursors.push_back(cursor); - } - } - if (!m_cursors.empty()) { - lldb::addr_t first_frame_pc = m_cursors.front().pc; - if (first_frame_pc != LLDB_INVALID_ADDRESS) { - const uint32_t resolve_scope = - eSymbolContextModule | eSymbolContextCompUnit | - eSymbolContextFunction | eSymbolContextSymbol; - - SymbolContext first_frame_sc( - first_frame->GetSymbolContext(resolve_scope)); - const AddressRange *addr_range_ptr = NULL; - AddressRange range; - if (first_frame_sc.function) - addr_range_ptr = &first_frame_sc.function->GetAddressRange(); - else if (first_frame_sc.symbol) { - range.GetBaseAddress() = first_frame_sc.symbol->GetAddress(); - range.SetByteSize(first_frame_sc.symbol->GetByteSize()); - addr_range_ptr = ⦥ - } - - if (addr_range_ptr) { - if (first_frame->GetFrameCodeAddress() == - addr_range_ptr->GetBaseAddress()) { - // We are at the first instruction, so we can recover the previous PC - // by dereferencing the SP - lldb::addr_t first_frame_sp = reg_ctx->GetSP(0); - // Read the real second frame return address into frame.pc - if (first_frame_sp && - process->ReadMemory(first_frame_sp, &frame.pc, sizeof(frame.pc), - error) == sizeof(frame.pc)) { - cursor.fp = m_cursors.front().fp; - cursor.pc = frame.pc; // Set the new second frame PC - - // Insert the second frame - m_cursors.insert(m_cursors.begin() + 1, cursor); - - m_cursors.front().fp = first_frame_sp; - } - } - } - } - } - // uint32_t i=0; - // printf(" PC FP\n"); - // printf(" ------------------ ------------------ \n"); - // for (i=0; iGetPC(LLDB_INVALID_ADDRESS); - cursor.fp = reg_ctx->GetFP(0); - - Frame_x86_64 frame = {cursor.fp, cursor.pc}; - - m_cursors.push_back(cursor); - Status error; - const size_t k_frame_size = sizeof(frame); - while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0)) { - // Read both the FP and PC (16 bytes) - if (process->ReadMemory(frame.fp, &frame.fp, k_frame_size, error) != - k_frame_size) - break; - - if (frame.pc >= 0x1000) { - cursor.pc = frame.pc; - cursor.fp = frame.fp; - m_cursors.push_back(cursor); - } - } - if (!m_cursors.empty()) { - lldb::addr_t first_frame_pc = m_cursors.front().pc; - if (first_frame_pc != LLDB_INVALID_ADDRESS) { - const uint32_t resolve_scope = - eSymbolContextModule | eSymbolContextCompUnit | - eSymbolContextFunction | eSymbolContextSymbol; - - SymbolContext first_frame_sc( - first_frame->GetSymbolContext(resolve_scope)); - const AddressRange *addr_range_ptr = NULL; - AddressRange range; - if (first_frame_sc.function) - addr_range_ptr = &first_frame_sc.function->GetAddressRange(); - else if (first_frame_sc.symbol) { - range.GetBaseAddress() = first_frame_sc.symbol->GetAddress(); - range.SetByteSize(first_frame_sc.symbol->GetByteSize()); - addr_range_ptr = ⦥ - } - - if (addr_range_ptr) { - if (first_frame->GetFrameCodeAddress() == - addr_range_ptr->GetBaseAddress()) { - // We are at the first instruction, so we can recover the previous PC - // by dereferencing the SP - lldb::addr_t first_frame_sp = reg_ctx->GetSP(0); - // Read the real second frame return address into frame.pc - if (process->ReadMemory(first_frame_sp, &frame.pc, sizeof(frame.pc), - error) == sizeof(frame.pc)) { - cursor.fp = m_cursors.front().fp; - cursor.pc = frame.pc; // Set the new second frame PC - - // Insert the second frame - m_cursors.insert(m_cursors.begin() + 1, cursor); - - m_cursors.front().fp = first_frame_sp; - } - } - } - } - } - return m_cursors.size(); -} Index: lldb/source/Target/Thread.cpp =================================================================== --- lldb/source/Target/Thread.cpp +++ lldb/source/Target/Thread.cpp @@ -13,7 +13,6 @@ // Project includes #include "lldb/Target/Thread.h" #include "Plugins/Process/Utility/UnwindLLDB.h" -#include "Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/FormatEntity.h" @@ -2055,10 +2054,7 @@ case llvm::Triple::hexagon: m_unwinder_ap.reset(new UnwindLLDB(*this)); break; - default: - if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple) - m_unwinder_ap.reset(new UnwindMacOSXFrameBackchain(*this)); break; } }