1 //===-- SBAttachInfo.cpp ----------------------------------------*- C++ -*-===// 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 //===----------------------------------------------------------------------===// 8 9 #include "lldb/API/SBAttachInfo.h" 10 #include "Utils.h" 11 #include "lldb/API/SBFileSpec.h" 12 #include "lldb/API/SBListener.h" 13 #include "lldb/Target/Process.h" 14 15 using namespace lldb; 16 using namespace lldb_private; 17 18 SBAttachInfo::SBAttachInfo() : m_opaque_sp(new ProcessAttachInfo()) {} 19 20 SBAttachInfo::SBAttachInfo(lldb::pid_t pid) 21 : m_opaque_sp(new ProcessAttachInfo()) { 22 m_opaque_sp->SetProcessID(pid); 23 } 24 25 SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) 26 : m_opaque_sp(new ProcessAttachInfo()) { 27 if (path && path[0]) 28 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); 29 m_opaque_sp->SetWaitForLaunch(wait_for); 30 } 31 32 SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) 33 : m_opaque_sp(new ProcessAttachInfo()) { 34 if (path && path[0]) 35 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); 36 m_opaque_sp->SetWaitForLaunch(wait_for); 37 m_opaque_sp->SetAsync(async); 38 } 39 40 SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs) 41 : m_opaque_sp(new ProcessAttachInfo()) { 42 m_opaque_sp = clone(rhs.m_opaque_sp); 43 } 44 45 SBAttachInfo::~SBAttachInfo() {} 46 47 lldb_private::ProcessAttachInfo &SBAttachInfo::ref() { return *m_opaque_sp; } 48 49 SBAttachInfo &SBAttachInfo::operator=(const SBAttachInfo &rhs) { 50 if (this != &rhs) 51 m_opaque_sp = clone(rhs.m_opaque_sp); 52 return *this; 53 } 54 55 lldb::pid_t SBAttachInfo::GetProcessID() { return m_opaque_sp->GetProcessID(); } 56 57 void SBAttachInfo::SetProcessID(lldb::pid_t pid) { 58 m_opaque_sp->SetProcessID(pid); 59 } 60 61 uint32_t SBAttachInfo::GetResumeCount() { 62 return m_opaque_sp->GetResumeCount(); 63 } 64 65 void SBAttachInfo::SetResumeCount(uint32_t c) { 66 m_opaque_sp->SetResumeCount(c); 67 } 68 69 const char *SBAttachInfo::GetProcessPluginName() { 70 return m_opaque_sp->GetProcessPluginName(); 71 } 72 73 void SBAttachInfo::SetProcessPluginName(const char *plugin_name) { 74 return m_opaque_sp->SetProcessPluginName(plugin_name); 75 } 76 77 void SBAttachInfo::SetExecutable(const char *path) { 78 if (path && path[0]) 79 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); 80 else 81 m_opaque_sp->GetExecutableFile().Clear(); 82 } 83 84 void SBAttachInfo::SetExecutable(SBFileSpec exe_file) { 85 if (exe_file.IsValid()) 86 m_opaque_sp->GetExecutableFile() = exe_file.ref(); 87 else 88 m_opaque_sp->GetExecutableFile().Clear(); 89 } 90 91 bool SBAttachInfo::GetWaitForLaunch() { 92 return m_opaque_sp->GetWaitForLaunch(); 93 } 94 95 void SBAttachInfo::SetWaitForLaunch(bool b) { 96 m_opaque_sp->SetWaitForLaunch(b); 97 } 98 99 void SBAttachInfo::SetWaitForLaunch(bool b, bool async) { 100 m_opaque_sp->SetWaitForLaunch(b); 101 m_opaque_sp->SetAsync(async); 102 } 103 104 bool SBAttachInfo::GetIgnoreExisting() { 105 return m_opaque_sp->GetIgnoreExisting(); 106 } 107 108 void SBAttachInfo::SetIgnoreExisting(bool b) { 109 m_opaque_sp->SetIgnoreExisting(b); 110 } 111 112 uint32_t SBAttachInfo::GetUserID() { return m_opaque_sp->GetUserID(); } 113 114 uint32_t SBAttachInfo::GetGroupID() { return m_opaque_sp->GetGroupID(); } 115 116 bool SBAttachInfo::UserIDIsValid() { return m_opaque_sp->UserIDIsValid(); } 117 118 bool SBAttachInfo::GroupIDIsValid() { return m_opaque_sp->GroupIDIsValid(); } 119 120 void SBAttachInfo::SetUserID(uint32_t uid) { m_opaque_sp->SetUserID(uid); } 121 122 void SBAttachInfo::SetGroupID(uint32_t gid) { m_opaque_sp->SetGroupID(gid); } 123 124 uint32_t SBAttachInfo::GetEffectiveUserID() { 125 return m_opaque_sp->GetEffectiveUserID(); 126 } 127 128 uint32_t SBAttachInfo::GetEffectiveGroupID() { 129 return m_opaque_sp->GetEffectiveGroupID(); 130 } 131 132 bool SBAttachInfo::EffectiveUserIDIsValid() { 133 return m_opaque_sp->EffectiveUserIDIsValid(); 134 } 135 136 bool SBAttachInfo::EffectiveGroupIDIsValid() { 137 return m_opaque_sp->EffectiveGroupIDIsValid(); 138 } 139 140 void SBAttachInfo::SetEffectiveUserID(uint32_t uid) { 141 m_opaque_sp->SetEffectiveUserID(uid); 142 } 143 144 void SBAttachInfo::SetEffectiveGroupID(uint32_t gid) { 145 m_opaque_sp->SetEffectiveGroupID(gid); 146 } 147 148 lldb::pid_t SBAttachInfo::GetParentProcessID() { 149 return m_opaque_sp->GetParentProcessID(); 150 } 151 152 void SBAttachInfo::SetParentProcessID(lldb::pid_t pid) { 153 m_opaque_sp->SetParentProcessID(pid); 154 } 155 156 bool SBAttachInfo::ParentProcessIDIsValid() { 157 return m_opaque_sp->ParentProcessIDIsValid(); 158 } 159 160 SBListener SBAttachInfo::GetListener() { 161 return SBListener(m_opaque_sp->GetListener()); 162 } 163 164 void SBAttachInfo::SetListener(SBListener &listener) { 165 m_opaque_sp->SetListener(listener.GetSP()); 166 } 167