]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ExecutionContext.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / lldb / include / lldb / Target / ExecutionContext.h
1 //===-- ExecutionContext.h --------------------------------------*- 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 //===----------------------------------------------------------------------===//
9 /// Execution context objects refer to objects in the execution of the
10 /// program that is being debugged. The consist of one or more of the 
11 /// following objects: target, process, thread, and frame. Many objects
12 /// in the debugger need to track different executions contexts. For
13 /// example, a local function variable might have an execution context
14 /// that refers to a stack frame. A global or static variable might 
15 /// refer to a target since a stack frame isn't required in order to
16 /// evaluate a global or static variable (a process isn't necessarily
17 /// needed for a global variable since we might be able to read the
18 /// variable value from a data section in one of the object files in 
19 /// a target). There are two types of objects that hold onto execution
20 /// contexts: ExecutionContextRef and ExecutionContext. Both of these
21 /// objects are deascribed below.
22 /// 
23 /// Not all objects in an ExectionContext objects will be valid. If you want
24 /// to refer stronly (ExectionContext) or weakly (ExectionContextRef) to
25 /// a process, then only the process and target references will be valid.
26 /// For threads, only the thread, process and target references will be
27 /// filled in. For frames, all of the objects will be filled in.
28 ///
29 /// These classes are designed to be used as baton objects that get passed
30 /// to a wide variety of functions that require execution contexts.
31 //===----------------------------------------------------------------------===//
32
33
34
35 #ifndef liblldb_ExecutionContext_h_
36 #define liblldb_ExecutionContext_h_
37
38 #include "lldb/lldb-private.h"
39 #include "lldb/Target/StackID.h"
40 #include "lldb/Host/Mutex.h"
41
42 namespace lldb_private {
43
44 //----------------------------------------------------------------------
45 /// @class ExecutionContextRef ExecutionContext.h "lldb/Target/ExecutionContext.h"
46 /// @brief A class that holds a weak reference to an execution context.
47 ///
48 /// ExecutionContextRef objects are designed to hold onto an execution
49 /// context that might change over time. For example, if an object wants
50 /// to refer to a stack frame, it should hold onto an ExecutionContextRef
51 /// to a frame object. The backing object that represents the stack frame
52 /// might change over time and instaces of this object can track the logical
53 /// object that refers to a frame even if it does change.
54 ///
55 /// These objects also don't keep execution objects around longer than they
56 /// should since they use weak pointers. For example if an object refers
57 /// to a stack frame and a stack frame is no longer in a thread, then a
58 /// ExecutionContextRef object that refers to that frame will not be able
59 /// to get a shared pointer to those objects since they are no longer around.
60 /// 
61 /// ExecutionContextRef objects can also be used as objects in classes
62 /// that want to track a "previous execution context". Since the weak 
63 /// references to the execution objects (target, process, thread and frame)
64 /// don't keep these objects around, they are safe to keep around. 
65 ///
66 /// The general rule of thumb is all long lived objects that want to
67 /// refer to execution contexts should use ExecutionContextRef objcts. 
68 /// The ExecutionContext class is used to temporarily get shared 
69 /// pointers to any execution context objects that are still around
70 /// so they are guaranteed to exist during a function that requires the
71 /// objects. ExecutionContext objects should NOT be used for long term
72 /// storage since they will keep objects alive with extra shared pointer 
73 /// references to these  objects.
74 //----------------------------------------------------------------------
75 class ExecutionContextRef
76 {
77 public:
78     //------------------------------------------------------------------
79     /// Default Constructor.
80     //------------------------------------------------------------------
81     ExecutionContextRef();
82
83     //------------------------------------------------------------------
84     /// Copy Constructor.
85     //------------------------------------------------------------------
86     ExecutionContextRef (const ExecutionContextRef &rhs);
87
88     //------------------------------------------------------------------
89     /// Construct using an ExecutionContext object that might be NULL.
90     /// 
91     /// If \a exe_ctx_ptr is valid, then make weak references to any
92     /// valid objects in the ExecutionContext, othewise no weak 
93     /// references to any execution context objects will be made.
94     //------------------------------------------------------------------
95     ExecutionContextRef (const ExecutionContext *exe_ctx_ptr);
96     
97     //------------------------------------------------------------------
98     /// Construct using an ExecutionContext object.
99     /// 
100     /// Make weak references to any valid objects in the ExecutionContext.
101     //------------------------------------------------------------------
102     ExecutionContextRef (const ExecutionContext &exe_ctx);
103
104     //------------------------------------------------------------------
105     /// Assignment operator
106     /// 
107     /// Copy all weak refernces in \a rhs.
108     //------------------------------------------------------------------
109     ExecutionContextRef &
110     operator =(const ExecutionContextRef &rhs);
111
112     //------------------------------------------------------------------
113     /// Assignment operator from a ExecutionContext
114     /// 
115     /// Make weak refernces to any stringly referenced objects in \a exe_ctx.
116     //------------------------------------------------------------------
117     ExecutionContextRef &
118     operator =(const ExecutionContext &exe_ctx);
119
120     //------------------------------------------------------------------
121     /// Construct using the target and all the selected items inside of it
122     /// (the process and its selected thread, and the thread's selected
123     /// frame). If there is no selected thread, default to the first thread
124     /// If there is no selected frame, default to the first frame. 
125     //------------------------------------------------------------------
126     ExecutionContextRef (Target *target, bool adopt_selected);
127
128     //------------------------------------------------------------------
129     /// Construct using an execution context scope.
130     ///
131     /// If the ExecutionContextScope object is valid and refers to a frame,
132     /// make weak refernces too the frame, thread, process and target.
133     /// If the ExecutionContextScope object is valid and refers to a thread,
134     /// make weak refernces too the thread, process and target.
135     /// If the ExecutionContextScope object is valid and refers to a process,
136     /// make weak refernces too the process and target.
137     /// If the ExecutionContextScope object is valid and refers to a target,
138     /// make weak refernces too the target.
139     //------------------------------------------------------------------
140     ExecutionContextRef (ExecutionContextScope *exe_scope);
141
142     //------------------------------------------------------------------
143     /// Construct using an execution context scope.
144     ///
145     /// If the ExecutionContextScope object refers to a frame,
146     /// make weak refernces too the frame, thread, process and target.
147     /// If the ExecutionContextScope object refers to a thread,
148     /// make weak refernces too the thread, process and target.
149     /// If the ExecutionContextScope object refers to a process,
150     /// make weak refernces too the process and target.
151     /// If the ExecutionContextScope object refers to a target,
152     /// make weak refernces too the target.
153     //------------------------------------------------------------------
154     ExecutionContextRef (ExecutionContextScope &exe_scope);
155
156     ~ExecutionContextRef();
157     //------------------------------------------------------------------
158     /// Clear the object's state.
159     ///
160     /// Sets the process and thread to NULL, and the frame index to an
161     /// invalid value.
162     //------------------------------------------------------------------
163     void
164     Clear ();
165
166     //------------------------------------------------------------------
167     /// Set accessor that creates a weak reference to the target 
168     /// referenced in \a target_sp.
169     ///
170     /// If \a target_sp is valid this object will create a weak 
171     /// reference to that object, otherwise any previous target weak
172     /// reference contained in this object will be reset.
173     ///
174     /// Only the weak reference to the target will be updated, no other
175     /// weak references will be modified. If you want this execution
176     /// context to make a weak reference to the target's process, use 
177     /// the ExecutionContextRef::SetContext() functions.
178     ///
179     /// @see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool)
180     //------------------------------------------------------------------
181     void
182     SetTargetSP (const lldb::TargetSP &target_sp);
183     
184     //------------------------------------------------------------------
185     /// Set accessor that creates a weak reference to the process 
186     /// referenced in \a process_sp.
187     ///
188     /// If \a process_sp is valid this object will create a weak 
189     /// reference to that object, otherwise any previous process weak
190     /// reference contained in this object will be reset.
191     ///
192     /// Only the weak reference to the process will be updated, no other
193     /// weak references will be modified. If you want this execution
194     /// context to make a weak reference to the target, use the
195     /// ExecutionContextRef::SetContext() functions.
196     ///
197     /// @see ExecutionContextRef::SetContext(const lldb::ProcessSP &)
198     //------------------------------------------------------------------
199     void
200     SetProcessSP (const lldb::ProcessSP &process_sp);
201     
202     //------------------------------------------------------------------
203     /// Set accessor that creates a weak reference to the thread 
204     /// referenced in \a thread_sp.
205     ///
206     /// If \a thread_sp is valid this object will create a weak 
207     /// reference to that object, otherwise any previous thread weak
208     /// reference contained in this object will be reset.
209     ///
210     /// Only the weak reference to the thread will be updated, no other
211     /// weak references will be modified. If you want this execution
212     /// context to make a weak reference to the thread's process and 
213     /// target, use the ExecutionContextRef::SetContext() functions.
214     ///
215     /// @see ExecutionContextRef::SetContext(const lldb::ThreadSP &)
216     //------------------------------------------------------------------
217     void
218     SetThreadSP (const lldb::ThreadSP &thread_sp);
219     
220     //------------------------------------------------------------------
221     /// Set accessor that creates a weak reference to the frame 
222     /// referenced in \a frame_sp.
223     ///
224     /// If \a frame_sp is valid this object will create a weak 
225     /// reference to that object, otherwise any previous frame weak
226     /// reference contained in this object will be reset.
227     ///
228     /// Only the weak reference to the frame will be updated, no other
229     /// weak references will be modified. If you want this execution
230     /// context to make a weak reference to the frame's thread, process
231     /// and target, use the ExecutionContextRef::SetContext() functions.
232     ///
233     /// @see ExecutionContextRef::SetContext(const lldb::StackFrameSP &)
234     //------------------------------------------------------------------
235     void
236     SetFrameSP (const lldb::StackFrameSP &frame_sp);
237
238     void
239     SetTargetPtr (Target* target, bool adopt_selected);
240     
241     void
242     SetProcessPtr (Process *process);
243     
244     void
245     SetThreadPtr (Thread *thread);
246     
247     void
248     SetFramePtr (StackFrame *frame);
249
250     //------------------------------------------------------------------
251     /// Get accessor that creates a strong reference from the weak target
252     /// reference contained in this object.
253     ///
254     /// @returns
255     ///     A shared pointer to a target that is not guaranteed to be valid.
256     //------------------------------------------------------------------
257     lldb::TargetSP
258     GetTargetSP () const;
259     
260     //------------------------------------------------------------------
261     /// Get accessor that creates a strong reference from the weak process
262     /// reference contained in this object.
263     ///
264     /// @returns
265     ///     A shared pointer to a process that is not guaranteed to be valid.
266     //------------------------------------------------------------------
267     lldb::ProcessSP
268     GetProcessSP () const;
269     
270     //------------------------------------------------------------------
271     /// Get accessor that creates a strong reference from the weak thread
272     /// reference contained in this object.
273     ///
274     /// @returns
275     ///     A shared pointer to a thread that is not guaranteed to be valid.
276     //------------------------------------------------------------------
277     lldb::ThreadSP
278     GetThreadSP () const;
279     
280     //------------------------------------------------------------------
281     /// Get accessor that creates a strong reference from the weak frame
282     /// reference contained in this object.
283     ///
284     /// @returns
285     ///     A shared pointer to a frame that is not guaranteed to be valid.
286     //------------------------------------------------------------------
287     lldb::StackFrameSP
288     GetFrameSP () const;
289
290     //------------------------------------------------------------------
291     /// Create an ExecutionContext object from this object.
292     ///
293     /// Create strong references to any execution context objects that
294     /// are still valid. Any of the returned shared pointers in the
295     /// ExecutionContext objects is not guaranteed to be valid.
296     /// @returns
297     ///     An execution context object that has strong references to
298     ///     any valid weak references in this object.
299     //------------------------------------------------------------------
300     ExecutionContext
301     Lock () const;
302
303     //------------------------------------------------------------------
304     /// Returns true if this object has a weak reference to a thread.
305     /// The return value is only an indication of wether this object has
306     /// a weak reference and does not indicate wether the weak rerference
307     /// is valid or not.
308     //------------------------------------------------------------------
309     bool
310     HasThreadRef () const
311     {
312         return m_tid != LLDB_INVALID_THREAD_ID;
313     }
314
315     //------------------------------------------------------------------
316     /// Returns true if this object has a weak reference to a frame.
317     /// The return value is only an indication of wether this object has
318     /// a weak reference and does not indicate wether the weak rerference
319     /// is valid or not.
320     //------------------------------------------------------------------
321     bool
322     HasFrameRef () const
323     {
324         return m_stack_id.IsValid();
325     }
326
327     void
328     ClearThread ()
329     {
330         m_thread_wp.reset();
331         m_tid = LLDB_INVALID_THREAD_ID;
332     }
333     
334     void
335     ClearFrame ()
336     {
337         m_stack_id.Clear();
338     }
339
340 protected:
341     //------------------------------------------------------------------
342     // Member variables
343     //------------------------------------------------------------------
344     lldb::TargetWP m_target_wp;             ///< A weak reference to a target
345     lldb::ProcessWP m_process_wp;           ///< A weak reference to a process
346     mutable lldb::ThreadWP m_thread_wp;     ///< A weak reference to a thread
347     lldb::tid_t m_tid;                      ///< The thread ID that this object refers to in case the backing object changes
348     StackID m_stack_id;                     ///< The stack ID that this object refers to in case the backing object changes
349 };
350
351 //----------------------------------------------------------------------
352 /// @class ExecutionContext ExecutionContext.h "lldb/Target/ExecutionContext.h"
353 /// @brief A class that contains an execution context.
354 ///
355 /// This baton object can be passed into any function that requires
356 /// a context that specifies a target, process, thread and frame.
357 /// These objects are designed to be used for short term execution
358 /// context object storage while a function might be trying to evaluate
359 /// something that requires a thread or frame. ExecutionContextRef 
360 /// objects can be used to initialize one of these objects to turn
361 /// the weak execution context object references to the target, process,
362 /// thread and frame into strong references (shared pointers) so that
363 /// functions can guarantee that these objects won't go away in the
364 /// middle of a function.
365 ///
366 /// ExecutionContext objects should be used as short lived objects
367 /// (typically on the stack) in order to lock down an execution context
368 /// for local use and for passing down to other functions that also
369 /// require specific contexts. They should NOT be used for long term
370 /// storage, for long term storage use ExecutionContextRef objects.
371 //----------------------------------------------------------------------
372 class ExecutionContext
373 {
374 public:
375     //------------------------------------------------------------------
376     /// Default Constructor.
377     //------------------------------------------------------------------
378     ExecutionContext();
379
380     //------------------------------------------------------------------
381     // Copy constructor
382     //------------------------------------------------------------------
383     ExecutionContext (const ExecutionContext &rhs);
384
385     //------------------------------------------------------------------
386     // Adopt the target and optionally its current context.
387     //------------------------------------------------------------------
388     ExecutionContext (Target* t, bool fill_current_process_thread_frame = true);
389     
390     //------------------------------------------------------------------
391     // Create execution contexts from shared pointers
392     //------------------------------------------------------------------
393     ExecutionContext (const lldb::TargetSP &target_sp, bool get_process);
394     ExecutionContext (const lldb::ProcessSP &process_sp);
395     ExecutionContext (const lldb::ThreadSP &thread_sp);
396     ExecutionContext (const lldb::StackFrameSP &frame_sp);
397     //------------------------------------------------------------------
398     // Create execution contexts from weak pointers
399     //------------------------------------------------------------------
400     ExecutionContext (const lldb::TargetWP &target_wp, bool get_process);
401     ExecutionContext (const lldb::ProcessWP &process_wp);
402     ExecutionContext (const lldb::ThreadWP &thread_wp);
403     ExecutionContext (const lldb::StackFrameWP &frame_wp);    
404     ExecutionContext (const ExecutionContextRef &exe_ctx_ref);
405     ExecutionContext (const ExecutionContextRef *exe_ctx_ref);
406     
407     // These two variants take in a locker, and grab the target, lock the API mutex into locker, then
408     // fill in the rest of the shared pointers.
409     ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker);
410     ExecutionContext (const ExecutionContextRef *exe_ctx_ref, Mutex::Locker &locker);
411     //------------------------------------------------------------------
412     // Create execution contexts from execution context scopes
413     //------------------------------------------------------------------
414     ExecutionContext (ExecutionContextScope *exe_scope);
415     ExecutionContext (ExecutionContextScope &exe_scope);
416     
417
418     ExecutionContext &
419     operator =(const ExecutionContext &rhs);
420
421     bool
422     operator ==(const ExecutionContext &rhs) const;
423     
424     bool
425     operator !=(const ExecutionContext &rhs) const;
426
427     //------------------------------------------------------------------
428     /// Construct with process, thread, and frame index.
429     ///
430     /// Initialize with process \a p, thread \a t, and frame index \a f.
431     ///
432     /// @param[in] process
433     ///     The process for this execution context.
434     ///
435     /// @param[in] thread
436     ///     The thread for this execution context.
437     ///
438     /// @param[in] frame
439     ///     The frame index for this execution context.
440     //------------------------------------------------------------------
441     ExecutionContext (Process* process,
442                       Thread *thread = NULL,
443                       StackFrame * frame = NULL);
444
445
446     ~ExecutionContext();
447     //------------------------------------------------------------------
448     /// Clear the object's state.
449     ///
450     /// Sets the process and thread to NULL, and the frame index to an
451     /// invalid value.
452     //------------------------------------------------------------------
453     void
454     Clear ();
455
456     RegisterContext *
457     GetRegisterContext () const;
458
459     ExecutionContextScope *
460     GetBestExecutionContextScope () const;
461
462     uint32_t
463     GetAddressByteSize() const;
464
465     //------------------------------------------------------------------
466     /// Returns a pointer to the target object.
467     ///
468     /// The returned pointer might be NULL. Calling HasTargetScope(), 
469     /// HasProcessScope(), HasThreadScope(), or HasFrameScope() 
470     /// can help to pre-validate this pointer so that this accessor can
471     /// freely be used without having to check for NULL each time.
472     ///
473     /// @see ExecutionContext::HasTargetScope() const
474     /// @see ExecutionContext::HasProcessScope() const
475     /// @see ExecutionContext::HasThreadScope() const
476     /// @see ExecutionContext::HasFrameScope() const
477     //------------------------------------------------------------------
478     Target *
479     GetTargetPtr () const;
480
481     //------------------------------------------------------------------
482     /// Returns a pointer to the process object.
483     ///
484     /// The returned pointer might be NULL. Calling HasProcessScope(), 
485     /// HasThreadScope(), or HasFrameScope()  can help to pre-validate 
486     /// this pointer so that this accessor can freely be used without
487     /// having to check for NULL each time.
488     ///
489     /// @see ExecutionContext::HasProcessScope() const
490     /// @see ExecutionContext::HasThreadScope() const
491     /// @see ExecutionContext::HasFrameScope() const
492     //------------------------------------------------------------------
493     Process *
494     GetProcessPtr () const;
495
496     //------------------------------------------------------------------
497     /// Returns a pointer to the thread object.
498     ///
499     /// The returned pointer might be NULL. Calling HasThreadScope() or
500     /// HasFrameScope() can help to pre-validate this pointer so that 
501     /// this accessor can freely be used without having to check for 
502     /// NULL each time.
503     ///
504     /// @see ExecutionContext::HasThreadScope() const
505     /// @see ExecutionContext::HasFrameScope() const
506     //------------------------------------------------------------------
507     Thread *
508     GetThreadPtr () const
509     {
510         return m_thread_sp.get();
511     }
512     
513     //------------------------------------------------------------------
514     /// Returns a pointer to the frame object.
515     ///
516     /// The returned pointer might be NULL. Calling HasFrameScope(),
517     /// can help to pre-validate this pointer so that this accessor can
518     /// freely be used without having to check for NULL each time.
519     ///
520     /// @see ExecutionContext::HasFrameScope() const
521     //------------------------------------------------------------------
522     StackFrame *
523     GetFramePtr () const
524     {
525         return m_frame_sp.get();
526     }
527
528     //------------------------------------------------------------------
529     /// Returns a reference to the target object.
530     ///
531     /// Clients should call HasTargetScope(), HasProcessScope(), 
532     /// HasThreadScope(), or HasFrameScope() prior to calling this 
533     /// function to ensure that this ExecutionContext object contains
534     /// a valid target.
535     ///
536     /// @see ExecutionContext::HasTargetScope() const
537     /// @see ExecutionContext::HasProcessScope() const
538     /// @see ExecutionContext::HasThreadScope() const
539     /// @see ExecutionContext::HasFrameScope() const
540     //------------------------------------------------------------------
541     Target &
542     GetTargetRef () const;
543     
544     //------------------------------------------------------------------
545     /// Returns a reference to the process object.
546     ///
547     /// Clients should call HasProcessScope(), HasThreadScope(), or 
548     /// HasFrameScope() prior to calling this  function to ensure that 
549     /// this ExecutionContext object contains a valid target.
550     ///
551     /// @see ExecutionContext::HasProcessScope() const
552     /// @see ExecutionContext::HasThreadScope() const
553     /// @see ExecutionContext::HasFrameScope() const
554     //------------------------------------------------------------------
555     Process &
556     GetProcessRef () const;
557     
558     //------------------------------------------------------------------
559     /// Returns a reference to the thread object.
560     ///
561     /// Clients should call HasThreadScope(), or  HasFrameScope() prior
562     /// to calling this  function to ensure that  this ExecutionContext
563     /// object contains a valid target.
564     ///
565     /// @see ExecutionContext::HasThreadScope() const
566     /// @see ExecutionContext::HasFrameScope() const
567     //------------------------------------------------------------------
568     Thread &
569     GetThreadRef () const;
570     
571     //------------------------------------------------------------------
572     /// Returns a reference to the thread object.
573     ///
574     /// Clients should call HasFrameScope() prior to calling this 
575     /// function to ensure that  this ExecutionContext object contains
576     /// a valid target.
577     ///
578     /// @see ExecutionContext::HasFrameScope() const
579     //------------------------------------------------------------------
580     StackFrame &
581     GetFrameRef () const;
582     
583     //------------------------------------------------------------------
584     /// Get accessor to get the target shared pointer.
585     ///
586     /// The returned shared pointer is not guaranteed to be valid.
587     //------------------------------------------------------------------
588     const lldb::TargetSP &
589     GetTargetSP () const
590     {
591         return m_target_sp;
592     }
593     
594     //------------------------------------------------------------------
595     /// Get accessor to get the process shared pointer.
596     ///
597     /// The returned shared pointer is not guaranteed to be valid.
598     //------------------------------------------------------------------
599     const lldb::ProcessSP &
600     GetProcessSP () const
601     {
602         return m_process_sp;
603     }
604
605     //------------------------------------------------------------------
606     /// Get accessor to get the thread shared pointer.
607     ///
608     /// The returned shared pointer is not guaranteed to be valid.
609     //------------------------------------------------------------------
610     const lldb::ThreadSP &
611     GetThreadSP () const
612     {
613         return m_thread_sp;
614     }
615         
616     //------------------------------------------------------------------
617     /// Get accessor to get the frame shared pointer.
618     ///
619     /// The returned shared pointer is not guaranteed to be valid.
620     //------------------------------------------------------------------
621     const lldb::StackFrameSP &
622     GetFrameSP () const
623     {
624         return m_frame_sp;
625     }
626
627     //------------------------------------------------------------------
628     /// Set accessor to set only the target shared pointer.
629     //------------------------------------------------------------------
630     void
631     SetTargetSP (const lldb::TargetSP &target_sp);
632     
633     //------------------------------------------------------------------
634     /// Set accessor to set only the process shared pointer.
635     //------------------------------------------------------------------
636     void
637     SetProcessSP (const lldb::ProcessSP &process_sp);
638     
639     //------------------------------------------------------------------
640     /// Set accessor to set only the thread shared pointer.
641     //------------------------------------------------------------------
642     void
643     SetThreadSP (const lldb::ThreadSP &thread_sp);
644     
645     //------------------------------------------------------------------
646     /// Set accessor to set only the frame shared pointer.
647     //------------------------------------------------------------------
648     void
649     SetFrameSP (const lldb::StackFrameSP &frame_sp);
650
651     //------------------------------------------------------------------
652     /// Set accessor to set only the target shared pointer from a target
653     /// pointer.
654     //------------------------------------------------------------------
655     void
656     SetTargetPtr (Target* target);
657     
658     //------------------------------------------------------------------
659     /// Set accessor to set only the process shared pointer from a 
660     /// process pointer.
661     //------------------------------------------------------------------
662     void
663     SetProcessPtr (Process *process);
664     
665     //------------------------------------------------------------------
666     /// Set accessor to set only the thread shared pointer from a thread
667     /// pointer.
668     //------------------------------------------------------------------
669     void
670     SetThreadPtr (Thread *thread);
671     
672     //------------------------------------------------------------------
673     /// Set accessor to set only the frame shared pointer from a frame
674     /// pointer.
675     //------------------------------------------------------------------
676     void
677     SetFramePtr (StackFrame *frame);
678
679     //------------------------------------------------------------------
680     // Set the execution context using a target shared pointer. 
681     //
682     // If "target_sp" is valid, sets the target context to match and
683     // if "get_process" is true, sets the process shared pointer if
684     // the target currently has a process.
685     //------------------------------------------------------------------
686     void
687     SetContext (const lldb::TargetSP &target_sp, bool get_process);
688     
689     //------------------------------------------------------------------
690     // Set the execution context using a process shared pointer.
691     //
692     // If "process_sp" is valid, then set the process and target in this
693     // context. Thread and frame contexts will be cleared.
694     // If "process_sp" is not valid, all shared pointers are reset.
695     //------------------------------------------------------------------
696     void
697     SetContext (const lldb::ProcessSP &process_sp);
698     
699     //------------------------------------------------------------------
700     // Set the execution context using a thread shared pointer.
701     //
702     // If "thread_sp" is valid, then set the thread, process and target
703     // in this context. The frame context will be cleared. 
704     // If "thread_sp" is not valid, all shared pointers are reset.
705     //------------------------------------------------------------------
706     void
707     SetContext (const lldb::ThreadSP &thread_sp);
708     
709     //------------------------------------------------------------------
710     // Set the execution context using a frame shared pointer.
711     //
712     // If "frame_sp" is valid, then set the frame, thread, process and 
713     // target in this context
714     // If "frame_sp" is not valid, all shared pointers are reset.
715     //------------------------------------------------------------------
716     void
717     SetContext (const lldb::StackFrameSP &frame_sp);
718
719     //------------------------------------------------------------------
720     /// Returns true the ExecutionContext object contains a valid 
721     /// target.
722     ///
723     /// This function can be called after initializing an ExecutionContext
724     /// object, and if it returns true, calls to GetTargetPtr() and 
725     /// GetTargetRef() do not need to be checked for validity.
726     //------------------------------------------------------------------
727     bool
728     HasTargetScope () const;
729
730     //------------------------------------------------------------------
731     /// Returns true the ExecutionContext object contains a valid 
732     /// target and process.
733     ///
734     /// This function can be called after initializing an ExecutionContext
735     /// object, and if it returns true, calls to GetTargetPtr() and 
736     /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not
737     /// need to be checked for validity.
738     //------------------------------------------------------------------
739     bool
740     HasProcessScope () const;
741
742     //------------------------------------------------------------------
743     /// Returns true the ExecutionContext object contains a valid 
744     /// target, process, and thread.
745     ///
746     /// This function can be called after initializing an ExecutionContext
747     /// object, and if it returns true, calls to GetTargetPtr(), 
748     /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(),
749     /// and GetThreadRef() do not need to be checked for validity.
750     //------------------------------------------------------------------
751     bool
752     HasThreadScope () const;
753     
754     //------------------------------------------------------------------
755     /// Returns true the ExecutionContext object contains a valid 
756     /// target, process, thread and frame.
757     ///
758     /// This function can be called after initializing an ExecutionContext
759     /// object, and if it returns true, calls to GetTargetPtr(), 
760     /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(),
761     /// GetThreadRef(), GetFramePtr(), and GetFrameRef() do not need
762     /// to be checked for validity.
763     //------------------------------------------------------------------
764     bool
765     HasFrameScope () const;
766     
767 protected:
768     //------------------------------------------------------------------
769     // Member variables
770     //------------------------------------------------------------------
771     lldb::TargetSP m_target_sp;     ///< The target that owns the process/thread/frame
772     lldb::ProcessSP m_process_sp;   ///< The process that owns the thread/frame
773     lldb::ThreadSP m_thread_sp;     ///< The thread that owns the frame
774     lldb::StackFrameSP m_frame_sp;  ///< The stack frame in thread.
775 };
776 } // namespace lldb_private
777
778 #endif  // liblldb_ExecutionContext_h_