1 //===-- ThreadMemory.cpp ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "Plugins/Process/Utility/ThreadMemory.h"
11 #include "lldb/Target/OperatingSystem.h"
12 #include "lldb/Target/RegisterContext.h"
13 #include "lldb/Target/Process.h"
14 #include "lldb/Target/StopInfo.h"
15 #include "lldb/Target/Unwind.h"
16 #include "Plugins/Process/Utility/RegisterContextThreadMemory.h"
19 using namespace lldb_private;
21 ThreadMemory::ThreadMemory (Process &process,
23 const ValueObjectSP &thread_info_valobj_sp) :
24 Thread (process, tid),
25 m_backing_thread_sp (),
26 m_thread_info_valobj_sp (thread_info_valobj_sp),
33 ThreadMemory::ThreadMemory (Process &process,
37 lldb::addr_t register_data_addr) :
38 Thread (process, tid),
39 m_backing_thread_sp (),
40 m_thread_info_valobj_sp (),
43 m_register_data_addr (register_data_addr)
52 ThreadMemory::~ThreadMemory()
58 ThreadMemory::WillResume (StateType resume_state)
60 if (m_backing_thread_sp)
61 m_backing_thread_sp->WillResume(resume_state);
65 ThreadMemory::ClearStackFrames ()
67 if (m_backing_thread_sp)
68 m_backing_thread_sp->ClearStackFrames();
69 Thread::ClearStackFrames();
73 ThreadMemory::GetRegisterContext ()
75 if (!m_reg_context_sp)
76 m_reg_context_sp.reset (new RegisterContextThreadMemory (*this, m_register_data_addr));
77 return m_reg_context_sp;
81 ThreadMemory::CreateRegisterContextForFrame (StackFrame *frame)
83 RegisterContextSP reg_ctx_sp;
84 uint32_t concrete_frame_idx = 0;
87 concrete_frame_idx = frame->GetConcreteFrameIndex ();
89 if (concrete_frame_idx == 0)
91 reg_ctx_sp = GetRegisterContext ();
95 Unwind *unwinder = GetUnwinder ();
97 reg_ctx_sp = unwinder->CreateRegisterContextForFrame (frame);
103 ThreadMemory::CalculateStopInfo ()
105 if (m_backing_thread_sp)
107 lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopInfo());
108 if (backing_stop_info_sp)
110 backing_stop_info_sp->SetThread (shared_from_this());
111 SetStopInfo (backing_stop_info_sp);
117 ProcessSP process_sp (GetProcess());
121 OperatingSystem *os = process_sp->GetOperatingSystem ();
124 SetStopInfo (os->CreateThreadStopReason (this));
133 ThreadMemory::RefreshStateAfterStop()
135 if (m_backing_thread_sp)
136 return m_backing_thread_sp->RefreshStateAfterStop();
138 if (m_reg_context_sp)
139 m_reg_context_sp->InvalidateAllRegisters();