Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1 | //===-- SBExecutionContext.cpp ------------------------------------*- C++ |
| 2 | //-*-===// |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 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 | |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 13 | #include "lldb/API/SBFrame.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 14 | #include "lldb/API/SBProcess.h" |
| 15 | #include "lldb/API/SBTarget.h" |
| 16 | #include "lldb/API/SBThread.h" |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 17 | |
| 18 | #include "lldb/Target/ExecutionContext.h" |
| 19 | |
| 20 | using namespace lldb; |
| 21 | using namespace lldb_private; |
| 22 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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()); |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 37 | SBExecutionContext::SBExecutionContext(const lldb::SBProcess &process) |
| 38 | : m_exe_ctx_sp(new ExecutionContextRef()) { |
| 39 | m_exe_ctx_sp->SetProcessSP(process.GetSP()); |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 42 | SBExecutionContext::SBExecutionContext(lldb::SBThread thread) |
| 43 | : m_exe_ctx_sp(new ExecutionContextRef()) { |
| 44 | m_exe_ctx_sp->SetThreadPtr(thread.get()); |
Enrico Granata | 06be059 | 2014-10-01 21:47:29 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 47 | SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame) |
| 48 | : m_exe_ctx_sp(new ExecutionContextRef()) { |
| 49 | m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP()); |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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; |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 60 | ExecutionContextRef *SBExecutionContext::get() const { |
| 61 | return m_exe_ctx_sp.get(); |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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; |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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; |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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; |
Enrico Granata | e85e84a | 2014-10-01 20:43:45 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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; |
Jim Ingham | ffc9f1d | 2014-10-14 01:20:07 +0000 | [diff] [blame] | 102 | } |