xref: /src/contrib/llvm-project/lldb/source/API/SBThreadPlan.cpp (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1cfca06d7SDimitry Andric //===-- SBThreadPlan.cpp --------------------------------------------------===//
2205afe67SEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6205afe67SEd Maste //
7205afe67SEd Maste //===----------------------------------------------------------------------===//
8205afe67SEd Maste 
9205afe67SEd Maste #include "lldb/API/SBThread.h"
106f8fc217SDimitry Andric #include "lldb/Utility/Instrumentation.h"
11205afe67SEd Maste 
12205afe67SEd Maste #include "lldb/API/SBFileSpec.h"
13205afe67SEd Maste #include "lldb/API/SBStream.h"
14ead24645SDimitry Andric #include "lldb/API/SBStructuredData.h"
1514f1b3e8SDimitry Andric #include "lldb/API/SBSymbolContext.h"
16205afe67SEd Maste #include "lldb/Breakpoint/BreakpointLocation.h"
17205afe67SEd Maste #include "lldb/Core/Debugger.h"
18ead24645SDimitry Andric #include "lldb/Core/StructuredDataImpl.h"
19205afe67SEd Maste #include "lldb/Interpreter/CommandInterpreter.h"
2014f1b3e8SDimitry Andric #include "lldb/Symbol/CompileUnit.h"
2114f1b3e8SDimitry Andric #include "lldb/Symbol/SymbolContext.h"
22205afe67SEd Maste #include "lldb/Target/Process.h"
23205afe67SEd Maste #include "lldb/Target/Queue.h"
24205afe67SEd Maste #include "lldb/Target/StopInfo.h"
2514f1b3e8SDimitry Andric #include "lldb/Target/SystemRuntime.h"
26205afe67SEd Maste #include "lldb/Target/Target.h"
2714f1b3e8SDimitry Andric #include "lldb/Target/Thread.h"
2814f1b3e8SDimitry Andric #include "lldb/Target/ThreadPlan.h"
29205afe67SEd Maste #include "lldb/Target/ThreadPlanPython.h"
3014f1b3e8SDimitry Andric #include "lldb/Target/ThreadPlanStepInRange.h"
31205afe67SEd Maste #include "lldb/Target/ThreadPlanStepInstruction.h"
32205afe67SEd Maste #include "lldb/Target/ThreadPlanStepOut.h"
33205afe67SEd Maste #include "lldb/Target/ThreadPlanStepRange.h"
3494994d37SDimitry Andric #include "lldb/Utility/State.h"
3574a628f7SDimitry Andric #include "lldb/Utility/Stream.h"
361b306c26SDimitry Andric #include "lldb/Utility/StructuredData.h"
37205afe67SEd Maste 
38205afe67SEd Maste #include "lldb/API/SBAddress.h"
39205afe67SEd Maste #include "lldb/API/SBDebugger.h"
40205afe67SEd Maste #include "lldb/API/SBEvent.h"
41205afe67SEd Maste #include "lldb/API/SBFrame.h"
42205afe67SEd Maste #include "lldb/API/SBProcess.h"
43205afe67SEd Maste #include "lldb/API/SBThreadPlan.h"
44205afe67SEd Maste #include "lldb/API/SBValue.h"
45205afe67SEd Maste 
465f29bb8aSDimitry Andric #include <memory>
475f29bb8aSDimitry Andric 
48205afe67SEd Maste using namespace lldb;
49205afe67SEd Maste using namespace lldb_private;
50205afe67SEd Maste 
51205afe67SEd Maste // Constructors
SBThreadPlan()526f8fc217SDimitry Andric SBThreadPlan::SBThreadPlan() { LLDB_INSTRUMENT_VA(this); }
53205afe67SEd Maste 
SBThreadPlan(const ThreadPlanSP & lldb_object_sp)5414f1b3e8SDimitry Andric SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
55b60736ecSDimitry Andric     : m_opaque_wp(lldb_object_sp) {
566f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, lldb_object_sp);
575f29bb8aSDimitry Andric }
58205afe67SEd Maste 
SBThreadPlan(const SBThreadPlan & rhs)5914f1b3e8SDimitry Andric SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
60b60736ecSDimitry Andric     : m_opaque_wp(rhs.m_opaque_wp) {
616f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
625f29bb8aSDimitry Andric }
63205afe67SEd Maste 
SBThreadPlan(lldb::SBThread & sb_thread,const char * class_name)6414f1b3e8SDimitry Andric SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
656f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_thread, class_name);
665f29bb8aSDimitry Andric 
67205afe67SEd Maste   Thread *thread = sb_thread.get();
68205afe67SEd Maste   if (thread)
6977fc4c14SDimitry Andric     m_opaque_wp = std::make_shared<ThreadPlanPython>(*thread, class_name,
7077fc4c14SDimitry Andric                                                      StructuredDataImpl());
71ead24645SDimitry Andric }
72ead24645SDimitry Andric 
SBThreadPlan(lldb::SBThread & sb_thread,const char * class_name,lldb::SBStructuredData & args_data)73ead24645SDimitry Andric SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name,
74ead24645SDimitry Andric                            lldb::SBStructuredData &args_data) {
756f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_thread, class_name, args_data);
76ead24645SDimitry Andric 
77ead24645SDimitry Andric   Thread *thread = sb_thread.get();
78ead24645SDimitry Andric   if (thread)
79b60736ecSDimitry Andric     m_opaque_wp = std::make_shared<ThreadPlanPython>(*thread, class_name,
8077fc4c14SDimitry Andric                                                      *args_data.m_impl_up);
81205afe67SEd Maste }
82205afe67SEd Maste 
83205afe67SEd Maste // Assignment operator
84205afe67SEd Maste 
operator =(const SBThreadPlan & rhs)8514f1b3e8SDimitry Andric const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
866f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
875f29bb8aSDimitry Andric 
88205afe67SEd Maste   if (this != &rhs)
89b60736ecSDimitry Andric     m_opaque_wp = rhs.m_opaque_wp;
906f8fc217SDimitry Andric   return *this;
91205afe67SEd Maste }
92205afe67SEd Maste // Destructor
93cfca06d7SDimitry Andric SBThreadPlan::~SBThreadPlan() = default;
94205afe67SEd Maste 
IsValid() const955f29bb8aSDimitry Andric bool SBThreadPlan::IsValid() const {
966f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
975f29bb8aSDimitry Andric   return this->operator bool();
985f29bb8aSDimitry Andric }
operator bool() const995f29bb8aSDimitry Andric SBThreadPlan::operator bool() const {
1006f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
101205afe67SEd Maste 
102b60736ecSDimitry Andric   return static_cast<bool>(GetSP());
1035f29bb8aSDimitry Andric }
104205afe67SEd Maste 
Clear()1055f29bb8aSDimitry Andric void SBThreadPlan::Clear() {
1066f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
107205afe67SEd Maste 
108b60736ecSDimitry Andric   m_opaque_wp.reset();
1095f29bb8aSDimitry Andric }
110205afe67SEd Maste 
GetStopReason()1115f29bb8aSDimitry Andric lldb::StopReason SBThreadPlan::GetStopReason() {
1126f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1135f29bb8aSDimitry Andric 
1145f29bb8aSDimitry Andric   return eStopReasonNone;
1155f29bb8aSDimitry Andric }
1165f29bb8aSDimitry Andric 
GetStopReasonDataCount()1175f29bb8aSDimitry Andric size_t SBThreadPlan::GetStopReasonDataCount() {
1186f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1195f29bb8aSDimitry Andric 
1205f29bb8aSDimitry Andric   return 0;
1215f29bb8aSDimitry Andric }
1225f29bb8aSDimitry Andric 
GetStopReasonDataAtIndex(uint32_t idx)1235f29bb8aSDimitry Andric uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
1246f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, idx);
1255f29bb8aSDimitry Andric 
1265f29bb8aSDimitry Andric   return 0;
1275f29bb8aSDimitry Andric }
128205afe67SEd Maste 
GetThread() const12914f1b3e8SDimitry Andric SBThread SBThreadPlan::GetThread() const {
1306f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1315f29bb8aSDimitry Andric 
132b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
133b60736ecSDimitry Andric   if (thread_plan_sp) {
1346f8fc217SDimitry Andric     return SBThread(thread_plan_sp->GetThread().shared_from_this());
13514f1b3e8SDimitry Andric   } else
1366f8fc217SDimitry Andric     return SBThread();
137205afe67SEd Maste }
138205afe67SEd Maste 
GetDescription(lldb::SBStream & description) const13914f1b3e8SDimitry Andric bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
1406f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, description);
1415f29bb8aSDimitry Andric 
142b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
143b60736ecSDimitry Andric   if (thread_plan_sp) {
144b60736ecSDimitry Andric     thread_plan_sp->GetDescription(description.get(), eDescriptionLevelFull);
14514f1b3e8SDimitry Andric   } else {
146205afe67SEd Maste     description.Printf("Empty SBThreadPlan");
147205afe67SEd Maste   }
148205afe67SEd Maste   return true;
149205afe67SEd Maste }
150205afe67SEd Maste 
SetThreadPlan(const ThreadPlanSP & lldb_object_wp)151b60736ecSDimitry Andric void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_wp) {
152b60736ecSDimitry Andric   m_opaque_wp = lldb_object_wp;
153205afe67SEd Maste }
154205afe67SEd Maste 
SetPlanComplete(bool success)15514f1b3e8SDimitry Andric void SBThreadPlan::SetPlanComplete(bool success) {
1566f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, success);
1575f29bb8aSDimitry Andric 
158b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
159b60736ecSDimitry Andric   if (thread_plan_sp)
160b60736ecSDimitry Andric     thread_plan_sp->SetPlanComplete(success);
161205afe67SEd Maste }
162205afe67SEd Maste 
IsPlanComplete()16314f1b3e8SDimitry Andric bool SBThreadPlan::IsPlanComplete() {
1646f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1655f29bb8aSDimitry Andric 
166b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
167b60736ecSDimitry Andric   if (thread_plan_sp)
168b60736ecSDimitry Andric     return thread_plan_sp->IsPlanComplete();
169205afe67SEd Maste   return true;
170205afe67SEd Maste }
171205afe67SEd Maste 
IsPlanStale()17214f1b3e8SDimitry Andric bool SBThreadPlan::IsPlanStale() {
1736f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1745f29bb8aSDimitry Andric 
175b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
176b60736ecSDimitry Andric   if (thread_plan_sp)
177b60736ecSDimitry Andric     return thread_plan_sp->IsPlanStale();
17814f1b3e8SDimitry Andric   return true;
17914f1b3e8SDimitry Andric }
18014f1b3e8SDimitry Andric 
IsValid()18114f1b3e8SDimitry Andric bool SBThreadPlan::IsValid() {
1826f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1835f29bb8aSDimitry Andric 
184b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
185b60736ecSDimitry Andric   if (thread_plan_sp)
186b60736ecSDimitry Andric     return thread_plan_sp->ValidatePlan(nullptr);
187205afe67SEd Maste   return false;
188205afe67SEd Maste }
189205afe67SEd Maste 
GetStopOthers()190b60736ecSDimitry Andric bool SBThreadPlan::GetStopOthers() {
1916f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this);
192b60736ecSDimitry Andric 
193b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
194b60736ecSDimitry Andric   if (thread_plan_sp)
195b60736ecSDimitry Andric     return thread_plan_sp->StopOthers();
196b60736ecSDimitry Andric   return false;
197b60736ecSDimitry Andric }
198b60736ecSDimitry Andric 
SetStopOthers(bool stop_others)199b60736ecSDimitry Andric void SBThreadPlan::SetStopOthers(bool stop_others) {
2006f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, stop_others);
201b60736ecSDimitry Andric 
202b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
203b60736ecSDimitry Andric   if (thread_plan_sp)
204b60736ecSDimitry Andric     thread_plan_sp->SetStopOthers(stop_others);
205b60736ecSDimitry Andric }
206b60736ecSDimitry Andric 
20714f1b3e8SDimitry Andric // This section allows an SBThreadPlan to push another of the common types of
20814f1b3e8SDimitry Andric // plans...
209205afe67SEd Maste //
21014f1b3e8SDimitry Andric // FIXME, you should only be able to queue thread plans from inside the methods
211f73363f1SDimitry Andric // of a Scripted Thread Plan.  Need a way to enforce that.
212205afe67SEd Maste 
213205afe67SEd Maste SBThreadPlan
QueueThreadPlanForStepOverRange(SBAddress & sb_start_address,lldb::addr_t size)214205afe67SEd Maste SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
21514f1b3e8SDimitry Andric                                               lldb::addr_t size) {
2166f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_start_address, size);
2175f29bb8aSDimitry Andric 
21894994d37SDimitry Andric   SBError error;
2196f8fc217SDimitry Andric   return QueueThreadPlanForStepOverRange(sb_start_address, size, error);
22094994d37SDimitry Andric }
22194994d37SDimitry Andric 
QueueThreadPlanForStepOverRange(SBAddress & sb_start_address,lldb::addr_t size,SBError & error)22294994d37SDimitry Andric SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
22394994d37SDimitry Andric     SBAddress &sb_start_address, lldb::addr_t size, SBError &error) {
2246f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_start_address, size, error);
2255f29bb8aSDimitry Andric 
226b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
227b60736ecSDimitry Andric   if (thread_plan_sp) {
228205afe67SEd Maste     Address *start_address = sb_start_address.get();
22914f1b3e8SDimitry Andric     if (!start_address) {
2306f8fc217SDimitry Andric       return SBThreadPlan();
231205afe67SEd Maste     }
232205afe67SEd Maste 
233205afe67SEd Maste     AddressRange range(*start_address, size);
234205afe67SEd Maste     SymbolContext sc;
235205afe67SEd Maste     start_address->CalculateSymbolContext(&sc);
23694994d37SDimitry Andric     Status plan_status;
23794994d37SDimitry Andric 
238b60736ecSDimitry Andric     SBThreadPlan plan = SBThreadPlan(
239b60736ecSDimitry Andric         thread_plan_sp->GetThread().QueueThreadPlanForStepOverRange(
24094994d37SDimitry Andric             false, range, sc, eAllThreads, plan_status));
24194994d37SDimitry Andric 
24294994d37SDimitry Andric     if (plan_status.Fail())
24394994d37SDimitry Andric       error.SetErrorString(plan_status.AsCString());
244cfca06d7SDimitry Andric     else
245b60736ecSDimitry Andric       plan.GetSP()->SetPrivate(true);
24694994d37SDimitry Andric 
2476f8fc217SDimitry Andric     return plan;
248205afe67SEd Maste   }
2496f8fc217SDimitry Andric   return SBThreadPlan();
250205afe67SEd Maste }
251205afe67SEd Maste 
252205afe67SEd Maste SBThreadPlan
QueueThreadPlanForStepInRange(SBAddress & sb_start_address,lldb::addr_t size)253205afe67SEd Maste SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
25414f1b3e8SDimitry Andric                                             lldb::addr_t size) {
2556f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_start_address, size);
2565f29bb8aSDimitry Andric 
25794994d37SDimitry Andric   SBError error;
2586f8fc217SDimitry Andric   return QueueThreadPlanForStepInRange(sb_start_address, size, error);
25994994d37SDimitry Andric }
26094994d37SDimitry Andric 
26194994d37SDimitry Andric SBThreadPlan
QueueThreadPlanForStepInRange(SBAddress & sb_start_address,lldb::addr_t size,SBError & error)26294994d37SDimitry Andric SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
26394994d37SDimitry Andric                                             lldb::addr_t size, SBError &error) {
2646f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_start_address, size, error);
2655f29bb8aSDimitry Andric 
266b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
267b60736ecSDimitry Andric   if (thread_plan_sp) {
268205afe67SEd Maste     Address *start_address = sb_start_address.get();
26914f1b3e8SDimitry Andric     if (!start_address) {
2706f8fc217SDimitry Andric       return SBThreadPlan();
271205afe67SEd Maste     }
272205afe67SEd Maste 
273205afe67SEd Maste     AddressRange range(*start_address, size);
274205afe67SEd Maste     SymbolContext sc;
275205afe67SEd Maste     start_address->CalculateSymbolContext(&sc);
27694994d37SDimitry Andric 
27794994d37SDimitry Andric     Status plan_status;
27894994d37SDimitry Andric     SBThreadPlan plan =
279b60736ecSDimitry Andric         SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepInRange(
2805f29bb8aSDimitry Andric             false, range, sc, nullptr, eAllThreads, plan_status));
28194994d37SDimitry Andric 
28294994d37SDimitry Andric     if (plan_status.Fail())
28394994d37SDimitry Andric       error.SetErrorString(plan_status.AsCString());
284cfca06d7SDimitry Andric     else
285b60736ecSDimitry Andric       plan.GetSP()->SetPrivate(true);
28694994d37SDimitry Andric 
2876f8fc217SDimitry Andric     return plan;
288205afe67SEd Maste   }
2896f8fc217SDimitry Andric   return SBThreadPlan();
290205afe67SEd Maste }
291205afe67SEd Maste 
292205afe67SEd Maste SBThreadPlan
QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,bool first_insn)29314f1b3e8SDimitry Andric SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
29414f1b3e8SDimitry Andric                                         bool first_insn) {
2956f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, frame_idx_to_step_to, first_insn);
2965f29bb8aSDimitry Andric 
29794994d37SDimitry Andric   SBError error;
2986f8fc217SDimitry Andric   return QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error);
29994994d37SDimitry Andric }
30094994d37SDimitry Andric 
30194994d37SDimitry Andric SBThreadPlan
QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,bool first_insn,SBError & error)30294994d37SDimitry Andric SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
30394994d37SDimitry Andric                                         bool first_insn, SBError &error) {
3046f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, frame_idx_to_step_to, first_insn, error);
3055f29bb8aSDimitry Andric 
306b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
307b60736ecSDimitry Andric   if (thread_plan_sp) {
308205afe67SEd Maste     SymbolContext sc;
309b60736ecSDimitry Andric     sc = thread_plan_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
31014f1b3e8SDimitry Andric         lldb::eSymbolContextEverything);
31194994d37SDimitry Andric 
31294994d37SDimitry Andric     Status plan_status;
31394994d37SDimitry Andric     SBThreadPlan plan =
314b60736ecSDimitry Andric         SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepOut(
31514f1b3e8SDimitry Andric             false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion,
31694994d37SDimitry Andric             frame_idx_to_step_to, plan_status));
31794994d37SDimitry Andric 
31894994d37SDimitry Andric     if (plan_status.Fail())
31994994d37SDimitry Andric       error.SetErrorString(plan_status.AsCString());
320cfca06d7SDimitry Andric     else
321b60736ecSDimitry Andric       plan.GetSP()->SetPrivate(true);
32294994d37SDimitry Andric 
3236f8fc217SDimitry Andric     return plan;
324205afe67SEd Maste   }
3256f8fc217SDimitry Andric   return SBThreadPlan();
326205afe67SEd Maste }
327205afe67SEd Maste 
328205afe67SEd Maste SBThreadPlan
QueueThreadPlanForRunToAddress(SBAddress sb_address)32914f1b3e8SDimitry Andric SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
3306f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_address);
3315f29bb8aSDimitry Andric 
33294994d37SDimitry Andric   SBError error;
3336f8fc217SDimitry Andric   return QueueThreadPlanForRunToAddress(sb_address, error);
33494994d37SDimitry Andric }
33594994d37SDimitry Andric 
QueueThreadPlanForRunToAddress(SBAddress sb_address,SBError & error)33694994d37SDimitry Andric SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
33794994d37SDimitry Andric                                                           SBError &error) {
3386f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, sb_address, error);
3395f29bb8aSDimitry Andric 
340b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
341b60736ecSDimitry Andric   if (thread_plan_sp) {
342205afe67SEd Maste     Address *address = sb_address.get();
343205afe67SEd Maste     if (!address)
3446f8fc217SDimitry Andric       return SBThreadPlan();
345205afe67SEd Maste 
34694994d37SDimitry Andric     Status plan_status;
34794994d37SDimitry Andric     SBThreadPlan plan =
348b60736ecSDimitry Andric         SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForRunToAddress(
34994994d37SDimitry Andric             false, *address, false, plan_status));
35094994d37SDimitry Andric 
35194994d37SDimitry Andric     if (plan_status.Fail())
35294994d37SDimitry Andric       error.SetErrorString(plan_status.AsCString());
353cfca06d7SDimitry Andric     else
354b60736ecSDimitry Andric       plan.GetSP()->SetPrivate(true);
35594994d37SDimitry Andric 
3566f8fc217SDimitry Andric     return plan;
35794994d37SDimitry Andric   }
3586f8fc217SDimitry Andric   return SBThreadPlan();
35994994d37SDimitry Andric }
36094994d37SDimitry Andric 
36194994d37SDimitry Andric SBThreadPlan
QueueThreadPlanForStepScripted(const char * script_class_name)36294994d37SDimitry Andric SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) {
3636f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, script_class_name);
3645f29bb8aSDimitry Andric 
36594994d37SDimitry Andric   SBError error;
3666f8fc217SDimitry Andric   return QueueThreadPlanForStepScripted(script_class_name, error);
36794994d37SDimitry Andric }
36894994d37SDimitry Andric 
36994994d37SDimitry Andric SBThreadPlan
QueueThreadPlanForStepScripted(const char * script_class_name,SBError & error)37094994d37SDimitry Andric SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
37194994d37SDimitry Andric                                              SBError &error) {
3726f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, script_class_name, error);
3735f29bb8aSDimitry Andric 
374b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
375b60736ecSDimitry Andric   if (thread_plan_sp) {
37694994d37SDimitry Andric     Status plan_status;
377ead24645SDimitry Andric     StructuredData::ObjectSP empty_args;
37894994d37SDimitry Andric     SBThreadPlan plan =
379b60736ecSDimitry Andric         SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
380ead24645SDimitry Andric             false, script_class_name, empty_args, false, plan_status));
381ead24645SDimitry Andric 
382ead24645SDimitry Andric     if (plan_status.Fail())
383ead24645SDimitry Andric       error.SetErrorString(plan_status.AsCString());
384cfca06d7SDimitry Andric     else
385b60736ecSDimitry Andric       plan.GetSP()->SetPrivate(true);
386ead24645SDimitry Andric 
3876f8fc217SDimitry Andric     return plan;
388ead24645SDimitry Andric   }
3896f8fc217SDimitry Andric   return SBThreadPlan();
390ead24645SDimitry Andric }
391ead24645SDimitry Andric 
392ead24645SDimitry Andric SBThreadPlan
QueueThreadPlanForStepScripted(const char * script_class_name,lldb::SBStructuredData & args_data,SBError & error)393ead24645SDimitry Andric SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
394ead24645SDimitry Andric                                              lldb::SBStructuredData &args_data,
395ead24645SDimitry Andric                                              SBError &error) {
3966f8fc217SDimitry Andric   LLDB_INSTRUMENT_VA(this, script_class_name, args_data, error);
397ead24645SDimitry Andric 
398b60736ecSDimitry Andric   ThreadPlanSP thread_plan_sp(GetSP());
399b60736ecSDimitry Andric   if (thread_plan_sp) {
400ead24645SDimitry Andric     Status plan_status;
401ead24645SDimitry Andric     StructuredData::ObjectSP args_obj = args_data.m_impl_up->GetObjectSP();
402ead24645SDimitry Andric     SBThreadPlan plan =
403b60736ecSDimitry Andric         SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
404ead24645SDimitry Andric             false, script_class_name, args_obj, false, plan_status));
40594994d37SDimitry Andric 
40694994d37SDimitry Andric     if (plan_status.Fail())
40794994d37SDimitry Andric       error.SetErrorString(plan_status.AsCString());
408cfca06d7SDimitry Andric     else
409b60736ecSDimitry Andric       plan.GetSP()->SetPrivate(true);
41094994d37SDimitry Andric 
4116f8fc217SDimitry Andric     return plan;
41214f1b3e8SDimitry Andric   } else {
4136f8fc217SDimitry Andric     return SBThreadPlan();
414205afe67SEd Maste   }
415205afe67SEd Maste }
416