180814287SRaphael Isemann //===-- SBThreadPlan.cpp --------------------------------------------------===//
22bdbfd50SJim Ingham //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
62bdbfd50SJim Ingham //
72bdbfd50SJim Ingham //===----------------------------------------------------------------------===//
82bdbfd50SJim Ingham
92bdbfd50SJim Ingham #include "lldb/API/SBThread.h"
10*1755f5b1SJonas Devlieghere #include "lldb/Utility/Instrumentation.h"
112bdbfd50SJim Ingham
122bdbfd50SJim Ingham #include "lldb/API/SBFileSpec.h"
132bdbfd50SJim Ingham #include "lldb/API/SBStream.h"
1427a14f19SJim Ingham #include "lldb/API/SBStructuredData.h"
15b9c1b51eSKate Stone #include "lldb/API/SBSymbolContext.h"
162bdbfd50SJim Ingham #include "lldb/Breakpoint/BreakpointLocation.h"
172bdbfd50SJim Ingham #include "lldb/Core/Debugger.h"
182bdbfd50SJim Ingham #include "lldb/Core/StreamFile.h"
1927a14f19SJim Ingham #include "lldb/Core/StructuredDataImpl.h"
202bdbfd50SJim Ingham #include "lldb/Interpreter/CommandInterpreter.h"
21b9c1b51eSKate Stone #include "lldb/Symbol/CompileUnit.h"
22b9c1b51eSKate Stone #include "lldb/Symbol/SymbolContext.h"
232bdbfd50SJim Ingham #include "lldb/Target/Process.h"
242bdbfd50SJim Ingham #include "lldb/Target/Queue.h"
252bdbfd50SJim Ingham #include "lldb/Target/StopInfo.h"
26b9c1b51eSKate Stone #include "lldb/Target/SystemRuntime.h"
272bdbfd50SJim Ingham #include "lldb/Target/Target.h"
28b9c1b51eSKate Stone #include "lldb/Target/Thread.h"
29b9c1b51eSKate Stone #include "lldb/Target/ThreadPlan.h"
302bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanPython.h"
31b9c1b51eSKate Stone #include "lldb/Target/ThreadPlanStepInRange.h"
322bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepInstruction.h"
332bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepOut.h"
342bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepRange.h"
35d821c997SPavel Labath #include "lldb/Utility/State.h"
36bf9a7730SZachary Turner #include "lldb/Utility/Stream.h"
37f2a8bccfSPavel Labath #include "lldb/Utility/StructuredData.h"
382bdbfd50SJim Ingham
392bdbfd50SJim Ingham #include "lldb/API/SBAddress.h"
402bdbfd50SJim Ingham #include "lldb/API/SBDebugger.h"
412bdbfd50SJim Ingham #include "lldb/API/SBEvent.h"
422bdbfd50SJim Ingham #include "lldb/API/SBFrame.h"
432bdbfd50SJim Ingham #include "lldb/API/SBProcess.h"
442bdbfd50SJim Ingham #include "lldb/API/SBThreadPlan.h"
452bdbfd50SJim Ingham #include "lldb/API/SBValue.h"
462bdbfd50SJim Ingham
47796ac80bSJonas Devlieghere #include <memory>
48796ac80bSJonas Devlieghere
492bdbfd50SJim Ingham using namespace lldb;
502bdbfd50SJim Ingham using namespace lldb_private;
512bdbfd50SJim Ingham
522bdbfd50SJim Ingham // Constructors
SBThreadPlan()53*1755f5b1SJonas Devlieghere SBThreadPlan::SBThreadPlan() { LLDB_INSTRUMENT_VA(this); }
542bdbfd50SJim Ingham
SBThreadPlan(const ThreadPlanSP & lldb_object_sp)55b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
562ba7ce40SJonas Devlieghere : m_opaque_wp(lldb_object_sp) {
57*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, lldb_object_sp);
58baf5664fSJonas Devlieghere }
592bdbfd50SJim Ingham
SBThreadPlan(const SBThreadPlan & rhs)60b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
612ba7ce40SJonas Devlieghere : m_opaque_wp(rhs.m_opaque_wp) {
62*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, rhs);
63baf5664fSJonas Devlieghere }
642bdbfd50SJim Ingham
SBThreadPlan(lldb::SBThread & sb_thread,const char * class_name)65b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
66*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_thread, class_name);
67baf5664fSJonas Devlieghere
682bdbfd50SJim Ingham Thread *thread = sb_thread.get();
692bdbfd50SJim Ingham if (thread)
7082de8df2SPavel Labath m_opaque_wp = std::make_shared<ThreadPlanPython>(*thread, class_name,
7182de8df2SPavel Labath StructuredDataImpl());
7227a14f19SJim Ingham }
7327a14f19SJim Ingham
SBThreadPlan(lldb::SBThread & sb_thread,const char * class_name,lldb::SBStructuredData & args_data)7427a14f19SJim Ingham SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name,
7527a14f19SJim Ingham lldb::SBStructuredData &args_data) {
76*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_thread, class_name, args_data);
7727a14f19SJim Ingham
7827a14f19SJim Ingham Thread *thread = sb_thread.get();
7927a14f19SJim Ingham if (thread)
802ba7ce40SJonas Devlieghere m_opaque_wp = std::make_shared<ThreadPlanPython>(*thread, class_name,
8182de8df2SPavel Labath *args_data.m_impl_up);
822bdbfd50SJim Ingham }
832bdbfd50SJim Ingham
842bdbfd50SJim Ingham // Assignment operator
852bdbfd50SJim Ingham
operator =(const SBThreadPlan & rhs)86b9c1b51eSKate Stone const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
87*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, rhs);
88baf5664fSJonas Devlieghere
892bdbfd50SJim Ingham if (this != &rhs)
902ba7ce40SJonas Devlieghere m_opaque_wp = rhs.m_opaque_wp;
91d232abc3SJonas Devlieghere return *this;
922bdbfd50SJim Ingham }
932bdbfd50SJim Ingham // Destructor
94866b7a65SJonas Devlieghere SBThreadPlan::~SBThreadPlan() = default;
952bdbfd50SJim Ingham
IsValid() const96baf5664fSJonas Devlieghere bool SBThreadPlan::IsValid() const {
97*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
987f5237bcSPavel Labath return this->operator bool();
997f5237bcSPavel Labath }
operator bool() const1007f5237bcSPavel Labath SBThreadPlan::operator bool() const {
101*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
1022bdbfd50SJim Ingham
1032ba7ce40SJonas Devlieghere return static_cast<bool>(GetSP());
104baf5664fSJonas Devlieghere }
1052bdbfd50SJim Ingham
Clear()106baf5664fSJonas Devlieghere void SBThreadPlan::Clear() {
107*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
1082bdbfd50SJim Ingham
1092ba7ce40SJonas Devlieghere m_opaque_wp.reset();
110baf5664fSJonas Devlieghere }
111baf5664fSJonas Devlieghere
GetStopReason()112baf5664fSJonas Devlieghere lldb::StopReason SBThreadPlan::GetStopReason() {
113*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
114baf5664fSJonas Devlieghere
115baf5664fSJonas Devlieghere return eStopReasonNone;
116baf5664fSJonas Devlieghere }
117baf5664fSJonas Devlieghere
GetStopReasonDataCount()118baf5664fSJonas Devlieghere size_t SBThreadPlan::GetStopReasonDataCount() {
119*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
120baf5664fSJonas Devlieghere
121baf5664fSJonas Devlieghere return 0;
122baf5664fSJonas Devlieghere }
123baf5664fSJonas Devlieghere
GetStopReasonDataAtIndex(uint32_t idx)124baf5664fSJonas Devlieghere uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
125*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, idx);
126baf5664fSJonas Devlieghere
127baf5664fSJonas Devlieghere return 0;
128baf5664fSJonas Devlieghere }
1292bdbfd50SJim Ingham
GetThread() const130b9c1b51eSKate Stone SBThread SBThreadPlan::GetThread() const {
131*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
132baf5664fSJonas Devlieghere
1332ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
1342ba7ce40SJonas Devlieghere if (thread_plan_sp) {
135d232abc3SJonas Devlieghere return SBThread(thread_plan_sp->GetThread().shared_from_this());
136b9c1b51eSKate Stone } else
137d232abc3SJonas Devlieghere return SBThread();
1382bdbfd50SJim Ingham }
1392bdbfd50SJim Ingham
GetDescription(lldb::SBStream & description) const140b9c1b51eSKate Stone bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
141*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, description);
142baf5664fSJonas Devlieghere
1432ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
1442ba7ce40SJonas Devlieghere if (thread_plan_sp) {
1452ba7ce40SJonas Devlieghere thread_plan_sp->GetDescription(description.get(), eDescriptionLevelFull);
146b9c1b51eSKate Stone } else {
1472bdbfd50SJim Ingham description.Printf("Empty SBThreadPlan");
1482bdbfd50SJim Ingham }
1492bdbfd50SJim Ingham return true;
1502bdbfd50SJim Ingham }
1512bdbfd50SJim Ingham
SetThreadPlan(const ThreadPlanSP & lldb_object_wp)1522ba7ce40SJonas Devlieghere void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_wp) {
1532ba7ce40SJonas Devlieghere m_opaque_wp = lldb_object_wp;
1542bdbfd50SJim Ingham }
1552bdbfd50SJim Ingham
SetPlanComplete(bool success)156b9c1b51eSKate Stone void SBThreadPlan::SetPlanComplete(bool success) {
157*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, success);
158baf5664fSJonas Devlieghere
1592ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
1602ba7ce40SJonas Devlieghere if (thread_plan_sp)
1612ba7ce40SJonas Devlieghere thread_plan_sp->SetPlanComplete(success);
1622bdbfd50SJim Ingham }
1632bdbfd50SJim Ingham
IsPlanComplete()164b9c1b51eSKate Stone bool SBThreadPlan::IsPlanComplete() {
165*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
166baf5664fSJonas Devlieghere
1672ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
1682ba7ce40SJonas Devlieghere if (thread_plan_sp)
1692ba7ce40SJonas Devlieghere return thread_plan_sp->IsPlanComplete();
1702bdbfd50SJim Ingham return true;
1712bdbfd50SJim Ingham }
1722bdbfd50SJim Ingham
IsPlanStale()173b9c1b51eSKate Stone bool SBThreadPlan::IsPlanStale() {
174*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
175baf5664fSJonas Devlieghere
1762ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
1772ba7ce40SJonas Devlieghere if (thread_plan_sp)
1782ba7ce40SJonas Devlieghere return thread_plan_sp->IsPlanStale();
179c915a7d2SJim Ingham return true;
180c915a7d2SJim Ingham }
181c915a7d2SJim Ingham
IsValid()182b9c1b51eSKate Stone bool SBThreadPlan::IsValid() {
183*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
184baf5664fSJonas Devlieghere
1852ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
1862ba7ce40SJonas Devlieghere if (thread_plan_sp)
1872ba7ce40SJonas Devlieghere return thread_plan_sp->ValidatePlan(nullptr);
1882bdbfd50SJim Ingham return false;
1892bdbfd50SJim Ingham }
1902bdbfd50SJim Ingham
GetStopOthers()191d3dfd8ceSJim Ingham bool SBThreadPlan::GetStopOthers() {
192*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
193d3dfd8ceSJim Ingham
194d3dfd8ceSJim Ingham ThreadPlanSP thread_plan_sp(GetSP());
195d3dfd8ceSJim Ingham if (thread_plan_sp)
196d3dfd8ceSJim Ingham return thread_plan_sp->StopOthers();
197d3dfd8ceSJim Ingham return false;
198d3dfd8ceSJim Ingham }
199d3dfd8ceSJim Ingham
SetStopOthers(bool stop_others)200d3dfd8ceSJim Ingham void SBThreadPlan::SetStopOthers(bool stop_others) {
201*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, stop_others);
202d3dfd8ceSJim Ingham
203d3dfd8ceSJim Ingham ThreadPlanSP thread_plan_sp(GetSP());
204d3dfd8ceSJim Ingham if (thread_plan_sp)
205d3dfd8ceSJim Ingham thread_plan_sp->SetStopOthers(stop_others);
206d3dfd8ceSJim Ingham }
207d3dfd8ceSJim Ingham
208b9c1b51eSKate Stone // This section allows an SBThreadPlan to push another of the common types of
209b9c1b51eSKate Stone // plans...
2102bdbfd50SJim Ingham //
211b9c1b51eSKate Stone // FIXME, you should only be able to queue thread plans from inside the methods
21205097246SAdrian Prantl // of a Scripted Thread Plan. Need a way to enforce that.
2132bdbfd50SJim Ingham
2142bdbfd50SJim Ingham SBThreadPlan
QueueThreadPlanForStepOverRange(SBAddress & sb_start_address,lldb::addr_t size)2152bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
216b9c1b51eSKate Stone lldb::addr_t size) {
217*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_start_address, size);
218baf5664fSJonas Devlieghere
219e103ae92SJonas Devlieghere SBError error;
220d232abc3SJonas Devlieghere return QueueThreadPlanForStepOverRange(sb_start_address, size, error);
221e103ae92SJonas Devlieghere }
222e103ae92SJonas Devlieghere
QueueThreadPlanForStepOverRange(SBAddress & sb_start_address,lldb::addr_t size,SBError & error)223e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
224e103ae92SJonas Devlieghere SBAddress &sb_start_address, lldb::addr_t size, SBError &error) {
225*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_start_address, size, error);
226baf5664fSJonas Devlieghere
2272ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
2282ba7ce40SJonas Devlieghere if (thread_plan_sp) {
2292bdbfd50SJim Ingham Address *start_address = sb_start_address.get();
230b9c1b51eSKate Stone if (!start_address) {
231d232abc3SJonas Devlieghere return SBThreadPlan();
2322bdbfd50SJim Ingham }
2332bdbfd50SJim Ingham
2342bdbfd50SJim Ingham AddressRange range(*start_address, size);
2352bdbfd50SJim Ingham SymbolContext sc;
2362bdbfd50SJim Ingham start_address->CalculateSymbolContext(&sc);
237e103ae92SJonas Devlieghere Status plan_status;
238e103ae92SJonas Devlieghere
2392ba7ce40SJonas Devlieghere SBThreadPlan plan = SBThreadPlan(
2402ba7ce40SJonas Devlieghere thread_plan_sp->GetThread().QueueThreadPlanForStepOverRange(
241e103ae92SJonas Devlieghere false, range, sc, eAllThreads, plan_status));
242e103ae92SJonas Devlieghere
243e103ae92SJonas Devlieghere if (plan_status.Fail())
244e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString());
245f7de4b5dSJim Ingham else
2462ba7ce40SJonas Devlieghere plan.GetSP()->SetPrivate(true);
247e103ae92SJonas Devlieghere
248d232abc3SJonas Devlieghere return plan;
2492bdbfd50SJim Ingham }
250d232abc3SJonas Devlieghere return SBThreadPlan();
2512bdbfd50SJim Ingham }
2522bdbfd50SJim Ingham
2532bdbfd50SJim Ingham SBThreadPlan
QueueThreadPlanForStepInRange(SBAddress & sb_start_address,lldb::addr_t size)2542bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
255b9c1b51eSKate Stone lldb::addr_t size) {
256*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_start_address, size);
257baf5664fSJonas Devlieghere
258e103ae92SJonas Devlieghere SBError error;
259d232abc3SJonas Devlieghere return QueueThreadPlanForStepInRange(sb_start_address, size, error);
260e103ae92SJonas Devlieghere }
261e103ae92SJonas Devlieghere
262e103ae92SJonas Devlieghere SBThreadPlan
QueueThreadPlanForStepInRange(SBAddress & sb_start_address,lldb::addr_t size,SBError & error)263e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
264e103ae92SJonas Devlieghere lldb::addr_t size, SBError &error) {
265*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_start_address, size, error);
266baf5664fSJonas Devlieghere
2672ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
2682ba7ce40SJonas Devlieghere if (thread_plan_sp) {
2692bdbfd50SJim Ingham Address *start_address = sb_start_address.get();
270b9c1b51eSKate Stone if (!start_address) {
271d232abc3SJonas Devlieghere return SBThreadPlan();
2722bdbfd50SJim Ingham }
2732bdbfd50SJim Ingham
2742bdbfd50SJim Ingham AddressRange range(*start_address, size);
2752bdbfd50SJim Ingham SymbolContext sc;
2762bdbfd50SJim Ingham start_address->CalculateSymbolContext(&sc);
277e103ae92SJonas Devlieghere
278e103ae92SJonas Devlieghere Status plan_status;
279e103ae92SJonas Devlieghere SBThreadPlan plan =
2802ba7ce40SJonas Devlieghere SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepInRange(
281248a1305SKonrad Kleine false, range, sc, nullptr, eAllThreads, plan_status));
282e103ae92SJonas Devlieghere
283e103ae92SJonas Devlieghere if (plan_status.Fail())
284e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString());
285f7de4b5dSJim Ingham else
2862ba7ce40SJonas Devlieghere plan.GetSP()->SetPrivate(true);
287e103ae92SJonas Devlieghere
288d232abc3SJonas Devlieghere return plan;
2892bdbfd50SJim Ingham }
290d232abc3SJonas Devlieghere return SBThreadPlan();
2912bdbfd50SJim Ingham }
2922bdbfd50SJim Ingham
2932bdbfd50SJim Ingham SBThreadPlan
QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,bool first_insn)294b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
295b9c1b51eSKate Stone bool first_insn) {
296*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, frame_idx_to_step_to, first_insn);
297baf5664fSJonas Devlieghere
298e103ae92SJonas Devlieghere SBError error;
299d232abc3SJonas Devlieghere return QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error);
300e103ae92SJonas Devlieghere }
301e103ae92SJonas Devlieghere
302e103ae92SJonas Devlieghere SBThreadPlan
QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,bool first_insn,SBError & error)303e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
304e103ae92SJonas Devlieghere bool first_insn, SBError &error) {
305*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, frame_idx_to_step_to, first_insn, error);
306baf5664fSJonas Devlieghere
3072ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
3082ba7ce40SJonas Devlieghere if (thread_plan_sp) {
3092bdbfd50SJim Ingham SymbolContext sc;
3102ba7ce40SJonas Devlieghere sc = thread_plan_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
311b9c1b51eSKate Stone lldb::eSymbolContextEverything);
312e103ae92SJonas Devlieghere
313e103ae92SJonas Devlieghere Status plan_status;
314e103ae92SJonas Devlieghere SBThreadPlan plan =
3152ba7ce40SJonas Devlieghere SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepOut(
316b9c1b51eSKate Stone false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion,
317e103ae92SJonas Devlieghere frame_idx_to_step_to, plan_status));
318e103ae92SJonas Devlieghere
319e103ae92SJonas Devlieghere if (plan_status.Fail())
320e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString());
321f7de4b5dSJim Ingham else
3222ba7ce40SJonas Devlieghere plan.GetSP()->SetPrivate(true);
323e103ae92SJonas Devlieghere
324d232abc3SJonas Devlieghere return plan;
3252bdbfd50SJim Ingham }
326d232abc3SJonas Devlieghere return SBThreadPlan();
3272bdbfd50SJim Ingham }
3282bdbfd50SJim Ingham
3292bdbfd50SJim Ingham SBThreadPlan
QueueThreadPlanForRunToAddress(SBAddress sb_address)330b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
331*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_address);
332baf5664fSJonas Devlieghere
333e103ae92SJonas Devlieghere SBError error;
334d232abc3SJonas Devlieghere return QueueThreadPlanForRunToAddress(sb_address, error);
335e103ae92SJonas Devlieghere }
336e103ae92SJonas Devlieghere
QueueThreadPlanForRunToAddress(SBAddress sb_address,SBError & error)337e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
338e103ae92SJonas Devlieghere SBError &error) {
339*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, sb_address, error);
340baf5664fSJonas Devlieghere
3412ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
3422ba7ce40SJonas Devlieghere if (thread_plan_sp) {
3432bdbfd50SJim Ingham Address *address = sb_address.get();
3442bdbfd50SJim Ingham if (!address)
345d232abc3SJonas Devlieghere return SBThreadPlan();
3462bdbfd50SJim Ingham
347e103ae92SJonas Devlieghere Status plan_status;
348e103ae92SJonas Devlieghere SBThreadPlan plan =
3492ba7ce40SJonas Devlieghere SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForRunToAddress(
350e103ae92SJonas Devlieghere false, *address, false, plan_status));
351e103ae92SJonas Devlieghere
352e103ae92SJonas Devlieghere if (plan_status.Fail())
353e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString());
354f7de4b5dSJim Ingham else
3552ba7ce40SJonas Devlieghere plan.GetSP()->SetPrivate(true);
356e103ae92SJonas Devlieghere
357d232abc3SJonas Devlieghere return plan;
3582bdbfd50SJim Ingham }
359d232abc3SJonas Devlieghere return SBThreadPlan();
3602bdbfd50SJim Ingham }
361c1c0fac7SAleksandr Urakov
362c1c0fac7SAleksandr Urakov SBThreadPlan
QueueThreadPlanForStepScripted(const char * script_class_name)363c1c0fac7SAleksandr Urakov SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) {
364*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, script_class_name);
365baf5664fSJonas Devlieghere
366e103ae92SJonas Devlieghere SBError error;
367d232abc3SJonas Devlieghere return QueueThreadPlanForStepScripted(script_class_name, error);
368e103ae92SJonas Devlieghere }
369e103ae92SJonas Devlieghere
370e103ae92SJonas Devlieghere SBThreadPlan
QueueThreadPlanForStepScripted(const char * script_class_name,SBError & error)371e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
372e103ae92SJonas Devlieghere SBError &error) {
373*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, script_class_name, error);
374baf5664fSJonas Devlieghere
3752ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
3762ba7ce40SJonas Devlieghere if (thread_plan_sp) {
377e103ae92SJonas Devlieghere Status plan_status;
37827a14f19SJim Ingham StructuredData::ObjectSP empty_args;
379e103ae92SJonas Devlieghere SBThreadPlan plan =
3802ba7ce40SJonas Devlieghere SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
38127a14f19SJim Ingham false, script_class_name, empty_args, false, plan_status));
38227a14f19SJim Ingham
38327a14f19SJim Ingham if (plan_status.Fail())
38427a14f19SJim Ingham error.SetErrorString(plan_status.AsCString());
385f7de4b5dSJim Ingham else
3862ba7ce40SJonas Devlieghere plan.GetSP()->SetPrivate(true);
38727a14f19SJim Ingham
388d232abc3SJonas Devlieghere return plan;
38927a14f19SJim Ingham }
390d232abc3SJonas Devlieghere return SBThreadPlan();
39127a14f19SJim Ingham }
39227a14f19SJim Ingham
39327a14f19SJim Ingham SBThreadPlan
QueueThreadPlanForStepScripted(const char * script_class_name,lldb::SBStructuredData & args_data,SBError & error)39427a14f19SJim Ingham SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
39527a14f19SJim Ingham lldb::SBStructuredData &args_data,
39627a14f19SJim Ingham SBError &error) {
397*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, script_class_name, args_data, error);
39827a14f19SJim Ingham
3992ba7ce40SJonas Devlieghere ThreadPlanSP thread_plan_sp(GetSP());
4002ba7ce40SJonas Devlieghere if (thread_plan_sp) {
40127a14f19SJim Ingham Status plan_status;
40227a14f19SJim Ingham StructuredData::ObjectSP args_obj = args_data.m_impl_up->GetObjectSP();
40327a14f19SJim Ingham SBThreadPlan plan =
4042ba7ce40SJonas Devlieghere SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
40527a14f19SJim Ingham false, script_class_name, args_obj, false, plan_status));
406e103ae92SJonas Devlieghere
407e103ae92SJonas Devlieghere if (plan_status.Fail())
408e103ae92SJonas Devlieghere error.SetErrorString(plan_status.AsCString());
409f7de4b5dSJim Ingham else
4102ba7ce40SJonas Devlieghere plan.GetSP()->SetPrivate(true);
411e103ae92SJonas Devlieghere
412d232abc3SJonas Devlieghere return plan;
413c1c0fac7SAleksandr Urakov } else {
414d232abc3SJonas Devlieghere return SBThreadPlan();
415c1c0fac7SAleksandr Urakov }
416c1c0fac7SAleksandr Urakov }
417