[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / API / SBProcessInfo.cpp
blob895fba95afbaeaf972dfb69136cea2478bb7bec2
1 //===-- SBProcessInfo.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/SBProcessInfo.h"
10 #include "Utils.h"
11 #include "lldb/API/SBFileSpec.h"
12 #include "lldb/Utility/Instrumentation.h"
13 #include "lldb/Utility/ProcessInfo.h"
15 using namespace lldb;
16 using namespace lldb_private;
18 SBProcessInfo::SBProcessInfo() { LLDB_INSTRUMENT_VA(this); }
20 SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) {
21 LLDB_INSTRUMENT_VA(this, rhs);
23 m_opaque_up = clone(rhs.m_opaque_up);
26 SBProcessInfo::~SBProcessInfo() = default;
28 SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
29 LLDB_INSTRUMENT_VA(this, rhs);
31 if (this != &rhs)
32 m_opaque_up = clone(rhs.m_opaque_up);
33 return *this;
36 ProcessInstanceInfo &SBProcessInfo::ref() {
37 if (m_opaque_up == nullptr) {
38 m_opaque_up = std::make_unique<ProcessInstanceInfo>();
40 return *m_opaque_up;
43 void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) {
44 ref() = proc_info_ref;
47 bool SBProcessInfo::IsValid() const {
48 LLDB_INSTRUMENT_VA(this);
49 return this->operator bool();
51 SBProcessInfo::operator bool() const {
52 LLDB_INSTRUMENT_VA(this);
54 return m_opaque_up != nullptr;
57 const char *SBProcessInfo::GetName() {
58 LLDB_INSTRUMENT_VA(this);
60 if (!m_opaque_up)
61 return nullptr;
63 return ConstString(m_opaque_up->GetName()).GetCString();
66 SBFileSpec SBProcessInfo::GetExecutableFile() {
67 LLDB_INSTRUMENT_VA(this);
69 SBFileSpec file_spec;
70 if (m_opaque_up) {
71 file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
73 return file_spec;
76 lldb::pid_t SBProcessInfo::GetProcessID() {
77 LLDB_INSTRUMENT_VA(this);
79 lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
80 if (m_opaque_up) {
81 proc_id = m_opaque_up->GetProcessID();
83 return proc_id;
86 uint32_t SBProcessInfo::GetUserID() {
87 LLDB_INSTRUMENT_VA(this);
89 uint32_t user_id = UINT32_MAX;
90 if (m_opaque_up) {
91 user_id = m_opaque_up->GetUserID();
93 return user_id;
96 uint32_t SBProcessInfo::GetGroupID() {
97 LLDB_INSTRUMENT_VA(this);
99 uint32_t group_id = UINT32_MAX;
100 if (m_opaque_up) {
101 group_id = m_opaque_up->GetGroupID();
103 return group_id;
106 bool SBProcessInfo::UserIDIsValid() {
107 LLDB_INSTRUMENT_VA(this);
109 bool is_valid = false;
110 if (m_opaque_up) {
111 is_valid = m_opaque_up->UserIDIsValid();
113 return is_valid;
116 bool SBProcessInfo::GroupIDIsValid() {
117 LLDB_INSTRUMENT_VA(this);
119 bool is_valid = false;
120 if (m_opaque_up) {
121 is_valid = m_opaque_up->GroupIDIsValid();
123 return is_valid;
126 uint32_t SBProcessInfo::GetEffectiveUserID() {
127 LLDB_INSTRUMENT_VA(this);
129 uint32_t user_id = UINT32_MAX;
130 if (m_opaque_up) {
131 user_id = m_opaque_up->GetEffectiveUserID();
133 return user_id;
136 uint32_t SBProcessInfo::GetEffectiveGroupID() {
137 LLDB_INSTRUMENT_VA(this);
139 uint32_t group_id = UINT32_MAX;
140 if (m_opaque_up) {
141 group_id = m_opaque_up->GetEffectiveGroupID();
143 return group_id;
146 bool SBProcessInfo::EffectiveUserIDIsValid() {
147 LLDB_INSTRUMENT_VA(this);
149 bool is_valid = false;
150 if (m_opaque_up) {
151 is_valid = m_opaque_up->EffectiveUserIDIsValid();
153 return is_valid;
156 bool SBProcessInfo::EffectiveGroupIDIsValid() {
157 LLDB_INSTRUMENT_VA(this);
159 bool is_valid = false;
160 if (m_opaque_up) {
161 is_valid = m_opaque_up->EffectiveGroupIDIsValid();
163 return is_valid;
166 lldb::pid_t SBProcessInfo::GetParentProcessID() {
167 LLDB_INSTRUMENT_VA(this);
169 lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
170 if (m_opaque_up) {
171 proc_id = m_opaque_up->GetParentProcessID();
173 return proc_id;
176 const char *SBProcessInfo::GetTriple() {
177 LLDB_INSTRUMENT_VA(this);
179 if (!m_opaque_up)
180 return nullptr;
182 const auto &arch = m_opaque_up->GetArchitecture();
183 if (!arch.IsValid())
184 return nullptr;
186 return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();