Path: blob/main/contrib/llvm-project/lldb/source/API/SBExecutionContext.cpp
39587 views
//===-- SBExecutionContext.cpp --------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/API/SBExecutionContext.h"9#include "lldb/Utility/Instrumentation.h"1011#include "lldb/API/SBFrame.h"12#include "lldb/API/SBProcess.h"13#include "lldb/API/SBTarget.h"14#include "lldb/API/SBThread.h"1516#include "lldb/Target/ExecutionContext.h"1718using namespace lldb;19using namespace lldb_private;2021SBExecutionContext::SBExecutionContext() { LLDB_INSTRUMENT_VA(this); }2223SBExecutionContext::SBExecutionContext(const lldb::SBExecutionContext &rhs)24: m_exe_ctx_sp(rhs.m_exe_ctx_sp) {25LLDB_INSTRUMENT_VA(this, rhs);26}2728SBExecutionContext::SBExecutionContext(29lldb::ExecutionContextRefSP exe_ctx_ref_sp)30: m_exe_ctx_sp(exe_ctx_ref_sp) {31LLDB_INSTRUMENT_VA(this, exe_ctx_ref_sp);32}3334SBExecutionContext::SBExecutionContext(const lldb::SBTarget &target)35: m_exe_ctx_sp(new ExecutionContextRef()) {36LLDB_INSTRUMENT_VA(this, target);3738m_exe_ctx_sp->SetTargetSP(target.GetSP());39}4041SBExecutionContext::SBExecutionContext(const lldb::SBProcess &process)42: m_exe_ctx_sp(new ExecutionContextRef()) {43LLDB_INSTRUMENT_VA(this, process);4445m_exe_ctx_sp->SetProcessSP(process.GetSP());46}4748SBExecutionContext::SBExecutionContext(lldb::SBThread thread)49: m_exe_ctx_sp(new ExecutionContextRef()) {50LLDB_INSTRUMENT_VA(this, thread);5152m_exe_ctx_sp->SetThreadPtr(thread.get());53}5455SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame)56: m_exe_ctx_sp(new ExecutionContextRef()) {57LLDB_INSTRUMENT_VA(this, frame);5859m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP());60}6162SBExecutionContext::~SBExecutionContext() = default;6364const SBExecutionContext &SBExecutionContext::65operator=(const lldb::SBExecutionContext &rhs) {66LLDB_INSTRUMENT_VA(this, rhs);6768m_exe_ctx_sp = rhs.m_exe_ctx_sp;69return *this;70}7172ExecutionContextRef *SBExecutionContext::get() const {73return m_exe_ctx_sp.get();74}7576SBTarget SBExecutionContext::GetTarget() const {77LLDB_INSTRUMENT_VA(this);7879SBTarget sb_target;80if (m_exe_ctx_sp) {81TargetSP target_sp(m_exe_ctx_sp->GetTargetSP());82if (target_sp)83sb_target.SetSP(target_sp);84}85return sb_target;86}8788SBProcess SBExecutionContext::GetProcess() const {89LLDB_INSTRUMENT_VA(this);9091SBProcess sb_process;92if (m_exe_ctx_sp) {93ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP());94if (process_sp)95sb_process.SetSP(process_sp);96}97return sb_process;98}99100SBThread SBExecutionContext::GetThread() const {101LLDB_INSTRUMENT_VA(this);102103SBThread sb_thread;104if (m_exe_ctx_sp) {105ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP());106if (thread_sp)107sb_thread.SetThread(thread_sp);108}109return sb_thread;110}111112SBFrame SBExecutionContext::GetFrame() const {113LLDB_INSTRUMENT_VA(this);114115SBFrame sb_frame;116if (m_exe_ctx_sp) {117StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP());118if (frame_sp)119sb_frame.SetFrameSP(frame_sp);120}121return sb_frame;122}123124125