2013-11-21 05:07:01 +08:00
|
|
|
//===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08: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
|
2013-11-21 05:07:01 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBPlatform.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2013-11-21 05:07:01 +08:00
|
|
|
#include "lldb/API/SBError.h"
|
|
|
|
#include "lldb/API/SBFileSpec.h"
|
2015-02-05 07:19:15 +08:00
|
|
|
#include "lldb/API/SBLaunchInfo.h"
|
2015-07-14 09:09:28 +08:00
|
|
|
#include "lldb/API/SBUnixSignals.h"
|
2013-11-21 05:07:01 +08:00
|
|
|
#include "lldb/Host/File.h"
|
|
|
|
#include "lldb/Target/Platform.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2017-11-14 00:16:33 +08:00
|
|
|
#include "lldb/Utility/ArchSpec.h"
|
2018-04-18 02:53:35 +08:00
|
|
|
#include "lldb/Utility/Args.h"
|
2017-05-12 12:51:55 +08:00
|
|
|
#include "lldb/Utility/Status.h"
|
2013-11-21 05:07:01 +08:00
|
|
|
|
2017-03-09 01:56:08 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
|
2015-02-05 07:19:15 +08:00
|
|
|
#include <functional>
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
// PlatformConnectOptions
|
|
|
|
struct PlatformConnectOptions {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
PlatformConnectOptions(const char *url = nullptr)
|
2013-11-21 05:07:01 +08:00
|
|
|
: m_url(), m_rsync_options(), m_rsync_remote_path_prefix(),
|
|
|
|
m_rsync_enabled(false), m_rsync_omit_hostname_from_remote_path(false),
|
|
|
|
m_local_cache_directory() {
|
|
|
|
if (url && url[0])
|
|
|
|
m_url = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
~PlatformConnectOptions() {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
std::string m_url;
|
|
|
|
std::string m_rsync_options;
|
|
|
|
std::string m_rsync_remote_path_prefix;
|
|
|
|
bool m_rsync_enabled;
|
|
|
|
bool m_rsync_omit_hostname_from_remote_path;
|
|
|
|
ConstString m_local_cache_directory;
|
|
|
|
};
|
|
|
|
|
|
|
|
// PlatformShellCommand
|
|
|
|
struct PlatformShellCommand {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
PlatformShellCommand(const char *shell_command = nullptr)
|
2018-05-10 18:46:03 +08:00
|
|
|
: m_command(), m_working_dir(), m_status(0), m_signo(0) {
|
2013-11-21 05:07:01 +08:00
|
|
|
if (shell_command && shell_command[0])
|
|
|
|
m_command = shell_command;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
~PlatformShellCommand() {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
std::string m_command;
|
|
|
|
std::string m_working_dir;
|
|
|
|
std::string m_output;
|
|
|
|
int m_status;
|
|
|
|
int m_signo;
|
2018-05-10 18:46:03 +08:00
|
|
|
Timeout<std::ratio<1>> m_timeout = llvm::None;
|
2013-11-21 05:07:01 +08:00
|
|
|
};
|
|
|
|
// SBPlatformConnectOptions
|
|
|
|
SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_ptr(new PlatformConnectOptions(url)) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, (const char *), url);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBPlatformConnectOptions::SBPlatformConnectOptions(
|
|
|
|
const SBPlatformConnectOptions &rhs)
|
|
|
|
: m_opaque_ptr(new PlatformConnectOptions()) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions,
|
|
|
|
(const lldb::SBPlatformConnectOptions &), rhs);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
*m_opaque_ptr = *rhs.m_opaque_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
void,
|
|
|
|
SBPlatformConnectOptions, operator=,(
|
|
|
|
const lldb::SBPlatformConnectOptions &),
|
|
|
|
rhs);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
*m_opaque_ptr = *rhs.m_opaque_ptr;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
const char *SBPlatformConnectOptions::GetURL() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, GetURL);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (m_opaque_ptr->m_url.empty())
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
return m_opaque_ptr->m_url.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatformConnectOptions::SetURL(const char *url) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetURL, (const char *),
|
|
|
|
url);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (url && url[0])
|
|
|
|
m_opaque_ptr->m_url = url;
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2013-11-21 05:07:01 +08:00
|
|
|
m_opaque_ptr->m_url.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBPlatformConnectOptions::GetRsyncEnabled() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatformConnectOptions, GetRsyncEnabled);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
return m_opaque_ptr->m_rsync_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatformConnectOptions::EnableRsync(
|
|
|
|
const char *options, const char *remote_path_prefix,
|
|
|
|
bool omit_hostname_from_remote_path) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, EnableRsync,
|
|
|
|
(const char *, const char *, bool), options,
|
|
|
|
remote_path_prefix, omit_hostname_from_remote_path);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
m_opaque_ptr->m_rsync_enabled = true;
|
|
|
|
m_opaque_ptr->m_rsync_omit_hostname_from_remote_path =
|
|
|
|
omit_hostname_from_remote_path;
|
|
|
|
if (remote_path_prefix && remote_path_prefix[0])
|
|
|
|
m_opaque_ptr->m_rsync_remote_path_prefix = remote_path_prefix;
|
|
|
|
else
|
|
|
|
m_opaque_ptr->m_rsync_remote_path_prefix.clear();
|
|
|
|
|
|
|
|
if (options && options[0])
|
|
|
|
m_opaque_ptr->m_rsync_options = options;
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2013-11-21 05:07:01 +08:00
|
|
|
m_opaque_ptr->m_rsync_options.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatformConnectOptions::DisableRsync() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformConnectOptions, DisableRsync);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
m_opaque_ptr->m_rsync_enabled = false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
const char *SBPlatformConnectOptions::GetLocalCacheDirectory() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions,
|
|
|
|
GetLocalCacheDirectory);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
return m_opaque_ptr->m_local_cache_directory.GetCString();
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory,
|
|
|
|
(const char *), path);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (path && path[0])
|
|
|
|
m_opaque_ptr->m_local_cache_directory.SetCString(path);
|
|
|
|
else
|
|
|
|
m_opaque_ptr->m_local_cache_directory = ConstString();
|
|
|
|
}
|
|
|
|
|
|
|
|
// SBPlatformShellCommand
|
|
|
|
SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_ptr(new PlatformShellCommand(shell_command)) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *),
|
|
|
|
shell_command);
|
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
|
|
|
|
SBPlatformShellCommand::SBPlatformShellCommand(
|
|
|
|
const SBPlatformShellCommand &rhs)
|
|
|
|
: m_opaque_ptr(new PlatformShellCommand()) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand,
|
|
|
|
(const lldb::SBPlatformShellCommand &), rhs);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
*m_opaque_ptr = *rhs.m_opaque_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; }
|
|
|
|
|
|
|
|
void SBPlatformShellCommand::Clear() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformShellCommand, Clear);
|
|
|
|
|
2015-07-28 17:18:32 +08:00
|
|
|
m_opaque_ptr->m_output = std::string();
|
2013-11-21 05:07:01 +08:00
|
|
|
m_opaque_ptr->m_status = 0;
|
|
|
|
m_opaque_ptr->m_signo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBPlatformShellCommand::GetCommand() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetCommand);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (m_opaque_ptr->m_command.empty())
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
return m_opaque_ptr->m_command.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatformShellCommand::SetCommand(const char *shell_command) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetCommand, (const char *),
|
|
|
|
shell_command);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (shell_command && shell_command[0])
|
|
|
|
m_opaque_ptr->m_command = shell_command;
|
|
|
|
else
|
|
|
|
m_opaque_ptr->m_command.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBPlatformShellCommand::GetWorkingDirectory() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand,
|
|
|
|
GetWorkingDirectory);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (m_opaque_ptr->m_working_dir.empty())
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
return m_opaque_ptr->m_working_dir.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatformShellCommand::SetWorkingDirectory(const char *path) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory,
|
|
|
|
(const char *), path);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (path && path[0])
|
|
|
|
m_opaque_ptr->m_working_dir = path;
|
|
|
|
else
|
|
|
|
m_opaque_ptr->m_working_dir.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBPlatformShellCommand::GetTimeoutSeconds() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatformShellCommand,
|
|
|
|
GetTimeoutSeconds);
|
|
|
|
|
2018-05-10 18:46:03 +08:00
|
|
|
if (m_opaque_ptr->m_timeout)
|
|
|
|
return m_opaque_ptr->m_timeout->count();
|
|
|
|
return UINT32_MAX;
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds,
|
|
|
|
(uint32_t), sec);
|
|
|
|
|
2018-05-10 18:46:03 +08:00
|
|
|
if (sec == UINT32_MAX)
|
|
|
|
m_opaque_ptr->m_timeout = llvm::None;
|
|
|
|
else
|
|
|
|
m_opaque_ptr->m_timeout = std::chrono::seconds(sec);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
int SBPlatformShellCommand::GetSignal() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetSignal);
|
|
|
|
|
|
|
|
return m_opaque_ptr->m_signo;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SBPlatformShellCommand::GetStatus() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetStatus);
|
2013-11-21 05:07:01 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return m_opaque_ptr->m_status;
|
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
|
|
|
|
const char *SBPlatformShellCommand::GetOutput() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetOutput);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (m_opaque_ptr->m_output.empty())
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
return m_opaque_ptr->m_output.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
// SBPlatform
|
2019-03-06 08:06:00 +08:00
|
|
|
SBPlatform::SBPlatform() : m_opaque_sp() {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBPlatform);
|
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
|
|
|
|
SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const char *), platform_name);
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2014-09-20 04:11:50 +08:00
|
|
|
if (platform_name && platform_name[0])
|
|
|
|
m_opaque_sp = Platform::Create(ConstString(platform_name), error);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBPlatform::~SBPlatform() {}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
bool SBPlatform::IsValid() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, 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 21:58:46 +08:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBPlatform::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return m_opaque_sp.get() != nullptr;
|
2019-03-06 08:06:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatform::Clear() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, Clear);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
m_opaque_sp.reset();
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
const char *SBPlatform::GetName() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetName);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp)
|
|
|
|
return platform_sp->GetName().GetCString();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::PlatformSP SBPlatform::GetSP() const { return m_opaque_sp; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
void SBPlatform::SetSP(const lldb::PlatformSP &platform_sp) {
|
|
|
|
m_opaque_sp = platform_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBPlatform::GetWorkingDirectory() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetWorkingDirectory);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp)
|
|
|
|
return platform_sp->GetWorkingDirectory().GetCString();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBPlatform::SetWorkingDirectory(const char *path) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *),
|
|
|
|
path);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
|
|
|
if (path)
|
2018-11-02 05:05:36 +08:00
|
|
|
platform_sp->SetWorkingDirectory(FileSpec(path));
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2018-11-02 05:05:36 +08:00
|
|
|
platform_sp->SetWorkingDirectory(FileSpec());
|
2013-11-21 05:07:01 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, ConnectRemote,
|
|
|
|
(lldb::SBPlatformConnectOptions &), connect_options);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError sb_error;
|
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp && connect_options.GetURL()) {
|
|
|
|
Args args;
|
2016-09-20 01:54:06 +08:00
|
|
|
args.AppendArgument(
|
|
|
|
llvm::StringRef::withNullAsEmpty(connect_options.GetURL()));
|
2013-11-21 05:07:01 +08:00
|
|
|
sb_error.ref() = platform_sp->ConnectRemote(args);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2013-11-21 05:07:01 +08:00
|
|
|
sb_error.SetErrorString("invalid platform");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBPlatform::DisconnectRemote() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, DisconnectRemote);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp)
|
|
|
|
platform_sp->DisconnectRemote();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBPlatform::IsConnected() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatform, IsConnected);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp)
|
2018-03-14 05:06:05 +08:00
|
|
|
return platform_sp->IsConnected();
|
2013-11-21 05:07:01 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBPlatform::GetTriple() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetTriple);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
2015-05-30 03:52:29 +08:00
|
|
|
ArchSpec arch(platform_sp->GetSystemArchitecture());
|
2013-11-21 05:07:01 +08:00
|
|
|
if (arch.IsValid()) {
|
|
|
|
// Const-ify the string so we don't need to worry about the lifetime of
|
|
|
|
// the string
|
|
|
|
return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
const char *SBPlatform::GetOSBuild() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSBuild);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
|
|
|
std::string s;
|
|
|
|
if (platform_sp->GetOSBuildString(s)) {
|
|
|
|
if (!s.empty()) {
|
|
|
|
// Const-ify the string so we don't need to worry about the lifetime of
|
|
|
|
// the string
|
|
|
|
return ConstString(s.c_str()).GetCString();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
const char *SBPlatform::GetOSDescription() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSDescription);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
|
|
|
std::string s;
|
2015-03-04 19:18:34 +08:00
|
|
|
if (platform_sp->GetOSKernelDescription(s)) {
|
2013-11-21 05:07:01 +08:00
|
|
|
if (!s.empty()) {
|
|
|
|
// Const-ify the string so we don't need to worry about the lifetime of
|
|
|
|
// the string
|
|
|
|
return ConstString(s.c_str()).GetCString();
|
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBPlatform::GetHostname() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetHostname);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp)
|
|
|
|
return platform_sp->GetHostname();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return nullptr;
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBPlatform::GetOSMajorVersion() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMajorVersion);
|
|
|
|
|
2018-06-18 23:02:23 +08:00
|
|
|
llvm::VersionTuple version;
|
|
|
|
if (PlatformSP platform_sp = GetSP())
|
|
|
|
version = platform_sp->GetOSVersion();
|
|
|
|
return version.empty() ? UINT32_MAX : version.getMajor();
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBPlatform::GetOSMinorVersion() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMinorVersion);
|
|
|
|
|
2018-06-18 23:02:23 +08:00
|
|
|
llvm::VersionTuple version;
|
|
|
|
if (PlatformSP platform_sp = GetSP())
|
|
|
|
version = platform_sp->GetOSVersion();
|
|
|
|
return version.getMinor().getValueOr(UINT32_MAX);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBPlatform::GetOSUpdateVersion() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSUpdateVersion);
|
|
|
|
|
2018-06-18 23:02:23 +08:00
|
|
|
llvm::VersionTuple version;
|
|
|
|
if (PlatformSP platform_sp = GetSP())
|
|
|
|
version = platform_sp->GetOSVersion();
|
|
|
|
return version.getSubminor().getValueOr(UINT32_MAX);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
2015-02-05 07:19:15 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Get,
|
|
|
|
(lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError sb_error;
|
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
|
|
|
sb_error.ref() = platform_sp->GetFile(src.ref(), dst.ref());
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2013-11-21 05:07:01 +08:00
|
|
|
sb_error.SetErrorString("invalid platform");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Put,
|
|
|
|
(lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst);
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
|
|
|
|
if (src.Exists()) {
|
|
|
|
uint32_t permissions =
|
|
|
|
FileSystem::Instance().GetPermissions(src.ref());
|
|
|
|
if (permissions == 0) {
|
|
|
|
if (FileSystem::Instance().IsDirectory(src.ref()))
|
|
|
|
permissions = eFilePermissionsDirectoryDefault;
|
|
|
|
else
|
|
|
|
permissions = eFilePermissionsFileDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
return platform_sp->PutFile(src.ref(), dst.ref(), permissions);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status error;
|
|
|
|
error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
|
|
|
|
src.ref().GetPath().c_str());
|
|
|
|
return error;
|
|
|
|
}));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Install,
|
|
|
|
(lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst);
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
|
|
|
|
if (src.Exists())
|
|
|
|
return platform_sp->Install(src.ref(), dst.ref());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
Status error;
|
|
|
|
error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
|
|
|
|
src.ref().GetPath().c_str());
|
|
|
|
return error;
|
|
|
|
}));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-05-30 03:52:29 +08:00
|
|
|
SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Run,
|
|
|
|
(lldb::SBPlatformShellCommand &), shell_command);
|
|
|
|
return LLDB_RECORD_RESULT(ExecuteConnected([&](const lldb::PlatformSP
|
|
|
|
&platform_sp) {
|
2015-02-05 07:19:15 +08:00
|
|
|
const char *command = shell_command.GetCommand();
|
|
|
|
if (!command)
|
2017-05-12 12:51:55 +08:00
|
|
|
return Status("invalid shell command (empty)");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-02-05 07:19:15 +08:00
|
|
|
const char *working_dir = shell_command.GetWorkingDirectory();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
if (working_dir == nullptr) {
|
2015-05-30 03:52:29 +08:00
|
|
|
working_dir = platform_sp->GetWorkingDirectory().GetCString();
|
2015-02-05 07:19:15 +08:00
|
|
|
if (working_dir)
|
2015-05-30 03:52:29 +08:00
|
|
|
shell_command.SetWorkingDirectory(working_dir);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
2018-11-02 05:05:36 +08:00
|
|
|
return platform_sp->RunShellCommand(command, FileSpec(working_dir),
|
2018-05-10 18:46:03 +08:00
|
|
|
&shell_command.m_opaque_ptr->m_status,
|
|
|
|
&shell_command.m_opaque_ptr->m_signo,
|
|
|
|
&shell_command.m_opaque_ptr->m_output,
|
|
|
|
shell_command.m_opaque_ptr->m_timeout);
|
2019-03-06 08:06:00 +08:00
|
|
|
}));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-02-05 07:19:15 +08:00
|
|
|
SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Launch, (lldb::SBLaunchInfo &),
|
|
|
|
launch_info);
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
|
|
|
|
ProcessLaunchInfo info = launch_info.ref();
|
|
|
|
Status error = platform_sp->LaunchProcess(info);
|
|
|
|
launch_info.set_ref(info);
|
|
|
|
return error;
|
|
|
|
}));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-02-05 07:19:15 +08:00
|
|
|
SBError SBPlatform::Kill(const lldb::pid_t pid) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t), pid);
|
|
|
|
return LLDB_RECORD_RESULT(
|
|
|
|
ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
|
|
|
|
return platform_sp->KillProcess(pid);
|
|
|
|
}));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-02-05 07:19:15 +08:00
|
|
|
SBError SBPlatform::ExecuteConnected(
|
2017-05-12 12:51:55 +08:00
|
|
|
const std::function<Status(const lldb::PlatformSP &)> &func) {
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError sb_error;
|
2015-02-05 07:19:15 +08:00
|
|
|
const auto platform_sp(GetSP());
|
2013-11-21 05:07:01 +08:00
|
|
|
if (platform_sp) {
|
|
|
|
if (platform_sp->IsConnected())
|
2015-02-05 07:19:15 +08:00
|
|
|
sb_error.ref() = func(platform_sp);
|
2013-11-21 05:07:01 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString("not connected");
|
2016-09-07 04:57:50 +08:00
|
|
|
} else
|
2013-11-21 05:07:01 +08:00
|
|
|
sb_error.SetErrorString("invalid platform");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
return sb_error;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, MakeDirectory,
|
|
|
|
(const char *, uint32_t), path, file_permissions);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError sb_error;
|
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
|
|
|
sb_error.ref() =
|
2018-11-02 05:05:36 +08:00
|
|
|
platform_sp->MakeDirectory(FileSpec(path), file_permissions);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2013-11-21 05:07:01 +08:00
|
|
|
sb_error.SetErrorString("invalid platform");
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
uint32_t SBPlatform::GetFilePermissions(const char *path) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(uint32_t, SBPlatform, GetFilePermissions, (const char *),
|
|
|
|
path);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
|
|
|
uint32_t file_permissions = 0;
|
2018-11-02 05:05:36 +08:00
|
|
|
platform_sp->GetFilePermissions(FileSpec(path), file_permissions);
|
2013-11-21 05:07:01 +08:00
|
|
|
return file_permissions;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-11-21 05:07:01 +08:00
|
|
|
return 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-02-05 07:19:15 +08:00
|
|
|
SBError SBPlatform::SetFilePermissions(const char *path,
|
2013-11-21 05:07:01 +08:00
|
|
|
uint32_t file_permissions) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, SetFilePermissions,
|
|
|
|
(const char *, uint32_t), path, file_permissions);
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError sb_error;
|
|
|
|
PlatformSP platform_sp(GetSP());
|
|
|
|
if (platform_sp) {
|
2018-11-02 05:05:36 +08:00
|
|
|
sb_error.ref() =
|
|
|
|
platform_sp->SetFilePermissions(FileSpec(path), file_permissions);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2013-11-21 05:07:01 +08:00
|
|
|
sb_error.SetErrorString("invalid platform");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_error);
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
SBUnixSignals SBPlatform::GetUnixSignals() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBUnixSignals, SBPlatform,
|
|
|
|
GetUnixSignals);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto platform_sp = GetSP())
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBUnixSignals{platform_sp});
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(SBUnixSignals());
|
2015-07-14 09:09:28 +08:00
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBPlatformConnectOptions>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const char *));
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions,
|
|
|
|
(const lldb::SBPlatformConnectOptions &));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
void,
|
|
|
|
SBPlatformConnectOptions, operator=,(
|
|
|
|
const lldb::SBPlatformConnectOptions &));
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetURL,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBPlatformConnectOptions, GetRsyncEnabled, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, EnableRsync,
|
|
|
|
(const char *, const char *, bool));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, DisableRsync, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions,
|
|
|
|
GetLocalCacheDirectory, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory,
|
|
|
|
(const char *));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *));
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand,
|
|
|
|
(const lldb::SBPlatformShellCommand &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand,
|
|
|
|
GetWorkingDirectory, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBPlatformShellCommand, GetTimeoutSeconds,
|
|
|
|
());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds,
|
|
|
|
(uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetSignal, ());
|
|
|
|
LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetStatus, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetOutput, ());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBPlatform>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetName, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetWorkingDirectory, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, ConnectRemote,
|
|
|
|
(lldb::SBPlatformConnectOptions &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBPlatform, DisconnectRemote, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBPlatform, IsConnected, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetTriple, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSBuild, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSDescription, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBPlatform, GetHostname, ());
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMajorVersion, ());
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMinorVersion, ());
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSUpdateVersion, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Get,
|
|
|
|
(lldb::SBFileSpec &, lldb::SBFileSpec &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Put,
|
|
|
|
(lldb::SBFileSpec &, lldb::SBFileSpec &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Install,
|
|
|
|
(lldb::SBFileSpec &, lldb::SBFileSpec &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Run,
|
|
|
|
(lldb::SBPlatformShellCommand &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Launch,
|
|
|
|
(lldb::SBLaunchInfo &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, MakeDirectory,
|
|
|
|
(const char *, uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetFilePermissions,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, SetFilePermissions,
|
|
|
|
(const char *, uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals,
|
|
|
|
());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|