LLDB mainline
ExecutionContext.h
Go to the documentation of this file.
1//===-- ExecutionContext.h --------------------------------------*- C++ -*-===//
2//
3// 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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_TARGET_EXECUTIONCONTEXT_H
10#define LLDB_TARGET_EXECUTIONCONTEXT_H
11
12#include <mutex>
13
15#include "lldb/Target/StackID.h"
16#include "lldb/lldb-private.h"
17
18namespace lldb_private {
19
20//===----------------------------------------------------------------------===//
21/// Execution context objects refer to objects in the execution of the program
22/// that is being debugged. The consist of one or more of the following
23/// objects: target, process, thread, and frame. Many objects in the debugger
24/// need to track different executions contexts. For example, a local function
25/// variable might have an execution context that refers to a stack frame. A
26/// global or static variable might refer to a target since a stack frame
27/// isn't required in order to evaluate a global or static variable (a process
28/// isn't necessarily needed for a global variable since we might be able to
29/// read the variable value from a data section in one of the object files in
30/// a target). There are two types of objects that hold onto execution
31/// contexts: ExecutionContextRef and ExecutionContext. Both of these objects
32/// are described below.
33///
34/// Not all objects in an ExecutionContext objects will be valid. If you want
35/// to refer strongly (ExecutionContext) or weakly (ExecutionContextRef) to a
36/// process, then only the process and target references will be valid. For
37/// threads, only the thread, process and target references will be filled in.
38/// For frames, all of the objects will be filled in.
39///
40/// These classes are designed to be used as baton objects that get passed to
41/// a wide variety of functions that require execution contexts.
42//===----------------------------------------------------------------------===//
43
44/// \class ExecutionContextRef ExecutionContext.h
45/// "lldb/Target/ExecutionContext.h"
46/// A class that holds a weak reference to an execution context.
47///
48/// ExecutionContextRef objects are designed to hold onto an execution context
49/// that might change over time. For example, if an object wants to refer to a
50/// stack frame, it should hold onto an ExecutionContextRef to a frame object.
51/// The backing object that represents the stack frame might change over time
52/// and instances of this object can track the logical object that refers to a
53/// 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 to a
57/// 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 to
59/// 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 that
62/// want to track a "previous execution context". Since the weak references to
63/// the execution objects (target, process, thread and frame) don't keep these
64/// objects around, they are safe to keep around.
65///
66/// The general rule of thumb is all long lived objects that want to refer to
67/// execution contexts should use ExecutionContextRef objects. The
68/// ExecutionContext class is used to temporarily get shared pointers to any
69/// execution context objects that are still around so they are guaranteed to
70/// exist during a function that requires the objects. ExecutionContext
71/// objects should NOT be used for long term storage since they will keep
72/// objects alive with extra shared pointer references to these objects.
74public:
75 /// Default Constructor.
77
78 /// Copy Constructor.
80
81 /// Construct using an ExecutionContext object that might be nullptr.
82 ///
83 /// If \a exe_ctx_ptr is valid, then make weak references to any valid
84 /// objects in the ExecutionContext, otherwise no weak references to any
85 /// execution context objects will be made.
86 ExecutionContextRef(const ExecutionContext *exe_ctx_ptr);
87
88 /// Construct using an ExecutionContext object.
89 ///
90 /// Make weak references to any valid objects in the ExecutionContext.
92
93 /// Construct using the target and all the selected items inside of it (the
94 /// process and its selected thread, and the thread's selected frame). If
95 /// there is no selected thread, default to the first thread. If there is no
96 /// selected frame, default to the first frame.
97 ExecutionContextRef(Target *target, bool adopt_selected);
98
99 /// Construct using the process and all the selected items inside of it (
100 /// the selected thread, and the thread's selected frame). If
101 /// there is no selected thread, default to the first thread. If there is no
102 /// selected frame, default to the first frame.
103 ExecutionContextRef(Process *process, bool adopt_selected);
104
105 /// Construct using the thread and all the selected items inside of it ( the
106 /// selected frame). If there is no selected frame, default to the first
107 /// frame.
108 ExecutionContextRef(Thread *thread, bool adopt_selected);
109
110 /// Construct using an execution context scope.
111 ///
112 /// If the ExecutionContextScope object is valid and refers to a frame, make
113 /// weak references too the frame, thread, process and target. If the
114 /// ExecutionContextScope object is valid and refers to a thread, make weak
115 /// references too the thread, process and target. If the
116 /// ExecutionContextScope object is valid and refers to a process, make weak
117 /// references too the process and target. If the ExecutionContextScope
118 /// object is valid and refers to a target, make weak references too the
119 /// target.
121
122 /// Construct using an execution context scope.
123 ///
124 /// If the ExecutionContextScope object refers to a frame, make weak
125 /// references too the frame, thread, process and target. If the
126 /// ExecutionContextScope object refers to a thread, make weak references
127 /// too the thread, process and target. If the ExecutionContextScope object
128 /// refers to a process, make weak references too the process and target. If
129 /// the ExecutionContextScope object refers to a target, make weak
130 /// references too the target.
132
134
135 /// Assignment operator
136 ///
137 /// Copy all weak references in \a rhs.
139
140 /// Assignment operator from a ExecutionContext
141 ///
142 /// Make weak references to any strongly referenced objects in \a exe_ctx.
144
145 /// Clear the object's state.
146 ///
147 /// Sets the process and thread to nullptr, and the frame index to an
148 /// invalid value.
149 void Clear();
150
151 /// Set accessor that creates a weak reference to the target referenced in
152 /// \a target_sp.
153 ///
154 /// If \a target_sp is valid this object will create a weak reference to
155 /// that object, otherwise any previous target weak reference contained in
156 /// this object will be reset.
157 ///
158 /// Only the weak reference to the target will be updated, no other weak
159 /// references will be modified. If you want this execution context to make
160 /// a weak reference to the target's process, use the
161 /// ExecutionContextRef::SetContext() functions.
162 ///
163 /// \see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool)
164 void SetTargetSP(const lldb::TargetSP &target_sp);
165
166 /// Set accessor that creates a weak reference to the process referenced in
167 /// \a process_sp.
168 ///
169 /// If \a process_sp is valid this object will create a weak reference to
170 /// that object, otherwise any previous process weak reference contained in
171 /// this object will be reset.
172 ///
173 /// Only the weak reference to the process will be updated, no other weak
174 /// references will be modified. If you want this execution context to make
175 /// a weak reference to the target, use the
176 /// ExecutionContextRef::SetContext() functions.
177 ///
178 /// \see ExecutionContextRef::SetContext(const lldb::ProcessSP &)
179 void SetProcessSP(const lldb::ProcessSP &process_sp);
180
181 /// Set accessor that creates a weak reference to the thread referenced in
182 /// \a thread_sp.
183 ///
184 /// If \a thread_sp is valid this object will create a weak reference to
185 /// that object, otherwise any previous thread weak reference contained in
186 /// this object will be reset.
187 ///
188 /// Only the weak reference to the thread will be updated, no other weak
189 /// references will be modified. If you want this execution context to make
190 /// a weak reference to the thread's process and target, use the
191 /// ExecutionContextRef::SetContext() functions.
192 ///
193 /// \see ExecutionContextRef::SetContext(const lldb::ThreadSP &)
194 void SetThreadSP(const lldb::ThreadSP &thread_sp);
195
196 /// Set accessor that creates a weak reference to the frame referenced in \a
197 /// frame_sp.
198 ///
199 /// If \a frame_sp is valid this object will create a weak reference to that
200 /// object, otherwise any previous frame weak reference contained in this
201 /// object will be reset.
202 ///
203 /// Only the weak reference to the frame will be updated, no other weak
204 /// references will be modified. If you want this execution context to make
205 /// a weak reference to the frame's thread, process and target, use the
206 /// ExecutionContextRef::SetContext() functions.
207 ///
208 /// \see ExecutionContextRef::SetContext(const lldb::StackFrameSP &)
209 void SetFrameSP(const lldb::StackFrameSP &frame_sp);
210
211 void SetTargetPtr(Target *target, bool adopt_selected);
212
213 void SetProcessPtr(Process *process, bool adopt_selected = false);
214
215 void SetThreadPtr(Thread *thread, bool adopt_selected = false);
216
217 void SetFramePtr(StackFrame *frame);
218
219 /// Get accessor that creates a strong reference from the weak target
220 /// reference contained in this object.
221 ///
222 /// \returns
223 /// A shared pointer to a target that is not guaranteed to be valid.
225
226 /// Get accessor that creates a strong reference from the weak process
227 /// reference contained in this object.
228 ///
229 /// \returns
230 /// A shared pointer to a process that is not guaranteed to be valid.
232
233 /// Get accessor that creates a strong reference from the weak thread
234 /// reference contained in this object.
235 ///
236 /// \returns
237 /// A shared pointer to a thread that is not guaranteed to be valid.
239
240 /// Get accessor that creates a strong reference from the weak frame
241 /// reference contained in this object.
242 ///
243 /// \returns
244 /// A shared pointer to a frame that is not guaranteed to be valid.
246
247 /// Create an ExecutionContext object from this object.
248 ///
249 /// Create strong references to any execution context objects that are still
250 /// valid. Any of the returned shared pointers in the ExecutionContext
251 /// objects is not guaranteed to be valid. \returns
252 /// An execution context object that has strong references to
253 /// any valid weak references in this object.
254 ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const;
255
256 /// Returns true if this object has a weak reference to a thread. The return
257 /// value is only an indication of whether this object has a weak reference
258 /// and does not indicate whether the weak reference is valid or not.
259 bool HasThreadRef() const { return m_tid != LLDB_INVALID_THREAD_ID; }
260
261 /// Returns true if this object has a weak reference to a frame. The return
262 /// value is only an indication of whether this object has a weak reference
263 /// and does not indicate whether the weak reference is valid or not.
264 bool HasFrameRef() const { return m_stack_id.IsValid(); }
265
266 void ClearThread() {
267 m_thread_wp.reset();
269 }
270
271 void ClearFrame() {
272 m_stack_id.Clear();
273 m_frame_list_wp.reset();
274 }
275
276protected:
277 // Member variables
278 lldb::TargetWP m_target_wp; ///< A weak reference to a target
279 lldb::ProcessWP m_process_wp; ///< A weak reference to a process
280 mutable lldb::ThreadWP m_thread_wp; ///< A weak reference to a thread
281 lldb::tid_t m_tid = LLDB_INVALID_THREAD_ID; ///< The thread ID that this
282 ///< object refers to in case the
283 /// backing object changes
284 StackID m_stack_id; ///< The stack ID that this object refers to in case the
285 ///< backing object changes
287 m_frame_list_wp; ///< Weak reference to the
288 ///< frame list that contains
289 ///< this frame. If we can create a valid
290 ///< StackFrameListSP from it, we must use it to resolve
291 ///< the StackID, otherwise, we should ask the Thread's
292 ///< StackFrameList.
293};
294
295/// \class ExecutionContext ExecutionContext.h
296/// "lldb/Target/ExecutionContext.h"
297/// A class that contains an execution context.
298///
299/// This baton object can be passed into any function that requires a context
300/// that specifies a target, process, thread and frame. These objects are
301/// designed to be used for short term execution context object storage while
302/// a function might be trying to evaluate something that requires a thread or
303/// frame. ExecutionContextRef objects can be used to initialize one of these
304/// objects to turn the weak execution context object references to the
305/// target, process, thread and frame into strong references (shared pointers)
306/// so that functions can guarantee that these objects won't go away in the
307/// middle of a function.
308///
309/// ExecutionContext objects should be used as short lived objects (typically
310/// on the stack) in order to lock down an execution context for local use and
311/// for passing down to other functions that also require specific contexts.
312/// They should NOT be used for long term storage, for long term storage use
313/// ExecutionContextRef objects.
315public:
316 /// Default Constructor.
318
319 // Copy constructor
321
322 // Adopt the target and optionally its current context.
323 ExecutionContext(Target *t, bool fill_current_process_thread_frame = true);
324
325 // Create execution contexts from shared pointers
326 ExecutionContext(const lldb::TargetSP &target_sp, bool get_process);
327 ExecutionContext(const lldb::ProcessSP &process_sp);
330
331 // Create execution contexts from weak pointers
332 ExecutionContext(const lldb::TargetWP &target_wp, bool get_process);
333 ExecutionContext(const lldb::ProcessWP &process_wp);
334 ExecutionContext(const lldb::ThreadWP &thread_wp);
335 ExecutionContext(const lldb::StackFrameWP &frame_wp);
336 ExecutionContext(const ExecutionContextRef &exe_ctx_ref);
337 ExecutionContext(const ExecutionContextRef *exe_ctx_ref,
338 bool thread_and_frame_only_if_stopped = false);
339
340 // Create execution contexts from execution context scopes
343
344 /// Construct with process, thread, and frame index.
345 ///
346 /// Initialize with process \a p, thread \a t, and frame index \a f.
347 ///
348 /// \param[in] process
349 /// The process for this execution context.
350 ///
351 /// \param[in] thread
352 /// The thread for this execution context.
353 ///
354 /// \param[in] frame
355 /// The frame index for this execution context.
356 ExecutionContext(Process *process, Thread *thread = nullptr,
357 StackFrame *frame = nullptr);
358
360
362
363 bool operator==(const ExecutionContext &rhs) const;
364
365 bool operator!=(const ExecutionContext &rhs) const;
366
367 /// Clear the object's state.
368 ///
369 /// Sets the process and thread to nullptr, and the frame index to an
370 /// invalid value.
371 void Clear();
372
374
376
377 uint32_t GetAddressByteSize() const;
378
380
381 /// Returns a pointer to the target object.
382 ///
383 /// The returned pointer might be nullptr. Calling HasTargetScope(),
384 /// HasProcessScope(), HasThreadScope(), or HasFrameScope() can help to pre-
385 /// validate this pointer so that this accessor can freely be used without
386 /// having to check for nullptr each time.
387 ///
388 /// \see ExecutionContext::HasTargetScope() const @see
389 /// ExecutionContext::HasProcessScope() const @see
390 /// ExecutionContext::HasThreadScope() const @see
391 /// ExecutionContext::HasFrameScope() const
392 Target *GetTargetPtr() const;
393
394 /// Returns a pointer to the process object.
395 ///
396 /// The returned pointer might be nullptr. Calling HasProcessScope(),
397 /// HasThreadScope(), or HasFrameScope() can help to pre-validate this
398 /// pointer so that this accessor can freely be used without having to check
399 /// for nullptr each time.
400 ///
401 /// \see ExecutionContext::HasProcessScope() const @see
402 /// ExecutionContext::HasThreadScope() const @see
403 /// ExecutionContext::HasFrameScope() const
404 Process *GetProcessPtr() const;
405
406 /// Returns a pointer to the thread object.
407 ///
408 /// The returned pointer might be nullptr. Calling HasThreadScope() or
409 /// HasFrameScope() can help to pre-validate this pointer so that this
410 /// accessor can freely be used without having to check for nullptr each
411 /// time.
412 ///
413 /// \see ExecutionContext::HasThreadScope() const @see
414 /// ExecutionContext::HasFrameScope() const
415 Thread *GetThreadPtr() const { return m_thread_sp.get(); }
416
417 /// Returns a pointer to the frame object.
418 ///
419 /// The returned pointer might be nullptr. Calling HasFrameScope(), can help
420 /// to pre-validate this pointer so that this accessor can freely be used
421 /// without having to check for nullptr each time.
422 ///
423 /// \see ExecutionContext::HasFrameScope() const
424 StackFrame *GetFramePtr() const { return m_frame_sp.get(); }
425
426 /// Returns a reference to the target object.
427 ///
428 /// Clients should call HasTargetScope(), HasProcessScope(),
429 /// HasThreadScope(), or HasFrameScope() prior to calling this function to
430 /// ensure that this ExecutionContext object contains a valid target.
431 ///
432 /// \see ExecutionContext::HasTargetScope() const @see
433 /// ExecutionContext::HasProcessScope() const @see
434 /// ExecutionContext::HasThreadScope() const @see
435 /// ExecutionContext::HasFrameScope() const
436 Target &GetTargetRef() const;
437
438 /// Returns a reference to the process object.
439 ///
440 /// Clients should call HasProcessScope(), HasThreadScope(), or
441 /// HasFrameScope() prior to calling this function to ensure that this
442 /// ExecutionContext object contains a valid target.
443 ///
444 /// \see ExecutionContext::HasProcessScope() const @see
445 /// ExecutionContext::HasThreadScope() const @see
446 /// ExecutionContext::HasFrameScope() const
447 Process &GetProcessRef() const;
448
449 /// Returns a reference to the thread object.
450 ///
451 /// Clients should call HasThreadScope(), or HasFrameScope() prior to
452 /// calling this function to ensure that this ExecutionContext object
453 /// contains a valid target.
454 ///
455 /// \see ExecutionContext::HasThreadScope() const @see
456 /// ExecutionContext::HasFrameScope() const
457 Thread &GetThreadRef() const;
458
459 /// Returns a reference to the thread object.
460 ///
461 /// Clients should call HasFrameScope() prior to calling this function to
462 /// ensure that this ExecutionContext object contains a valid target.
463 ///
464 /// \see ExecutionContext::HasFrameScope() const
465 StackFrame &GetFrameRef() const;
466
467 /// Get accessor to get the target shared pointer.
468 ///
469 /// The returned shared pointer is not guaranteed to be valid.
470 const lldb::TargetSP &GetTargetSP() const { return m_target_sp; }
471
472 /// Get accessor to get the process shared pointer.
473 ///
474 /// The returned shared pointer is not guaranteed to be valid.
475 const lldb::ProcessSP &GetProcessSP() const { return m_process_sp; }
476
477 /// Get accessor to get the thread shared pointer.
478 ///
479 /// The returned shared pointer is not guaranteed to be valid.
480 const lldb::ThreadSP &GetThreadSP() const { return m_thread_sp; }
481
482 /// Get accessor to get the frame shared pointer.
483 ///
484 /// The returned shared pointer is not guaranteed to be valid.
485 const lldb::StackFrameSP &GetFrameSP() const { return m_frame_sp; }
486
487 /// Set accessor to set only the target shared pointer.
488 void SetTargetSP(const lldb::TargetSP &target_sp);
489
490 /// Set accessor to set only the process shared pointer.
491 void SetProcessSP(const lldb::ProcessSP &process_sp);
492
493 /// Set accessor to set only the thread shared pointer.
494 void SetThreadSP(const lldb::ThreadSP &thread_sp);
495
496 /// Set accessor to set only the frame shared pointer.
497 void SetFrameSP(const lldb::StackFrameSP &frame_sp);
498
499 /// Set accessor to set only the target shared pointer from a target
500 /// pointer.
501 void SetTargetPtr(Target *target);
502
503 /// Set accessor to set only the process shared pointer from a process
504 /// pointer.
505 void SetProcessPtr(Process *process);
506
507 /// Set accessor to set only the thread shared pointer from a thread
508 /// pointer.
509 void SetThreadPtr(Thread *thread);
510
511 /// Set accessor to set only the frame shared pointer from a frame pointer.
512 void SetFramePtr(StackFrame *frame);
513
514 // Set the execution context using a target shared pointer.
515 //
516 // If "target_sp" is valid, sets the target context to match and if
517 // "get_process" is true, sets the process shared pointer if the target
518 // currently has a process.
519 void SetContext(const lldb::TargetSP &target_sp, bool get_process);
520
521 // Set the execution context using a process shared pointer.
522 //
523 // If "process_sp" is valid, then set the process and target in this context.
524 // Thread and frame contexts will be cleared. If "process_sp" is not valid,
525 // all shared pointers are reset.
526 void SetContext(const lldb::ProcessSP &process_sp);
527
528 // Set the execution context using a thread shared pointer.
529 //
530 // If "thread_sp" is valid, then set the thread, process and target in this
531 // context. The frame context will be cleared. If "thread_sp" is not valid,
532 // all shared pointers are reset.
533 void SetContext(const lldb::ThreadSP &thread_sp);
534
535 // Set the execution context using a frame shared pointer.
536 //
537 // If "frame_sp" is valid, then set the frame, thread, process and target in
538 // this context If "frame_sp" is not valid, all shared pointers are reset.
539 void SetContext(const lldb::StackFrameSP &frame_sp);
540
541 /// Returns true the ExecutionContext object contains a valid target.
542 ///
543 /// This function can be called after initializing an ExecutionContext
544 /// object, and if it returns true, calls to GetTargetPtr() and
545 /// GetTargetRef() do not need to be checked for validity.
546 bool HasTargetScope() const;
547
548 /// Returns true the ExecutionContext object contains a valid target and
549 /// process.
550 ///
551 /// This function can be called after initializing an ExecutionContext
552 /// object, and if it returns true, calls to GetTargetPtr() and
553 /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not need to be
554 /// checked for validity.
555 bool HasProcessScope() const;
556
557 /// Returns true the ExecutionContext object contains a valid target,
558 /// process, and thread.
559 ///
560 /// This function can be called after initializing an ExecutionContext
561 /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(),
562 /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), and GetThreadRef() do
563 /// not need to be checked for validity.
564 bool HasThreadScope() const;
565
566 /// Returns true the ExecutionContext object contains a valid target,
567 /// process, thread and frame.
568 ///
569 /// This function can be called after initializing an ExecutionContext
570 /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(),
571 /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), GetThreadRef(),
572 /// GetFramePtr(), and GetFrameRef() do not need to be checked for validity.
573 bool HasFrameScope() const;
574
575protected:
576 // Member variables
577 lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame
578 lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame
579 lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame
580 lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread.
581};
582
583/// A wrapper class representing an execution context with non-null Target
584/// and Process pointers, a locked API mutex and a locked ProcessRunLock.
585/// The locks are private by design: to unlock them, destroy the
586/// StoppedExecutionContext.
589 lldb::ProcessSP &process_sp,
590 lldb::ThreadSP &thread_sp,
591 lldb::StackFrameSP &frame_sp,
592 std::unique_lock<std::recursive_mutex> api_lock,
594 : m_api_lock(std::move(api_lock)), m_stop_locker(std::move(stop_locker)) {
595 assert(target_sp);
596 assert(process_sp);
597 assert(m_api_lock.owns_lock());
598 assert(m_stop_locker.IsLocked());
599 SetTargetSP(target_sp);
600 SetProcessSP(process_sp);
601 SetThreadSP(thread_sp);
602 SetFrameSP(frame_sp);
603 }
604
605 /// Transfers ownership of the locks from `other` to `this`, making `other`
606 /// unusable.
609 other.m_thread_sp, other.m_frame_sp,
610 std::move(other.m_api_lock),
611 std::move(other.m_stop_locker)) {
612 other.Clear();
613 }
614
615 /// Clears this context, unlocking the ProcessRunLock and returning the
616 /// locked API lock, allowing callers to resume the process. Similar to
617 /// a move operation, this object is no longer usable.
618 [[nodiscard]] std::unique_lock<std::recursive_mutex> AllowResume();
619
620private:
621 std::unique_lock<std::recursive_mutex> m_api_lock;
623};
624
625llvm::Expected<StoppedExecutionContext>
626GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr);
627llvm::Expected<StoppedExecutionContext>
629
630} // namespace lldb_private
631
632#endif // LLDB_TARGET_EXECUTIONCONTEXT_H
Execution context objects refer to objects in the execution of the program that is being debugged.
ExecutionContextRef(const ExecutionContextRef &rhs)
Copy Constructor.
StackID m_stack_id
The stack ID that this object refers to in case the backing object changes.
bool HasFrameRef() const
Returns true if this object has a weak reference to a frame.
ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const
Create an ExecutionContext object from this object.
void SetThreadSP(const lldb::ThreadSP &thread_sp)
Set accessor that creates a weak reference to the thread referenced in thread_sp.
void Clear()
Clear the object's state.
lldb::StackFrameSP GetFrameSP() const
Get accessor that creates a strong reference from the weak frame reference contained in this object.
lldb::ProcessWP m_process_wp
A weak reference to a process.
ExecutionContextRef(ExecutionContextScope *exe_scope)
Construct using an execution context scope.
lldb::ThreadSP GetThreadSP() const
Get accessor that creates a strong reference from the weak thread reference contained in this object.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor that creates a weak reference to the frame referenced in frame_sp.
lldb::tid_t m_tid
The thread ID that this object refers to in case the backing object changes.
lldb::TargetSP GetTargetSP() const
Get accessor that creates a strong reference from the weak target reference contained in this object.
bool HasThreadRef() const
Returns true if this object has a weak reference to a thread.
void SetTargetPtr(Target *target, bool adopt_selected)
lldb::ProcessSP GetProcessSP() const
Get accessor that creates a strong reference from the weak process reference contained in this object...
void SetThreadPtr(Thread *thread, bool adopt_selected=false)
ExecutionContextRef & operator=(const ExecutionContextRef &rhs)
Assignment operator.
ExecutionContextRef()
Default Constructor.
void SetTargetSP(const lldb::TargetSP &target_sp)
Set accessor that creates a weak reference to the target referenced in target_sp.
void SetProcessPtr(Process *process, bool adopt_selected=false)
lldb::TargetWP m_target_wp
A weak reference to a target.
void SetProcessSP(const lldb::ProcessSP &process_sp)
Set accessor that creates a weak reference to the process referenced in process_sp.
lldb::StackFrameListWP m_frame_list_wp
Weak reference to the frame list that contains this frame.
lldb::ThreadWP m_thread_wp
A weak reference to a thread.
ExecutionContextRef(ExecutionContextScope &exe_scope)
Construct using an execution context scope.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor to set only the frame shared pointer.
bool HasThreadScope() const
Returns true the ExecutionContext object contains a valid target, process, and thread.
void SetProcessPtr(Process *process)
Set accessor to set only the process shared pointer from a process pointer.
bool HasProcessScope() const
Returns true the ExecutionContext object contains a valid target and process.
ExecutionContextScope * GetBestExecutionContextScope() const
ExecutionContext(const ExecutionContext &rhs)
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
void Clear()
Clear the object's state.
ExecutionContext()
Default Constructor.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
void SetProcessSP(const lldb::ProcessSP &process_sp)
Set accessor to set only the process shared pointer.
lldb::StackFrameSP m_frame_sp
The stack frame in thread.
bool operator==(const ExecutionContext &rhs) const
void SetThreadPtr(Thread *thread)
Set accessor to set only the thread shared pointer from a thread pointer.
lldb::ByteOrder GetByteOrder() const
void SetTargetPtr(Target *target)
Set accessor to set only the target shared pointer from a target pointer.
lldb::TargetSP m_target_sp
The target that owns the process/thread/frame.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
const lldb::StackFrameSP & GetFrameSP() const
Get accessor to get the frame shared pointer.
ExecutionContext(const lldb::ThreadSP &thread_sp)
Process & GetProcessRef() const
Returns a reference to the process object.
void SetContext(const lldb::TargetSP &target_sp, bool get_process)
void SetTargetSP(const lldb::TargetSP &target_sp)
Set accessor to set only the target shared pointer.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
void SetThreadSP(const lldb::ThreadSP &thread_sp)
Set accessor to set only the thread shared pointer.
void SetContext(const lldb::StackFrameSP &frame_sp)
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
void SetContext(const lldb::ThreadSP &thread_sp)
StackFrame & GetFrameRef() const
Returns a reference to the thread object.
bool HasFrameScope() const
Returns true the ExecutionContext object contains a valid target, process, thread and frame.
lldb::ThreadSP m_thread_sp
The thread that owns the frame.
ExecutionContext(const lldb::StackFrameSP &frame_sp)
lldb::ProcessSP m_process_sp
The process that owns the thread/frame.
bool operator!=(const ExecutionContext &rhs) const
Target & GetTargetRef() const
Returns a reference to the target object.
void SetFramePtr(StackFrame *frame)
Set accessor to set only the frame shared pointer from a frame pointer.
ExecutionContext & operator=(const ExecutionContext &rhs)
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread & GetThreadRef() const
Returns a reference to the thread object.
RegisterContext * GetRegisterContext() const
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A plug-in interface definition class for debugging a process.
Definition Process.h:354
This base class provides an interface to stack frames.
Definition StackFrame.h:44
#define LLDB_INVALID_THREAD_ID
A class that represents a running process on the host machine.
llvm::Expected< StoppedExecutionContext > GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr)
std::weak_ptr< lldb_private::StackFrame > StackFrameWP
std::weak_ptr< lldb_private::StackFrameList > StackFrameListWP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::Process > ProcessSP
ByteOrder
Byte ordering definitions.
std::weak_ptr< lldb_private::Process > ProcessWP
std::weak_ptr< lldb_private::Target > TargetWP
std::shared_ptr< lldb_private::Target > TargetSP
std::weak_ptr< lldb_private::Thread > ThreadWP
uint64_t tid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP
StoppedExecutionContext(StoppedExecutionContext &&other)
Transfers ownership of the locks from other to this, making other unusable.
ProcessRunLock::ProcessRunLocker m_stop_locker
StoppedExecutionContext(lldb::TargetSP &target_sp, lldb::ProcessSP &process_sp, lldb::ThreadSP &thread_sp, lldb::StackFrameSP &frame_sp, std::unique_lock< std::recursive_mutex > api_lock, ProcessRunLock::ProcessRunLocker stop_locker)
std::unique_lock< std::recursive_mutex > m_api_lock
std::unique_lock< std::recursive_mutex > AllowResume()
Clears this context, unlocking the ProcessRunLock and returning the locked API lock,...