[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / API / SBExecutionContext.cpp
bloba0b68e6efe384af20fdebbb6387b750b35004347
1 //===-- SBExecutionContext.cpp --------------------------------------------===//
2 //
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
6 //
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"
19 using namespace lldb;
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;
70 return *this;
73 ExecutionContextRef *SBExecutionContext::get() const {
74 return m_exe_ctx_sp.get();
77 SBTarget SBExecutionContext::GetTarget() const {
78 LLDB_INSTRUMENT_VA(this);
80 SBTarget sb_target;
81 if (m_exe_ctx_sp) {
82 TargetSP target_sp(m_exe_ctx_sp->GetTargetSP());
83 if (target_sp)
84 sb_target.SetSP(target_sp);
86 return sb_target;
89 SBProcess SBExecutionContext::GetProcess() const {
90 LLDB_INSTRUMENT_VA(this);
92 SBProcess sb_process;
93 if (m_exe_ctx_sp) {
94 ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP());
95 if (process_sp)
96 sb_process.SetSP(process_sp);
98 return sb_process;
101 SBThread SBExecutionContext::GetThread() const {
102 LLDB_INSTRUMENT_VA(this);
104 SBThread sb_thread;
105 if (m_exe_ctx_sp) {
106 ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP());
107 if (thread_sp)
108 sb_thread.SetThread(thread_sp);
110 return sb_thread;
113 SBFrame SBExecutionContext::GetFrame() const {
114 LLDB_INSTRUMENT_VA(this);
116 SBFrame sb_frame;
117 if (m_exe_ctx_sp) {
118 StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP());
119 if (frame_sp)
120 sb_frame.SetFrameSP(frame_sp);
122 return sb_frame;