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
113 /// Construct using an execution context scope.
114 ///
115 /// If the ExecutionContextScope object is valid and refers to a frame, make
116 /// weak references too the frame, thread, process and target. If the
117 /// ExecutionContextScope object is valid and refers to a thread, make weak
118 /// references too the thread, process and target. If the
119 /// ExecutionContextScope object is valid and refers to a process, make weak
120 /// references too the process and target. If the ExecutionContextScope
121 /// object is valid and refers to a target, make weak references too the
122 /// target.
124
125 /// Construct using an execution context scope.
126 ///
127 /// If the ExecutionContextScope object refers to a frame, make weak
128 /// references too the frame, thread, process and target. If the
129 /// ExecutionContextScope object refers to a thread, make weak references
130 /// too the thread, process and target. If the ExecutionContextScope object
131 /// refers to a process, make weak references too the process and target. If
132 /// the ExecutionContextScope object refers to a target, make weak
133 /// references too the target.
135
137
138 /// Assignment operator
139 ///
140 /// Copy all weak references in \a rhs.
142
143 /// Assignment operator from a ExecutionContext
144 ///
145 /// Make weak references to any strongly referenced objects in \a exe_ctx.
147
148 /// Clear the object's state.
149 ///
150 /// Sets the process and thread to nullptr, and the frame index to an
151 /// invalid value.
152 void Clear();
153
154 /// Set accessor that creates a weak reference to the target referenced in
155 /// \a target_sp.
156 ///
157 /// If \a target_sp is valid this object will create a weak reference to
158 /// that object, otherwise any previous target weak reference contained in
159 /// this object will be reset.
160 ///
161 /// Only the weak reference to the target will be updated, no other weak
162 /// references will be modified. If you want this execution context to make
163 /// a weak reference to the target's process, use the
164 /// ExecutionContextRef::SetContext() functions.
165 ///
166 /// \see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool)
167 void SetTargetSP(const lldb::TargetSP &target_sp);
168
169 /// Set accessor that creates a weak reference to the process referenced in
170 /// \a process_sp.
171 ///
172 /// If \a process_sp is valid this object will create a weak reference to
173 /// that object, otherwise any previous process weak reference contained in
174 /// this object will be reset.
175 ///
176 /// Only the weak reference to the process will be updated, no other weak
177 /// references will be modified. If you want this execution context to make
178 /// a weak reference to the target, use the
179 /// ExecutionContextRef::SetContext() functions.
180 ///
181 /// \see ExecutionContextRef::SetContext(const lldb::ProcessSP &)
182 void SetProcessSP(const lldb::ProcessSP &process_sp);
183
184 /// Set accessor that creates a weak reference to the thread referenced in
185 /// \a thread_sp.
186 ///
187 /// If \a thread_sp is valid this object will create a weak reference to
188 /// that object, otherwise any previous thread weak reference contained in
189 /// this object will be reset.
190 ///
191 /// Only the weak reference to the thread will be updated, no other weak
192 /// references will be modified. If you want this execution context to make
193 /// a weak reference to the thread's process and target, use the
194 /// ExecutionContextRef::SetContext() functions.
195 ///
196 /// \see ExecutionContextRef::SetContext(const lldb::ThreadSP &)
197 void SetThreadSP(const lldb::ThreadSP &thread_sp);
198
199 /// Set accessor that creates a weak reference to the frame referenced in \a
200 /// frame_sp.
201 ///
202 /// If \a frame_sp is valid this object will create a weak reference to that
203 /// object, otherwise any previous frame weak reference contained in this
204 /// object will be reset.
205 ///
206 /// Only the weak reference to the frame will be updated, no other weak
207 /// references will be modified. If you want this execution context to make
208 /// a weak reference to the frame's thread, process and target, use the
209 /// ExecutionContextRef::SetContext() functions.
210 ///
211 /// \see ExecutionContextRef::SetContext(const lldb::StackFrameSP &)
212 void SetFrameSP(const lldb::StackFrameSP &frame_sp);
213
214 void SetTargetPtr(Target *target, bool adopt_selected);
215
216 void SetProcessPtr(Process *process, bool adopt_selected = false);
217
218 void SetThreadPtr(Thread *thread, bool adopt_selected = false);
219
220 void SetFramePtr(StackFrame *frame);
221
222 /// Get accessor that creates a strong reference from the weak target
223 /// reference contained in this object.
224 ///
225 /// \returns
226 /// A shared pointer to a target that is not guaranteed to be valid.
228
229 /// Get accessor that creates a strong reference from the weak process
230 /// reference contained in this object.
231 ///
232 /// \returns
233 /// A shared pointer to a process that is not guaranteed to be valid.
235
236 /// Get accessor that creates a strong reference from the weak thread
237 /// reference contained in this object.
238 ///
239 /// \returns
240 /// A shared pointer to a thread that is not guaranteed to be valid.
242
243 /// Get accessor that creates a strong reference from the weak frame
244 /// reference contained in this object.
245 ///
246 /// \returns
247 /// A shared pointer to a frame that is not guaranteed to be valid.
249
250 /// Create an ExecutionContext object from this object.
251 ///
252 /// Create strong references to any execution context objects that are still
253 /// valid. Any of the returned shared pointers in the ExecutionContext
254 /// objects is not guaranteed to be valid. \returns
255 /// An execution context object that has strong references to
256 /// any valid weak references in this object.
257 ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const;
258
259 /// Returns true if this object has a weak reference to a thread. The return
260 /// value is only an indication of whether this object has a weak reference
261 /// and does not indicate whether the weak reference is valid or not.
262 bool HasThreadRef() const { return m_tid != LLDB_INVALID_THREAD_ID; }
263
264 /// Returns true if this object has a weak reference to a frame. The return
265 /// value is only an indication of whether this object has a weak reference
266 /// and does not indicate whether the weak reference is valid or not.
267 bool HasFrameRef() const { return m_stack_id.IsValid(); }
268
269 void ClearThread() {
270 m_thread_wp.reset();
272 }
273
274 void ClearFrame() {
275 m_stack_id.Clear();
276 m_frame_list_id.reset();
277 }
278
279 friend llvm::Expected<StoppedExecutionContext>
281
282protected:
283 // Member variables
284 lldb::TargetWP m_target_wp; ///< A weak reference to a target
285 lldb::ProcessWP m_process_wp; ///< A weak reference to a process
286 mutable lldb::ThreadWP m_thread_wp; ///< A weak reference to a thread
287 lldb::tid_t m_tid = LLDB_INVALID_THREAD_ID; ///< The thread ID that this
288 ///< object refers to in case the
289 /// backing object changes
290 StackID m_stack_id; ///< The stack ID that this object refers to in case the
291 ///< backing object changes
292 /// A map of identifiers to scripted frame providers used in this thread.
293 mutable std::optional<
294 std::pair<ScriptedFrameProviderDescriptor, lldb::frame_list_id_t>>
296};
297
298/// \class ExecutionContext ExecutionContext.h
299/// "lldb/Target/ExecutionContext.h"
300/// A class that contains an execution context.
301///
302/// This baton object can be passed into any function that requires a context
303/// that specifies a target, process, thread and frame. These objects are
304/// designed to be used for short term execution context object storage while
305/// a function might be trying to evaluate something that requires a thread or
306/// frame. ExecutionContextRef objects can be used to initialize one of these
307/// objects to turn the weak execution context object references to the
308/// target, process, thread and frame into strong references (shared pointers)
309/// so that functions can guarantee that these objects won't go away in the
310/// middle of a function.
311///
312/// ExecutionContext objects should be used as short lived objects (typically
313/// on the stack) in order to lock down an execution context for local use and
314/// for passing down to other functions that also require specific contexts.
315/// They should NOT be used for long term storage, for long term storage use
316/// ExecutionContextRef objects.
318public:
319 /// Default Constructor.
321
322 // Copy constructor
324
325 // Adopt the target and optionally its current context.
326 ExecutionContext(Target *t, bool fill_current_process_thread_frame = true);
327
328 // Create execution contexts from shared pointers
329 ExecutionContext(const lldb::TargetSP &target_sp, bool get_process);
330 ExecutionContext(const lldb::ProcessSP &process_sp);
333
334 // Create execution contexts from weak pointers
335 ExecutionContext(const lldb::TargetWP &target_wp, bool get_process);
336 ExecutionContext(const lldb::ProcessWP &process_wp);
337 ExecutionContext(const lldb::ThreadWP &thread_wp);
338 ExecutionContext(const lldb::StackFrameWP &frame_wp);
339 ExecutionContext(const ExecutionContextRef &exe_ctx_ref);
340 ExecutionContext(const ExecutionContextRef *exe_ctx_ref,
341 bool thread_and_frame_only_if_stopped = false);
342
343 // Create execution contexts from execution context scopes
346
347 /// Construct with process, thread, and frame index.
348 ///
349 /// Initialize with process \a p, thread \a t, and frame index \a f.
350 ///
351 /// \param[in] process
352 /// The process for this execution context.
353 ///
354 /// \param[in] thread
355 /// The thread for this execution context.
356 ///
357 /// \param[in] frame
358 /// The frame index for this execution context.
359 ExecutionContext(Process *process, Thread *thread = nullptr,
360 StackFrame *frame = nullptr);
361
363
365
366 bool operator==(const ExecutionContext &rhs) const;
367
368 bool operator!=(const ExecutionContext &rhs) const;
369
370 /// Clear the object's state.
371 ///
372 /// Sets the process and thread to nullptr, and the frame index to an
373 /// invalid value.
374 void Clear();
375
377
379
380 uint32_t GetAddressByteSize() const;
381
383
384 /// Returns a pointer to the target object.
385 ///
386 /// The returned pointer might be nullptr. Calling HasTargetScope(),
387 /// HasProcessScope(), HasThreadScope(), or HasFrameScope() can help to pre-
388 /// validate this pointer so that this accessor can freely be used without
389 /// having to check for nullptr each time.
390 ///
391 /// \see ExecutionContext::HasTargetScope() const @see
392 /// ExecutionContext::HasProcessScope() const @see
393 /// ExecutionContext::HasThreadScope() const @see
394 /// ExecutionContext::HasFrameScope() const
395 Target *GetTargetPtr() const;
396
397 /// Returns a pointer to the process object.
398 ///
399 /// The returned pointer might be nullptr. Calling HasProcessScope(),
400 /// HasThreadScope(), or HasFrameScope() can help to pre-validate this
401 /// pointer so that this accessor can freely be used without having to check
402 /// for nullptr each time.
403 ///
404 /// \see ExecutionContext::HasProcessScope() const @see
405 /// ExecutionContext::HasThreadScope() const @see
406 /// ExecutionContext::HasFrameScope() const
407 Process *GetProcessPtr() const;
408
409 /// Returns a pointer to the thread object.
410 ///
411 /// The returned pointer might be nullptr. Calling HasThreadScope() or
412 /// HasFrameScope() can help to pre-validate this pointer so that this
413 /// accessor can freely be used without having to check for nullptr each
414 /// time.
415 ///
416 /// \see ExecutionContext::HasThreadScope() const @see
417 /// ExecutionContext::HasFrameScope() const
418 Thread *GetThreadPtr() const { return m_thread_sp.get(); }
419
420 /// Returns a pointer to the frame object.
421 ///
422 /// The returned pointer might be nullptr. Calling HasFrameScope(), can help
423 /// to pre-validate this pointer so that this accessor can freely be used
424 /// without having to check for nullptr each time.
425 ///
426 /// \see ExecutionContext::HasFrameScope() const
427 StackFrame *GetFramePtr() const { return m_frame_sp.get(); }
428
429 /// Returns a reference to the target object.
430 ///
431 /// Clients should call HasTargetScope(), HasProcessScope(),
432 /// HasThreadScope(), or HasFrameScope() prior to calling this function to
433 /// ensure that this ExecutionContext object contains a valid target.
434 ///
435 /// \see ExecutionContext::HasTargetScope() const @see
436 /// ExecutionContext::HasProcessScope() const @see
437 /// ExecutionContext::HasThreadScope() const @see
438 /// ExecutionContext::HasFrameScope() const
439 Target &GetTargetRef() const;
440
441 /// Returns a reference to the process object.
442 ///
443 /// Clients should call HasProcessScope(), HasThreadScope(), or
444 /// HasFrameScope() prior to calling this function to ensure that this
445 /// ExecutionContext object contains a valid target.
446 ///
447 /// \see ExecutionContext::HasProcessScope() const @see
448 /// ExecutionContext::HasThreadScope() const @see
449 /// ExecutionContext::HasFrameScope() const
450 Process &GetProcessRef() const;
451
452 /// Returns a reference to the thread object.
453 ///
454 /// Clients should call HasThreadScope(), or HasFrameScope() prior to
455 /// calling this function to ensure that this ExecutionContext object
456 /// contains a valid target.
457 ///
458 /// \see ExecutionContext::HasThreadScope() const @see
459 /// ExecutionContext::HasFrameScope() const
460 Thread &GetThreadRef() const;
461
462 /// Returns a reference to the thread object.
463 ///
464 /// Clients should call HasFrameScope() prior to calling this function to
465 /// ensure that this ExecutionContext object contains a valid target.
466 ///
467 /// \see ExecutionContext::HasFrameScope() const
468 StackFrame &GetFrameRef() const;
469
470 /// Get accessor to get the target shared pointer.
471 ///
472 /// The returned shared pointer is not guaranteed to be valid.
473 const lldb::TargetSP &GetTargetSP() const { return m_target_sp; }
474
475 /// Get accessor to get the process shared pointer.
476 ///
477 /// The returned shared pointer is not guaranteed to be valid.
478 const lldb::ProcessSP &GetProcessSP() const { return m_process_sp; }
479
480 /// Get accessor to get the thread shared pointer.
481 ///
482 /// The returned shared pointer is not guaranteed to be valid.
483 const lldb::ThreadSP &GetThreadSP() const { return m_thread_sp; }
484
485 /// Get accessor to get the frame shared pointer.
486 ///
487 /// The returned shared pointer is not guaranteed to be valid.
488 const lldb::StackFrameSP &GetFrameSP() const { return m_frame_sp; }
489
490 /// Set accessor to set only the target shared pointer.
491 void SetTargetSP(const lldb::TargetSP &target_sp);
492
493 /// Set accessor to set only the process shared pointer.
494 void SetProcessSP(const lldb::ProcessSP &process_sp);
495
496 /// Set accessor to set only the thread shared pointer.
497 void SetThreadSP(const lldb::ThreadSP &thread_sp);
498
499 /// Set accessor to set only the frame shared pointer.
500 void SetFrameSP(const lldb::StackFrameSP &frame_sp);
501
502 /// Set accessor to set only the target shared pointer from a target
503 /// pointer.
504 void SetTargetPtr(Target *target);
505
506 /// Set accessor to set only the process shared pointer from a process
507 /// pointer.
508 void SetProcessPtr(Process *process);
509
510 /// Set accessor to set only the thread shared pointer from a thread
511 /// pointer.
512 void SetThreadPtr(Thread *thread);
513
514 /// Set accessor to set only the frame shared pointer from a frame pointer.
515 void SetFramePtr(StackFrame *frame);
516
517 // Set the execution context using a target shared pointer.
518 //
519 // If "target_sp" is valid, sets the target context to match and if
520 // "get_process" is true, sets the process shared pointer if the target
521 // currently has a process.
522 void SetContext(const lldb::TargetSP &target_sp, bool get_process);
523
524 // Set the execution context using a process shared pointer.
525 //
526 // If "process_sp" is valid, then set the process and target in this context.
527 // Thread and frame contexts will be cleared. If "process_sp" is not valid,
528 // all shared pointers are reset.
529 void SetContext(const lldb::ProcessSP &process_sp);
530
531 // Set the execution context using a thread shared pointer.
532 //
533 // If "thread_sp" is valid, then set the thread, process and target in this
534 // context. The frame context will be cleared. If "thread_sp" is not valid,
535 // all shared pointers are reset.
536 void SetContext(const lldb::ThreadSP &thread_sp);
537
538 // Set the execution context using a frame shared pointer.
539 //
540 // If "frame_sp" is valid, then set the frame, thread, process and target in
541 // this context If "frame_sp" is not valid, all shared pointers are reset.
542 void SetContext(const lldb::StackFrameSP &frame_sp);
543
544 /// Returns true the ExecutionContext object contains a valid target.
545 ///
546 /// This function can be called after initializing an ExecutionContext
547 /// object, and if it returns true, calls to GetTargetPtr() and
548 /// GetTargetRef() do not need to be checked for validity.
549 bool HasTargetScope() const;
550
551 /// Returns true the ExecutionContext object contains a valid target and
552 /// process.
553 ///
554 /// This function can be called after initializing an ExecutionContext
555 /// object, and if it returns true, calls to GetTargetPtr() and
556 /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not need to be
557 /// checked for validity.
558 bool HasProcessScope() const;
559
560 /// Returns true the ExecutionContext object contains a valid target,
561 /// process, and thread.
562 ///
563 /// This function can be called after initializing an ExecutionContext
564 /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(),
565 /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), and GetThreadRef() do
566 /// not need to be checked for validity.
567 bool HasThreadScope() const;
568
569 /// Returns true the ExecutionContext object contains a valid target,
570 /// process, thread and frame.
571 ///
572 /// This function can be called after initializing an ExecutionContext
573 /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(),
574 /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), GetThreadRef(),
575 /// GetFramePtr(), and GetFrameRef() do not need to be checked for validity.
576 bool HasFrameScope() const;
577
578protected:
579 // Member variables
580 lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame
581 lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame
582 lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame
583 lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread.
584};
585
586/// A wrapper class representing an execution context with non-null Target
587/// and Process pointers, a locked API mutex and a locked ProcessRunLock.
588/// The locks are private by design: to unlock them, destroy the
589/// StoppedExecutionContext.
592 lldb::ProcessSP &process_sp,
593 lldb::ThreadSP &thread_sp,
594 lldb::StackFrameSP &frame_sp,
595 std::unique_lock<std::recursive_mutex> api_lock,
597 : m_api_lock(std::move(api_lock)), m_stop_locker(std::move(stop_locker)) {
598 assert(target_sp);
599 assert(process_sp);
600 assert(m_api_lock.owns_lock());
601 assert(m_stop_locker.IsLocked());
602 SetTargetSP(target_sp);
603 SetProcessSP(process_sp);
604 SetThreadSP(thread_sp);
605 SetFrameSP(frame_sp);
606 }
607
608 /// Transfers ownership of the locks from `other` to `this`, making `other`
609 /// unusable.
612 other.m_thread_sp, other.m_frame_sp,
613 std::move(other.m_api_lock),
614 std::move(other.m_stop_locker)) {
615 other.Clear();
616 }
617
618 /// Clears this context, unlocking the ProcessRunLock and returning the
619 /// locked API lock, allowing callers to resume the process. Similar to
620 /// a move operation, this object is no longer usable.
621 [[nodiscard]] std::unique_lock<std::recursive_mutex> AllowResume();
622
623private:
624 std::unique_lock<std::recursive_mutex> m_api_lock;
626};
627
628llvm::Expected<StoppedExecutionContext>
629GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr);
630llvm::Expected<StoppedExecutionContext>
632
633} // namespace lldb_private
634
635#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.
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.
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.
ExecutionContextRef(ExecutionContextScope &exe_scope)
Construct using an execution context scope.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor to set only the frame shared pointer.
bool HasThreadScope() const
Returns true the ExecutionContext object contains a valid target, process, and thread.
void SetProcessPtr(Process *process)
Set accessor to set only the process shared pointer from a process pointer.
bool HasProcessScope() const
Returns true the ExecutionContext object contains a valid target and process.
ExecutionContextScope * GetBestExecutionContextScope() const
ExecutionContext(const ExecutionContext &rhs)
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
void Clear()
Clear the object's state.
ExecutionContext()
Default Constructor.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
void SetProcessSP(const lldb::ProcessSP &process_sp)
Set accessor to set only the process shared pointer.
lldb::StackFrameSP m_frame_sp
The stack frame in thread.
bool operator==(const ExecutionContext &rhs) const
void SetThreadPtr(Thread *thread)
Set accessor to set only the thread shared pointer from a thread pointer.
lldb::ByteOrder GetByteOrder() const
void SetTargetPtr(Target *target)
Set accessor to set only the target shared pointer from a target pointer.
lldb::TargetSP m_target_sp
The target that owns the process/thread/frame.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
const lldb::StackFrameSP & GetFrameSP() const
Get accessor to get the frame shared pointer.
ExecutionContext(const lldb::ThreadSP &thread_sp)
Process & GetProcessRef() const
Returns a reference to the process object.
void SetContext(const lldb::TargetSP &target_sp, bool get_process)
void SetTargetSP(const lldb::TargetSP &target_sp)
Set accessor to set only the target shared pointer.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
void SetThreadSP(const lldb::ThreadSP &thread_sp)
Set accessor to set only the thread shared pointer.
void SetContext(const lldb::StackFrameSP &frame_sp)
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
void SetContext(const lldb::ThreadSP &thread_sp)
StackFrame & GetFrameRef() const
Returns a reference to the thread object.
bool HasFrameScope() const
Returns true the ExecutionContext object contains a valid target, process, thread and frame.
lldb::ThreadSP m_thread_sp
The thread that owns the frame.
ExecutionContext(const lldb::StackFrameSP &frame_sp)
lldb::ProcessSP m_process_sp
The process that owns the thread/frame.
bool operator!=(const ExecutionContext &rhs) const
Target & GetTargetRef() const
Returns a reference to the target object.
void SetFramePtr(StackFrame *frame)
Set accessor to set only the frame shared pointer from a frame pointer.
ExecutionContext & operator=(const ExecutionContext &rhs)
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread & GetThreadRef() const
Returns a reference to the thread object.
RegisterContext * GetRegisterContext() const
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A plug-in interface definition class for debugging a process.
Definition Process.h:354
This base class provides an interface to stack frames.
Definition StackFrame.h:44
#define LLDB_INVALID_THREAD_ID
A class that represents a running process on the host machine.
llvm::Expected< StoppedExecutionContext > GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr)
std::weak_ptr< lldb_private::StackFrame > StackFrameWP
std::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,...