Files
clang-p2996/lldb/source/API/SBProcessInfo.cpp
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00

145 lines
3.2 KiB
C++

//===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBProcessInfo.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/Target/Process.h"
using namespace lldb;
using namespace lldb_private;
SBProcessInfo::SBProcessInfo() : m_opaque_ap() {}
SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_ap() {
if (rhs.IsValid()) {
ref() = *rhs.m_opaque_ap;
}
}
SBProcessInfo::~SBProcessInfo() {}
SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
if (this != &rhs) {
if (rhs.IsValid())
ref() = *rhs.m_opaque_ap;
else
m_opaque_ap.reset();
}
return *this;
}
ProcessInstanceInfo &SBProcessInfo::ref() {
if (m_opaque_ap == nullptr) {
m_opaque_ap.reset(new ProcessInstanceInfo());
}
return *m_opaque_ap;
}
void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) {
ref() = proc_info_ref;
}
bool SBProcessInfo::IsValid() const { return m_opaque_ap != nullptr; }
const char *SBProcessInfo::GetName() {
const char *name = nullptr;
if (m_opaque_ap) {
name = m_opaque_ap->GetName();
}
return name;
}
SBFileSpec SBProcessInfo::GetExecutableFile() {
SBFileSpec file_spec;
if (m_opaque_ap) {
file_spec.SetFileSpec(m_opaque_ap->GetExecutableFile());
}
return file_spec;
}
lldb::pid_t SBProcessInfo::GetProcessID() {
lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
if (m_opaque_ap) {
proc_id = m_opaque_ap->GetProcessID();
}
return proc_id;
}
uint32_t SBProcessInfo::GetUserID() {
uint32_t user_id = UINT32_MAX;
if (m_opaque_ap) {
user_id = m_opaque_ap->GetUserID();
}
return user_id;
}
uint32_t SBProcessInfo::GetGroupID() {
uint32_t group_id = UINT32_MAX;
if (m_opaque_ap) {
group_id = m_opaque_ap->GetGroupID();
}
return group_id;
}
bool SBProcessInfo::UserIDIsValid() {
bool is_valid = false;
if (m_opaque_ap) {
is_valid = m_opaque_ap->UserIDIsValid();
}
return is_valid;
}
bool SBProcessInfo::GroupIDIsValid() {
bool is_valid = false;
if (m_opaque_ap) {
is_valid = m_opaque_ap->GroupIDIsValid();
}
return is_valid;
}
uint32_t SBProcessInfo::GetEffectiveUserID() {
uint32_t user_id = UINT32_MAX;
if (m_opaque_ap) {
user_id = m_opaque_ap->GetEffectiveUserID();
}
return user_id;
}
uint32_t SBProcessInfo::GetEffectiveGroupID() {
uint32_t group_id = UINT32_MAX;
if (m_opaque_ap) {
group_id = m_opaque_ap->GetEffectiveGroupID();
}
return group_id;
}
bool SBProcessInfo::EffectiveUserIDIsValid() {
bool is_valid = false;
if (m_opaque_ap) {
is_valid = m_opaque_ap->EffectiveUserIDIsValid();
}
return is_valid;
}
bool SBProcessInfo::EffectiveGroupIDIsValid() {
bool is_valid = false;
if (m_opaque_ap) {
is_valid = m_opaque_ap->EffectiveGroupIDIsValid();
}
return is_valid;
}
lldb::pid_t SBProcessInfo::GetParentProcessID() {
lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
if (m_opaque_ap) {
proc_id = m_opaque_ap->GetParentProcessID();
}
return proc_id;
}