[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- SBProcessInfo.cpp -------------------------------------------------===//
|
2017-08-01 07:34:26 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// 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
|
2017-08-01 07:34:26 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBProcessInfo.h"
|
2019-03-06 00:06:00 +00:00
|
|
|
#include "SBReproducerPrivate.h"
|
2019-03-06 00:05:55 +00:00
|
|
|
#include "Utils.h"
|
2021-06-04 15:29:34 +07:00
|
|
|
#include "lldb/API/SBEnvironment.h"
|
2017-08-01 07:34:26 +00:00
|
|
|
#include "lldb/API/SBFileSpec.h"
|
Move ProcessInfo from Host to Utility.
There are set of classes in Target that describe the parameters of a
process - e.g. it's PID, name, user id, and similar. However, since it
is a bare description of a process and contains no actual functionality,
there's nothing specifically that makes this appropriate for being in
Target -- it could just as well be describing a process on the host, or
some hypothetical virtual process that doesn't even exist.
To cement this, I'm moving these classes to Utility. It's possible that
we can find a better place for it in the future, but as it is neither
Host specific nor Target specific, Utility seems like the most appropriate
place for the time being.
After this there is only 2 remaining references to Target from Host,
which I'll address in a followup.
Differential Revision: https://reviews.llvm.org/D58842
llvm-svn: 355342
2019-03-04 21:51:03 +00:00
|
|
|
#include "lldb/Utility/ProcessInfo.h"
|
2017-08-01 07:34:26 +00:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
SBProcessInfo::SBProcessInfo() : m_opaque_up() {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcessInfo);
|
|
|
|
}
|
2017-08-01 07:34:26 +00:00
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &), rhs);
|
|
|
|
|
2019-03-06 00:05:55 +00:00
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 22:57:06 -08:00
|
|
|
SBProcessInfo::~SBProcessInfo() = default;
|
2017-08-01 07:34:26 +00:00
|
|
|
|
|
|
|
SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBProcessInfo &,
|
|
|
|
SBProcessInfo, operator=,(const lldb::SBProcessInfo &),
|
|
|
|
rhs);
|
|
|
|
|
2019-03-06 00:05:55 +00:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2019-04-03 21:31:22 +00:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcessInstanceInfo &SBProcessInfo::ref() {
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up == nullptr) {
|
2020-06-24 16:25:05 -07:00
|
|
|
m_opaque_up = std::make_unique<ProcessInstanceInfo>();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
2019-02-13 06:25:41 +00:00
|
|
|
return *m_opaque_up;
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) {
|
|
|
|
ref() = proc_info_ref;
|
|
|
|
}
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
bool SBProcessInfo::IsValid() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 13:58:46 +00:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBProcessInfo::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, operator bool);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
|
|
|
return m_opaque_up != nullptr;
|
|
|
|
}
|
2017-08-01 07:34:26 +00:00
|
|
|
|
|
|
|
const char *SBProcessInfo::GetName() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetName);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
const char *name = nullptr;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
name = m_opaque_up->GetName();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBFileSpec SBProcessInfo::GetExecutableFile() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBProcessInfo,
|
|
|
|
GetExecutableFile);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
SBFileSpec file_spec;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(file_spec);
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::pid_t SBProcessInfo::GetProcessID() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetProcessID);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
proc_id = m_opaque_up->GetProcessID();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return proc_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBProcessInfo::GetUserID() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetUserID);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
uint32_t user_id = UINT32_MAX;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
user_id = m_opaque_up->GetUserID();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return user_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBProcessInfo::GetGroupID() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetGroupID);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
uint32_t group_id = UINT32_MAX;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
group_id = m_opaque_up->GetGroupID();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return group_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBProcessInfo::UserIDIsValid() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, UserIDIsValid);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
bool is_valid = false;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
is_valid = m_opaque_up->UserIDIsValid();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return is_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBProcessInfo::GroupIDIsValid() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, GroupIDIsValid);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
bool is_valid = false;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
is_valid = m_opaque_up->GroupIDIsValid();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return is_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBProcessInfo::GetEffectiveUserID() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveUserID);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
uint32_t user_id = UINT32_MAX;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
user_id = m_opaque_up->GetEffectiveUserID();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return user_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBProcessInfo::GetEffectiveGroupID() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveGroupID);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
uint32_t group_id = UINT32_MAX;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
group_id = m_opaque_up->GetEffectiveGroupID();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return group_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBProcessInfo::EffectiveUserIDIsValid() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveUserIDIsValid);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
bool is_valid = false;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
is_valid = m_opaque_up->EffectiveUserIDIsValid();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return is_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBProcessInfo::EffectiveGroupIDIsValid() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveGroupIDIsValid);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
bool is_valid = false;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
is_valid = m_opaque_up->EffectiveGroupIDIsValid();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return is_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::pid_t SBProcessInfo::GetParentProcessID() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetParentProcessID);
|
|
|
|
|
2017-08-01 07:34:26 +00:00
|
|
|
lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up) {
|
|
|
|
proc_id = m_opaque_up->GetParentProcessID();
|
2017-08-01 07:34:26 +00:00
|
|
|
}
|
|
|
|
return proc_id;
|
|
|
|
}
|
2019-03-19 17:13:13 +00:00
|
|
|
|
2021-05-30 17:28:09 +07:00
|
|
|
const char *SBProcessInfo::GetTriple() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetTriple);
|
|
|
|
|
|
|
|
const char *triple = nullptr;
|
|
|
|
if (m_opaque_up) {
|
|
|
|
const auto &arch = m_opaque_up->GetArchitecture();
|
|
|
|
if (arch.IsValid()) {
|
|
|
|
// Const-ify the string so we don't need to worry about the lifetime of
|
|
|
|
// the string
|
|
|
|
triple = ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return triple;
|
|
|
|
}
|
|
|
|
|
2021-06-04 15:29:34 +07:00
|
|
|
uint32_t SBProcessInfo::GetNumArguments() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetNumArguments);
|
|
|
|
|
|
|
|
uint32_t num = 0;
|
|
|
|
if (m_opaque_up) {
|
|
|
|
num = m_opaque_up->GetArguments().size();
|
|
|
|
}
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBProcessInfo::GetArgumentAtIndex(uint32_t index) {
|
|
|
|
LLDB_RECORD_METHOD(const char *, SBProcessInfo, GetArgumentAtIndex,
|
|
|
|
(uint32_t), index);
|
|
|
|
|
|
|
|
const char *argument = nullptr;
|
|
|
|
if (m_opaque_up) {
|
|
|
|
argument = m_opaque_up->GetArguments().GetArgumentAtIndex(index);
|
|
|
|
}
|
|
|
|
return argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBEnvironment SBProcessInfo::GetEnvironment() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBProcessInfo,
|
|
|
|
GetEnvironment);
|
|
|
|
|
|
|
|
if (m_opaque_up) {
|
|
|
|
return LLDB_RECORD_RESULT(SBEnvironment(m_opaque_up->GetEnvironment()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return LLDB_RECORD_RESULT(SBEnvironment());
|
|
|
|
}
|
|
|
|
|
2019-03-19 17:13:13 +00:00
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBProcessInfo>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
lldb::SBProcessInfo &,
|
|
|
|
SBProcessInfo, operator=,(const lldb::SBProcessInfo &));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetName, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBProcessInfo, GetExecutableFile,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetProcessID, ());
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetUserID, ());
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetGroupID, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBProcessInfo, UserIDIsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBProcessInfo, GroupIDIsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveUserID, ());
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveGroupID, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveUserIDIsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveGroupIDIsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetParentProcessID, ());
|
2021-05-30 17:28:09 +07:00
|
|
|
LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetTriple, ());
|
2021-06-04 15:29:34 +07:00
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetNumArguments, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetArgumentAtIndex,
|
|
|
|
(uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBProcessInfo, GetEnvironment, ());
|
2019-03-19 17:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|