Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 1 | //===-- SBExecutionContext.cpp ------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/API/SBExecutionContext.h" |
| 11 | |
| 12 | #include "lldb/API/SBTarget.h" |
| 13 | #include "lldb/API/SBProcess.h" |
| 14 | #include "lldb/API/SBThread.h" |
| 15 | #include "lldb/API/SBFrame.h" |
| 16 | |
| 17 | #include "lldb/Target/ExecutionContext.h" |
| 18 | |
| 19 | using namespace lldb; |
| 20 | using namespace lldb_private; |
| 21 | |
| 22 | SBExecutionContext::SBExecutionContext() : |
| 23 | m_exe_ctx_sp() |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | SBExecutionContext::SBExecutionContext (const lldb::SBExecutionContext &rhs) : |
| 28 | m_exe_ctx_sp(rhs.m_exe_ctx_sp) |
| 29 | { |
| 30 | } |
| 31 | |
Enrico Granata | 06be059 | 2014-10-01 21:47:29 +0000 | [diff] [blame] | 32 | SBExecutionContext::SBExecutionContext (lldb::ExecutionContextRefSP exe_ctx_ref_sp) : |
| 33 | m_exe_ctx_sp(exe_ctx_ref_sp) |
| 34 | { |
| 35 | } |
| 36 | |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 37 | SBExecutionContext::SBExecutionContext (const lldb::SBTarget &target) : |
| 38 | m_exe_ctx_sp(new ExecutionContextRef()) |
| 39 | { |
| 40 | m_exe_ctx_sp->SetTargetSP(target.GetSP()); |
| 41 | } |
| 42 | |
| 43 | SBExecutionContext::SBExecutionContext (const lldb::SBProcess &process) : |
| 44 | m_exe_ctx_sp(new ExecutionContextRef()) |
| 45 | { |
| 46 | m_exe_ctx_sp->SetProcessSP(process.GetSP()); |
| 47 | } |
| 48 | |
| 49 | SBExecutionContext::SBExecutionContext (lldb::SBThread thread) : |
| 50 | m_exe_ctx_sp(new ExecutionContextRef()) |
| 51 | { |
| 52 | m_exe_ctx_sp->SetThreadPtr(thread.get()); |
| 53 | } |
| 54 | |
| 55 | SBExecutionContext::SBExecutionContext (const lldb::SBFrame &frame) : |
| 56 | m_exe_ctx_sp(new ExecutionContextRef()) |
| 57 | { |
| 58 | m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP()); |
| 59 | } |
| 60 | |
| 61 | SBExecutionContext::~SBExecutionContext() |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | const SBExecutionContext & |
| 66 | SBExecutionContext::operator = (const lldb::SBExecutionContext &rhs) |
| 67 | { |
| 68 | m_exe_ctx_sp = rhs.m_exe_ctx_sp; |
| 69 | return *this; |
| 70 | } |
| 71 | |
Jim Ingham | ffc9f1d | 2014-10-14 01:20:07 +0000 | [diff] [blame] | 72 | ExecutionContextRef * |
| 73 | SBExecutionContext::get () const |
| 74 | { |
| 75 | return m_exe_ctx_sp.get(); |
| 76 | } |
| 77 | |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 78 | SBTarget |
| 79 | SBExecutionContext::GetTarget () const |
| 80 | { |
| 81 | SBTarget sb_target; |
| 82 | if (m_exe_ctx_sp) |
| 83 | { |
| 84 | TargetSP target_sp(m_exe_ctx_sp->GetTargetSP()); |
| 85 | if (target_sp) |
| 86 | sb_target.SetSP(target_sp); |
| 87 | } |
| 88 | return sb_target; |
| 89 | } |
| 90 | |
| 91 | SBProcess |
| 92 | SBExecutionContext::GetProcess () const |
| 93 | { |
| 94 | SBProcess sb_process; |
| 95 | if (m_exe_ctx_sp) |
| 96 | { |
| 97 | ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP()); |
| 98 | if (process_sp) |
| 99 | sb_process.SetSP(process_sp); |
| 100 | } |
| 101 | return sb_process; |
| 102 | } |
| 103 | |
| 104 | SBThread |
| 105 | SBExecutionContext::GetThread () const |
| 106 | { |
| 107 | SBThread sb_thread; |
| 108 | if (m_exe_ctx_sp) |
| 109 | { |
| 110 | ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP()); |
| 111 | if (thread_sp) |
| 112 | sb_thread.SetThread(thread_sp); |
| 113 | } |
| 114 | return sb_thread; |
| 115 | } |
| 116 | |
| 117 | SBFrame |
| 118 | SBExecutionContext::GetFrame () const |
| 119 | { |
| 120 | SBFrame sb_frame; |
| 121 | if (m_exe_ctx_sp) |
| 122 | { |
| 123 | StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP()); |
| 124 | if (frame_sp) |
| 125 | sb_frame.SetFrameSP(frame_sp); |
| 126 | } |
| 127 | return sb_frame; |
| 128 | } |
| 129 | |