diff options
author | Greg Clayton <gclayton@apple.com> | 2013-05-09 01:55:29 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-05-09 01:55:29 +0000 |
commit | 6e0ff1a3cb5a1719c12ce156c4297d724c20b955 (patch) | |
tree | 2ea43845a7393dc9bb2df095f72b25a3393ca914 /lldb/source/Plugins/Process/Utility/ThreadMemory.cpp | |
parent | 083fcdb41448362b803c47fe85dfeb830d25220c (diff) | |
download | bcm5719-llvm-6e0ff1a3cb5a1719c12ce156c4297d724c20b955.tar.gz bcm5719-llvm-6e0ff1a3cb5a1719c12ce156c4297d724c20b955.zip |
Changed the formerly pure virtual function:
namespace lldb_private {
class Thread
{
virtual lldb::StopInfoSP
GetPrivateStopReason() = 0;
};
}
To not be virtual. The lldb_private::Thread now handles the correct caching and will call a new pure virtual function:
namespace lldb_private {
class Thread
{
virtual bool
CalculateStopInfo() = 0;
}
}
This function must be overridden by thead lldb_private::Thread subclass and the only thing it needs to do is to set the Thread::StopInfo() with the current stop reason and return true, or return false if there is no stop reason. The lldb_private::Thread class will take care of calling this function only when it is required. This allows lldb_private::Thread subclasses to be a bit simpler and not all need to duplicate the cache and invalidation settings.
Also renamed:
lldb::StopInfoSP
lldb_private::Thread::GetPrivateStopReason();
To:
lldb::StopInfoSP
lldb_private::Thread::GetPrivateStopInfo();
Also cleaned up a case where the ThreadPlanStepOverBreakpoint might not re-set its breakpoint if the thread disappears (which was happening due to a bug when using the OperatingSystem plug-ins with memory threads and real threads).
llvm-svn: 181501
Diffstat (limited to 'lldb/source/Plugins/Process/Utility/ThreadMemory.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/Utility/ThreadMemory.cpp | 208 |
1 files changed, 18 insertions, 190 deletions
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(); } |