LLDB  mainline
SBProcessInfo.cpp
Go to the documentation of this file.
1 //===-- SBProcessInfo.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 
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBFileSpec.h"
14 
15 using namespace lldb;
16 using namespace lldb_private;
17 
18 SBProcessInfo::SBProcessInfo() : m_opaque_up() {
20 }
21 
22 SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() {
24 
25  m_opaque_up = clone(rhs.m_opaque_up);
26 }
27 
29 
32  SBProcessInfo, operator=,(const lldb::SBProcessInfo &),
33  rhs);
34 
35  if (this != &rhs)
36  m_opaque_up = clone(rhs.m_opaque_up);
37  return LLDB_RECORD_RESULT(*this);
38 }
39 
40 ProcessInstanceInfo &SBProcessInfo::ref() {
41  if (m_opaque_up == nullptr) {
42  m_opaque_up.reset(new ProcessInstanceInfo());
43  }
44  return *m_opaque_up;
45 }
46 
47 void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) {
48  ref() = proc_info_ref;
49 }
50 
51 bool SBProcessInfo::IsValid() const {
53  return this->operator bool();
54 }
55 SBProcessInfo::operator bool() const {
56  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, operator bool);
57 
58  return m_opaque_up != nullptr;
59 }
60 
61 const char *SBProcessInfo::GetName() {
63 
64  const char *name = nullptr;
65  if (m_opaque_up) {
66  name = m_opaque_up->GetName();
67  }
68  return name;
69 }
70 
74 
75  SBFileSpec file_spec;
76  if (m_opaque_up) {
77  file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
78  }
79  return LLDB_RECORD_RESULT(file_spec);
80 }
81 
84 
86  if (m_opaque_up) {
87  proc_id = m_opaque_up->GetProcessID();
88  }
89  return proc_id;
90 }
91 
94 
95  uint32_t user_id = UINT32_MAX;
96  if (m_opaque_up) {
97  user_id = m_opaque_up->GetUserID();
98  }
99  return user_id;
100 }
101 
104 
105  uint32_t group_id = UINT32_MAX;
106  if (m_opaque_up) {
107  group_id = m_opaque_up->GetGroupID();
108  }
109  return group_id;
110 }
111 
114 
115  bool is_valid = false;
116  if (m_opaque_up) {
117  is_valid = m_opaque_up->UserIDIsValid();
118  }
119  return is_valid;
120 }
121 
124 
125  bool is_valid = false;
126  if (m_opaque_up) {
127  is_valid = m_opaque_up->GroupIDIsValid();
128  }
129  return is_valid;
130 }
131 
134 
135  uint32_t user_id = UINT32_MAX;
136  if (m_opaque_up) {
137  user_id = m_opaque_up->GetEffectiveUserID();
138  }
139  return user_id;
140 }
141 
144 
145  uint32_t group_id = UINT32_MAX;
146  if (m_opaque_up) {
147  group_id = m_opaque_up->GetEffectiveGroupID();
148  }
149  return group_id;
150 }
151 
154 
155  bool is_valid = false;
156  if (m_opaque_up) {
157  is_valid = m_opaque_up->EffectiveUserIDIsValid();
158  }
159  return is_valid;
160 }
161 
164 
165  bool is_valid = false;
166  if (m_opaque_up) {
167  is_valid = m_opaque_up->EffectiveGroupIDIsValid();
168  }
169  return is_valid;
170 }
171 
174 
176  if (m_opaque_up) {
177  proc_id = m_opaque_up->GetParentProcessID();
178  }
179  return proc_id;
180 }
181 
182 namespace lldb_private {
183 namespace repro {
184 
185 template <>
191  SBProcessInfo, operator=,(const lldb::SBProcessInfo &));
193  LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, operator bool, ());
194  LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetName, ());
196  ());
207 }
208 
209 }
210 }
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:92
lldb::pid_t GetProcessID()
lldb::pid_t GetParentProcessID()
#define UINT32_MAX
Definition: lldb-defines.h:31
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
uint32_t GetEffectiveGroupID()
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
const char * GetName()
SBProcessInfo & operator=(const SBProcessInfo &rhs)
SBFileSpec GetExecutableFile()
bool IsValid() const
Definition: SBAddress.h:15
uint64_t pid_t
Definition: lldb-types.h:85
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
uint32_t GetEffectiveUserID()
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
void RegisterMethods< SBProcessInfo >(Registry &R)
#define LLDB_RECORD_RESULT(Result)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)