summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process/Utility/ThreadMemory.cpp')
-rw-r--r--lldb/source/Plugins/Process/Utility/ThreadMemory.cpp212
1 files changed, 180 insertions, 32 deletions
diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
index 62c6aeb9c75..3d08026cf98 100644
--- a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
@@ -13,6 +13,7 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Unwind.h"
+#include "Plugins/Process/Utility/RegisterContextThreadMemory.h"
using namespace lldb;
using namespace lldb_private;
@@ -53,42 +54,32 @@ ThreadMemory::~ThreadMemory()
DestroyThread();
}
-bool
+void
ThreadMemory::WillResume (StateType resume_state)
{
- ClearStackFrames();
- Thread::WillResume(resume_state);
+ if (m_backing_thread_sp)
+ m_backing_thread_sp->WillResume(resume_state);
+}
+void
+ThreadMemory::ClearStackFrames ()
+{
if (m_backing_thread_sp)
- return m_backing_thread_sp->WillResume(resume_state);
- return true;
+ m_backing_thread_sp->ClearStackFrames();
+ Thread::ClearStackFrames();
}
RegisterContextSP
ThreadMemory::GetRegisterContext ()
{
- if (m_backing_thread_sp)
- return m_backing_thread_sp->GetRegisterContext();
-
if (!m_reg_context_sp)
- {
- ProcessSP process_sp (GetProcess());
- if (process_sp)
- {
- OperatingSystem *os = process_sp->GetOperatingSystem ();
- if (os)
- m_reg_context_sp = os->CreateRegisterContextForThread (this, m_register_data_addr);
- }
- }
+ m_reg_context_sp.reset (new RegisterContextThreadMemory (*this, m_register_data_addr));
return m_reg_context_sp;
}
RegisterContextSP
ThreadMemory::CreateRegisterContextForFrame (StackFrame *frame)
{
- if (m_backing_thread_sp)
- return m_backing_thread_sp->CreateRegisterContextForFrame(frame);
-
RegisterContextSP reg_ctx_sp;
uint32_t concrete_frame_idx = 0;
@@ -108,11 +99,179 @@ 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 ()
{
+ if (m_actual_stop_info_sp)
+ return m_actual_stop_info_sp;
+
if (m_backing_thread_sp)
- return m_backing_thread_sp->GetPrivateStopReason();
+ {
+ lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopReason());
+ 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;
+ }
+ }
ProcessSP process_sp (GetProcess());
@@ -150,15 +309,4 @@ ThreadMemory::RefreshStateAfterStop()
{
if (m_backing_thread_sp)
return m_backing_thread_sp->RefreshStateAfterStop();
-
-
- // Don't fetch the registers by calling Thread::GetRegisterContext() below.
- // We might not have fetched any registers yet and we don't want to fetch
- // the registers just to call invalidate on them...
- RegisterContextSP reg_ctx_sp(m_reg_context_sp);
- if (reg_ctx_sp)
- {
- const bool force = true;
- reg_ctx_sp->InvalidateIfNeeded (force);
- }
}
OpenPOWER on IntegriCloud