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() { m_stack_id.Clear(); }
272
273protected:
274 // Member variables
275 lldb::TargetWP m_target_wp; ///< A weak reference to a target
276 lldb::ProcessWP m_process_wp; ///< A weak reference to a process
277 mutable lldb::ThreadWP m_thread_wp; ///< A weak reference to a thread
278 lldb::tid_t m_tid = LLDB_INVALID_THREAD_ID; ///< The thread ID that this
279 ///< object refers to in case the
280 /// backing object changes
281 StackID m_stack_id; ///< The stack ID that this object refers to in case the
282 ///backing object changes
283};
284
285/// \class ExecutionContext ExecutionContext.h
286/// "lldb/Target/ExecutionContext.h"
287/// A class that contains an execution context.
288///
289/// This baton object can be passed into any function that requires a context
290/// that specifies a target, process, thread and frame. These objects are
291/// designed to be used for short term execution context object storage while
292/// a function might be trying to evaluate something that requires a thread or
293/// frame. ExecutionContextRef objects can be used to initialize one of these
294/// objects to turn the weak execution context object references to the
295/// target, process, thread and frame into strong references (shared pointers)
296/// so that functions can guarantee that these objects won't go away in the
297/// middle of a function.
298///
299/// ExecutionContext objects should be used as short lived objects (typically
300/// on the stack) in order to lock down an execution context for local use and
301/// for passing down to other functions that also require specific contexts.
302/// They should NOT be used for long term storage, for long term storage use
303/// ExecutionContextRef objects.
305public:
306 /// Default Constructor.
308
309 // Copy constructor
311
312 // Adopt the target and optionally its current context.
313 ExecutionContext(Target *t, bool fill_current_process_thread_frame = true);
314
315 // Create execution contexts from shared pointers
316 ExecutionContext(const lldb::TargetSP &target_sp, bool get_process);
317 ExecutionContext(const lldb::ProcessSP &process_sp);
318 ExecutionContext(const lldb::ThreadSP &thread_sp);
319 ExecutionContext(const lldb::StackFrameSP &frame_sp);
320
321 // Create execution contexts from weak pointers
322 ExecutionContext(const lldb::TargetWP &target_wp, bool get_process);
323 ExecutionContext(const lldb::ProcessWP &process_wp);
324 ExecutionContext(const lldb::ThreadWP &thread_wp);
325 ExecutionContext(const lldb::StackFrameWP &frame_wp);
326 ExecutionContext(const ExecutionContextRef &exe_ctx_ref);
327 ExecutionContext(const ExecutionContextRef *exe_ctx_ref,
328 bool thread_and_frame_only_if_stopped = false);
329
330 // Create execution contexts from execution context scopes
333
334 /// Construct with process, thread, and frame index.
335 ///
336 /// Initialize with process \a p, thread \a t, and frame index \a f.
337 ///
338 /// \param[in] process
339 /// The process for this execution context.
340 ///
341 /// \param[in] thread
342 /// The thread for this execution context.
343 ///
344 /// \param[in] frame
345 /// The frame index for this execution context.
346 ExecutionContext(Process *process, Thread *thread = nullptr,
347 StackFrame *frame = nullptr);
348
350
352
353 bool operator==(const ExecutionContext &rhs) const;
354
355 bool operator!=(const ExecutionContext &rhs) const;
356
357 /// Clear the object's state.
358 ///
359 /// Sets the process and thread to nullptr, and the frame index to an
360 /// invalid value.
361 void Clear();
362
364
366
367 uint32_t GetAddressByteSize() const;
368
370
371 /// Returns a pointer to the target object.
372 ///
373 /// The returned pointer might be nullptr. Calling HasTargetScope(),
374 /// HasProcessScope(), HasThreadScope(), or HasFrameScope() can help to pre-
375 /// validate this pointer so that this accessor can freely be used without
376 /// having to check for nullptr each time.
377 ///
378 /// \see ExecutionContext::HasTargetScope() const @see
379 /// ExecutionContext::HasProcessScope() const @see
380 /// ExecutionContext::HasThreadScope() const @see
381 /// ExecutionContext::HasFrameScope() const
382 Target *GetTargetPtr() const;
383
384 /// Returns a pointer to the process object.
385 ///
386 /// The returned pointer might be nullptr. Calling HasProcessScope(),
387 /// HasThreadScope(), or HasFrameScope() can help to pre-validate this
388 /// pointer so that this accessor can freely be used without having to check
389 /// for nullptr each time.
390 ///
391 /// \see ExecutionContext::HasProcessScope() const @see
392 /// ExecutionContext::HasThreadScope() const @see
393 /// ExecutionContext::HasFrameScope() const
394 Process *GetProcessPtr() const;
395
396 /// Returns a pointer to the thread object.
397 ///
398 /// The returned pointer might be nullptr. Calling HasThreadScope() or
399 /// HasFrameScope() can help to pre-validate this pointer so that this
400 /// accessor can freely be used without having to check for nullptr each
401 /// time.
402 ///
403 /// \see ExecutionContext::HasThreadScope() const @see
404 /// ExecutionContext::HasFrameScope() const
405 Thread *GetThreadPtr() const { return m_thread_sp.get(); }
406
407 /// Returns a pointer to the frame object.
408 ///
409 /// The returned pointer might be nullptr. Calling HasFrameScope(), can help
410 /// to pre-validate this pointer so that this accessor can freely be used
411 /// without having to check for nullptr each time.
412 ///
413 /// \see ExecutionContext::HasFrameScope() const
414 StackFrame *GetFramePtr() const { return m_frame_sp.get(); }
415
416 /// Returns a reference to the target object.
417 ///
418 /// Clients should call HasTargetScope(), HasProcessScope(),
419 /// HasThreadScope(), or HasFrameScope() prior to calling this function to
420 /// ensure that this ExecutionContext object contains a valid target.
421 ///
422 /// \see ExecutionContext::HasTargetScope() const @see
423 /// ExecutionContext::HasProcessScope() const @see
424 /// ExecutionContext::HasThreadScope() const @see
425 /// ExecutionContext::HasFrameScope() const
426 Target &GetTargetRef() const;
427
428 /// Returns a reference to the process object.
429 ///
430 /// Clients should call HasProcessScope(), HasThreadScope(), or
431 /// HasFrameScope() prior to calling this function to ensure that this
432 /// ExecutionContext object contains a valid target.
433 ///
434 /// \see ExecutionContext::HasProcessScope() const @see
435 /// ExecutionContext::HasThreadScope() const @see
436 /// ExecutionContext::HasFrameScope() const
437 Process &GetProcessRef() const;
438
439 /// Returns a reference to the thread object.
440 ///
441 /// Clients should call HasThreadScope(), or HasFrameScope() prior to
442 /// calling this function to ensure that this ExecutionContext object
443 /// contains a valid target.
444 ///
445 /// \see ExecutionContext::HasThreadScope() const @see
446 /// ExecutionContext::HasFrameScope() const
447 Thread &GetThreadRef() const;
448
449 /// Returns a reference to the thread object.
450 ///
451 /// Clients should call HasFrameScope() prior to calling this function to
452 /// ensure that this ExecutionContext object contains a valid target.
453 ///
454 /// \see ExecutionContext::HasFrameScope() const
455 StackFrame &GetFrameRef() const;
456
457 /// Get accessor to get the target shared pointer.
458 ///
459 /// The returned shared pointer is not guaranteed to be valid.
460 const lldb::TargetSP &GetTargetSP() const { return m_target_sp; }
461
462 /// Get accessor to get the process shared pointer.
463 ///
464 /// The returned shared pointer is not guaranteed to be valid.
465 const lldb::ProcessSP &GetProcessSP() const { return m_process_sp; }
466
467 /// Get accessor to get the thread shared pointer.
468 ///
469 /// The returned shared pointer is not guaranteed to be valid.
470 const lldb::ThreadSP &GetThreadSP() const { return m_thread_sp; }
471
472 /// Get accessor to get the frame shared pointer.
473 ///
474 /// The returned shared pointer is not guaranteed to be valid.
475 const lldb::StackFrameSP &GetFrameSP() const { return m_frame_sp; }
476
477 /// Set accessor to set only the target shared pointer.
478 void SetTargetSP(const lldb::TargetSP &target_sp);
479
480 /// Set accessor to set only the process shared pointer.
481 void SetProcessSP(const lldb::ProcessSP &process_sp);
482
483 /// Set accessor to set only the thread shared pointer.
484 void SetThreadSP(const lldb::ThreadSP &thread_sp);
485
486 /// Set accessor to set only the frame shared pointer.
487 void SetFrameSP(const lldb::StackFrameSP &frame_sp);
488
489 /// Set accessor to set only the target shared pointer from a target
490 /// pointer.
491 void SetTargetPtr(Target *target);
492
493 /// Set accessor to set only the process shared pointer from a process
494 /// pointer.
495 void SetProcessPtr(Process *process);
496
497 /// Set accessor to set only the thread shared pointer from a thread
498 /// pointer.
499 void SetThreadPtr(Thread *thread);
500
501 /// Set accessor to set only the frame shared pointer from a frame pointer.
502 void SetFramePtr(StackFrame *frame);
503
504 // Set the execution context using a target shared pointer.
505 //
506 // If "target_sp" is valid, sets the target context to match and if
507 // "get_process" is true, sets the process shared pointer if the target
508 // currently has a process.
509 void SetContext(const lldb::TargetSP &target_sp, bool get_process);
510
511 // Set the execution context using a process shared pointer.
512 //
513 // If "process_sp" is valid, then set the process and target in this context.
514 // Thread and frame contexts will be cleared. If "process_sp" is not valid,
515 // all shared pointers are reset.
516 void SetContext(const lldb::ProcessSP &process_sp);
517
518 // Set the execution context using a thread shared pointer.
519 //
520 // If "thread_sp" is valid, then set the thread, process and target in this
521 // context. The frame context will be cleared. If "thread_sp" is not valid,
522 // all shared pointers are reset.
523 void SetContext(const lldb::ThreadSP &thread_sp);
524
525 // Set the execution context using a frame shared pointer.
526 //
527 // If "frame_sp" is valid, then set the frame, thread, process and target in
528 // this context If "frame_sp" is not valid, all shared pointers are reset.
529 void SetContext(const lldb::StackFrameSP &frame_sp);
530
531 /// Returns true the ExecutionContext object contains a valid target.
532 ///
533 /// This function can be called after initializing an ExecutionContext
534 /// object, and if it returns true, calls to GetTargetPtr() and
535 /// GetTargetRef() do not need to be checked for validity.
536 bool HasTargetScope() const;
537
538 /// Returns true the ExecutionContext object contains a valid target and
539 /// process.
540 ///
541 /// This function can be called after initializing an ExecutionContext
542 /// object, and if it returns true, calls to GetTargetPtr() and
543 /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not need to be
544 /// checked for validity.
545 bool HasProcessScope() const;
546
547 /// Returns true the ExecutionContext object contains a valid target,
548 /// process, and thread.
549 ///
550 /// This function can be called after initializing an ExecutionContext
551 /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(),
552 /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), and GetThreadRef() do
553 /// not need to be checked for validity.
554 bool HasThreadScope() const;
555
556 /// Returns true the ExecutionContext object contains a valid target,
557 /// process, thread and frame.
558 ///
559 /// This function can be called after initializing an ExecutionContext
560 /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(),
561 /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), GetThreadRef(),
562 /// GetFramePtr(), and GetFrameRef() do not need to be checked for validity.
563 bool HasFrameScope() const;
564
565protected:
566 // Member variables
567 lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame
568 lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame
569 lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame
570 lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread.
571};
572
573/// A wrapper class representing an execution context with non-null Target
574/// and Process pointers, a locked API mutex and a locked ProcessRunLock.
575/// The locks are private by design: to unlock them, destroy the
576/// StoppedExecutionContext.
579 lldb::ProcessSP &process_sp,
580 lldb::ThreadSP &thread_sp,
581 lldb::StackFrameSP &frame_sp,
582 std::unique_lock<std::recursive_mutex> api_lock,
584 : m_api_lock(std::move(api_lock)), m_stop_locker(std::move(stop_locker)) {
585 assert(target_sp);
586 assert(process_sp);
587 assert(m_api_lock.owns_lock());
588 assert(m_stop_locker.IsLocked());
589 SetTargetSP(target_sp);
590 SetProcessSP(process_sp);
591 SetThreadSP(thread_sp);
592 SetFrameSP(frame_sp);
593 }
594
595 /// Transfers ownership of the locks from `other` to `this`, making `other`
596 /// unusable.
599 other.m_thread_sp, other.m_frame_sp,
600 std::move(other.m_api_lock),
601 std::move(other.m_stop_locker)) {
602 other.Clear();
603 }
604
605 /// Clears this context, unlocking the ProcessRunLock and returning the
606 /// locked API lock, allowing callers to resume the process. Similar to
607 /// a move operation, this object is no longer usable.
608 [[nodiscard]] std::unique_lock<std::recursive_mutex> AllowResume();
609
610private:
611 std::unique_lock<std::recursive_mutex> m_api_lock;
613};
614
615llvm::Expected<StoppedExecutionContext>
616GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr);
617llvm::Expected<StoppedExecutionContext>
619
620} // namespace lldb_private
621
622#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::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.
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.
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
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.
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:357
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::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,...