1 //===-- SBAttachInfo.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 //===----------------------------------------------------------------------===// 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 #include "lldb/Utility/Instrumentation.h" 15 16 using namespace lldb; 17 using namespace lldb_private; 18 19 SBAttachInfo::SBAttachInfo() : m_opaque_sp(new ProcessAttachInfo()) { 20 LLDB_INSTRUMENT_VA(this); 21 } 22 23 SBAttachInfo::SBAttachInfo(lldb::pid_t pid) 24 : m_opaque_sp(new ProcessAttachInfo()) { 25 LLDB_INSTRUMENT_VA(this, pid); 26 27 m_opaque_sp->SetProcessID(pid); 28 } 29 30 SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) 31 : m_opaque_sp(new ProcessAttachInfo()) { 32 LLDB_INSTRUMENT_VA(this, path, wait_for); 33 34 if (path && path[0]) 35 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); 36 m_opaque_sp->SetWaitForLaunch(wait_for); 37 } 38 39 SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) 40 : m_opaque_sp(new ProcessAttachInfo()) { 41 LLDB_INSTRUMENT_VA(this, path, wait_for, async); 42 43 if (path && path[0]) 44 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); 45 m_opaque_sp->SetWaitForLaunch(wait_for); 46 m_opaque_sp->SetAsync(async); 47 } 48 49 SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs) 50 : m_opaque_sp(new ProcessAttachInfo()) { 51 LLDB_INSTRUMENT_VA(this, rhs); 52 53 m_opaque_sp = clone(rhs.m_opaque_sp); 54 } 55 56 SBAttachInfo::~SBAttachInfo() = default; 57 58 lldb_private::ProcessAttachInfo &SBAttachInfo::ref() { return *m_opaque_sp; } 59 60 SBAttachInfo &SBAttachInfo::operator=(const SBAttachInfo &rhs) { 61 LLDB_INSTRUMENT_VA(this, rhs); 62 63 if (this != &rhs) 64 m_opaque_sp = clone(rhs.m_opaque_sp); 65 return *this; 66 } 67 68 lldb::pid_t SBAttachInfo::GetProcessID() { 69 LLDB_INSTRUMENT_VA(this); 70 71 return m_opaque_sp->GetProcessID(); 72 } 73 74 void SBAttachInfo::SetProcessID(lldb::pid_t pid) { 75 LLDB_INSTRUMENT_VA(this, pid); 76 77 m_opaque_sp->SetProcessID(pid); 78 } 79 80 uint32_t SBAttachInfo::GetResumeCount() { 81 LLDB_INSTRUMENT_VA(this); 82 83 return m_opaque_sp->GetResumeCount(); 84 } 85 86 void SBAttachInfo::SetResumeCount(uint32_t c) { 87 LLDB_INSTRUMENT_VA(this, c); 88 89 m_opaque_sp->SetResumeCount(c); 90 } 91 92 const char *SBAttachInfo::GetProcessPluginName() { 93 LLDB_INSTRUMENT_VA(this); 94 95 return m_opaque_sp->GetProcessPluginName(); 96 } 97 98 void SBAttachInfo::SetProcessPluginName(const char *plugin_name) { 99 LLDB_INSTRUMENT_VA(this, plugin_name); 100 101 return m_opaque_sp->SetProcessPluginName(plugin_name); 102 } 103 104 void SBAttachInfo::SetExecutable(const char *path) { 105 LLDB_INSTRUMENT_VA(this, path); 106 107 if (path && path[0]) 108 m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); 109 else 110 m_opaque_sp->GetExecutableFile().Clear(); 111 } 112 113 void SBAttachInfo::SetExecutable(SBFileSpec exe_file) { 114 LLDB_INSTRUMENT_VA(this, exe_file); 115 116 if (exe_file.IsValid()) 117 m_opaque_sp->GetExecutableFile() = exe_file.ref(); 118 else 119 m_opaque_sp->GetExecutableFile().Clear(); 120 } 121 122 bool SBAttachInfo::GetWaitForLaunch() { 123 LLDB_INSTRUMENT_VA(this); 124 125 return m_opaque_sp->GetWaitForLaunch(); 126 } 127 128 void SBAttachInfo::SetWaitForLaunch(bool b) { 129 LLDB_INSTRUMENT_VA(this, b); 130 131 m_opaque_sp->SetWaitForLaunch(b); 132 } 133 134 void SBAttachInfo::SetWaitForLaunch(bool b, bool async) { 135 LLDB_INSTRUMENT_VA(this, b, async); 136 137 m_opaque_sp->SetWaitForLaunch(b); 138 m_opaque_sp->SetAsync(async); 139 } 140 141 bool SBAttachInfo::GetIgnoreExisting() { 142 LLDB_INSTRUMENT_VA(this); 143 144 return m_opaque_sp->GetIgnoreExisting(); 145 } 146 147 void SBAttachInfo::SetIgnoreExisting(bool b) { 148 LLDB_INSTRUMENT_VA(this, b); 149 150 m_opaque_sp->SetIgnoreExisting(b); 151 } 152 153 uint32_t SBAttachInfo::GetUserID() { 154 LLDB_INSTRUMENT_VA(this); 155 156 return m_opaque_sp->GetUserID(); 157 } 158 159 uint32_t SBAttachInfo::GetGroupID() { 160 LLDB_INSTRUMENT_VA(this); 161 162 return m_opaque_sp->GetGroupID(); 163 } 164 165 bool SBAttachInfo::UserIDIsValid() { 166 LLDB_INSTRUMENT_VA(this); 167 168 return m_opaque_sp->UserIDIsValid(); 169 } 170 171 bool SBAttachInfo::GroupIDIsValid() { 172 LLDB_INSTRUMENT_VA(this); 173 174 return m_opaque_sp->GroupIDIsValid(); 175 } 176 177 void SBAttachInfo::SetUserID(uint32_t uid) { 178 LLDB_INSTRUMENT_VA(this, uid); 179 180 m_opaque_sp->SetUserID(uid); 181 } 182 183 void SBAttachInfo::SetGroupID(uint32_t gid) { 184 LLDB_INSTRUMENT_VA(this, gid); 185 186 m_opaque_sp->SetGroupID(gid); 187 } 188 189 uint32_t SBAttachInfo::GetEffectiveUserID() { 190 LLDB_INSTRUMENT_VA(this); 191 192 return m_opaque_sp->GetEffectiveUserID(); 193 } 194 195 uint32_t SBAttachInfo::GetEffectiveGroupID() { 196 LLDB_INSTRUMENT_VA(this); 197 198 return m_opaque_sp->GetEffectiveGroupID(); 199 } 200 201 bool SBAttachInfo::EffectiveUserIDIsValid() { 202 LLDB_INSTRUMENT_VA(this); 203 204 return m_opaque_sp->EffectiveUserIDIsValid(); 205 } 206 207 bool SBAttachInfo::EffectiveGroupIDIsValid() { 208 LLDB_INSTRUMENT_VA(this); 209 210 return m_opaque_sp->EffectiveGroupIDIsValid(); 211 } 212 213 void SBAttachInfo::SetEffectiveUserID(uint32_t uid) { 214 LLDB_INSTRUMENT_VA(this, uid); 215 216 m_opaque_sp->SetEffectiveUserID(uid); 217 } 218 219 void SBAttachInfo::SetEffectiveGroupID(uint32_t gid) { 220 LLDB_INSTRUMENT_VA(this, gid); 221 222 m_opaque_sp->SetEffectiveGroupID(gid); 223 } 224 225 lldb::pid_t SBAttachInfo::GetParentProcessID() { 226 LLDB_INSTRUMENT_VA(this); 227 228 return m_opaque_sp->GetParentProcessID(); 229 } 230 231 void SBAttachInfo::SetParentProcessID(lldb::pid_t pid) { 232 LLDB_INSTRUMENT_VA(this, pid); 233 234 m_opaque_sp->SetParentProcessID(pid); 235 } 236 237 bool SBAttachInfo::ParentProcessIDIsValid() { 238 LLDB_INSTRUMENT_VA(this); 239 240 return m_opaque_sp->ParentProcessIDIsValid(); 241 } 242 243 SBListener SBAttachInfo::GetListener() { 244 LLDB_INSTRUMENT_VA(this); 245 246 return SBListener(m_opaque_sp->GetListener()); 247 } 248 249 void SBAttachInfo::SetListener(SBListener &listener) { 250 LLDB_INSTRUMENT_VA(this, listener); 251 252 m_opaque_sp->SetListener(listener.GetSP()); 253 } 254