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