1 //===-- SBThread.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 "lldb/API/SBThread.h"
12 #include "lldb/API/SBSymbolContext.h"
13 #include "lldb/API/SBFileSpec.h"
14 #include "lldb/API/SBStream.h"
15 #include "lldb/Breakpoint/BreakpointLocation.h"
16 #include "lldb/Core/Debugger.h"
17 #include "lldb/Core/State.h"
18 #include "lldb/Core/Stream.h"
19 #include "lldb/Core/StreamFile.h"
20 #include "lldb/Core/StructuredData.h"
21 #include "lldb/Interpreter/CommandInterpreter.h"
22 #include "lldb/Target/SystemRuntime.h"
23 #include "lldb/Target/Thread.h"
24 #include "lldb/Target/ThreadPlan.h"
25 #include "lldb/Target/Process.h"
26 #include "lldb/Target/Queue.h"
27 #include "lldb/Symbol/SymbolContext.h"
28 #include "lldb/Symbol/CompileUnit.h"
29 #include "lldb/Target/StopInfo.h"
30 #include "lldb/Target/Target.h"
31 #include "lldb/Target/ThreadPlan.h"
32 #include "lldb/Target/ThreadPlanPython.h"
33 #include "lldb/Target/ThreadPlanStepInstruction.h"
34 #include "lldb/Target/ThreadPlanStepOut.h"
35 #include "lldb/Target/ThreadPlanStepRange.h"
36 #include "lldb/Target/ThreadPlanStepInRange.h"
39 #include "lldb/API/SBAddress.h"
40 #include "lldb/API/SBDebugger.h"
41 #include "lldb/API/SBEvent.h"
42 #include "lldb/API/SBFrame.h"
43 #include "lldb/API/SBProcess.h"
44 #include "lldb/API/SBThreadPlan.h"
45 #include "lldb/API/SBValue.h"
48 using namespace lldb_private;
50 //----------------------------------------------------------------------
52 //----------------------------------------------------------------------
53 SBThreadPlan::SBThreadPlan ()
57 SBThreadPlan::SBThreadPlan (const ThreadPlanSP& lldb_object_sp) :
58 m_opaque_sp (lldb_object_sp)
62 SBThreadPlan::SBThreadPlan (const SBThreadPlan &rhs) :
63 m_opaque_sp (rhs.m_opaque_sp)
68 SBThreadPlan::SBThreadPlan (lldb::SBThread &sb_thread, const char *class_name)
70 Thread *thread = sb_thread.get();
72 m_opaque_sp.reset(new ThreadPlanPython(*thread, class_name));
75 //----------------------------------------------------------------------
76 // Assignment operator
77 //----------------------------------------------------------------------
79 const lldb::SBThreadPlan &
80 SBThreadPlan::operator = (const SBThreadPlan &rhs)
83 m_opaque_sp = rhs.m_opaque_sp;
86 //----------------------------------------------------------------------
88 //----------------------------------------------------------------------
89 SBThreadPlan::~SBThreadPlan()
93 lldb_private::ThreadPlan *
96 return m_opaque_sp.get();
100 SBThreadPlan::IsValid() const
102 return m_opaque_sp.get() != NULL;
106 SBThreadPlan::Clear ()
112 SBThreadPlan::GetStopReason()
114 return eStopReasonNone;
118 SBThreadPlan::GetStopReasonDataCount()
124 SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx)
130 SBThreadPlan::GetThread () const
134 return SBThread(m_opaque_sp->GetThread().shared_from_this());
141 SBThreadPlan::GetDescription (lldb::SBStream &description) const
145 m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull);
149 description.Printf("Empty SBThreadPlan");
155 SBThreadPlan::SetThreadPlan (const ThreadPlanSP& lldb_object_sp)
157 m_opaque_sp = lldb_object_sp;
161 SBThreadPlan::SetPlanComplete (bool success)
164 m_opaque_sp->SetPlanComplete (success);
168 SBThreadPlan::IsPlanComplete()
171 return m_opaque_sp->IsPlanComplete();
177 SBThreadPlan::IsValid()
180 return m_opaque_sp->ValidatePlan(nullptr);
185 // This section allows an SBThreadPlan to push another of the common types of plans...
187 // FIXME, you should only be able to queue thread plans from inside the methods of a
188 // Scripted Thread Plan. Need a way to enforce that.
191 SBThreadPlan::QueueThreadPlanForStepOverRange (SBAddress &sb_start_address,
196 Address *start_address = sb_start_address.get();
199 return SBThreadPlan();
202 AddressRange range (*start_address, size);
204 start_address->CalculateSymbolContext(&sc);
205 return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange (false,
212 return SBThreadPlan();
217 SBThreadPlan::QueueThreadPlanForStepInRange (SBAddress &sb_start_address,
222 Address *start_address = sb_start_address.get();
225 return SBThreadPlan();
228 AddressRange range (*start_address, size);
230 start_address->CalculateSymbolContext(&sc);
231 return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForStepInRange (false,
239 return SBThreadPlan();
244 SBThreadPlan::QueueThreadPlanForStepOut (uint32_t frame_idx_to_step_to, bool first_insn)
249 sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
250 return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForStepOut (false,
256 frame_idx_to_step_to));
260 return SBThreadPlan();
265 SBThreadPlan::QueueThreadPlanForRunToAddress (SBAddress sb_address)
269 Address *address = sb_address.get();
271 return SBThreadPlan();
273 return SBThreadPlan (m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress (false,
279 return SBThreadPlan();