Index: source/Plugins/Process/Windows/Common/TargetThreadWindows.h =================================================================== --- source/Plugins/Process/Windows/Common/TargetThreadWindows.h +++ source/Plugins/Process/Windows/Common/TargetThreadWindows.h @@ -42,10 +42,10 @@ HostThread GetHostThread() const { return m_host_thread; } private: - lldb::RegisterContextSP CreateRegisterContextForFrameIndex(uint32_t idx); + lldb::RegisterContextSP CreateRegisterContextForZerothFrame(); HostThread m_host_thread; }; -} +} // namespace lldb_private #endif Index: source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp =================================================================== --- source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp +++ source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp @@ -16,10 +16,10 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" +#include "Plugins/Process/Utility/UnwindLLDB.h" #include "ProcessWindows.h" #include "ProcessWindowsLog.h" #include "TargetThreadWindows.h" -#include "Plugins/Process/Utility/UnwindLLDB.h" #if defined(_WIN64) #include "x64/RegisterContextWindows_x64.h" @@ -49,18 +49,27 @@ RegisterContextSP TargetThreadWindows::GetRegisterContext() { if (!m_reg_context_sp) - m_reg_context_sp = CreateRegisterContextForFrameIndex(0); + m_reg_context_sp = CreateRegisterContextForZerothFrame(); return m_reg_context_sp; } RegisterContextSP TargetThreadWindows::CreateRegisterContextForFrame(StackFrame *frame) { - return CreateRegisterContextForFrameIndex(frame->GetConcreteFrameIndex()); + uint32_t concrete_frame_idx = 0; + if (frame) + concrete_frame_idx = frame->GetConcreteFrameIndex(); + if (concrete_frame_idx == 0) + return CreateRegisterContextForZerothFrame(); + + Unwind *unwinder = GetUnwinder(); + if (unwinder) + return unwinder->CreateRegisterContextForFrame(frame); + + return RegisterContextSP(); } -RegisterContextSP -TargetThreadWindows::CreateRegisterContextForFrameIndex(uint32_t idx) { +RegisterContextSP TargetThreadWindows::CreateRegisterContextForZerothFrame() { if (!m_reg_context_sp) { ArchSpec arch = HostInfo::GetArchitecture(); switch (arch.GetMachine()) { @@ -68,12 +77,12 @@ #if defined(_WIN64) // FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64 #else - m_reg_context_sp.reset(new RegisterContextWindows_x86(*this, idx)); + m_reg_context_sp.reset(new RegisterContextWindows_x86(*this, 0)); #endif break; case llvm::Triple::x86_64: #if defined(_WIN64) - m_reg_context_sp.reset(new RegisterContextWindows_x64(*this, idx)); + m_reg_context_sp.reset(new RegisterContextWindows_x64(*this, 0)); #else // LLDB is 32-bit, but the target process is 64-bit. We probably can't debug // this. @@ -118,9 +127,10 @@ DWORD previous_suspend_count = 0; HANDLE thread_handle = m_host_thread.GetNativeThread().GetSystemHandle(); do { - // ResumeThread returns -1 on error, or the thread's *previous* suspend count on success. - // This means that the return value is 1 when the thread was restarted. - // Note that DWORD is an unsigned int, so we need to explicitly compare with -1. + // ResumeThread returns -1 on error, or the thread's *previous* suspend + // count on success. This means that the return value is 1 when the thread + // was restarted. Note that DWORD is an unsigned int, so we need to + // explicitly compare with -1. previous_suspend_count = ::ResumeThread(thread_handle); if (previous_suspend_count == (DWORD)-1)