1696bd635SAlexander Shaposhnikov //===-- SBThreadPlan.cpp ----------------------------------------*- C++ -*-===//
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 
9baf5664fSJonas Devlieghere #include "SBReproducerPrivate.h"
102bdbfd50SJim Ingham #include "lldb/API/SBThread.h"
112bdbfd50SJim Ingham 
122bdbfd50SJim Ingham #include "lldb/API/SBFileSpec.h"
132bdbfd50SJim Ingham #include "lldb/API/SBStream.h"
14b9c1b51eSKate Stone #include "lldb/API/SBSymbolContext.h"
152bdbfd50SJim Ingham #include "lldb/Breakpoint/BreakpointLocation.h"
162bdbfd50SJim Ingham #include "lldb/Core/Debugger.h"
172bdbfd50SJim Ingham #include "lldb/Core/StreamFile.h"
182bdbfd50SJim Ingham #include "lldb/Interpreter/CommandInterpreter.h"
19b9c1b51eSKate Stone #include "lldb/Symbol/CompileUnit.h"
20b9c1b51eSKate Stone #include "lldb/Symbol/SymbolContext.h"
212bdbfd50SJim Ingham #include "lldb/Target/Process.h"
222bdbfd50SJim Ingham #include "lldb/Target/Queue.h"
232bdbfd50SJim Ingham #include "lldb/Target/StopInfo.h"
24b9c1b51eSKate Stone #include "lldb/Target/SystemRuntime.h"
252bdbfd50SJim Ingham #include "lldb/Target/Target.h"
26b9c1b51eSKate Stone #include "lldb/Target/Thread.h"
27b9c1b51eSKate Stone #include "lldb/Target/ThreadPlan.h"
282bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanPython.h"
29b9c1b51eSKate Stone #include "lldb/Target/ThreadPlanStepInRange.h"
302bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepInstruction.h"
312bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepOut.h"
322bdbfd50SJim Ingham #include "lldb/Target/ThreadPlanStepRange.h"
33d821c997SPavel Labath #include "lldb/Utility/State.h"
34bf9a7730SZachary Turner #include "lldb/Utility/Stream.h"
35f2a8bccfSPavel Labath #include "lldb/Utility/StructuredData.h"
362bdbfd50SJim Ingham 
372bdbfd50SJim Ingham #include "lldb/API/SBAddress.h"
382bdbfd50SJim Ingham #include "lldb/API/SBDebugger.h"
392bdbfd50SJim Ingham #include "lldb/API/SBEvent.h"
402bdbfd50SJim Ingham #include "lldb/API/SBFrame.h"
412bdbfd50SJim Ingham #include "lldb/API/SBProcess.h"
422bdbfd50SJim Ingham #include "lldb/API/SBThreadPlan.h"
432bdbfd50SJim Ingham #include "lldb/API/SBValue.h"
442bdbfd50SJim Ingham 
45796ac80bSJonas Devlieghere #include <memory>
46796ac80bSJonas Devlieghere 
472bdbfd50SJim Ingham using namespace lldb;
482bdbfd50SJim Ingham using namespace lldb_private;
492bdbfd50SJim Ingham 
502bdbfd50SJim Ingham // Constructors
51baf5664fSJonas Devlieghere SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); }
522bdbfd50SJim Ingham 
53b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
54baf5664fSJonas Devlieghere     : m_opaque_sp(lldb_object_sp) {
55baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &),
56baf5664fSJonas Devlieghere                           lldb_object_sp);
57baf5664fSJonas Devlieghere }
582bdbfd50SJim Ingham 
59b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
60baf5664fSJonas Devlieghere     : m_opaque_sp(rhs.m_opaque_sp) {
61baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs);
62baf5664fSJonas Devlieghere }
632bdbfd50SJim Ingham 
64b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
65baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *),
66baf5664fSJonas Devlieghere                           sb_thread, class_name);
67baf5664fSJonas Devlieghere 
682bdbfd50SJim Ingham   Thread *thread = sb_thread.get();
692bdbfd50SJim Ingham   if (thread)
70796ac80bSJonas Devlieghere     m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name);
712bdbfd50SJim Ingham }
722bdbfd50SJim Ingham 
732bdbfd50SJim Ingham // Assignment operator
742bdbfd50SJim Ingham 
75b9c1b51eSKate Stone const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
76baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(const lldb::SBThreadPlan &,
77baf5664fSJonas Devlieghere                      SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs);
78baf5664fSJonas Devlieghere 
792bdbfd50SJim Ingham   if (this != &rhs)
802bdbfd50SJim Ingham     m_opaque_sp = rhs.m_opaque_sp;
81306809f2SJonas Devlieghere   return LLDB_RECORD_RESULT(*this);
822bdbfd50SJim Ingham }
832bdbfd50SJim Ingham // Destructor
84b9c1b51eSKate Stone SBThreadPlan::~SBThreadPlan() {}
852bdbfd50SJim Ingham 
8626ca5a57SPavel Labath lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); }
872bdbfd50SJim Ingham 
88baf5664fSJonas Devlieghere bool SBThreadPlan::IsValid() const {
89baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid);
907f5237bcSPavel Labath   return this->operator bool();
917f5237bcSPavel Labath }
927f5237bcSPavel Labath SBThreadPlan::operator bool() const {
937f5237bcSPavel Labath   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool);
942bdbfd50SJim Ingham 
95*248a1305SKonrad Kleine   return m_opaque_sp.get() != nullptr;
96baf5664fSJonas Devlieghere }
972bdbfd50SJim Ingham 
98baf5664fSJonas Devlieghere void SBThreadPlan::Clear() {
99baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear);
1002bdbfd50SJim Ingham 
101baf5664fSJonas Devlieghere   m_opaque_sp.reset();
102baf5664fSJonas Devlieghere }
103baf5664fSJonas Devlieghere 
104baf5664fSJonas Devlieghere lldb::StopReason SBThreadPlan::GetStopReason() {
105baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThreadPlan, GetStopReason);
106baf5664fSJonas Devlieghere 
107baf5664fSJonas Devlieghere   return eStopReasonNone;
108baf5664fSJonas Devlieghere }
109baf5664fSJonas Devlieghere 
110baf5664fSJonas Devlieghere size_t SBThreadPlan::GetStopReasonDataCount() {
111baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadPlan, GetStopReasonDataCount);
112baf5664fSJonas Devlieghere 
113baf5664fSJonas Devlieghere   return 0;
114baf5664fSJonas Devlieghere }
115baf5664fSJonas Devlieghere 
116baf5664fSJonas Devlieghere uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
117baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
118baf5664fSJonas Devlieghere                      (uint32_t), idx);
119baf5664fSJonas Devlieghere 
120baf5664fSJonas Devlieghere   return 0;
121baf5664fSJonas Devlieghere }
1222bdbfd50SJim Ingham 
123b9c1b51eSKate Stone SBThread SBThreadPlan::GetThread() const {
124baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread);
125baf5664fSJonas Devlieghere 
126b9c1b51eSKate Stone   if (m_opaque_sp) {
127baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(
128baf5664fSJonas Devlieghere         SBThread(m_opaque_sp->GetThread().shared_from_this()));
129b9c1b51eSKate Stone   } else
130baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThread());
1312bdbfd50SJim Ingham }
1322bdbfd50SJim Ingham 
133b9c1b51eSKate Stone bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
134baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription,
135baf5664fSJonas Devlieghere                            (lldb::SBStream &), description);
136baf5664fSJonas Devlieghere 
137b9c1b51eSKate Stone   if (m_opaque_sp) {
1382bdbfd50SJim Ingham     m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull);
139b9c1b51eSKate Stone   } else {
1402bdbfd50SJim Ingham     description.Printf("Empty SBThreadPlan");
1412bdbfd50SJim Ingham   }
1422bdbfd50SJim Ingham   return true;
1432bdbfd50SJim Ingham }
1442bdbfd50SJim Ingham 
145b9c1b51eSKate Stone void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_sp) {
1462bdbfd50SJim Ingham   m_opaque_sp = lldb_object_sp;
1472bdbfd50SJim Ingham }
1482bdbfd50SJim Ingham 
149b9c1b51eSKate Stone void SBThreadPlan::SetPlanComplete(bool success) {
150baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success);
151baf5664fSJonas Devlieghere 
1522bdbfd50SJim Ingham   if (m_opaque_sp)
1532bdbfd50SJim Ingham     m_opaque_sp->SetPlanComplete(success);
1542bdbfd50SJim Ingham }
1552bdbfd50SJim Ingham 
156b9c1b51eSKate Stone bool SBThreadPlan::IsPlanComplete() {
157baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete);
158baf5664fSJonas Devlieghere 
1592bdbfd50SJim Ingham   if (m_opaque_sp)
1602bdbfd50SJim Ingham     return m_opaque_sp->IsPlanComplete();
1612bdbfd50SJim Ingham   else
1622bdbfd50SJim Ingham     return true;
1632bdbfd50SJim Ingham }
1642bdbfd50SJim Ingham 
165b9c1b51eSKate Stone bool SBThreadPlan::IsPlanStale() {
166baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale);
167baf5664fSJonas Devlieghere 
168c915a7d2SJim Ingham   if (m_opaque_sp)
169c915a7d2SJim Ingham     return m_opaque_sp->IsPlanStale();
170c915a7d2SJim Ingham   else
171c915a7d2SJim Ingham     return true;
172c915a7d2SJim Ingham }
173c915a7d2SJim Ingham 
174b9c1b51eSKate Stone bool SBThreadPlan::IsValid() {
175baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid);
176baf5664fSJonas Devlieghere 
1772bdbfd50SJim Ingham   if (m_opaque_sp)
1782bdbfd50SJim Ingham     return m_opaque_sp->ValidatePlan(nullptr);
1792bdbfd50SJim Ingham   else
1802bdbfd50SJim Ingham     return false;
1812bdbfd50SJim Ingham }
1822bdbfd50SJim Ingham 
183b9c1b51eSKate Stone // This section allows an SBThreadPlan to push another of the common types of
184b9c1b51eSKate Stone // plans...
1852bdbfd50SJim Ingham //
186b9c1b51eSKate Stone // FIXME, you should only be able to queue thread plans from inside the methods
18705097246SAdrian Prantl // of a Scripted Thread Plan.  Need a way to enforce that.
1882bdbfd50SJim Ingham 
1892bdbfd50SJim Ingham SBThreadPlan
1902bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
191b9c1b51eSKate Stone                                               lldb::addr_t size) {
192baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
193baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOverRange,
194baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
195baf5664fSJonas Devlieghere 
196e103ae92SJonas Devlieghere   SBError error;
197baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
198baf5664fSJonas Devlieghere       QueueThreadPlanForStepOverRange(sb_start_address, size, error));
199e103ae92SJonas Devlieghere }
200e103ae92SJonas Devlieghere 
201e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
202e103ae92SJonas Devlieghere     SBAddress &sb_start_address, lldb::addr_t size, SBError &error) {
203baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
204baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOverRange,
205baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
206baf5664fSJonas Devlieghere                      sb_start_address, size, error);
207baf5664fSJonas Devlieghere 
208b9c1b51eSKate Stone   if (m_opaque_sp) {
2092bdbfd50SJim Ingham     Address *start_address = sb_start_address.get();
210b9c1b51eSKate Stone     if (!start_address) {
211baf5664fSJonas Devlieghere       return LLDB_RECORD_RESULT(SBThreadPlan());
2122bdbfd50SJim Ingham     }
2132bdbfd50SJim Ingham 
2142bdbfd50SJim Ingham     AddressRange range(*start_address, size);
2152bdbfd50SJim Ingham     SymbolContext sc;
2162bdbfd50SJim Ingham     start_address->CalculateSymbolContext(&sc);
217e103ae92SJonas Devlieghere     Status plan_status;
218e103ae92SJonas Devlieghere 
219e103ae92SJonas Devlieghere     SBThreadPlan plan =
220e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange(
221e103ae92SJonas Devlieghere             false, range, sc, eAllThreads, plan_status));
222e103ae92SJonas Devlieghere 
223e103ae92SJonas Devlieghere     if (plan_status.Fail())
224e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
225e103ae92SJonas Devlieghere 
226baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
227b9c1b51eSKate Stone   } else {
228baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
2292bdbfd50SJim Ingham   }
2302bdbfd50SJim Ingham }
2312bdbfd50SJim Ingham 
2322bdbfd50SJim Ingham SBThreadPlan
2332bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
234b9c1b51eSKate Stone                                             lldb::addr_t size) {
235baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
236baf5664fSJonas Devlieghere                      QueueThreadPlanForStepInRange,
237baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
238baf5664fSJonas Devlieghere 
239e103ae92SJonas Devlieghere   SBError error;
240baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
241baf5664fSJonas Devlieghere       QueueThreadPlanForStepInRange(sb_start_address, size, error));
242e103ae92SJonas Devlieghere }
243e103ae92SJonas Devlieghere 
244e103ae92SJonas Devlieghere SBThreadPlan
245e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
246e103ae92SJonas Devlieghere                                             lldb::addr_t size, SBError &error) {
247baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
248baf5664fSJonas Devlieghere                      QueueThreadPlanForStepInRange,
249baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
250baf5664fSJonas Devlieghere                      sb_start_address, size, error);
251baf5664fSJonas Devlieghere 
252b9c1b51eSKate Stone   if (m_opaque_sp) {
2532bdbfd50SJim Ingham     Address *start_address = sb_start_address.get();
254b9c1b51eSKate Stone     if (!start_address) {
255baf5664fSJonas Devlieghere       return LLDB_RECORD_RESULT(SBThreadPlan());
2562bdbfd50SJim Ingham     }
2572bdbfd50SJim Ingham 
2582bdbfd50SJim Ingham     AddressRange range(*start_address, size);
2592bdbfd50SJim Ingham     SymbolContext sc;
2602bdbfd50SJim Ingham     start_address->CalculateSymbolContext(&sc);
261e103ae92SJonas Devlieghere 
262e103ae92SJonas Devlieghere     Status plan_status;
263e103ae92SJonas Devlieghere     SBThreadPlan plan =
264e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange(
265*248a1305SKonrad Kleine             false, range, sc, nullptr, eAllThreads, plan_status));
266e103ae92SJonas Devlieghere 
267e103ae92SJonas Devlieghere     if (plan_status.Fail())
268e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
269e103ae92SJonas Devlieghere 
270baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
271b9c1b51eSKate Stone   } else {
272baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
2732bdbfd50SJim Ingham   }
2742bdbfd50SJim Ingham }
2752bdbfd50SJim Ingham 
2762bdbfd50SJim Ingham SBThreadPlan
277b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
278b9c1b51eSKate Stone                                         bool first_insn) {
279baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
280baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOut, (uint32_t, bool),
281baf5664fSJonas Devlieghere                      frame_idx_to_step_to, first_insn);
282baf5664fSJonas Devlieghere 
283e103ae92SJonas Devlieghere   SBError error;
284baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
285baf5664fSJonas Devlieghere       QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error));
286e103ae92SJonas Devlieghere }
287e103ae92SJonas Devlieghere 
288e103ae92SJonas Devlieghere SBThreadPlan
289e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
290e103ae92SJonas Devlieghere                                         bool first_insn, SBError &error) {
291baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
292baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOut,
293baf5664fSJonas Devlieghere                      (uint32_t, bool, lldb::SBError &), frame_idx_to_step_to,
294baf5664fSJonas Devlieghere                      first_insn, error);
295baf5664fSJonas Devlieghere 
296b9c1b51eSKate Stone   if (m_opaque_sp) {
2972bdbfd50SJim Ingham     SymbolContext sc;
298b9c1b51eSKate Stone     sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
299b9c1b51eSKate Stone         lldb::eSymbolContextEverything);
300e103ae92SJonas Devlieghere 
301e103ae92SJonas Devlieghere     Status plan_status;
302e103ae92SJonas Devlieghere     SBThreadPlan plan =
303e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOut(
304b9c1b51eSKate Stone             false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion,
305e103ae92SJonas Devlieghere             frame_idx_to_step_to, plan_status));
306e103ae92SJonas Devlieghere 
307e103ae92SJonas Devlieghere     if (plan_status.Fail())
308e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
309e103ae92SJonas Devlieghere 
310baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
311b9c1b51eSKate Stone   } else {
312baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
3132bdbfd50SJim Ingham   }
3142bdbfd50SJim Ingham }
3152bdbfd50SJim Ingham 
3162bdbfd50SJim Ingham SBThreadPlan
317b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
318baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
319baf5664fSJonas Devlieghere                      QueueThreadPlanForRunToAddress, (lldb::SBAddress),
320baf5664fSJonas Devlieghere                      sb_address);
321baf5664fSJonas Devlieghere 
322e103ae92SJonas Devlieghere   SBError error;
323baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(QueueThreadPlanForRunToAddress(sb_address, error));
324e103ae92SJonas Devlieghere }
325e103ae92SJonas Devlieghere 
326e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
327e103ae92SJonas Devlieghere                                                           SBError &error) {
328baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
329baf5664fSJonas Devlieghere                      QueueThreadPlanForRunToAddress,
330baf5664fSJonas Devlieghere                      (lldb::SBAddress, lldb::SBError &), sb_address, error);
331baf5664fSJonas Devlieghere 
332b9c1b51eSKate Stone   if (m_opaque_sp) {
3332bdbfd50SJim Ingham     Address *address = sb_address.get();
3342bdbfd50SJim Ingham     if (!address)
335baf5664fSJonas Devlieghere       return LLDB_RECORD_RESULT(SBThreadPlan());
3362bdbfd50SJim Ingham 
337e103ae92SJonas Devlieghere     Status plan_status;
338e103ae92SJonas Devlieghere     SBThreadPlan plan =
339e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress(
340e103ae92SJonas Devlieghere             false, *address, false, plan_status));
341e103ae92SJonas Devlieghere 
342e103ae92SJonas Devlieghere     if (plan_status.Fail())
343e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
344e103ae92SJonas Devlieghere 
345baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
346b9c1b51eSKate Stone   } else {
347baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
3482bdbfd50SJim Ingham   }
3492bdbfd50SJim Ingham }
350c1c0fac7SAleksandr Urakov 
351c1c0fac7SAleksandr Urakov SBThreadPlan
352c1c0fac7SAleksandr Urakov SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) {
353baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
354baf5664fSJonas Devlieghere                      QueueThreadPlanForStepScripted, (const char *),
355baf5664fSJonas Devlieghere                      script_class_name);
356baf5664fSJonas Devlieghere 
357e103ae92SJonas Devlieghere   SBError error;
358baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
359baf5664fSJonas Devlieghere       QueueThreadPlanForStepScripted(script_class_name, error));
360e103ae92SJonas Devlieghere }
361e103ae92SJonas Devlieghere 
362e103ae92SJonas Devlieghere SBThreadPlan
363e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
364e103ae92SJonas Devlieghere                                              SBError &error) {
365baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
366baf5664fSJonas Devlieghere                      QueueThreadPlanForStepScripted,
367baf5664fSJonas Devlieghere                      (const char *, lldb::SBError &), script_class_name, error);
368baf5664fSJonas Devlieghere 
369c1c0fac7SAleksandr Urakov   if (m_opaque_sp) {
370e103ae92SJonas Devlieghere     Status plan_status;
371e103ae92SJonas Devlieghere     SBThreadPlan plan =
372e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
373e103ae92SJonas Devlieghere             false, script_class_name, false, plan_status));
374e103ae92SJonas Devlieghere 
375e103ae92SJonas Devlieghere     if (plan_status.Fail())
376e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
377e103ae92SJonas Devlieghere 
378baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
379c1c0fac7SAleksandr Urakov   } else {
380baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
381c1c0fac7SAleksandr Urakov   }
382c1c0fac7SAleksandr Urakov }
383ae211eceSMichal Gorny 
384ae211eceSMichal Gorny namespace lldb_private {
385ae211eceSMichal Gorny namespace repro {
386ae211eceSMichal Gorny 
387ae211eceSMichal Gorny template <>
388ae211eceSMichal Gorny void RegisterMethods<SBThreadPlan>(Registry &R) {
389ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, ());
390ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &));
391ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &));
392ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *));
393ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &,
394ae211eceSMichal Gorny                        SBThreadPlan, operator=,(const lldb::SBThreadPlan &));
395ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ());
396ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ());
397ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ());
398ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::StopReason, SBThreadPlan, GetStopReason, ());
399ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(size_t, SBThreadPlan, GetStopReasonDataCount, ());
400ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
401ae211eceSMichal Gorny                        (uint32_t));
402ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBThreadPlan, GetThread, ());
403ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, GetDescription,
404ae211eceSMichal Gorny                              (lldb::SBStream &));
405ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBThreadPlan, SetPlanComplete, (bool));
406ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ());
407ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ());
408ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ());
409ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
410ae211eceSMichal Gorny                        QueueThreadPlanForStepOverRange,
411ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t));
412ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
413ae211eceSMichal Gorny                        QueueThreadPlanForStepOverRange,
414ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
415ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
416ae211eceSMichal Gorny                        QueueThreadPlanForStepInRange,
417ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t));
418ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
419ae211eceSMichal Gorny                        QueueThreadPlanForStepInRange,
420ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
421ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
422ae211eceSMichal Gorny                        QueueThreadPlanForStepOut, (uint32_t, bool));
423ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
424ae211eceSMichal Gorny                        QueueThreadPlanForStepOut,
425ae211eceSMichal Gorny                        (uint32_t, bool, lldb::SBError &));
426ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
427ae211eceSMichal Gorny                        QueueThreadPlanForRunToAddress, (lldb::SBAddress));
428ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
429ae211eceSMichal Gorny                        QueueThreadPlanForRunToAddress,
430ae211eceSMichal Gorny                        (lldb::SBAddress, lldb::SBError &));
431ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
432ae211eceSMichal Gorny                        QueueThreadPlanForStepScripted, (const char *));
433ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
434ae211eceSMichal Gorny                        QueueThreadPlanForStepScripted,
435ae211eceSMichal Gorny                        (const char *, lldb::SBError &));
436ae211eceSMichal Gorny }
437ae211eceSMichal Gorny 
438ae211eceSMichal Gorny }
439ae211eceSMichal Gorny }
440