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 //----------------------------------------------------------------------
512bdbfd50SJim Ingham // Constructors
522bdbfd50SJim Ingham //----------------------------------------------------------------------
53baf5664fSJonas Devlieghere SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); }
542bdbfd50SJim Ingham 
55b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
56baf5664fSJonas Devlieghere     : m_opaque_sp(lldb_object_sp) {
57baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &),
58baf5664fSJonas Devlieghere                           lldb_object_sp);
59baf5664fSJonas Devlieghere }
602bdbfd50SJim Ingham 
61b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
62baf5664fSJonas Devlieghere     : m_opaque_sp(rhs.m_opaque_sp) {
63baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs);
64baf5664fSJonas Devlieghere }
652bdbfd50SJim Ingham 
66b9c1b51eSKate Stone SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
67baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *),
68baf5664fSJonas Devlieghere                           sb_thread, class_name);
69baf5664fSJonas Devlieghere 
702bdbfd50SJim Ingham   Thread *thread = sb_thread.get();
712bdbfd50SJim Ingham   if (thread)
72796ac80bSJonas Devlieghere     m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name);
732bdbfd50SJim Ingham }
742bdbfd50SJim Ingham 
752bdbfd50SJim Ingham //----------------------------------------------------------------------
762bdbfd50SJim Ingham // Assignment operator
772bdbfd50SJim Ingham //----------------------------------------------------------------------
782bdbfd50SJim Ingham 
79b9c1b51eSKate Stone const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
80baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(const lldb::SBThreadPlan &,
81baf5664fSJonas Devlieghere                      SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs);
82baf5664fSJonas Devlieghere 
832bdbfd50SJim Ingham   if (this != &rhs)
842bdbfd50SJim Ingham     m_opaque_sp = rhs.m_opaque_sp;
852bdbfd50SJim Ingham   return *this;
862bdbfd50SJim Ingham }
872bdbfd50SJim Ingham //----------------------------------------------------------------------
882bdbfd50SJim Ingham // Destructor
892bdbfd50SJim Ingham //----------------------------------------------------------------------
90b9c1b51eSKate Stone SBThreadPlan::~SBThreadPlan() {}
912bdbfd50SJim Ingham 
92baf5664fSJonas Devlieghere lldb_private::ThreadPlan *SBThreadPlan::get() {
93baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(lldb_private::ThreadPlan *, SBThreadPlan, get);
942bdbfd50SJim Ingham 
95baf5664fSJonas Devlieghere   return m_opaque_sp.get();
96baf5664fSJonas Devlieghere }
972bdbfd50SJim Ingham 
98baf5664fSJonas Devlieghere bool SBThreadPlan::IsValid() const {
99baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid);
1007f5237bcSPavel Labath   return this->operator bool();
1017f5237bcSPavel Labath }
1027f5237bcSPavel Labath SBThreadPlan::operator bool() const {
1037f5237bcSPavel Labath   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool);
1042bdbfd50SJim Ingham 
105baf5664fSJonas Devlieghere   return m_opaque_sp.get() != NULL;
106baf5664fSJonas Devlieghere }
1072bdbfd50SJim Ingham 
108baf5664fSJonas Devlieghere void SBThreadPlan::Clear() {
109baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear);
1102bdbfd50SJim Ingham 
111baf5664fSJonas Devlieghere   m_opaque_sp.reset();
112baf5664fSJonas Devlieghere }
113baf5664fSJonas Devlieghere 
114baf5664fSJonas Devlieghere lldb::StopReason SBThreadPlan::GetStopReason() {
115baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThreadPlan, GetStopReason);
116baf5664fSJonas Devlieghere 
117baf5664fSJonas Devlieghere   return eStopReasonNone;
118baf5664fSJonas Devlieghere }
119baf5664fSJonas Devlieghere 
120baf5664fSJonas Devlieghere size_t SBThreadPlan::GetStopReasonDataCount() {
121baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadPlan, GetStopReasonDataCount);
122baf5664fSJonas Devlieghere 
123baf5664fSJonas Devlieghere   return 0;
124baf5664fSJonas Devlieghere }
125baf5664fSJonas Devlieghere 
126baf5664fSJonas Devlieghere uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
127baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
128baf5664fSJonas Devlieghere                      (uint32_t), idx);
129baf5664fSJonas Devlieghere 
130baf5664fSJonas Devlieghere   return 0;
131baf5664fSJonas Devlieghere }
1322bdbfd50SJim Ingham 
133b9c1b51eSKate Stone SBThread SBThreadPlan::GetThread() const {
134baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread);
135baf5664fSJonas Devlieghere 
136b9c1b51eSKate Stone   if (m_opaque_sp) {
137baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(
138baf5664fSJonas Devlieghere         SBThread(m_opaque_sp->GetThread().shared_from_this()));
139b9c1b51eSKate Stone   } else
140baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThread());
1412bdbfd50SJim Ingham }
1422bdbfd50SJim Ingham 
143b9c1b51eSKate Stone bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
144baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription,
145baf5664fSJonas Devlieghere                            (lldb::SBStream &), description);
146baf5664fSJonas Devlieghere 
147b9c1b51eSKate Stone   if (m_opaque_sp) {
1482bdbfd50SJim Ingham     m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull);
149b9c1b51eSKate Stone   } else {
1502bdbfd50SJim Ingham     description.Printf("Empty SBThreadPlan");
1512bdbfd50SJim Ingham   }
1522bdbfd50SJim Ingham   return true;
1532bdbfd50SJim Ingham }
1542bdbfd50SJim Ingham 
155b9c1b51eSKate Stone void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_sp) {
1562bdbfd50SJim Ingham   m_opaque_sp = lldb_object_sp;
1572bdbfd50SJim Ingham }
1582bdbfd50SJim Ingham 
159b9c1b51eSKate Stone void SBThreadPlan::SetPlanComplete(bool success) {
160baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success);
161baf5664fSJonas Devlieghere 
1622bdbfd50SJim Ingham   if (m_opaque_sp)
1632bdbfd50SJim Ingham     m_opaque_sp->SetPlanComplete(success);
1642bdbfd50SJim Ingham }
1652bdbfd50SJim Ingham 
166b9c1b51eSKate Stone bool SBThreadPlan::IsPlanComplete() {
167baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete);
168baf5664fSJonas Devlieghere 
1692bdbfd50SJim Ingham   if (m_opaque_sp)
1702bdbfd50SJim Ingham     return m_opaque_sp->IsPlanComplete();
1712bdbfd50SJim Ingham   else
1722bdbfd50SJim Ingham     return true;
1732bdbfd50SJim Ingham }
1742bdbfd50SJim Ingham 
175b9c1b51eSKate Stone bool SBThreadPlan::IsPlanStale() {
176baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale);
177baf5664fSJonas Devlieghere 
178c915a7d2SJim Ingham   if (m_opaque_sp)
179c915a7d2SJim Ingham     return m_opaque_sp->IsPlanStale();
180c915a7d2SJim Ingham   else
181c915a7d2SJim Ingham     return true;
182c915a7d2SJim Ingham }
183c915a7d2SJim Ingham 
184b9c1b51eSKate Stone bool SBThreadPlan::IsValid() {
185baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid);
186baf5664fSJonas Devlieghere 
1872bdbfd50SJim Ingham   if (m_opaque_sp)
1882bdbfd50SJim Ingham     return m_opaque_sp->ValidatePlan(nullptr);
1892bdbfd50SJim Ingham   else
1902bdbfd50SJim Ingham     return false;
1912bdbfd50SJim Ingham }
1922bdbfd50SJim Ingham 
193b9c1b51eSKate Stone // This section allows an SBThreadPlan to push another of the common types of
194b9c1b51eSKate Stone // plans...
1952bdbfd50SJim Ingham //
196b9c1b51eSKate Stone // FIXME, you should only be able to queue thread plans from inside the methods
19705097246SAdrian Prantl // of a Scripted Thread Plan.  Need a way to enforce that.
1982bdbfd50SJim Ingham 
1992bdbfd50SJim Ingham SBThreadPlan
2002bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
201b9c1b51eSKate Stone                                               lldb::addr_t size) {
202baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
203baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOverRange,
204baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
205baf5664fSJonas Devlieghere 
206e103ae92SJonas Devlieghere   SBError error;
207baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
208baf5664fSJonas Devlieghere       QueueThreadPlanForStepOverRange(sb_start_address, size, error));
209e103ae92SJonas Devlieghere }
210e103ae92SJonas Devlieghere 
211e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
212e103ae92SJonas Devlieghere     SBAddress &sb_start_address, lldb::addr_t size, SBError &error) {
213baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
214baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOverRange,
215baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
216baf5664fSJonas Devlieghere                      sb_start_address, size, error);
217baf5664fSJonas Devlieghere 
218b9c1b51eSKate Stone   if (m_opaque_sp) {
2192bdbfd50SJim Ingham     Address *start_address = sb_start_address.get();
220b9c1b51eSKate Stone     if (!start_address) {
221baf5664fSJonas Devlieghere       return LLDB_RECORD_RESULT(SBThreadPlan());
2222bdbfd50SJim Ingham     }
2232bdbfd50SJim Ingham 
2242bdbfd50SJim Ingham     AddressRange range(*start_address, size);
2252bdbfd50SJim Ingham     SymbolContext sc;
2262bdbfd50SJim Ingham     start_address->CalculateSymbolContext(&sc);
227e103ae92SJonas Devlieghere     Status plan_status;
228e103ae92SJonas Devlieghere 
229e103ae92SJonas Devlieghere     SBThreadPlan plan =
230e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange(
231e103ae92SJonas Devlieghere             false, range, sc, eAllThreads, plan_status));
232e103ae92SJonas Devlieghere 
233e103ae92SJonas Devlieghere     if (plan_status.Fail())
234e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
235e103ae92SJonas Devlieghere 
236baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
237b9c1b51eSKate Stone   } else {
238baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
2392bdbfd50SJim Ingham   }
2402bdbfd50SJim Ingham }
2412bdbfd50SJim Ingham 
2422bdbfd50SJim Ingham SBThreadPlan
2432bdbfd50SJim Ingham SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
244b9c1b51eSKate Stone                                             lldb::addr_t size) {
245baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
246baf5664fSJonas Devlieghere                      QueueThreadPlanForStepInRange,
247baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
248baf5664fSJonas Devlieghere 
249e103ae92SJonas Devlieghere   SBError error;
250baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
251baf5664fSJonas Devlieghere       QueueThreadPlanForStepInRange(sb_start_address, size, error));
252e103ae92SJonas Devlieghere }
253e103ae92SJonas Devlieghere 
254e103ae92SJonas Devlieghere SBThreadPlan
255e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
256e103ae92SJonas Devlieghere                                             lldb::addr_t size, SBError &error) {
257baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
258baf5664fSJonas Devlieghere                      QueueThreadPlanForStepInRange,
259baf5664fSJonas Devlieghere                      (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
260baf5664fSJonas Devlieghere                      sb_start_address, size, error);
261baf5664fSJonas Devlieghere 
262b9c1b51eSKate Stone   if (m_opaque_sp) {
2632bdbfd50SJim Ingham     Address *start_address = sb_start_address.get();
264b9c1b51eSKate Stone     if (!start_address) {
265baf5664fSJonas Devlieghere       return LLDB_RECORD_RESULT(SBThreadPlan());
2662bdbfd50SJim Ingham     }
2672bdbfd50SJim Ingham 
2682bdbfd50SJim Ingham     AddressRange range(*start_address, size);
2692bdbfd50SJim Ingham     SymbolContext sc;
2702bdbfd50SJim Ingham     start_address->CalculateSymbolContext(&sc);
271e103ae92SJonas Devlieghere 
272e103ae92SJonas Devlieghere     Status plan_status;
273e103ae92SJonas Devlieghere     SBThreadPlan plan =
274e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange(
275e103ae92SJonas Devlieghere             false, range, sc, NULL, eAllThreads, plan_status));
276e103ae92SJonas Devlieghere 
277e103ae92SJonas Devlieghere     if (plan_status.Fail())
278e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
279e103ae92SJonas Devlieghere 
280baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
281b9c1b51eSKate Stone   } else {
282baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
2832bdbfd50SJim Ingham   }
2842bdbfd50SJim Ingham }
2852bdbfd50SJim Ingham 
2862bdbfd50SJim Ingham SBThreadPlan
287b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
288b9c1b51eSKate Stone                                         bool first_insn) {
289baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
290baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOut, (uint32_t, bool),
291baf5664fSJonas Devlieghere                      frame_idx_to_step_to, first_insn);
292baf5664fSJonas Devlieghere 
293e103ae92SJonas Devlieghere   SBError error;
294baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
295baf5664fSJonas Devlieghere       QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error));
296e103ae92SJonas Devlieghere }
297e103ae92SJonas Devlieghere 
298e103ae92SJonas Devlieghere SBThreadPlan
299e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
300e103ae92SJonas Devlieghere                                         bool first_insn, SBError &error) {
301baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
302baf5664fSJonas Devlieghere                      QueueThreadPlanForStepOut,
303baf5664fSJonas Devlieghere                      (uint32_t, bool, lldb::SBError &), frame_idx_to_step_to,
304baf5664fSJonas Devlieghere                      first_insn, error);
305baf5664fSJonas Devlieghere 
306b9c1b51eSKate Stone   if (m_opaque_sp) {
3072bdbfd50SJim Ingham     SymbolContext sc;
308b9c1b51eSKate Stone     sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
309b9c1b51eSKate Stone         lldb::eSymbolContextEverything);
310e103ae92SJonas Devlieghere 
311e103ae92SJonas Devlieghere     Status plan_status;
312e103ae92SJonas Devlieghere     SBThreadPlan plan =
313e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOut(
314b9c1b51eSKate Stone             false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion,
315e103ae92SJonas Devlieghere             frame_idx_to_step_to, plan_status));
316e103ae92SJonas Devlieghere 
317e103ae92SJonas Devlieghere     if (plan_status.Fail())
318e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
319e103ae92SJonas Devlieghere 
320baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
321b9c1b51eSKate Stone   } else {
322baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
3232bdbfd50SJim Ingham   }
3242bdbfd50SJim Ingham }
3252bdbfd50SJim Ingham 
3262bdbfd50SJim Ingham SBThreadPlan
327b9c1b51eSKate Stone SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
328baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
329baf5664fSJonas Devlieghere                      QueueThreadPlanForRunToAddress, (lldb::SBAddress),
330baf5664fSJonas Devlieghere                      sb_address);
331baf5664fSJonas Devlieghere 
332e103ae92SJonas Devlieghere   SBError error;
333baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(QueueThreadPlanForRunToAddress(sb_address, error));
334e103ae92SJonas Devlieghere }
335e103ae92SJonas Devlieghere 
336e103ae92SJonas Devlieghere SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
337e103ae92SJonas Devlieghere                                                           SBError &error) {
338baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
339baf5664fSJonas Devlieghere                      QueueThreadPlanForRunToAddress,
340baf5664fSJonas Devlieghere                      (lldb::SBAddress, lldb::SBError &), sb_address, error);
341baf5664fSJonas Devlieghere 
342b9c1b51eSKate Stone   if (m_opaque_sp) {
3432bdbfd50SJim Ingham     Address *address = sb_address.get();
3442bdbfd50SJim Ingham     if (!address)
345baf5664fSJonas Devlieghere       return LLDB_RECORD_RESULT(SBThreadPlan());
3462bdbfd50SJim Ingham 
347e103ae92SJonas Devlieghere     Status plan_status;
348e103ae92SJonas Devlieghere     SBThreadPlan plan =
349e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_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());
354e103ae92SJonas Devlieghere 
355baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
356b9c1b51eSKate Stone   } else {
357baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
3582bdbfd50SJim Ingham   }
3592bdbfd50SJim Ingham }
360c1c0fac7SAleksandr Urakov 
361c1c0fac7SAleksandr Urakov SBThreadPlan
362c1c0fac7SAleksandr Urakov SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) {
363baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
364baf5664fSJonas Devlieghere                      QueueThreadPlanForStepScripted, (const char *),
365baf5664fSJonas Devlieghere                      script_class_name);
366baf5664fSJonas Devlieghere 
367e103ae92SJonas Devlieghere   SBError error;
368baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(
369baf5664fSJonas Devlieghere       QueueThreadPlanForStepScripted(script_class_name, error));
370e103ae92SJonas Devlieghere }
371e103ae92SJonas Devlieghere 
372e103ae92SJonas Devlieghere SBThreadPlan
373e103ae92SJonas Devlieghere SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
374e103ae92SJonas Devlieghere                                              SBError &error) {
375baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
376baf5664fSJonas Devlieghere                      QueueThreadPlanForStepScripted,
377baf5664fSJonas Devlieghere                      (const char *, lldb::SBError &), script_class_name, error);
378baf5664fSJonas Devlieghere 
379c1c0fac7SAleksandr Urakov   if (m_opaque_sp) {
380e103ae92SJonas Devlieghere     Status plan_status;
381e103ae92SJonas Devlieghere     SBThreadPlan plan =
382e103ae92SJonas Devlieghere         SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
383e103ae92SJonas Devlieghere             false, script_class_name, false, plan_status));
384e103ae92SJonas Devlieghere 
385e103ae92SJonas Devlieghere     if (plan_status.Fail())
386e103ae92SJonas Devlieghere       error.SetErrorString(plan_status.AsCString());
387e103ae92SJonas Devlieghere 
388baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(plan);
389c1c0fac7SAleksandr Urakov   } else {
390baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBThreadPlan());
391c1c0fac7SAleksandr Urakov   }
392c1c0fac7SAleksandr Urakov }
393*ae211eceSMichal Gorny 
394*ae211eceSMichal Gorny namespace lldb_private {
395*ae211eceSMichal Gorny namespace repro {
396*ae211eceSMichal Gorny 
397*ae211eceSMichal Gorny template <>
398*ae211eceSMichal Gorny void RegisterMethods<SBThreadPlan>(Registry &R) {
399*ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, ());
400*ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &));
401*ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &));
402*ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *));
403*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &,
404*ae211eceSMichal Gorny                        SBThreadPlan, operator=,(const lldb::SBThreadPlan &));
405*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb_private::ThreadPlan *, SBThreadPlan, get, ());
406*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ());
407*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ());
408*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ());
409*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::StopReason, SBThreadPlan, GetStopReason, ());
410*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(size_t, SBThreadPlan, GetStopReasonDataCount, ());
411*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
412*ae211eceSMichal Gorny                        (uint32_t));
413*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBThreadPlan, GetThread, ());
414*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, GetDescription,
415*ae211eceSMichal Gorny                              (lldb::SBStream &));
416*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBThreadPlan, SetPlanComplete, (bool));
417*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ());
418*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ());
419*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ());
420*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
421*ae211eceSMichal Gorny                        QueueThreadPlanForStepOverRange,
422*ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t));
423*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
424*ae211eceSMichal Gorny                        QueueThreadPlanForStepOverRange,
425*ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
426*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
427*ae211eceSMichal Gorny                        QueueThreadPlanForStepInRange,
428*ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t));
429*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
430*ae211eceSMichal Gorny                        QueueThreadPlanForStepInRange,
431*ae211eceSMichal Gorny                        (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
432*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
433*ae211eceSMichal Gorny                        QueueThreadPlanForStepOut, (uint32_t, bool));
434*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
435*ae211eceSMichal Gorny                        QueueThreadPlanForStepOut,
436*ae211eceSMichal Gorny                        (uint32_t, bool, lldb::SBError &));
437*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
438*ae211eceSMichal Gorny                        QueueThreadPlanForRunToAddress, (lldb::SBAddress));
439*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
440*ae211eceSMichal Gorny                        QueueThreadPlanForRunToAddress,
441*ae211eceSMichal Gorny                        (lldb::SBAddress, lldb::SBError &));
442*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
443*ae211eceSMichal Gorny                        QueueThreadPlanForStepScripted, (const char *));
444*ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
445*ae211eceSMichal Gorny                        QueueThreadPlanForStepScripted,
446*ae211eceSMichal Gorny                        (const char *, lldb::SBError &));
447*ae211eceSMichal Gorny }
448*ae211eceSMichal Gorny 
449*ae211eceSMichal Gorny }
450*ae211eceSMichal Gorny }
451