blob: 3e0731d9c0e76ed0350772a1f0cfb798e03c5e2d [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- ExecutionContext.cpp ------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner24943d22010-06-08 16:52:24 +00009
10#include "lldb/Target/ExecutionContext.h"
11#include "lldb/Target/ExecutionContextScope.h"
12#include "lldb/Target/StackFrame.h"
13#include "lldb/Target/Process.h"
14#include "lldb/Target/Target.h"
15#include "lldb/Target/Thread.h"
16
17using namespace lldb_private;
18
19ExecutionContext::ExecutionContext() :
Greg Clayton567e7f32011-09-22 04:58:26 +000020 m_target_sp (),
21 m_process_sp (),
22 m_thread_sp (),
23 m_frame_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000024{
25}
26
Greg Clayton567e7f32011-09-22 04:58:26 +000027ExecutionContext::ExecutionContext (const ExecutionContext &rhs) :
Greg Claytonb4d7fc02012-02-17 07:49:44 +000028 m_target_sp(rhs.m_target_sp),
Greg Clayton567e7f32011-09-22 04:58:26 +000029 m_process_sp(rhs.m_process_sp),
Greg Claytonb4d7fc02012-02-17 07:49:44 +000030 m_thread_sp(rhs.m_thread_sp),
31 m_frame_sp(rhs.m_frame_sp)
Greg Clayton567e7f32011-09-22 04:58:26 +000032{
33}
34
Greg Claytonb4d7fc02012-02-17 07:49:44 +000035ExecutionContext::ExecutionContext (const lldb::TargetSP &target_sp, bool get_process) :
36 m_target_sp (),
37 m_process_sp (),
38 m_thread_sp (),
39 m_frame_sp ()
Greg Clayton567e7f32011-09-22 04:58:26 +000040{
Greg Claytonb4d7fc02012-02-17 07:49:44 +000041 if (target_sp)
42 SetContext (target_sp, get_process);
43}
44
45ExecutionContext::ExecutionContext (const lldb::ProcessSP &process_sp) :
46 m_target_sp (),
47 m_process_sp (),
48 m_thread_sp (),
49 m_frame_sp ()
50{
51 if (process_sp)
52 SetContext (process_sp);
53}
54
55ExecutionContext::ExecutionContext (const lldb::ThreadSP &thread_sp) :
56 m_target_sp (),
57 m_process_sp (),
58 m_thread_sp (),
59 m_frame_sp ()
60{
61 if (thread_sp)
62 SetContext (thread_sp);
63}
64
65ExecutionContext::ExecutionContext (const lldb::StackFrameSP &frame_sp) :
66 m_target_sp (),
67 m_process_sp (),
68 m_thread_sp (),
69 m_frame_sp ()
70{
71 if (frame_sp)
72 SetContext (frame_sp);
Greg Clayton567e7f32011-09-22 04:58:26 +000073}
74
Greg Claytonf4124de2012-02-21 00:09:25 +000075ExecutionContext::ExecutionContext (const lldb::TargetWP &target_wp, bool get_process) :
76 m_target_sp (),
77 m_process_sp (),
78 m_thread_sp (),
79 m_frame_sp ()
80{
81 lldb::TargetSP target_sp(target_wp.lock());
82 if (target_sp)
83 SetContext (target_sp, get_process);
84}
85
86ExecutionContext::ExecutionContext (const lldb::ProcessWP &process_wp) :
87 m_target_sp (),
88 m_process_sp (),
89 m_thread_sp (),
90 m_frame_sp ()
91{
92 lldb::ProcessSP process_sp(process_wp.lock());
93 if (process_sp)
94 SetContext (process_sp);
95}
96
97ExecutionContext::ExecutionContext (const lldb::ThreadWP &thread_wp) :
98 m_target_sp (),
99 m_process_sp (),
100 m_thread_sp (),
101 m_frame_sp ()
102{
103 lldb::ThreadSP thread_sp(thread_wp.lock());
104 if (thread_sp)
105 SetContext (thread_sp);
106}
107
108ExecutionContext::ExecutionContext (const lldb::StackFrameWP &frame_wp) :
109 m_target_sp (),
110 m_process_sp (),
111 m_thread_sp (),
112 m_frame_sp ()
113{
114 lldb::StackFrameSP frame_sp(frame_wp.lock());
115 if (frame_sp)
116 SetContext (frame_sp);
117}
118
Chris Lattner24943d22010-06-08 16:52:24 +0000119ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_frame) :
Greg Clayton13d24fb2012-01-29 20:56:30 +0000120 m_target_sp (t->shared_from_this()),
Greg Clayton567e7f32011-09-22 04:58:26 +0000121 m_process_sp (),
122 m_thread_sp (),
123 m_frame_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +0000124{
125 if (t && fill_current_process_thread_frame)
126 {
Greg Clayton567e7f32011-09-22 04:58:26 +0000127 m_process_sp = t->GetProcessSP();
128 if (m_process_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000129 {
Greg Clayton567e7f32011-09-22 04:58:26 +0000130 m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread();
131 if (m_thread_sp)
Greg Clayton13d24fb2012-01-29 20:56:30 +0000132 m_frame_sp = m_thread_sp->GetSelectedFrame();
Chris Lattner24943d22010-06-08 16:52:24 +0000133 }
134 }
135}
136
Greg Clayton567e7f32011-09-22 04:58:26 +0000137ExecutionContext::ExecutionContext(Process* process, Thread *thread, StackFrame *frame) :
Greg Clayton13d24fb2012-01-29 20:56:30 +0000138 m_target_sp (),
139 m_process_sp (process->shared_from_this()),
140 m_thread_sp (thread->shared_from_this()),
141 m_frame_sp (frame->shared_from_this())
Chris Lattner24943d22010-06-08 16:52:24 +0000142{
Greg Clayton13d24fb2012-01-29 20:56:30 +0000143 if (process)
144 m_target_sp = process->GetTarget().shared_from_this();
Chris Lattner24943d22010-06-08 16:52:24 +0000145}
146
Greg Claytonb4d7fc02012-02-17 07:49:44 +0000147ExecutionContext::ExecutionContext (const ExecutionContextRef &exe_ctx_ref) :
148 m_target_sp (exe_ctx_ref.GetTargetSP()),
149 m_process_sp (exe_ctx_ref.GetProcessSP()),
150 m_thread_sp (exe_ctx_ref.GetThreadSP()),
151 m_frame_sp (exe_ctx_ref.GetFrameSP())
152{
153}
154
155ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr) :
156 m_target_sp (),
157 m_process_sp (),
158 m_thread_sp (),
159 m_frame_sp ()
160{
161 if (exe_ctx_ref_ptr)
162 {
163 m_target_sp = exe_ctx_ref_ptr->GetTargetSP();
164 m_process_sp = exe_ctx_ref_ptr->GetProcessSP();
165 m_thread_sp = exe_ctx_ref_ptr->GetThreadSP();
166 m_frame_sp = exe_ctx_ref_ptr->GetFrameSP();
167 }
168}
169
170ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr) :
171 m_target_sp (),
172 m_process_sp (),
173 m_thread_sp (),
174 m_frame_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +0000175{
176 if (exe_scope_ptr)
Greg Claytona830adb2010-10-04 01:05:56 +0000177 exe_scope_ptr->CalculateExecutionContext (*this);
Chris Lattner24943d22010-06-08 16:52:24 +0000178}
179
180ExecutionContext::ExecutionContext (ExecutionContextScope &exe_scope_ref)
181{
Greg Claytona830adb2010-10-04 01:05:56 +0000182 exe_scope_ref.CalculateExecutionContext (*this);
Chris Lattner24943d22010-06-08 16:52:24 +0000183}
184
185void
186ExecutionContext::Clear()
187{
Greg Clayton567e7f32011-09-22 04:58:26 +0000188 m_target_sp.reset();
189 m_process_sp.reset();
190 m_thread_sp.reset();
191 m_frame_sp.reset();
192}
193
194ExecutionContext::~ExecutionContext()
195{
Chris Lattner24943d22010-06-08 16:52:24 +0000196}
197
Greg Claytonb4d7fc02012-02-17 07:49:44 +0000198uint32_t
199ExecutionContext::GetAddressByteSize() const
200{
201 if (m_target_sp && m_target_sp->GetArchitecture().IsValid())
202 m_target_sp->GetArchitecture().GetAddressByteSize();
203 if (m_process_sp)
204 m_process_sp->GetAddressByteSize();
205 return sizeof(void *);
206}
207
208
Chris Lattner24943d22010-06-08 16:52:24 +0000209
210RegisterContext *
211ExecutionContext::GetRegisterContext () const
212{
Greg Clayton567e7f32011-09-22 04:58:26 +0000213 if (m_frame_sp)
214 return m_frame_sp->GetRegisterContext().get();
215 else if (m_thread_sp)
216 return m_thread_sp->GetRegisterContext().get();
217 return NULL;
218}
219
220Target *
221ExecutionContext::GetTargetPtr () const
222{
223 if (m_target_sp)
224 return m_target_sp.get();
225 if (m_process_sp)
226 return &m_process_sp->GetTarget();
227 return NULL;
228}
229
230Process *
231ExecutionContext::GetProcessPtr () const
232{
233 if (m_process_sp)
234 return m_process_sp.get();
235 if (m_target_sp)
236 return m_target_sp->GetProcessSP().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000237 return NULL;
238}
239
240ExecutionContextScope *
241ExecutionContext::GetBestExecutionContextScope () const
242{
Greg Clayton567e7f32011-09-22 04:58:26 +0000243 if (m_frame_sp)
244 return m_frame_sp.get();
245 if (m_thread_sp)
246 return m_thread_sp.get();
247 if (m_process_sp)
248 return m_process_sp.get();
249 return m_target_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000250}
Greg Clayton801417e2011-07-07 01:59:51 +0000251
Greg Clayton567e7f32011-09-22 04:58:26 +0000252Target &
253ExecutionContext::GetTargetRef () const
Greg Clayton801417e2011-07-07 01:59:51 +0000254{
Greg Claytonf4124de2012-02-21 00:09:25 +0000255#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
Greg Clayton567e7f32011-09-22 04:58:26 +0000256 assert (m_target_sp.get());
Greg Claytonf4124de2012-02-21 00:09:25 +0000257#endif
Greg Clayton567e7f32011-09-22 04:58:26 +0000258 return *m_target_sp;
Greg Clayton801417e2011-07-07 01:59:51 +0000259}
Greg Clayton567e7f32011-09-22 04:58:26 +0000260
261Process &
262ExecutionContext::GetProcessRef () const
263{
Greg Claytonf4124de2012-02-21 00:09:25 +0000264#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
Greg Clayton567e7f32011-09-22 04:58:26 +0000265 assert (m_process_sp.get());
Greg Claytonf4124de2012-02-21 00:09:25 +0000266#endif
Greg Clayton567e7f32011-09-22 04:58:26 +0000267 return *m_process_sp;
268}
269
270Thread &
271ExecutionContext::GetThreadRef () const
272{
Greg Claytonf4124de2012-02-21 00:09:25 +0000273#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
Greg Clayton567e7f32011-09-22 04:58:26 +0000274 assert (m_thread_sp.get());
Greg Claytonf4124de2012-02-21 00:09:25 +0000275#endif
Greg Clayton567e7f32011-09-22 04:58:26 +0000276 return *m_thread_sp;
277}
278
279StackFrame &
280ExecutionContext::GetFrameRef () const
281{
Greg Claytonf4124de2012-02-21 00:09:25 +0000282#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
Greg Clayton567e7f32011-09-22 04:58:26 +0000283 assert (m_frame_sp.get());
Greg Claytonf4124de2012-02-21 00:09:25 +0000284#endif
Greg Clayton567e7f32011-09-22 04:58:26 +0000285 return *m_frame_sp;
286}
287
288void
289ExecutionContext::SetTargetSP (const lldb::TargetSP &target_sp)
290{
291 m_target_sp = target_sp;
292}
293
294void
295ExecutionContext::SetProcessSP (const lldb::ProcessSP &process_sp)
296{
297 m_process_sp = process_sp;
298}
299
300void
301ExecutionContext::SetThreadSP (const lldb::ThreadSP &thread_sp)
302{
303 m_thread_sp = thread_sp;
304}
305
306void
307ExecutionContext::SetFrameSP (const lldb::StackFrameSP &frame_sp)
308{
309 m_frame_sp = frame_sp;
310}
311
312void
313ExecutionContext::SetTargetPtr (Target* target)
314{
Greg Clayton13d24fb2012-01-29 20:56:30 +0000315 if (target)
316 m_target_sp = target->shared_from_this();
317 else
318 m_target_sp.reset();
Greg Clayton567e7f32011-09-22 04:58:26 +0000319}
320
321void
322ExecutionContext::SetProcessPtr (Process *process)
323{
Greg Clayton13d24fb2012-01-29 20:56:30 +0000324 if (process)
325 m_process_sp = process->shared_from_this();
326 else
327 m_process_sp.reset();
Greg Clayton567e7f32011-09-22 04:58:26 +0000328}
329
330void
331ExecutionContext::SetThreadPtr (Thread *thread)
332{
Greg Clayton13d24fb2012-01-29 20:56:30 +0000333 if (thread)
334 m_thread_sp = thread->shared_from_this();
335 else
336 m_thread_sp.reset();
Greg Clayton567e7f32011-09-22 04:58:26 +0000337}
338
339void
340ExecutionContext::SetFramePtr (StackFrame *frame)
341{
Greg Clayton13d24fb2012-01-29 20:56:30 +0000342 if (frame)
343 m_frame_sp = frame->shared_from_this();
344 else
345 m_frame_sp.reset();
Greg Clayton567e7f32011-09-22 04:58:26 +0000346}
347
Greg Claytonb4d7fc02012-02-17 07:49:44 +0000348void
349ExecutionContext::SetContext (const lldb::TargetSP &target_sp, bool get_process)
350{
351 m_target_sp = target_sp;
352 if (get_process && target_sp)
353 m_process_sp = target_sp->GetProcessSP();
354 else
355 m_process_sp.reset();
356 m_thread_sp.reset();
357 m_frame_sp.reset();
358}
359
360void
361ExecutionContext::SetContext (const lldb::ProcessSP &process_sp)
362{
363 m_process_sp = process_sp;
364 if (process_sp)
365 m_target_sp = process_sp->GetTarget().shared_from_this();
366 else
367 m_target_sp.reset();
368 m_thread_sp.reset();
369 m_frame_sp.reset();
370}
371
372void
373ExecutionContext::SetContext (const lldb::ThreadSP &thread_sp)
374{
375 m_frame_sp.reset();
376 m_thread_sp = thread_sp;
377 if (thread_sp)
378 {
Greg Claytonf4124de2012-02-21 00:09:25 +0000379 m_process_sp = thread_sp->GetProcess();
Greg Claytonb4d7fc02012-02-17 07:49:44 +0000380 if (m_process_sp)
381 m_target_sp = m_process_sp->GetTarget().shared_from_this();
382 else
383 m_target_sp.reset();
384 }
385 else
386 {
387 m_target_sp.reset();
388 m_process_sp.reset();
389 }
390}
391
392void
393ExecutionContext::SetContext (const lldb::StackFrameSP &frame_sp)
394{
395 m_frame_sp = frame_sp;
396 if (frame_sp)
397 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000398 m_thread_sp = frame_sp->CalculateThread();
Greg Claytonb4d7fc02012-02-17 07:49:44 +0000399 if (m_thread_sp)
400 {
Greg Claytonf4124de2012-02-21 00:09:25 +0000401 m_process_sp = m_thread_sp->GetProcess();
Greg Claytonb4d7fc02012-02-17 07:49:44 +0000402 if (m_process_sp)
403 m_target_sp = m_process_sp->GetTarget().shared_from_this();
404 else
405 m_target_sp.reset();
406 }
407 else
408 {
409 m_target_sp.reset();
410 m_process_sp.reset();
411 }
412 }
413 else
414 {
415 m_target_sp.reset();
416 m_process_sp.reset();
417 m_thread_sp.reset();
418 }
419}
420
421ExecutionContext &
422ExecutionContext::operator =(const ExecutionContext &rhs)
423{
424 if (this != &rhs)
425 {
426 m_target_sp = rhs.m_target_sp;
427 m_process_sp = rhs.m_process_sp;
428 m_thread_sp = rhs.m_thread_sp;
429 m_frame_sp = rhs.m_frame_sp;
430 }
431 return *this;
432}
433
434bool
435ExecutionContext::operator ==(const ExecutionContext &rhs) const
436{
437 // Check that the frame shared pointers match, or both are valid and their stack
438 // IDs match since sometimes we get new objects that represent the same
439 // frame within a thread.
440 if ((m_frame_sp == rhs.m_frame_sp) || (m_frame_sp && rhs.m_frame_sp && m_frame_sp->GetStackID() == rhs.m_frame_sp->GetStackID()))
441 {
442 // Check that the thread shared pointers match, or both are valid and
443 // their thread IDs match since sometimes we get new objects that
444 // represent the same thread within a process.
445 if ((m_thread_sp == rhs.m_thread_sp) || (m_thread_sp && rhs.m_thread_sp && m_thread_sp->GetID() == rhs.m_thread_sp->GetID()))
446 {
447 // Processes and targets don't change much
448 return m_process_sp == rhs.m_process_sp && m_target_sp == rhs.m_target_sp;
449 }
450 }
451 return false;
452}
453
454bool
455ExecutionContext::operator !=(const ExecutionContext &rhs) const
456{
457 return !(*this == rhs);
458}
459
460
461ExecutionContextRef::ExecutionContextRef() :
462 m_target_wp (),
463 m_process_wp (),
464 m_thread_wp (),
465 m_frame_wp (),
466 m_tid(LLDB_INVALID_THREAD_ID),
467 m_stack_id ()
468{
469}
470
471ExecutionContextRef::ExecutionContextRef (const ExecutionContext *exe_ctx) :
472 m_target_wp (),
473 m_process_wp (),
474 m_thread_wp (),
475 m_frame_wp (),
476 m_tid(LLDB_INVALID_THREAD_ID),
477 m_stack_id ()
478{
479 if (exe_ctx)
480 *this = *exe_ctx;
481}
482
483ExecutionContextRef::ExecutionContextRef (const ExecutionContext &exe_ctx) :
484 m_target_wp (),
485 m_process_wp (),
486 m_thread_wp (),
487 m_frame_wp (),
488 m_tid(LLDB_INVALID_THREAD_ID),
489 m_stack_id ()
490{
491 *this = exe_ctx;
492}
493
494
495ExecutionContextRef::ExecutionContextRef (Target *target, bool adopt_selected) :
496 m_target_wp(),
497 m_process_wp(),
498 m_thread_wp(),
499 m_frame_wp(),
500 m_tid(LLDB_INVALID_THREAD_ID),
501 m_stack_id ()
502{
503 SetTargetPtr (target, adopt_selected);
504}
505
506
507
508
509ExecutionContextRef::ExecutionContextRef (const ExecutionContextRef &rhs) :
510 m_target_wp (rhs.m_target_wp),
511 m_process_wp(rhs.m_process_wp),
512 m_thread_wp (rhs.m_thread_wp),
513 m_frame_wp (rhs.m_frame_wp),
514 m_tid (rhs.m_tid),
515 m_stack_id (rhs.m_stack_id)
516{
517}
518
519ExecutionContextRef &
520ExecutionContextRef::operator =(const ExecutionContextRef &rhs)
521{
522 if (this != &rhs)
523 {
524 m_target_wp = rhs.m_target_wp;
525 m_process_wp = rhs.m_process_wp;
526 m_thread_wp = rhs.m_thread_wp;
527 m_frame_wp = rhs.m_frame_wp;
528 m_tid = rhs.m_tid;
529 m_stack_id = rhs.m_stack_id;
530 }
531 return *this;
532}
533
534ExecutionContextRef &
535ExecutionContextRef::operator =(const ExecutionContext &exe_ctx)
536{
537 m_target_wp = exe_ctx.GetTargetSP();
538 m_process_wp = exe_ctx.GetProcessSP();
539 SetThreadSP (exe_ctx.GetThreadSP());
540 SetFrameSP (exe_ctx.GetFrameSP());
541 return *this;
542}
543
544void
545ExecutionContextRef::Clear()
546{
547 m_target_wp.reset();
548 m_process_wp.reset();
549 m_thread_wp.reset();
550 m_frame_wp.reset();
551 m_tid = LLDB_INVALID_THREAD_ID;
552 m_stack_id.Clear();
553}
554
555ExecutionContextRef::~ExecutionContextRef()
556{
557}
558
559void
560ExecutionContextRef::SetTargetSP (const lldb::TargetSP &target_sp)
561{
562 m_target_wp = target_sp;
563}
564
565void
566ExecutionContextRef::SetProcessSP (const lldb::ProcessSP &process_sp)
567{
568 m_process_wp = process_sp;
569}
570
571void
572ExecutionContextRef::SetThreadSP (const lldb::ThreadSP &thread_sp)
573{
574 m_thread_wp = thread_sp;
575 if (thread_sp)
576 m_tid = thread_sp->GetID();
577 else
578 m_tid = LLDB_INVALID_THREAD_ID;
579}
580
581void
582ExecutionContextRef::SetFrameSP (const lldb::StackFrameSP &frame_sp)
583{
584 m_frame_wp = frame_sp;
585 if (frame_sp)
586 m_stack_id = frame_sp->GetStackID();
587 else
588 m_stack_id.Clear();
589}
590
591void
592ExecutionContextRef::SetTargetPtr (Target* target, bool adopt_selected)
593{
594 Clear();
595 if (target)
596 {
597 lldb::TargetSP target_sp (target->shared_from_this());
598 if (target_sp)
599 {
600 m_target_wp = target_sp;
601 if (adopt_selected)
602 {
603 lldb::ProcessSP process_sp (target_sp->GetProcessSP());
604 if (process_sp)
605 {
606 m_process_wp = process_sp;
607 if (process_sp)
608 {
609 lldb::ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread());
610 if (!thread_sp)
611 thread_sp = process_sp->GetThreadList().GetThreadAtIndex(0);
612
613 if (thread_sp)
614 {
615 SetThreadSP (thread_sp);
616 lldb::StackFrameSP frame_sp (thread_sp->GetSelectedFrame());
617 if (!frame_sp)
618 frame_sp = thread_sp->GetStackFrameAtIndex(0);
619 if (frame_sp)
620 SetFrameSP (frame_sp);
621 }
622 }
623 }
624 }
625 }
626 }
627}
628
629void
630ExecutionContextRef::SetProcessPtr (Process *process)
631{
632 if (process)
633 m_process_wp = process->shared_from_this();
634 else
635 m_process_wp.reset();
636}
637
638void
639ExecutionContextRef::SetThreadPtr (Thread *thread)
640{
641 if (thread)
642 m_thread_wp = thread->shared_from_this();
643 else
644 m_thread_wp.reset();
645}
646
647void
648ExecutionContextRef::SetFramePtr (StackFrame *frame)
649{
650 if (frame)
651 m_frame_wp = frame->shared_from_this();
652 else
653 m_frame_wp.reset();
654}
655
656
657lldb::ThreadSP
658ExecutionContextRef::GetThreadSP () const
659{
660 lldb::ThreadSP thread_sp (m_thread_wp.lock());
661 if (!thread_sp && m_tid != LLDB_INVALID_THREAD_ID)
662 {
663 lldb::ProcessSP process_sp(GetProcessSP());
664 if (process_sp)
665 {
666 thread_sp = process_sp->GetThreadList().FindThreadByID(m_tid);
667 m_thread_wp = thread_sp;
668 }
669 }
670 return thread_sp;
671}
672
673lldb::StackFrameSP
674ExecutionContextRef::GetFrameSP () const
675{
676 lldb::StackFrameSP frame_sp (m_frame_wp.lock());
677 if (!frame_sp && m_stack_id.IsValid())
678 {
679 lldb::ThreadSP thread_sp (GetThreadSP());
680 if (thread_sp)
681 {
682 frame_sp = thread_sp->GetFrameWithStackID (m_stack_id);
683 m_frame_wp = frame_sp;
684 }
685 }
686 return frame_sp;
687}
688
689ExecutionContext
690ExecutionContextRef::Lock () const
691{
692 return ExecutionContext(this);
693}
694
695