blob: c740c8b7492fc9e439dcf9b6aba2af4d2f7fcc34 [file] [log] [blame]
Raphael Isemann80814282020-01-24 08:23:27 +01001//===-- SBThreadPlan.cpp --------------------------------------------------===//
Jim Ingham2bdbfd52014-09-29 23:17:18 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Jim Ingham2bdbfd52014-09-29 23:17:18 +00006//
7//===----------------------------------------------------------------------===//
8
Jonas Devliegherebaf56642019-03-06 00:06:00 +00009#include "SBReproducerPrivate.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000010#include "lldb/API/SBThread.h"
11
Jim Ingham2bdbfd52014-09-29 23:17:18 +000012#include "lldb/API/SBFileSpec.h"
13#include "lldb/API/SBStream.h"
Jim Ingham27a14f12019-10-03 22:50:18 +000014#include "lldb/API/SBStructuredData.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000015#include "lldb/API/SBSymbolContext.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000016#include "lldb/Breakpoint/BreakpointLocation.h"
17#include "lldb/Core/Debugger.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000018#include "lldb/Core/StreamFile.h"
Jim Ingham27a14f12019-10-03 22:50:18 +000019#include "lldb/Core/StructuredDataImpl.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000020#include "lldb/Interpreter/CommandInterpreter.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000021#include "lldb/Symbol/CompileUnit.h"
22#include "lldb/Symbol/SymbolContext.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000023#include "lldb/Target/Process.h"
24#include "lldb/Target/Queue.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000025#include "lldb/Target/StopInfo.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000026#include "lldb/Target/SystemRuntime.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000027#include "lldb/Target/Target.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000028#include "lldb/Target/Thread.h"
29#include "lldb/Target/ThreadPlan.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000030#include "lldb/Target/ThreadPlanPython.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000031#include "lldb/Target/ThreadPlanStepInRange.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000032#include "lldb/Target/ThreadPlanStepInstruction.h"
33#include "lldb/Target/ThreadPlanStepOut.h"
34#include "lldb/Target/ThreadPlanStepRange.h"
Pavel Labathd821c992018-08-07 11:07:21 +000035#include "lldb/Utility/State.h"
Zachary Turnerbf9a7732017-02-02 21:39:50 +000036#include "lldb/Utility/Stream.h"
Pavel Labathf2a8bcc2017-06-27 10:45:31 +000037#include "lldb/Utility/StructuredData.h"
Jim Ingham2bdbfd52014-09-29 23:17:18 +000038
39#include "lldb/API/SBAddress.h"
40#include "lldb/API/SBDebugger.h"
41#include "lldb/API/SBEvent.h"
42#include "lldb/API/SBFrame.h"
43#include "lldb/API/SBProcess.h"
44#include "lldb/API/SBThreadPlan.h"
45#include "lldb/API/SBValue.h"
46
Jonas Devlieghere796ac802019-02-11 23:13:08 +000047#include <memory>
48
Jim Ingham2bdbfd52014-09-29 23:17:18 +000049using namespace lldb;
50using namespace lldb_private;
51
Jim Ingham2bdbfd52014-09-29 23:17:18 +000052// Constructors
Jonas Devliegherebaf56642019-03-06 00:06:00 +000053SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); }
Jim Ingham2bdbfd52014-09-29 23:17:18 +000054
Kate Stoneb9c1b512016-09-06 20:57:50 +000055SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -070056 : m_opaque_wp(lldb_object_sp) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +000057 LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &),
58 lldb_object_sp);
59}
Jim Ingham2bdbfd52014-09-29 23:17:18 +000060
Kate Stoneb9c1b512016-09-06 20:57:50 +000061SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -070062 : m_opaque_wp(rhs.m_opaque_wp) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +000063 LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs);
64}
Jim Ingham2bdbfd52014-09-29 23:17:18 +000065
Kate Stoneb9c1b512016-09-06 20:57:50 +000066SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +000067 LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *),
68 sb_thread, class_name);
69
Kate Stoneb9c1b512016-09-06 20:57:50 +000070 Thread *thread = sb_thread.get();
71 if (thread)
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -070072 m_opaque_wp =
73 std::make_shared<ThreadPlanPython>(*thread, class_name, nullptr);
Jim Ingham27a14f12019-10-03 22:50:18 +000074}
75
76SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name,
77 lldb::SBStructuredData &args_data) {
78 LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *,
79 SBStructuredData &),
80 sb_thread, class_name, args_data);
81
82 Thread *thread = sb_thread.get();
83 if (thread)
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -070084 m_opaque_wp = std::make_shared<ThreadPlanPython>(*thread, class_name,
Jim Ingham27a14f12019-10-03 22:50:18 +000085 args_data.m_impl_up.get());
Jim Ingham2bdbfd52014-09-29 23:17:18 +000086}
87
Jim Ingham2bdbfd52014-09-29 23:17:18 +000088// Assignment operator
Jim Ingham2bdbfd52014-09-29 23:17:18 +000089
Kate Stoneb9c1b512016-09-06 20:57:50 +000090const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +000091 LLDB_RECORD_METHOD(const lldb::SBThreadPlan &,
92 SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs);
93
Kate Stoneb9c1b512016-09-06 20:57:50 +000094 if (this != &rhs)
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -070095 m_opaque_wp = rhs.m_opaque_wp;
Jonas Devlieghere306809f2019-04-03 21:31:22 +000096 return LLDB_RECORD_RESULT(*this);
Jim Ingham2bdbfd52014-09-29 23:17:18 +000097}
Jim Ingham2bdbfd52014-09-29 23:17:18 +000098// Destructor
Jonas Devlieghere866b7a62020-02-17 22:57:06 -080099SBThreadPlan::~SBThreadPlan() = default;
Kate Stoneb9c1b512016-09-06 20:57:50 +0000100
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000101bool SBThreadPlan::IsValid() const {
102 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid);
Pavel Labath7f5237b2019-03-11 13:58:46 +0000103 return this->operator bool();
104}
105SBThreadPlan::operator bool() const {
106 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000107
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700108 return static_cast<bool>(GetSP());
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000109}
Kate Stoneb9c1b512016-09-06 20:57:50 +0000110
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000111void SBThreadPlan::Clear() {
112 LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000113
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700114 m_opaque_wp.reset();
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000115}
116
117lldb::StopReason SBThreadPlan::GetStopReason() {
118 LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThreadPlan, GetStopReason);
119
120 return eStopReasonNone;
121}
122
123size_t SBThreadPlan::GetStopReasonDataCount() {
124 LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadPlan, GetStopReasonDataCount);
125
126 return 0;
127}
128
129uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
130 LLDB_RECORD_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
131 (uint32_t), idx);
132
133 return 0;
134}
Kate Stoneb9c1b512016-09-06 20:57:50 +0000135
136SBThread SBThreadPlan::GetThread() const {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000137 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread);
138
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700139 ThreadPlanSP thread_plan_sp(GetSP());
140 if (thread_plan_sp) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000141 return LLDB_RECORD_RESULT(
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700142 SBThread(thread_plan_sp->GetThread().shared_from_this()));
Kate Stoneb9c1b512016-09-06 20:57:50 +0000143 } else
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000144 return LLDB_RECORD_RESULT(SBThread());
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000145}
146
Kate Stoneb9c1b512016-09-06 20:57:50 +0000147bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000148 LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription,
149 (lldb::SBStream &), description);
150
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700151 ThreadPlanSP thread_plan_sp(GetSP());
152 if (thread_plan_sp) {
153 thread_plan_sp->GetDescription(description.get(), eDescriptionLevelFull);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000154 } else {
155 description.Printf("Empty SBThreadPlan");
156 }
157 return true;
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000158}
159
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700160void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_wp) {
161 m_opaque_wp = lldb_object_wp;
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000162}
163
Kate Stoneb9c1b512016-09-06 20:57:50 +0000164void SBThreadPlan::SetPlanComplete(bool success) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000165 LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success);
166
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700167 ThreadPlanSP thread_plan_sp(GetSP());
168 if (thread_plan_sp)
169 thread_plan_sp->SetPlanComplete(success);
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000170}
171
Kate Stoneb9c1b512016-09-06 20:57:50 +0000172bool SBThreadPlan::IsPlanComplete() {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000173 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete);
174
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700175 ThreadPlanSP thread_plan_sp(GetSP());
176 if (thread_plan_sp)
177 return thread_plan_sp->IsPlanComplete();
178 return true;
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000179}
180
Kate Stoneb9c1b512016-09-06 20:57:50 +0000181bool SBThreadPlan::IsPlanStale() {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000182 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale);
183
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700184 ThreadPlanSP thread_plan_sp(GetSP());
185 if (thread_plan_sp)
186 return thread_plan_sp->IsPlanStale();
187 return true;
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000188}
189
Kate Stoneb9c1b512016-09-06 20:57:50 +0000190bool SBThreadPlan::IsValid() {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000191 LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid);
192
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700193 ThreadPlanSP thread_plan_sp(GetSP());
194 if (thread_plan_sp)
195 return thread_plan_sp->ValidatePlan(nullptr);
196 return false;
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000197}
198
Kate Stoneb9c1b512016-09-06 20:57:50 +0000199// This section allows an SBThreadPlan to push another of the common types of
200// plans...
201//
202// FIXME, you should only be able to queue thread plans from inside the methods
Adrian Prantl05097242018-04-30 16:49:04 +0000203// of a Scripted Thread Plan. Need a way to enforce that.
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000204
205SBThreadPlan
Kate Stoneb9c1b512016-09-06 20:57:50 +0000206SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
207 lldb::addr_t size) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000208 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
209 QueueThreadPlanForStepOverRange,
210 (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
211
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000212 SBError error;
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000213 return LLDB_RECORD_RESULT(
214 QueueThreadPlanForStepOverRange(sb_start_address, size, error));
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000215}
216
217SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
218 SBAddress &sb_start_address, lldb::addr_t size, SBError &error) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000219 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
220 QueueThreadPlanForStepOverRange,
221 (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
222 sb_start_address, size, error);
223
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700224 ThreadPlanSP thread_plan_sp(GetSP());
225 if (thread_plan_sp) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000226 Address *start_address = sb_start_address.get();
227 if (!start_address) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000228 return LLDB_RECORD_RESULT(SBThreadPlan());
Kate Stoneb9c1b512016-09-06 20:57:50 +0000229 }
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000230
Kate Stoneb9c1b512016-09-06 20:57:50 +0000231 AddressRange range(*start_address, size);
232 SymbolContext sc;
233 start_address->CalculateSymbolContext(&sc);
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000234 Status plan_status;
235
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700236 SBThreadPlan plan = SBThreadPlan(
237 thread_plan_sp->GetThread().QueueThreadPlanForStepOverRange(
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000238 false, range, sc, eAllThreads, plan_status));
239
240 if (plan_status.Fail())
241 error.SetErrorString(plan_status.AsCString());
Jim Inghamf7de4b52020-04-10 15:37:05 -0700242 else
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700243 plan.GetSP()->SetPrivate(true);
244
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000245 return LLDB_RECORD_RESULT(plan);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000246 }
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700247 return LLDB_RECORD_RESULT(SBThreadPlan());
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000248}
249
250SBThreadPlan
Kate Stoneb9c1b512016-09-06 20:57:50 +0000251SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
252 lldb::addr_t size) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000253 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
254 QueueThreadPlanForStepInRange,
255 (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
256
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000257 SBError error;
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000258 return LLDB_RECORD_RESULT(
259 QueueThreadPlanForStepInRange(sb_start_address, size, error));
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000260}
261
262SBThreadPlan
263SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
264 lldb::addr_t size, SBError &error) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000265 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
266 QueueThreadPlanForStepInRange,
267 (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
268 sb_start_address, size, error);
269
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700270 ThreadPlanSP thread_plan_sp(GetSP());
271 if (thread_plan_sp) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000272 Address *start_address = sb_start_address.get();
273 if (!start_address) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000274 return LLDB_RECORD_RESULT(SBThreadPlan());
Kate Stoneb9c1b512016-09-06 20:57:50 +0000275 }
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000276
Kate Stoneb9c1b512016-09-06 20:57:50 +0000277 AddressRange range(*start_address, size);
278 SymbolContext sc;
279 start_address->CalculateSymbolContext(&sc);
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000280
281 Status plan_status;
282 SBThreadPlan plan =
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700283 SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepInRange(
Konrad Kleine248a1302019-05-23 11:14:47 +0000284 false, range, sc, nullptr, eAllThreads, plan_status));
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000285
286 if (plan_status.Fail())
287 error.SetErrorString(plan_status.AsCString());
Jim Inghamf7de4b52020-04-10 15:37:05 -0700288 else
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700289 plan.GetSP()->SetPrivate(true);
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000290
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000291 return LLDB_RECORD_RESULT(plan);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000292 }
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700293 return LLDB_RECORD_RESULT(SBThreadPlan());
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000294}
295
296SBThreadPlan
Kate Stoneb9c1b512016-09-06 20:57:50 +0000297SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
298 bool first_insn) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000299 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
300 QueueThreadPlanForStepOut, (uint32_t, bool),
301 frame_idx_to_step_to, first_insn);
302
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000303 SBError error;
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000304 return LLDB_RECORD_RESULT(
305 QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error));
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000306}
307
308SBThreadPlan
309SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
310 bool first_insn, SBError &error) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000311 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
312 QueueThreadPlanForStepOut,
313 (uint32_t, bool, lldb::SBError &), frame_idx_to_step_to,
314 first_insn, error);
315
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700316 ThreadPlanSP thread_plan_sp(GetSP());
317 if (thread_plan_sp) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000318 SymbolContext sc;
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700319 sc = thread_plan_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
Kate Stoneb9c1b512016-09-06 20:57:50 +0000320 lldb::eSymbolContextEverything);
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000321
322 Status plan_status;
323 SBThreadPlan plan =
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700324 SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepOut(
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000325 false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion,
326 frame_idx_to_step_to, plan_status));
327
328 if (plan_status.Fail())
329 error.SetErrorString(plan_status.AsCString());
Jim Inghamf7de4b52020-04-10 15:37:05 -0700330 else
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700331 plan.GetSP()->SetPrivate(true);
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000332
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000333 return LLDB_RECORD_RESULT(plan);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000334 }
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700335 return LLDB_RECORD_RESULT(SBThreadPlan());
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000336}
337
338SBThreadPlan
Kate Stoneb9c1b512016-09-06 20:57:50 +0000339SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000340 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
341 QueueThreadPlanForRunToAddress, (lldb::SBAddress),
342 sb_address);
343
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000344 SBError error;
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000345 return LLDB_RECORD_RESULT(QueueThreadPlanForRunToAddress(sb_address, error));
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000346}
347
348SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
349 SBError &error) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000350 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
351 QueueThreadPlanForRunToAddress,
352 (lldb::SBAddress, lldb::SBError &), sb_address, error);
353
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700354 ThreadPlanSP thread_plan_sp(GetSP());
355 if (thread_plan_sp) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000356 Address *address = sb_address.get();
357 if (!address)
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000358 return LLDB_RECORD_RESULT(SBThreadPlan());
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000359
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000360 Status plan_status;
361 SBThreadPlan plan =
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700362 SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForRunToAddress(
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000363 false, *address, false, plan_status));
364
365 if (plan_status.Fail())
366 error.SetErrorString(plan_status.AsCString());
Jim Inghamf7de4b52020-04-10 15:37:05 -0700367 else
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700368 plan.GetSP()->SetPrivate(true);
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000369
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000370 return LLDB_RECORD_RESULT(plan);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000371 }
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700372 return LLDB_RECORD_RESULT(SBThreadPlan());
Jim Ingham2bdbfd52014-09-29 23:17:18 +0000373}
Aleksandr Urakovc1c0fac2018-10-25 08:27:42 +0000374
375SBThreadPlan
376SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000377 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
378 QueueThreadPlanForStepScripted, (const char *),
379 script_class_name);
380
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000381 SBError error;
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000382 return LLDB_RECORD_RESULT(
383 QueueThreadPlanForStepScripted(script_class_name, error));
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000384}
385
386SBThreadPlan
387SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
388 SBError &error) {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000389 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
390 QueueThreadPlanForStepScripted,
391 (const char *, lldb::SBError &), script_class_name, error);
392
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700393 ThreadPlanSP thread_plan_sp(GetSP());
394 if (thread_plan_sp) {
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000395 Status plan_status;
Jim Ingham27a14f12019-10-03 22:50:18 +0000396 StructuredData::ObjectSP empty_args;
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000397 SBThreadPlan plan =
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700398 SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
Jim Ingham27a14f12019-10-03 22:50:18 +0000399 false, script_class_name, empty_args, false, plan_status));
400
401 if (plan_status.Fail())
402 error.SetErrorString(plan_status.AsCString());
Jim Inghamf7de4b52020-04-10 15:37:05 -0700403 else
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700404 plan.GetSP()->SetPrivate(true);
Jim Ingham27a14f12019-10-03 22:50:18 +0000405
406 return LLDB_RECORD_RESULT(plan);
Jim Ingham27a14f12019-10-03 22:50:18 +0000407 }
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700408 return LLDB_RECORD_RESULT(SBThreadPlan());
Jim Ingham27a14f12019-10-03 22:50:18 +0000409}
410
411SBThreadPlan
412SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
413 lldb::SBStructuredData &args_data,
414 SBError &error) {
415 LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
416 QueueThreadPlanForStepScripted,
417 (const char *, lldb::SBStructuredData &, lldb::SBError &),
418 script_class_name, args_data, error);
419
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700420 ThreadPlanSP thread_plan_sp(GetSP());
421 if (thread_plan_sp) {
Jim Ingham27a14f12019-10-03 22:50:18 +0000422 Status plan_status;
423 StructuredData::ObjectSP args_obj = args_data.m_impl_up->GetObjectSP();
424 SBThreadPlan plan =
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700425 SBThreadPlan(thread_plan_sp->GetThread().QueueThreadPlanForStepScripted(
Jim Ingham27a14f12019-10-03 22:50:18 +0000426 false, script_class_name, args_obj, false, plan_status));
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000427
428 if (plan_status.Fail())
429 error.SetErrorString(plan_status.AsCString());
Jim Inghamf7de4b52020-04-10 15:37:05 -0700430 else
Jonas Devlieghere2ba7ce401e2020-07-20 16:50:59 -0700431 plan.GetSP()->SetPrivate(true);
Jonas Devliegheree103ae92018-11-15 01:18:15 +0000432
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000433 return LLDB_RECORD_RESULT(plan);
Aleksandr Urakovc1c0fac2018-10-25 08:27:42 +0000434 } else {
Jonas Devliegherebaf56642019-03-06 00:06:00 +0000435 return LLDB_RECORD_RESULT(SBThreadPlan());
Aleksandr Urakovc1c0fac2018-10-25 08:27:42 +0000436 }
437}
Michal Gornyae211ec2019-03-19 17:13:13 +0000438
439namespace lldb_private {
440namespace repro {
441
442template <>
443void RegisterMethods<SBThreadPlan>(Registry &R) {
444 LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, ());
445 LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &));
446 LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &));
447 LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *));
Jim Ingham27a14f12019-10-03 22:50:18 +0000448 LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *,
449 lldb::SBStructuredData &));
Michal Gornyae211ec2019-03-19 17:13:13 +0000450 LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &,
451 SBThreadPlan, operator=,(const lldb::SBThreadPlan &));
Michal Gornyae211ec2019-03-19 17:13:13 +0000452 LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ());
453 LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ());
454 LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ());
455 LLDB_REGISTER_METHOD(lldb::StopReason, SBThreadPlan, GetStopReason, ());
456 LLDB_REGISTER_METHOD(size_t, SBThreadPlan, GetStopReasonDataCount, ());
457 LLDB_REGISTER_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
458 (uint32_t));
459 LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBThreadPlan, GetThread, ());
460 LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, GetDescription,
461 (lldb::SBStream &));
462 LLDB_REGISTER_METHOD(void, SBThreadPlan, SetPlanComplete, (bool));
463 LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ());
464 LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ());
465 LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ());
466 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
467 QueueThreadPlanForStepOverRange,
468 (lldb::SBAddress &, lldb::addr_t));
469 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
470 QueueThreadPlanForStepOverRange,
471 (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
472 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
473 QueueThreadPlanForStepInRange,
474 (lldb::SBAddress &, lldb::addr_t));
475 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
476 QueueThreadPlanForStepInRange,
477 (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
478 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
479 QueueThreadPlanForStepOut, (uint32_t, bool));
480 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
481 QueueThreadPlanForStepOut,
482 (uint32_t, bool, lldb::SBError &));
483 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
484 QueueThreadPlanForRunToAddress, (lldb::SBAddress));
485 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
486 QueueThreadPlanForRunToAddress,
487 (lldb::SBAddress, lldb::SBError &));
488 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
489 QueueThreadPlanForStepScripted, (const char *));
490 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
491 QueueThreadPlanForStepScripted,
492 (const char *, lldb::SBError &));
Jim Ingham27a14f12019-10-03 22:50:18 +0000493 LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
494 QueueThreadPlanForStepScripted,
495 (const char *, lldb::SBStructuredData &,
496 lldb::SBError &));
Michal Gornyae211ec2019-03-19 17:13:13 +0000497}
498
499}
500}