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