diff options
Diffstat (limited to 'lldb/source/Plugins/Process')
12 files changed, 80 insertions, 317 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index afa18dacc7d..c78aa42da20 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -385,11 +385,16 @@ ProcessKDP::DoResume () if (kernel_thread_sp) { const StateType thread_resume_state = kernel_thread_sp->GetTemporaryResumeState(); + + if (log) + log->Printf ("ProcessKDP::DoResume() thread_resume_state = %s", StateAsCString(thread_resume_state)); switch (thread_resume_state) { case eStateSuspended: // Nothing to do here when a thread will stay suspended // we just leave the CPU mask bit set to zero for the thread + if (log) + log->Printf ("ProcessKDP::DoResume() = suspended???"); break; case eStateStepping: @@ -398,6 +403,8 @@ ProcessKDP::DoResume () if (reg_ctx_sp) { + if (log) + log->Printf ("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (true);"); reg_ctx_sp->HardwareSingleStep (true); resume = true; } @@ -412,15 +419,17 @@ ProcessKDP::DoResume () { lldb::RegisterContextSP reg_ctx_sp (kernel_thread_sp->GetRegisterContext()); - if (reg_ctx_sp) - { - reg_ctx_sp->HardwareSingleStep (false); - resume = true; - } - else - { - error.SetErrorStringWithFormat("KDP thread 0x%llx has no register context", kernel_thread_sp->GetID()); - } + if (reg_ctx_sp) + { + if (log) + log->Printf ("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (false);"); + reg_ctx_sp->HardwareSingleStep (false); + resume = true; + } + else + { + error.SetErrorStringWithFormat("KDP thread 0x%llx has no register context", kernel_thread_sp->GetID()); + } } break; @@ -540,22 +549,15 @@ ProcessKDP::DoDetach(bool keep_stopped) // If we are going to keep the target stopped, then don't send the disconnect message. if (!keep_stopped && m_comm.IsConnected()) { - - bool disconnect_success = m_comm.SendRequestDisconnect(); - if (!disconnect_success) - { - if (log) - log->PutCString ("ProcessKDP::DoDetach(): send disconnect request failed"); - } - - ConnectionStatus comm_disconnect_result = m_comm.Disconnect (); + const bool success = m_comm.SendRequestDisconnect(); if (log) { - if (comm_disconnect_result == eConnectionStatusSuccess) - log->PutCString ("ProcessKDP::DoDetach() conncection channel shutdown successfully"); + if (success) + log->PutCString ("ProcessKDP::DoDetach() detach packet sent successfully"); else log->PutCString ("ProcessKDP::DoDetach() connection channel shutdown failed"); } + m_comm.Disconnect (); } } StopAsyncThread (); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp index 6f0116e7f44..94567c87eda 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -148,26 +148,23 @@ ThreadKDP::CreateRegisterContextForFrame (StackFrame *frame) return reg_ctx_sp; } -lldb::StopInfoSP -ThreadKDP::GetPrivateStopReason () +bool +ThreadKDP::CalculateStopInfo () { ProcessSP process_sp (GetProcess()); if (process_sp) { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id != process_stop_id || - (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid())) + if (m_cached_stop_info_sp) { - if (IsStillAtLastBreakpointHit()) - return m_actual_stop_info_sp; - - if (m_cached_stop_info_sp) - SetStopInfo (m_cached_stop_info_sp); - else - SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); + SetStopInfo (m_cached_stop_info_sp); + } + else + { + SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); } + return true; } - return m_actual_stop_info_sp; + return false; } void diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h index 5a980f504fc..7dc373f0355 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h @@ -89,13 +89,10 @@ protected: lldb::addr_t m_thread_dispatch_qaddr; lldb::StopInfoSP m_cached_stop_info_sp; //------------------------------------------------------------------ - // Member variables. + // Protected member functions. //------------------------------------------------------------------ - - virtual lldb::StopInfoSP - GetPrivateStopReason (); - - + virtual bool + CalculateStopInfo (); }; #endif // liblldb_ThreadKDP_h_ diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp index 1d43201a08d..45461c0341d 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp @@ -138,10 +138,11 @@ POSIXThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) return reg_ctx_sp; } -lldb::StopInfoSP -POSIXThread::GetPrivateStopReason() +bool +POSIXThread::CalculateStopInfo() { - return m_actual_stop_info_sp; + SetStopInfo (m_actual_stop_info_sp); + return true; } Unwind * diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.h b/lldb/source/Plugins/Process/POSIX/POSIXThread.h index 69bca49839a..fc6c759f0f5 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.h +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.h @@ -97,8 +97,8 @@ private: ProcessMonitor & GetMonitor(); - lldb::StopInfoSP - GetPrivateStopReason(); + virtual bool + CalculateStopInfo(); void BreakNotify(const ProcessMessage &message); void WatchNotify(const ProcessMessage &message); diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp index 3d08026cf98..56e5a9a59fa 100644 --- a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp +++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp @@ -99,209 +99,34 @@ ThreadMemory::CreateRegisterContextForFrame (StackFrame *frame) return reg_ctx_sp; } - -//class StopInfoThreadMemory : public StopInfo -//{ -//public: -// //------------------------------------------------------------------ -// // Constructors and Destructors -// //------------------------------------------------------------------ -// StopInfoThreadMemory (Thread &thread, -// uint64_t value, -// StopInfoSP &backing_stop_info_sp) : -// StopInfo (thread, value), -// m_backing_stop_info_sp (backing_stop_info_sp) -// { -// } -// -// virtual -// ~StopInfoThreadMemory() -// { -// } -// -// virtual bool -// IsValid () const -// { -// ThreadSP backing_thread_sp (m_thread.GetBackingThread()); -// if (backing_thread_sp) -// return backing_thread_sp->IsValid(); -// return StopInfo::IsValid(); -// } -// -// virtual Thread & -// GetThread() -// { -// return m_thread; -// } -// -// virtual const Thread & -// GetThread() const -// { -// return m_thread; -// } -// -// virtual uint64_t -// GetValue() const -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetValue(); -// return StopInfo::GetValue(); -// } -// -// virtual lldb::StopReason -// GetStopReason () const -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetStopReason(); -// return eStopReasonNone; -// } -// -// // ShouldStopSynchronous will get called before any thread plans are consulted, and if it says we should -// // resume the target, then we will just immediately resume. This should not run any code in or resume the -// // target. -// -// virtual bool -// ShouldStopSynchronous (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->ShouldStopSynchronous(event_ptr); -// return StopInfo::ShouldStopSynchronous (event_ptr); -// } -// -// // If should stop returns false, check if we should notify of this event -// virtual bool -// ShouldNotify (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->ShouldNotify(event_ptr); -// return StopInfo::ShouldNotify (event_ptr); -// } -// -// virtual void -// WillResume (lldb::StateType resume_state) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->WillResume(resume_state); -// return StopInfo::WillResume (resume_state); -// } -// -// virtual const char * -// GetDescription () -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetDescription(); -// return StopInfo::GetDescription(); -// } -// -// virtual void -// SetDescription (const char *desc_cstr) -// { -// if (m_backing_stop_info_sp) -// m_backing_stop_info_sp->SetDescription(desc_cstr); -// StopInfo::SetDescription(desc_cstr); -// } -// -// // Sometimes the thread plan logic will know that it wants a given stop to stop or not, -// // regardless of what the ordinary logic for that StopInfo would dictate. The main example -// // of this is the ThreadPlanCallFunction, which for instance knows - based on how that particular -// // expression was executed - whether it wants all breakpoints to auto-continue or not. -// // Use OverrideShouldStop on the StopInfo to implement this. -// -// virtual void -// OverrideShouldStop (bool override_value) -// { -// if (m_backing_stop_info_sp) -// m_backing_stop_info_sp->OverrideShouldStop(override_value); -// StopInfo::OverrideShouldStop (override_value); -// } -// -// virtual bool -// GetOverrideShouldStop() -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetOverrideShouldStop(); -// return StopInfo::GetOverrideShouldStop(); -// } -// -// virtual bool -// GetOverriddenShouldStopValue () -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->GetOverriddenShouldStopValue(); -// return StopInfo::GetOverriddenShouldStopValue(); -// } -// -// virtual void -// PerformAction (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->PerformAction(event_ptr); -// return StopInfo::PerformAction(event_ptr); -// } -// -// virtual bool -// ShouldStop (Event *event_ptr) -// { -// if (m_backing_stop_info_sp) -// return m_backing_stop_info_sp->ShouldStop(event_ptr); -// return StopInfo::ShouldStop(event_ptr); -// } -// -// -//protected: -// StopInfoSP m_backing_stop_info_sp; -// -//private: -// DISALLOW_COPY_AND_ASSIGN (StopInfoThreadMemory); -//}; - - -lldb::StopInfoSP -ThreadMemory::GetPrivateStopReason () +bool +ThreadMemory::CalculateStopInfo () { - if (m_actual_stop_info_sp) - return m_actual_stop_info_sp; - if (m_backing_thread_sp) { - lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopReason()); + lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopInfo()); if (backing_stop_info_sp) { - m_actual_stop_info_sp = backing_stop_info_sp; - m_actual_stop_info_sp->SetThread (shared_from_this()); - return m_actual_stop_info_sp; + backing_stop_info_sp->SetThread (shared_from_this()); + SetStopInfo (backing_stop_info_sp); + return true; } } - - ProcessSP process_sp (GetProcess()); - - if (process_sp) + else { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id != process_stop_id || - (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid())) - { - if (IsStillAtLastBreakpointHit()) - return m_actual_stop_info_sp; + ProcessSP process_sp (GetProcess()); - // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason - // for this thread, then m_actual_stop_info_sp will not ever contain - // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false" - // check will never be able to tell us if we have the correct stop info - // for this thread and we will continually send qThreadStopInfo packets - // down to the remote GDB server, so we need to keep our own notion - // of the stop ID that m_actual_stop_info_sp is valid for (even if it - // contains nothing). We use m_thread_stop_reason_stop_id for this below. - m_thread_stop_reason_stop_id = process_stop_id; - m_actual_stop_info_sp.reset(); - + if (process_sp) + { OperatingSystem *os = process_sp->GetOperatingSystem (); if (os) - m_actual_stop_info_sp = os->CreateThreadStopReason (this); + { + SetStopInfo (os->CreateThreadStopReason (this)); + return true; + } } } - return m_actual_stop_info_sp; - + return false; } void @@ -309,4 +134,7 @@ ThreadMemory::RefreshStateAfterStop() { if (m_backing_thread_sp) return m_backing_thread_sp->RefreshStateAfterStop(); + + if (m_reg_context_sp) + m_reg_context_sp->InvalidateAllRegisters(); } diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.h b/lldb/source/Plugins/Process/Utility/ThreadMemory.h index 2a1f7d6b67d..07eb45dcb43 100644 --- a/lldb/source/Plugins/Process/Utility/ThreadMemory.h +++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.h @@ -39,8 +39,8 @@ public: virtual lldb::RegisterContextSP CreateRegisterContextForFrame (lldb_private::StackFrame *frame); - virtual lldb::StopInfoSP - GetPrivateStopReason (); + virtual bool + CalculateStopInfo (); virtual const char * GetInfo () diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 0302f9312b7..0008dbfa288 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1770,7 +1770,7 @@ ProcessGDBRemote::DoDestroy () for (size_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = threads.GetThreadAtIndex(i); - StopInfoSP stop_info_sp = thread_sp->GetPrivateStopReason(); + StopInfoSP stop_info_sp = thread_sp->GetPrivateStopInfo(); StopReason reason = eStopReasonInvalid; if (stop_info_sp) reason = stop_info_sp->GetStopReason(); @@ -1805,7 +1805,7 @@ ProcessGDBRemote::DoDestroy () for (size_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = threads.GetThreadAtIndex(i); - StopInfoSP stop_info_sp = thread_sp->GetPrivateStopReason(); + StopInfoSP stop_info_sp = thread_sp->GetPrivateStopInfo(); StopReason reason = eStopReasonInvalid; if (stop_info_sp) reason = stop_info_sp->GetStopReason(); diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 40b367c3993..38fb84d66ef 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -197,56 +197,18 @@ ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, StringExtractor &respons return gdb_reg_ctx->PrivateSetRegisterValue (reg, response); } -lldb::StopInfoSP -ThreadGDBRemote::GetPrivateStopReason () +bool +ThreadGDBRemote::CalculateStopInfo () { ProcessSP process_sp (GetProcess()); if (process_sp) { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id == process_stop_id) - { - // Our stop info is up to date even if it is empty... - return m_actual_stop_info_sp; - } - - if (m_actual_stop_info_sp && m_actual_stop_info_sp->IsValid()) - { - // The stop info is up to date, reset it so everything updates - SetStopInfo (m_actual_stop_info_sp); - } - else - { - if (IsStillAtLastBreakpointHit()) - { - SetStopInfo(m_actual_stop_info_sp); - } - else - { - // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason - // for this thread, then m_actual_stop_info_sp will not ever contain - // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false" - // check will never be able to tell us if we have the correct stop info - // for this thread and we will continually send qThreadStopInfo packets - // down to the remote GDB server, so we need to keep our own notion - // of the stop ID that m_actual_stop_info_sp is valid for (even if it - // contains nothing). We use m_thread_stop_reason_stop_id for this below. - m_actual_stop_info_sp.reset(); - - StringExtractorGDBRemote stop_packet; - ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get()); - if (gdb_process->GetGDBRemote().GetThreadStopInfo(GetProtocolID(), stop_packet)) - { - gdb_process->SetThreadStopInfo (stop_packet); - } - else - { - SetStopInfo (StopInfoSP()); - } - } - } + StringExtractorGDBRemote stop_packet; + ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get()); + if (gdb_process->GetGDBRemote().GetThreadStopInfo(GetProtocolID(), stop_packet)) + return gdb_process->SetThreadStopInfo (stop_packet) == eStateStopped; } - return m_actual_stop_info_sp; + return false; } diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index 8dfc4bb78cb..50a3f19c650 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -98,8 +98,8 @@ protected: void SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id); - virtual lldb::StopInfoSP - GetPrivateStopReason (); + virtual bool + CalculateStopInfo (); }; diff --git a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp index a4e366101fa..85a7a20e042 100644 --- a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp @@ -117,39 +117,16 @@ ThreadMachCore::CreateRegisterContextForFrame (StackFrame *frame) return reg_ctx_sp; } -lldb::StopInfoSP -ThreadMachCore::GetPrivateStopReason () +bool +ThreadMachCore::CalculateStopInfo () { ProcessSP process_sp (GetProcess()); - if (process_sp) { - const uint32_t process_stop_id = process_sp->GetStopID(); - if (m_thread_stop_reason_stop_id != process_stop_id || - (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid())) - { - if (IsStillAtLastBreakpointHit()) - return m_actual_stop_info_sp; - - // TODO: can we query the initial state of the thread here? - // For now I am just going to pretend that a SIGSTOP happened. - - SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); - - // If GetKDPProcess().SetThreadStopInfo() doesn't find a stop reason - // for this thread, then m_actual_stop_info_sp will not ever contain - // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false" - // check will never be able to tell us if we have the correct stop info - // for this thread and we will continually send qThreadStopInfo packets - // down to the remote KDP server, so we need to keep our own notion - // of the stop ID that m_actual_stop_info_sp is valid for (even if it - // contains nothing). We use m_thread_stop_reason_stop_id for this below. - // m_thread_stop_reason_stop_id = process_stop_id; - // m_actual_stop_info_sp.reset(); - - } + SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP)); + return true; } - return m_actual_stop_info_sp; + return false; } diff --git a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h index cc687573c6a..756a04a3cbd 100644 --- a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h +++ b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h @@ -79,11 +79,10 @@ protected: lldb::addr_t m_thread_dispatch_qaddr; lldb::RegisterContextSP m_thread_reg_ctx_sp; //------------------------------------------------------------------ - // Member variables. + // Protected member functions. //------------------------------------------------------------------ - - virtual lldb::StopInfoSP - GetPrivateStopReason (); + virtual bool + CalculateStopInfo (); }; #endif // liblldb_ThreadMachCore_h_ |