1 //===-- SBExecutionContext.cpp --------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBExecutionContext.h"
10 #include "lldb/Utility/Instrumentation.h"
12 #include "lldb/API/SBFrame.h"
13 #include "lldb/API/SBProcess.h"
14 #include "lldb/API/SBTarget.h"
15 #include "lldb/API/SBThread.h"
17 #include "lldb/Target/ExecutionContext.h"
20 using namespace lldb_private
;
22 SBExecutionContext::SBExecutionContext() { LLDB_INSTRUMENT_VA(this); }
24 SBExecutionContext::SBExecutionContext(const lldb::SBExecutionContext
&rhs
)
25 : m_exe_ctx_sp(rhs
.m_exe_ctx_sp
) {
26 LLDB_INSTRUMENT_VA(this, rhs
);
29 SBExecutionContext::SBExecutionContext(
30 lldb::ExecutionContextRefSP exe_ctx_ref_sp
)
31 : m_exe_ctx_sp(exe_ctx_ref_sp
) {
32 LLDB_INSTRUMENT_VA(this, exe_ctx_ref_sp
);
35 SBExecutionContext::SBExecutionContext(const lldb::SBTarget
&target
)
36 : m_exe_ctx_sp(new ExecutionContextRef()) {
37 LLDB_INSTRUMENT_VA(this, target
);
39 m_exe_ctx_sp
->SetTargetSP(target
.GetSP());
42 SBExecutionContext::SBExecutionContext(const lldb::SBProcess
&process
)
43 : m_exe_ctx_sp(new ExecutionContextRef()) {
44 LLDB_INSTRUMENT_VA(this, process
);
46 m_exe_ctx_sp
->SetProcessSP(process
.GetSP());
49 SBExecutionContext::SBExecutionContext(lldb::SBThread thread
)
50 : m_exe_ctx_sp(new ExecutionContextRef()) {
51 LLDB_INSTRUMENT_VA(this, thread
);
53 m_exe_ctx_sp
->SetThreadPtr(thread
.get());
56 SBExecutionContext::SBExecutionContext(const lldb::SBFrame
&frame
)
57 : m_exe_ctx_sp(new ExecutionContextRef()) {
58 LLDB_INSTRUMENT_VA(this, frame
);
60 m_exe_ctx_sp
->SetFrameSP(frame
.GetFrameSP());
63 SBExecutionContext::~SBExecutionContext() = default;
65 const SBExecutionContext
&SBExecutionContext::
66 operator=(const lldb::SBExecutionContext
&rhs
) {
67 LLDB_INSTRUMENT_VA(this, rhs
);
69 m_exe_ctx_sp
= rhs
.m_exe_ctx_sp
;
73 ExecutionContextRef
*SBExecutionContext::get() const {
74 return m_exe_ctx_sp
.get();
77 SBTarget
SBExecutionContext::GetTarget() const {
78 LLDB_INSTRUMENT_VA(this);
82 TargetSP
target_sp(m_exe_ctx_sp
->GetTargetSP());
84 sb_target
.SetSP(target_sp
);
89 SBProcess
SBExecutionContext::GetProcess() const {
90 LLDB_INSTRUMENT_VA(this);
94 ProcessSP
process_sp(m_exe_ctx_sp
->GetProcessSP());
96 sb_process
.SetSP(process_sp
);
101 SBThread
SBExecutionContext::GetThread() const {
102 LLDB_INSTRUMENT_VA(this);
106 ThreadSP
thread_sp(m_exe_ctx_sp
->GetThreadSP());
108 sb_thread
.SetThread(thread_sp
);
113 SBFrame
SBExecutionContext::GetFrame() const {
114 LLDB_INSTRUMENT_VA(this);
118 StackFrameSP
frame_sp(m_exe_ctx_sp
->GetFrameSP());
120 sb_frame
.SetFrameSP(frame_sp
);