1*435933ddSDimitry Andric //===-- SBExecutionContext.cpp ------------------------------------*- C++
2*435933ddSDimitry Andric //-*-===//
37aa51b79SEd Maste //
47aa51b79SEd Maste //                     The LLVM Compiler Infrastructure
57aa51b79SEd Maste //
67aa51b79SEd Maste // This file is distributed under the University of Illinois Open Source
77aa51b79SEd Maste // License. See LICENSE.TXT for details.
87aa51b79SEd Maste //
97aa51b79SEd Maste //===----------------------------------------------------------------------===//
107aa51b79SEd Maste 
117aa51b79SEd Maste #include "lldb/API/SBExecutionContext.h"
127aa51b79SEd Maste 
137aa51b79SEd Maste #include "lldb/API/SBFrame.h"
14*435933ddSDimitry Andric #include "lldb/API/SBProcess.h"
15*435933ddSDimitry Andric #include "lldb/API/SBTarget.h"
16*435933ddSDimitry Andric #include "lldb/API/SBThread.h"
177aa51b79SEd Maste 
187aa51b79SEd Maste #include "lldb/Target/ExecutionContext.h"
197aa51b79SEd Maste 
207aa51b79SEd Maste using namespace lldb;
217aa51b79SEd Maste using namespace lldb_private;
227aa51b79SEd Maste 
SBExecutionContext()23*435933ddSDimitry Andric SBExecutionContext::SBExecutionContext() : m_exe_ctx_sp() {}
247aa51b79SEd Maste 
SBExecutionContext(const lldb::SBExecutionContext & rhs)25*435933ddSDimitry Andric SBExecutionContext::SBExecutionContext(const lldb::SBExecutionContext &rhs)
26*435933ddSDimitry Andric     : m_exe_ctx_sp(rhs.m_exe_ctx_sp) {}
277aa51b79SEd Maste 
SBExecutionContext(lldb::ExecutionContextRefSP exe_ctx_ref_sp)28*435933ddSDimitry Andric SBExecutionContext::SBExecutionContext(
29*435933ddSDimitry Andric     lldb::ExecutionContextRefSP exe_ctx_ref_sp)
30*435933ddSDimitry Andric     : m_exe_ctx_sp(exe_ctx_ref_sp) {}
317aa51b79SEd Maste 
SBExecutionContext(const lldb::SBTarget & target)32*435933ddSDimitry Andric SBExecutionContext::SBExecutionContext(const lldb::SBTarget &target)
33*435933ddSDimitry Andric     : m_exe_ctx_sp(new ExecutionContextRef()) {
347aa51b79SEd Maste   m_exe_ctx_sp->SetTargetSP(target.GetSP());
357aa51b79SEd Maste }
367aa51b79SEd Maste 
SBExecutionContext(const lldb::SBProcess & process)37*435933ddSDimitry Andric SBExecutionContext::SBExecutionContext(const lldb::SBProcess &process)
38*435933ddSDimitry Andric     : m_exe_ctx_sp(new ExecutionContextRef()) {
397aa51b79SEd Maste   m_exe_ctx_sp->SetProcessSP(process.GetSP());
407aa51b79SEd Maste }
417aa51b79SEd Maste 
SBExecutionContext(lldb::SBThread thread)42*435933ddSDimitry Andric SBExecutionContext::SBExecutionContext(lldb::SBThread thread)
43*435933ddSDimitry Andric     : m_exe_ctx_sp(new ExecutionContextRef()) {
447aa51b79SEd Maste   m_exe_ctx_sp->SetThreadPtr(thread.get());
457aa51b79SEd Maste }
467aa51b79SEd Maste 
SBExecutionContext(const lldb::SBFrame & frame)47*435933ddSDimitry Andric SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame)
48*435933ddSDimitry Andric     : m_exe_ctx_sp(new ExecutionContextRef()) {
497aa51b79SEd Maste   m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP());
507aa51b79SEd Maste }
517aa51b79SEd Maste 
~SBExecutionContext()52*435933ddSDimitry Andric SBExecutionContext::~SBExecutionContext() {}
537aa51b79SEd Maste 
54*435933ddSDimitry Andric const SBExecutionContext &SBExecutionContext::
operator =(const lldb::SBExecutionContext & rhs)55*435933ddSDimitry Andric operator=(const lldb::SBExecutionContext &rhs) {
567aa51b79SEd Maste   m_exe_ctx_sp = rhs.m_exe_ctx_sp;
577aa51b79SEd Maste   return *this;
587aa51b79SEd Maste }
597aa51b79SEd Maste 
get() const60*435933ddSDimitry Andric ExecutionContextRef *SBExecutionContext::get() const {
617aa51b79SEd Maste   return m_exe_ctx_sp.get();
627aa51b79SEd Maste }
637aa51b79SEd Maste 
GetTarget() const64*435933ddSDimitry Andric SBTarget SBExecutionContext::GetTarget() const {
657aa51b79SEd Maste   SBTarget sb_target;
66*435933ddSDimitry Andric   if (m_exe_ctx_sp) {
677aa51b79SEd Maste     TargetSP target_sp(m_exe_ctx_sp->GetTargetSP());
687aa51b79SEd Maste     if (target_sp)
697aa51b79SEd Maste       sb_target.SetSP(target_sp);
707aa51b79SEd Maste   }
717aa51b79SEd Maste   return sb_target;
727aa51b79SEd Maste }
737aa51b79SEd Maste 
GetProcess() const74*435933ddSDimitry Andric SBProcess SBExecutionContext::GetProcess() const {
757aa51b79SEd Maste   SBProcess sb_process;
76*435933ddSDimitry Andric   if (m_exe_ctx_sp) {
777aa51b79SEd Maste     ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP());
787aa51b79SEd Maste     if (process_sp)
797aa51b79SEd Maste       sb_process.SetSP(process_sp);
807aa51b79SEd Maste   }
817aa51b79SEd Maste   return sb_process;
827aa51b79SEd Maste }
837aa51b79SEd Maste 
GetThread() const84*435933ddSDimitry Andric SBThread SBExecutionContext::GetThread() const {
857aa51b79SEd Maste   SBThread sb_thread;
86*435933ddSDimitry Andric   if (m_exe_ctx_sp) {
877aa51b79SEd Maste     ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP());
887aa51b79SEd Maste     if (thread_sp)
897aa51b79SEd Maste       sb_thread.SetThread(thread_sp);
907aa51b79SEd Maste   }
917aa51b79SEd Maste   return sb_thread;
927aa51b79SEd Maste }
937aa51b79SEd Maste 
GetFrame() const94*435933ddSDimitry Andric SBFrame SBExecutionContext::GetFrame() const {
957aa51b79SEd Maste   SBFrame sb_frame;
96*435933ddSDimitry Andric   if (m_exe_ctx_sp) {
977aa51b79SEd Maste     StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP());
987aa51b79SEd Maste     if (frame_sp)
997aa51b79SEd Maste       sb_frame.SetFrameSP(frame_sp);
1007aa51b79SEd Maste   }
1017aa51b79SEd Maste   return sb_frame;
1027aa51b79SEd Maste }
103