]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/API/SBExecutionContext.cpp
Merge ACPICA 20170728.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / API / SBExecutionContext.cpp
1 //===-- SBExecutionContext.cpp ------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #include "lldb/API/SBExecutionContext.h"
12
13 #include "lldb/API/SBFrame.h"
14 #include "lldb/API/SBProcess.h"
15 #include "lldb/API/SBTarget.h"
16 #include "lldb/API/SBThread.h"
17
18 #include "lldb/Target/ExecutionContext.h"
19
20 using namespace lldb;
21 using namespace lldb_private;
22
23 SBExecutionContext::SBExecutionContext() : m_exe_ctx_sp() {}
24
25 SBExecutionContext::SBExecutionContext(const lldb::SBExecutionContext &rhs)
26     : m_exe_ctx_sp(rhs.m_exe_ctx_sp) {}
27
28 SBExecutionContext::SBExecutionContext(
29     lldb::ExecutionContextRefSP exe_ctx_ref_sp)
30     : m_exe_ctx_sp(exe_ctx_ref_sp) {}
31
32 SBExecutionContext::SBExecutionContext(const lldb::SBTarget &target)
33     : m_exe_ctx_sp(new ExecutionContextRef()) {
34   m_exe_ctx_sp->SetTargetSP(target.GetSP());
35 }
36
37 SBExecutionContext::SBExecutionContext(const lldb::SBProcess &process)
38     : m_exe_ctx_sp(new ExecutionContextRef()) {
39   m_exe_ctx_sp->SetProcessSP(process.GetSP());
40 }
41
42 SBExecutionContext::SBExecutionContext(lldb::SBThread thread)
43     : m_exe_ctx_sp(new ExecutionContextRef()) {
44   m_exe_ctx_sp->SetThreadPtr(thread.get());
45 }
46
47 SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame)
48     : m_exe_ctx_sp(new ExecutionContextRef()) {
49   m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP());
50 }
51
52 SBExecutionContext::~SBExecutionContext() {}
53
54 const SBExecutionContext &SBExecutionContext::
55 operator=(const lldb::SBExecutionContext &rhs) {
56   m_exe_ctx_sp = rhs.m_exe_ctx_sp;
57   return *this;
58 }
59
60 ExecutionContextRef *SBExecutionContext::get() const {
61   return m_exe_ctx_sp.get();
62 }
63
64 SBTarget SBExecutionContext::GetTarget() const {
65   SBTarget sb_target;
66   if (m_exe_ctx_sp) {
67     TargetSP target_sp(m_exe_ctx_sp->GetTargetSP());
68     if (target_sp)
69       sb_target.SetSP(target_sp);
70   }
71   return sb_target;
72 }
73
74 SBProcess SBExecutionContext::GetProcess() const {
75   SBProcess sb_process;
76   if (m_exe_ctx_sp) {
77     ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP());
78     if (process_sp)
79       sb_process.SetSP(process_sp);
80   }
81   return sb_process;
82 }
83
84 SBThread SBExecutionContext::GetThread() const {
85   SBThread sb_thread;
86   if (m_exe_ctx_sp) {
87     ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP());
88     if (thread_sp)
89       sb_thread.SetThread(thread_sp);
90   }
91   return sb_thread;
92 }
93
94 SBFrame SBExecutionContext::GetFrame() const {
95   SBFrame sb_frame;
96   if (m_exe_ctx_sp) {
97     StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP());
98     if (frame_sp)
99       sb_frame.SetFrameSP(frame_sp);
100   }
101   return sb_frame;
102 }