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