@@ -53,13 +53,13 @@ using namespace lldb_private;
53
53
SBThreadPlan::SBThreadPlan () { LLDB_RECORD_CONSTRUCTOR_NO_ARGS (SBThreadPlan); }
54
54
55
55
SBThreadPlan::SBThreadPlan (const ThreadPlanSP &lldb_object_sp)
56
- : m_opaque_sp (lldb_object_sp) {
56
+ : m_opaque_wp (lldb_object_sp) {
57
57
LLDB_RECORD_CONSTRUCTOR (SBThreadPlan, (const lldb::ThreadPlanSP &),
58
58
lldb_object_sp);
59
59
}
60
60
61
61
SBThreadPlan::SBThreadPlan (const SBThreadPlan &rhs)
62
- : m_opaque_sp (rhs.m_opaque_sp ) {
62
+ : m_opaque_wp (rhs.m_opaque_wp ) {
63
63
LLDB_RECORD_CONSTRUCTOR (SBThreadPlan, (const lldb::SBThreadPlan &), rhs);
64
64
}
65
65
@@ -69,8 +69,8 @@ SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
69
69
70
70
Thread *thread = sb_thread.get ();
71
71
if (thread)
72
- m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name,
73
- nullptr );
72
+ m_opaque_wp =
73
+ std::make_shared<ThreadPlanPython>(*thread, class_name, nullptr );
74
74
}
75
75
76
76
SBThreadPlan::SBThreadPlan (lldb::SBThread &sb_thread, const char *class_name,
@@ -81,7 +81,7 @@ SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name,
81
81
82
82
Thread *thread = sb_thread.get ();
83
83
if (thread)
84
- m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name,
84
+ m_opaque_wp = std::make_shared<ThreadPlanPython>(*thread, class_name,
85
85
args_data.m_impl_up .get ());
86
86
}
87
87
@@ -92,28 +92,26 @@ const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
92
92
SBThreadPlan, operator =,(const lldb::SBThreadPlan &), rhs);
93
93
94
94
if (this != &rhs)
95
- m_opaque_sp = rhs.m_opaque_sp ;
95
+ m_opaque_wp = rhs.m_opaque_wp ;
96
96
return LLDB_RECORD_RESULT (*this );
97
97
}
98
98
// Destructor
99
99
SBThreadPlan::~SBThreadPlan () = default ;
100
100
101
- lldb_private::ThreadPlan *SBThreadPlan::get () { return m_opaque_sp.get (); }
102
-
103
101
bool SBThreadPlan::IsValid () const {
104
102
LLDB_RECORD_METHOD_CONST_NO_ARGS (bool , SBThreadPlan, IsValid);
105
103
return this ->operator bool ();
106
104
}
107
105
SBThreadPlan::operator bool () const {
108
106
LLDB_RECORD_METHOD_CONST_NO_ARGS (bool , SBThreadPlan, operator bool );
109
107
110
- return m_opaque_sp. get () != nullptr ;
108
+ return static_cast < bool >( GetSP ()) ;
111
109
}
112
110
113
111
void SBThreadPlan::Clear () {
114
112
LLDB_RECORD_METHOD_NO_ARGS (void , SBThreadPlan, Clear);
115
113
116
- m_opaque_sp .reset ();
114
+ m_opaque_wp .reset ();
117
115
}
118
116
119
117
lldb::StopReason SBThreadPlan::GetStopReason () {
@@ -138,9 +136,10 @@ uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
138
136
SBThread SBThreadPlan::GetThread () const {
139
137
LLDB_RECORD_METHOD_CONST_NO_ARGS (lldb::SBThread, SBThreadPlan, GetThread);
140
138
141
- if (m_opaque_sp) {
139
+ ThreadPlanSP thread_plan_sp (GetSP ());
140
+ if (thread_plan_sp) {
142
141
return LLDB_RECORD_RESULT (
143
- SBThread (m_opaque_sp ->GetThread ().shared_from_this ()));
142
+ SBThread (thread_plan_sp ->GetThread ().shared_from_this ()));
144
143
} else
145
144
return LLDB_RECORD_RESULT (SBThread ());
146
145
}
@@ -149,50 +148,52 @@ bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
149
148
LLDB_RECORD_METHOD_CONST (bool , SBThreadPlan, GetDescription,
150
149
(lldb::SBStream &), description);
151
150
152
- if (m_opaque_sp) {
153
- m_opaque_sp->GetDescription (description.get (), eDescriptionLevelFull);
151
+ ThreadPlanSP thread_plan_sp (GetSP ());
152
+ if (thread_plan_sp) {
153
+ thread_plan_sp->GetDescription (description.get (), eDescriptionLevelFull);
154
154
} else {
155
155
description.Printf (" Empty SBThreadPlan" );
156
156
}
157
157
return true ;
158
158
}
159
159
160
- void SBThreadPlan::SetThreadPlan (const ThreadPlanSP &lldb_object_sp ) {
161
- m_opaque_sp = lldb_object_sp ;
160
+ void SBThreadPlan::SetThreadPlan (const ThreadPlanSP &lldb_object_wp ) {
161
+ m_opaque_wp = lldb_object_wp ;
162
162
}
163
163
164
164
void SBThreadPlan::SetPlanComplete (bool success) {
165
165
LLDB_RECORD_METHOD (void , SBThreadPlan, SetPlanComplete, (bool ), success);
166
166
167
- if (m_opaque_sp)
168
- m_opaque_sp->SetPlanComplete (success);
167
+ ThreadPlanSP thread_plan_sp (GetSP ());
168
+ if (thread_plan_sp)
169
+ thread_plan_sp->SetPlanComplete (success);
169
170
}
170
171
171
172
bool SBThreadPlan::IsPlanComplete () {
172
173
LLDB_RECORD_METHOD_NO_ARGS (bool , SBThreadPlan, IsPlanComplete);
173
174
174
- if (m_opaque_sp)
175
- return m_opaque_sp-> IsPlanComplete ();
176
- else
177
- return true ;
175
+ ThreadPlanSP thread_plan_sp ( GetSP ());
176
+ if (thread_plan_sp)
177
+ return thread_plan_sp-> IsPlanComplete ();
178
+ return true ;
178
179
}
179
180
180
181
bool SBThreadPlan::IsPlanStale () {
181
182
LLDB_RECORD_METHOD_NO_ARGS (bool , SBThreadPlan, IsPlanStale);
182
183
183
- if (m_opaque_sp)
184
- return m_opaque_sp-> IsPlanStale ();
185
- else
186
- return true ;
184
+ ThreadPlanSP thread_plan_sp ( GetSP ());
185
+ if (thread_plan_sp)
186
+ return thread_plan_sp-> IsPlanStale ();
187
+ return true ;
187
188
}
188
189
189
190
bool SBThreadPlan::IsValid () {
190
191
LLDB_RECORD_METHOD_NO_ARGS (bool , SBThreadPlan, IsValid);
191
192
192
- if (m_opaque_sp)
193
- return m_opaque_sp-> ValidatePlan ( nullptr );
194
- else
195
- return false ;
193
+ ThreadPlanSP thread_plan_sp ( GetSP ());
194
+ if (thread_plan_sp)
195
+ return thread_plan_sp-> ValidatePlan ( nullptr );
196
+ return false ;
196
197
}
197
198
198
199
// This section allows an SBThreadPlan to push another of the common types of
@@ -220,7 +221,8 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
220
221
(lldb::SBAddress &, lldb::addr_t , lldb::SBError &),
221
222
sb_start_address, size, error);
222
223
223
- if (m_opaque_sp) {
224
+ ThreadPlanSP thread_plan_sp (GetSP ());
225
+ if (thread_plan_sp) {
224
226
Address *start_address = sb_start_address.get ();
225
227
if (!start_address) {
226
228
return LLDB_RECORD_RESULT (SBThreadPlan ());
@@ -231,19 +233,18 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
231
233
start_address->CalculateSymbolContext (&sc);
232
234
Status plan_status;
233
235
234
- SBThreadPlan plan =
235
- SBThreadPlan (m_opaque_sp ->GetThread ().QueueThreadPlanForStepOverRange (
236
+ SBThreadPlan plan = SBThreadPlan (
237
+ thread_plan_sp ->GetThread ().QueueThreadPlanForStepOverRange (
236
238
false , range, sc, eAllThreads, plan_status));
237
239
238
240
if (plan_status.Fail ())
239
241
error.SetErrorString (plan_status.AsCString ());
240
242
else
241
- plan.m_opaque_sp ->SetPrivate (true );
242
-
243
+ plan.GetSP () ->SetPrivate (true );
244
+
243
245
return LLDB_RECORD_RESULT (plan);
244
- } else {
245
- return LLDB_RECORD_RESULT (SBThreadPlan ());
246
246
}
247
+ return LLDB_RECORD_RESULT (SBThreadPlan ());
247
248
}
248
249
249
250
SBThreadPlan
@@ -266,7 +267,8 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
266
267
(lldb::SBAddress &, lldb::addr_t , lldb::SBError &),
267
268
sb_start_address, size, error);
268
269
269
- if (m_opaque_sp) {
270
+ ThreadPlanSP thread_plan_sp (GetSP ());
271
+ if (thread_plan_sp) {
270
272
Address *start_address = sb_start_address.get ();
271
273
if (!start_address) {
272
274
return LLDB_RECORD_RESULT (SBThreadPlan ());
@@ -278,18 +280,17 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
278
280
279
281
Status plan_status;
280
282
SBThreadPlan plan =
281
- SBThreadPlan (m_opaque_sp ->GetThread ().QueueThreadPlanForStepInRange (
283
+ SBThreadPlan (thread_plan_sp ->GetThread ().QueueThreadPlanForStepInRange (
282
284
false , range, sc, nullptr , eAllThreads, plan_status));
283
285
284
286
if (plan_status.Fail ())
285
287
error.SetErrorString (plan_status.AsCString ());
286
288
else
287
- plan.m_opaque_sp ->SetPrivate (true );
289
+ plan.GetSP () ->SetPrivate (true );
288
290
289
291
return LLDB_RECORD_RESULT (plan);
290
- } else {
291
- return LLDB_RECORD_RESULT (SBThreadPlan ());
292
292
}
293
+ return LLDB_RECORD_RESULT (SBThreadPlan ());
293
294
}
294
295
295
296
SBThreadPlan
@@ -312,26 +313,26 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
312
313
(uint32_t , bool , lldb::SBError &), frame_idx_to_step_to,
313
314
first_insn, error);
314
315
315
- if (m_opaque_sp) {
316
+ ThreadPlanSP thread_plan_sp (GetSP ());
317
+ if (thread_plan_sp) {
316
318
SymbolContext sc;
317
- sc = m_opaque_sp ->GetThread ().GetStackFrameAtIndex (0 )->GetSymbolContext (
319
+ sc = thread_plan_sp ->GetThread ().GetStackFrameAtIndex (0 )->GetSymbolContext (
318
320
lldb::eSymbolContextEverything);
319
321
320
322
Status plan_status;
321
323
SBThreadPlan plan =
322
- SBThreadPlan (m_opaque_sp ->GetThread ().QueueThreadPlanForStepOut (
324
+ SBThreadPlan (thread_plan_sp ->GetThread ().QueueThreadPlanForStepOut (
323
325
false , &sc, first_insn, false , eVoteYes, eVoteNoOpinion,
324
326
frame_idx_to_step_to, plan_status));
325
327
326
328
if (plan_status.Fail ())
327
329
error.SetErrorString (plan_status.AsCString ());
328
330
else
329
- plan.m_opaque_sp ->SetPrivate (true );
331
+ plan.GetSP () ->SetPrivate (true );
330
332
331
333
return LLDB_RECORD_RESULT (plan);
332
- } else {
333
- return LLDB_RECORD_RESULT (SBThreadPlan ());
334
334
}
335
+ return LLDB_RECORD_RESULT (SBThreadPlan ());
335
336
}
336
337
337
338
SBThreadPlan
@@ -350,25 +351,25 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
350
351
QueueThreadPlanForRunToAddress,
351
352
(lldb::SBAddress, lldb::SBError &), sb_address, error);
352
353
353
- if (m_opaque_sp) {
354
+ ThreadPlanSP thread_plan_sp (GetSP ());
355
+ if (thread_plan_sp) {
354
356
Address *address = sb_address.get ();
355
357
if (!address)
356
358
return LLDB_RECORD_RESULT (SBThreadPlan ());
357
359
358
360
Status plan_status;
359
361
SBThreadPlan plan =
360
- SBThreadPlan (m_opaque_sp ->GetThread ().QueueThreadPlanForRunToAddress (
362
+ SBThreadPlan (thread_plan_sp ->GetThread ().QueueThreadPlanForRunToAddress (
361
363
false , *address, false , plan_status));
362
364
363
365
if (plan_status.Fail ())
364
366
error.SetErrorString (plan_status.AsCString ());
365
367
else
366
- plan.m_opaque_sp ->SetPrivate (true );
368
+ plan.GetSP () ->SetPrivate (true );
367
369
368
370
return LLDB_RECORD_RESULT (plan);
369
- } else {
370
- return LLDB_RECORD_RESULT (SBThreadPlan ());
371
371
}
372
+ return LLDB_RECORD_RESULT (SBThreadPlan ());
372
373
}
373
374
374
375
SBThreadPlan
@@ -389,22 +390,22 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
389
390
QueueThreadPlanForStepScripted,
390
391
(const char *, lldb::SBError &), script_class_name, error);
391
392
392
- if (m_opaque_sp) {
393
+ ThreadPlanSP thread_plan_sp (GetSP ());
394
+ if (thread_plan_sp) {
393
395
Status plan_status;
394
396
StructuredData::ObjectSP empty_args;
395
397
SBThreadPlan plan =
396
- SBThreadPlan (m_opaque_sp ->GetThread ().QueueThreadPlanForStepScripted (
398
+ SBThreadPlan (thread_plan_sp ->GetThread ().QueueThreadPlanForStepScripted (
397
399
false , script_class_name, empty_args, false , plan_status));
398
400
399
401
if (plan_status.Fail ())
400
402
error.SetErrorString (plan_status.AsCString ());
401
403
else
402
- plan.m_opaque_sp ->SetPrivate (true );
404
+ plan.GetSP () ->SetPrivate (true );
403
405
404
406
return LLDB_RECORD_RESULT (plan);
405
- } else {
406
- return LLDB_RECORD_RESULT (SBThreadPlan ());
407
407
}
408
+ return LLDB_RECORD_RESULT (SBThreadPlan ());
408
409
}
409
410
410
411
SBThreadPlan
@@ -416,17 +417,18 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
416
417
(const char *, lldb::SBStructuredData &, lldb::SBError &),
417
418
script_class_name, args_data, error);
418
419
419
- if (m_opaque_sp) {
420
+ ThreadPlanSP thread_plan_sp (GetSP ());
421
+ if (thread_plan_sp) {
420
422
Status plan_status;
421
423
StructuredData::ObjectSP args_obj = args_data.m_impl_up ->GetObjectSP ();
422
424
SBThreadPlan plan =
423
- SBThreadPlan (m_opaque_sp ->GetThread ().QueueThreadPlanForStepScripted (
425
+ SBThreadPlan (thread_plan_sp ->GetThread ().QueueThreadPlanForStepScripted (
424
426
false , script_class_name, args_obj, false , plan_status));
425
427
426
428
if (plan_status.Fail ())
427
429
error.SetErrorString (plan_status.AsCString ());
428
430
else
429
- plan.m_opaque_sp ->SetPrivate (true );
431
+ plan.GetSP () ->SetPrivate (true );
430
432
431
433
return LLDB_RECORD_RESULT (plan);
432
434
} else {
0 commit comments