LLDB  mainline
SBProcessInfo.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
10 #include "Utils.h"
11 #include "lldb/API/SBFileSpec.h"
14 
15 using namespace lldb;
16 using namespace lldb_private;
17 
19 
21  LLDB_INSTRUMENT_VA(this, rhs);
22 
23  m_opaque_up = clone(rhs.m_opaque_up);
24 }
25 
27 
29  LLDB_INSTRUMENT_VA(this, rhs);
30 
31  if (this != &rhs)
32  m_opaque_up = clone(rhs.m_opaque_up);
33  return *this;
34 }
35 
37  if (m_opaque_up == nullptr) {
38  m_opaque_up = std::make_unique<ProcessInstanceInfo>();
39  }
40  return *m_opaque_up;
41 }
42 
44  ref() = proc_info_ref;
45 }
46 
47 bool SBProcessInfo::IsValid() const {
48  LLDB_INSTRUMENT_VA(this);
49  return this->operator bool();
50 }
51 SBProcessInfo::operator bool() const {
52  LLDB_INSTRUMENT_VA(this);
53 
54  return m_opaque_up != nullptr;
55 }
56 
57 const char *SBProcessInfo::GetName() {
58  LLDB_INSTRUMENT_VA(this);
59 
60  const char *name = nullptr;
61  if (m_opaque_up) {
62  name = m_opaque_up->GetName();
63  }
64  return name;
65 }
66 
68  LLDB_INSTRUMENT_VA(this);
69 
70  SBFileSpec file_spec;
71  if (m_opaque_up) {
72  file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
73  }
74  return file_spec;
75 }
76 
78  LLDB_INSTRUMENT_VA(this);
79 
81  if (m_opaque_up) {
82  proc_id = m_opaque_up->GetProcessID();
83  }
84  return proc_id;
85 }
86 
88  LLDB_INSTRUMENT_VA(this);
89 
90  uint32_t user_id = UINT32_MAX;
91  if (m_opaque_up) {
92  user_id = m_opaque_up->GetUserID();
93  }
94  return user_id;
95 }
96 
98  LLDB_INSTRUMENT_VA(this);
99 
100  uint32_t group_id = UINT32_MAX;
101  if (m_opaque_up) {
102  group_id = m_opaque_up->GetGroupID();
103  }
104  return group_id;
105 }
106 
108  LLDB_INSTRUMENT_VA(this);
109 
110  bool is_valid = false;
111  if (m_opaque_up) {
112  is_valid = m_opaque_up->UserIDIsValid();
113  }
114  return is_valid;
115 }
116 
118  LLDB_INSTRUMENT_VA(this);
119 
120  bool is_valid = false;
121  if (m_opaque_up) {
122  is_valid = m_opaque_up->GroupIDIsValid();
123  }
124  return is_valid;
125 }
126 
128  LLDB_INSTRUMENT_VA(this);
129 
130  uint32_t user_id = UINT32_MAX;
131  if (m_opaque_up) {
132  user_id = m_opaque_up->GetEffectiveUserID();
133  }
134  return user_id;
135 }
136 
138  LLDB_INSTRUMENT_VA(this);
139 
140  uint32_t group_id = UINT32_MAX;
141  if (m_opaque_up) {
142  group_id = m_opaque_up->GetEffectiveGroupID();
143  }
144  return group_id;
145 }
146 
148  LLDB_INSTRUMENT_VA(this);
149 
150  bool is_valid = false;
151  if (m_opaque_up) {
152  is_valid = m_opaque_up->EffectiveUserIDIsValid();
153  }
154  return is_valid;
155 }
156 
158  LLDB_INSTRUMENT_VA(this);
159 
160  bool is_valid = false;
161  if (m_opaque_up) {
162  is_valid = m_opaque_up->EffectiveGroupIDIsValid();
163  }
164  return is_valid;
165 }
166 
168  LLDB_INSTRUMENT_VA(this);
169 
171  if (m_opaque_up) {
172  proc_id = m_opaque_up->GetParentProcessID();
173  }
174  return proc_id;
175 }
176 
178  LLDB_INSTRUMENT_VA(this);
179 
180  const char *triple = nullptr;
181  if (m_opaque_up) {
182  const auto &arch = m_opaque_up->GetArchitecture();
183  if (arch.IsValid()) {
184  // Const-ify the string so we don't need to worry about the lifetime of
185  // the string
186  triple = ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
187  }
188  }
189  return triple;
190 }
lldb::SBProcessInfo::EffectiveUserIDIsValid
bool EffectiveUserIDIsValid()
Definition: SBProcessInfo.cpp:147
Instrumentation.h
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:106
lldb::SBProcessInfo::~SBProcessInfo
~SBProcessInfo()
lldb::SBProcessInfo::IsValid
bool IsValid() const
Definition: SBProcessInfo.cpp:47
lldb::SBProcessInfo::GroupIDIsValid
bool GroupIDIsValid()
Definition: SBProcessInfo.cpp:117
lldb::SBProcessInfo::GetTriple
const char * GetTriple()
Return the target triple (arch-vendor-os) for the described process.
Definition: SBProcessInfo.cpp:177
LLDB_INVALID_PROCESS_ID
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:81
lldb::SBProcessInfo::UserIDIsValid
bool UserIDIsValid()
Definition: SBProcessInfo.cpp:107
lldb::SBProcessInfo
Definition: SBProcessInfo.h:16
lldb::SBProcessInfo::GetName
const char * GetName()
Definition: SBProcessInfo.cpp:57
lldb::SBFileSpec::SetFileSpec
void SetFileSpec(const lldb_private::FileSpec &fspec)
Definition: SBFileSpec.cpp:164
lldb::SBProcessInfo::SetProcessInfo
void SetProcessInfo(const lldb_private::ProcessInstanceInfo &proc_info_ref)
Definition: SBProcessInfo.cpp:43
lldb::SBProcessInfo::EffectiveGroupIDIsValid
bool EffectiveGroupIDIsValid()
Definition: SBProcessInfo.cpp:157
ProcessInfo.h
lldb_private::clone
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Utils.h
SBFileSpec.h
lldb_private::ConstString
Definition: ConstString.h:39
lldb::SBProcessInfo::SBProcessInfo
SBProcessInfo()
Definition: SBProcessInfo.cpp:18
lldb::SBProcessInfo::GetEffectiveUserID
uint32_t GetEffectiveUserID()
Definition: SBProcessInfo.cpp:127
lldb::SBProcessInfo::ref
lldb_private::ProcessInstanceInfo & ref()
Definition: SBProcessInfo.cpp:36
lldb::SBProcessInfo::GetExecutableFile
SBFileSpec GetExecutableFile()
Definition: SBProcessInfo.cpp:67
uint32_t
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb::SBProcessInfo::GetParentProcessID
lldb::pid_t GetParentProcessID()
Definition: SBProcessInfo.cpp:167
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
lldb::SBFileSpec
Definition: SBFileSpec.h:16
SBProcessInfo.h
lldb::SBProcessInfo::GetUserID
uint32_t GetUserID()
Definition: SBProcessInfo.cpp:87
lldb::SBProcessInfo::m_opaque_up
std::unique_ptr< lldb_private::ProcessInstanceInfo > m_opaque_up
Definition: SBProcessInfo.h:63
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
lldb::SBProcessInfo::GetGroupID
uint32_t GetGroupID()
Definition: SBProcessInfo.cpp:97
lldb
Definition: SBAddress.h:15
lldb::SBProcessInfo::GetEffectiveGroupID
uint32_t GetEffectiveGroupID()
Definition: SBProcessInfo.cpp:137
lldb::SBProcessInfo::GetProcessID
lldb::pid_t GetProcessID()
Definition: SBProcessInfo.cpp:77
lldb::SBProcessInfo::operator=
SBProcessInfo & operator=(const SBProcessInfo &rhs)
Definition: SBProcessInfo.cpp:28