diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
commit | b76161e41bc2c07cd47f9c61f875d1be95e26d10 (patch) | |
tree | d03c19ce10dec6419f97df1d4dac9d47eb88982f /source/Plugins/Platform | |
parent | 8b4000f13b303cc154136abc74c55670673e2a96 (diff) |
Notes
Diffstat (limited to 'source/Plugins/Platform')
42 files changed, 585 insertions, 572 deletions
diff --git a/source/Plugins/Platform/Android/AdbClient.cpp b/source/Plugins/Platform/Android/AdbClient.cpp index 2060bd1de7355..d3bcee6f487d7 100644 --- a/source/Plugins/Platform/Android/AdbClient.cpp +++ b/source/Plugins/Platform/Android/AdbClient.cpp @@ -46,7 +46,7 @@ using namespace std::chrono; namespace { -const seconds kReadTimeout(8); +const seconds kReadTimeout(12); const char *kOKAY = "OKAY"; const char *kFAIL = "FAIL"; const char *kDATA = "DATA"; @@ -65,9 +65,9 @@ const uint32_t kDefaultMode = 0100770; // S_IFREG | S_IRWXU | S_IRWXG const char *kSocketNamespaceAbstract = "localabstract"; const char *kSocketNamespaceFileSystem = "localfilesystem"; -Error ReadAllBytes(Connection &conn, void *buffer, size_t size) { +Status ReadAllBytes(Connection &conn, void *buffer, size_t size) { - Error error; + Status error; ConnectionStatus status; char *read_buffer = static_cast<char *>(buffer); @@ -86,7 +86,7 @@ Error ReadAllBytes(Connection &conn, void *buffer, size_t size) { now = steady_clock::now(); } if (total_read_bytes < size) - error = Error( + error = Status( "Unable to read requested number of bytes. Connection status: %d.", status); return error; @@ -94,8 +94,8 @@ Error ReadAllBytes(Connection &conn, void *buffer, size_t size) { } // namespace -Error AdbClient::CreateByDeviceID(const std::string &device_id, - AdbClient &adb) { +Status AdbClient::CreateByDeviceID(const std::string &device_id, + AdbClient &adb) { DeviceIDList connect_devices; auto error = adb.GetDevices(connect_devices); if (error.Fail()) @@ -109,15 +109,15 @@ Error AdbClient::CreateByDeviceID(const std::string &device_id, if (android_serial.empty()) { if (connect_devices.size() != 1) - return Error("Expected a single connected device, got instead %zu - try " - "setting 'ANDROID_SERIAL'", - connect_devices.size()); + return Status("Expected a single connected device, got instead %zu - try " + "setting 'ANDROID_SERIAL'", + connect_devices.size()); adb.SetDeviceID(connect_devices.front()); } else { auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial); if (find_it == connect_devices.end()) - return Error("Device \"%s\" not found", android_serial.c_str()); + return Status("Device \"%s\" not found", android_serial.c_str()); adb.SetDeviceID(*find_it); } @@ -136,15 +136,15 @@ void AdbClient::SetDeviceID(const std::string &device_id) { const std::string &AdbClient::GetDeviceID() const { return m_device_id; } -Error AdbClient::Connect() { - Error error; +Status AdbClient::Connect() { + Status error; m_conn.reset(new ConnectionFileDescriptor); m_conn->Connect("connect://localhost:5037", &error); return error; } -Error AdbClient::GetDevices(DeviceIDList &device_list) { +Status AdbClient::GetDevices(DeviceIDList &device_list) { device_list.clear(); auto error = SendMessage("host:devices"); @@ -171,8 +171,8 @@ Error AdbClient::GetDevices(DeviceIDList &device_list) { return error; } -Error AdbClient::SetPortForwarding(const uint16_t local_port, - const uint16_t remote_port) { +Status AdbClient::SetPortForwarding(const uint16_t local_port, + const uint16_t remote_port) { char message[48]; snprintf(message, sizeof(message), "forward:tcp:%d;tcp:%d", local_port, remote_port); @@ -184,9 +184,10 @@ Error AdbClient::SetPortForwarding(const uint16_t local_port, return ReadResponseStatus(); } -Error AdbClient::SetPortForwarding(const uint16_t local_port, - llvm::StringRef remote_socket_name, - const UnixSocketNamespace socket_namespace) { +Status +AdbClient::SetPortForwarding(const uint16_t local_port, + llvm::StringRef remote_socket_name, + const UnixSocketNamespace socket_namespace) { char message[PATH_MAX]; const char *sock_namespace_str = (socket_namespace == UnixSocketNamespaceAbstract) @@ -202,7 +203,7 @@ Error AdbClient::SetPortForwarding(const uint16_t local_port, return ReadResponseStatus(); } -Error AdbClient::DeletePortForwarding(const uint16_t local_port) { +Status AdbClient::DeletePortForwarding(const uint16_t local_port) { char message[32]; snprintf(message, sizeof(message), "killforward:tcp:%d", local_port); @@ -213,8 +214,8 @@ Error AdbClient::DeletePortForwarding(const uint16_t local_port) { return ReadResponseStatus(); } -Error AdbClient::SendMessage(const std::string &packet, const bool reconnect) { - Error error; +Status AdbClient::SendMessage(const std::string &packet, const bool reconnect) { + Status error; if (!m_conn || reconnect) { error = Connect(); if (error.Fail()) @@ -235,13 +236,13 @@ Error AdbClient::SendMessage(const std::string &packet, const bool reconnect) { return error; } -Error AdbClient::SendDeviceMessage(const std::string &packet) { +Status AdbClient::SendDeviceMessage(const std::string &packet) { std::ostringstream msg; msg << "host-serial:" << m_device_id << ":" << packet; return SendMessage(msg.str()); } -Error AdbClient::ReadMessage(std::vector<char> &message) { +Status AdbClient::ReadMessage(std::vector<char> &message) { message.clear(); char buffer[5]; @@ -262,19 +263,19 @@ Error AdbClient::ReadMessage(std::vector<char> &message) { return error; } -Error AdbClient::ReadMessageStream(std::vector<char> &message, - milliseconds timeout) { +Status AdbClient::ReadMessageStream(std::vector<char> &message, + milliseconds timeout) { auto start = steady_clock::now(); message.clear(); - Error error; + Status error; lldb::ConnectionStatus status = lldb::eConnectionStatusSuccess; char buffer[1024]; while (error.Success() && status == lldb::eConnectionStatusSuccess) { auto end = steady_clock::now(); auto elapsed = end - start; if (elapsed >= timeout) - return Error("Timed out"); + return Status("Timed out"); size_t n = m_conn->Read(buffer, sizeof(buffer), duration_cast<microseconds>(timeout - elapsed), @@ -285,7 +286,7 @@ Error AdbClient::ReadMessageStream(std::vector<char> &message, return error; } -Error AdbClient::ReadResponseStatus() { +Status AdbClient::ReadResponseStatus() { char response_id[5]; static const size_t packet_len = 4; @@ -301,9 +302,9 @@ Error AdbClient::ReadResponseStatus() { return error; } -Error AdbClient::GetResponseError(const char *response_id) { +Status AdbClient::GetResponseError(const char *response_id) { if (strcmp(response_id, kFAIL) != 0) - return Error("Got unexpected response id from adb: \"%s\"", response_id); + return Status("Got unexpected response id from adb: \"%s\"", response_id); std::vector<char> error_message; auto error = ReadMessage(error_message); @@ -314,7 +315,7 @@ Error AdbClient::GetResponseError(const char *response_id) { return error; } -Error AdbClient::SwitchDeviceTransport() { +Status AdbClient::SwitchDeviceTransport() { std::ostringstream msg; msg << "host:transport:" << m_device_id; @@ -325,19 +326,20 @@ Error AdbClient::SwitchDeviceTransport() { return ReadResponseStatus(); } -Error AdbClient::StartSync() { +Status AdbClient::StartSync() { auto error = SwitchDeviceTransport(); if (error.Fail()) - return Error("Failed to switch to device transport: %s", error.AsCString()); + return Status("Failed to switch to device transport: %s", + error.AsCString()); error = Sync(); if (error.Fail()) - return Error("Sync failed: %s", error.AsCString()); + return Status("Sync failed: %s", error.AsCString()); return error; } -Error AdbClient::Sync() { +Status AdbClient::Sync() { auto error = SendMessage("sync:", false); if (error.Fail()) return error; @@ -345,17 +347,18 @@ Error AdbClient::Sync() { return ReadResponseStatus(); } -Error AdbClient::ReadAllBytes(void *buffer, size_t size) { +Status AdbClient::ReadAllBytes(void *buffer, size_t size) { return ::ReadAllBytes(*m_conn, buffer, size); } -Error AdbClient::internalShell(const char *command, milliseconds timeout, - std::vector<char> &output_buf) { +Status AdbClient::internalShell(const char *command, milliseconds timeout, + std::vector<char> &output_buf) { output_buf.clear(); auto error = SwitchDeviceTransport(); if (error.Fail()) - return Error("Failed to switch to device transport: %s", error.AsCString()); + return Status("Failed to switch to device transport: %s", + error.AsCString()); StreamString adb_command; adb_command.Printf("shell:%s", command); @@ -376,15 +379,15 @@ Error AdbClient::internalShell(const char *command, milliseconds timeout, static const char *kShellPrefix = "/system/bin/sh:"; if (output_buf.size() > strlen(kShellPrefix)) { if (!memcmp(&output_buf[0], kShellPrefix, strlen(kShellPrefix))) - return Error("Shell command %s failed: %s", command, - std::string(output_buf.begin(), output_buf.end()).c_str()); + return Status("Shell command %s failed: %s", command, + std::string(output_buf.begin(), output_buf.end()).c_str()); } - return Error(); + return Status(); } -Error AdbClient::Shell(const char *command, milliseconds timeout, - std::string *output) { +Status AdbClient::Shell(const char *command, milliseconds timeout, + std::string *output) { std::vector<char> output_buffer; auto error = internalShell(command, timeout, output_buffer); if (error.Fail()) @@ -395,8 +398,8 @@ Error AdbClient::Shell(const char *command, milliseconds timeout, return error; } -Error AdbClient::ShellToFile(const char *command, milliseconds timeout, - const FileSpec &output_file_spec) { +Status AdbClient::ShellToFile(const char *command, milliseconds timeout, + const FileSpec &output_file_spec) { std::vector<char> output_buffer; auto error = internalShell(command, timeout, output_buffer); if (error.Fail()) @@ -406,17 +409,17 @@ Error AdbClient::ShellToFile(const char *command, milliseconds timeout, std::error_code EC; llvm::raw_fd_ostream dst(output_filename, EC, llvm::sys::fs::F_None); if (EC) - return Error("Unable to open local file %s", output_filename.c_str()); + return Status("Unable to open local file %s", output_filename.c_str()); dst.write(&output_buffer[0], output_buffer.size()); dst.close(); if (dst.has_error()) - return Error("Failed to write file %s", output_filename.c_str()); - return Error(); + return Status("Failed to write file %s", output_filename.c_str()); + return Status(); } std::unique_ptr<AdbClient::SyncService> -AdbClient::GetSyncService(Error &error) { +AdbClient::GetSyncService(Status &error) { std::unique_ptr<SyncService> sync_service; error = StartSync(); if (error.Success()) @@ -425,15 +428,15 @@ AdbClient::GetSyncService(Error &error) { return sync_service; } -Error AdbClient::SyncService::internalPullFile(const FileSpec &remote_file, - const FileSpec &local_file) { +Status AdbClient::SyncService::internalPullFile(const FileSpec &remote_file, + const FileSpec &local_file) { const auto local_file_path = local_file.GetPath(); llvm::FileRemover local_file_remover(local_file_path); std::error_code EC; llvm::raw_fd_ostream dst(local_file_path, EC, llvm::sys::fs::F_None); if (EC) - return Error("Unable to open local file %s", local_file_path.c_str()); + return Status("Unable to open local file %s", local_file_path.c_str()); const auto remote_file_path = remote_file.GetPath(false); auto error = SendSyncRequest(kRECV, remote_file_path.length(), @@ -452,18 +455,18 @@ Error AdbClient::SyncService::internalPullFile(const FileSpec &remote_file, } dst.close(); if (dst.has_error()) - return Error("Failed to write file %s", local_file_path.c_str()); + return Status("Failed to write file %s", local_file_path.c_str()); local_file_remover.releaseFile(); return error; } -Error AdbClient::SyncService::internalPushFile(const FileSpec &local_file, - const FileSpec &remote_file) { +Status AdbClient::SyncService::internalPushFile(const FileSpec &local_file, + const FileSpec &remote_file) { const auto local_file_path(local_file.GetPath()); std::ifstream src(local_file_path.c_str(), std::ios::in | std::ios::binary); if (!src.is_open()) - return Error("Unable to open local file %s", local_file_path.c_str()); + return Status("Unable to open local file %s", local_file_path.c_str()); std::stringstream file_description; file_description << remote_file.GetPath(false).c_str() << "," << kDefaultMode; @@ -478,7 +481,7 @@ Error AdbClient::SyncService::internalPushFile(const FileSpec &local_file, size_t chunk_size = src.gcount(); error = SendSyncRequest(kDATA, chunk_size, chunk); if (error.Fail()) - return Error("Failed to send file chunk: %s", error.AsCString()); + return Status("Failed to send file chunk: %s", error.AsCString()); } error = SendSyncRequest( kDONE, llvm::sys::toTimeT(FileSystem::GetModificationTime(local_file)), @@ -490,31 +493,31 @@ Error AdbClient::SyncService::internalPushFile(const FileSpec &local_file, uint32_t data_len; error = ReadSyncHeader(response_id, data_len); if (error.Fail()) - return Error("Failed to read DONE response: %s", error.AsCString()); + return Status("Failed to read DONE response: %s", error.AsCString()); if (response_id == kFAIL) { std::string error_message(data_len, 0); error = ReadAllBytes(&error_message[0], data_len); if (error.Fail()) - return Error("Failed to read DONE error message: %s", error.AsCString()); - return Error("Failed to push file: %s", error_message.c_str()); + return Status("Failed to read DONE error message: %s", error.AsCString()); + return Status("Failed to push file: %s", error_message.c_str()); } else if (response_id != kOKAY) - return Error("Got unexpected DONE response: %s", response_id.c_str()); + return Status("Got unexpected DONE response: %s", response_id.c_str()); // If there was an error reading the source file, finish the adb file // transfer first so that adb isn't expecting any more data. if (src.bad()) - return Error("Failed read on %s", local_file_path.c_str()); + return Status("Failed read on %s", local_file_path.c_str()); return error; } -Error AdbClient::SyncService::internalStat(const FileSpec &remote_file, - uint32_t &mode, uint32_t &size, - uint32_t &mtime) { +Status AdbClient::SyncService::internalStat(const FileSpec &remote_file, + uint32_t &mode, uint32_t &size, + uint32_t &mtime) { const std::string remote_file_path(remote_file.GetPath(false)); auto error = SendSyncRequest(kSTAT, remote_file_path.length(), remote_file_path.c_str()); if (error.Fail()) - return Error("Failed to send request: %s", error.AsCString()); + return Status("Failed to send request: %s", error.AsCString()); static const size_t stat_len = strlen(kSTAT); static const size_t response_len = stat_len + (sizeof(uint32_t) * 3); @@ -522,7 +525,7 @@ Error AdbClient::SyncService::internalStat(const FileSpec &remote_file, std::vector<char> buffer(response_len); error = ReadAllBytes(&buffer[0], buffer.size()); if (error.Fail()) - return Error("Failed to read response: %s", error.AsCString()); + return Status("Failed to read response: %s", error.AsCString()); DataExtractor extractor(&buffer[0], buffer.size(), eByteOrderLittle, sizeof(void *)); @@ -530,33 +533,33 @@ Error AdbClient::SyncService::internalStat(const FileSpec &remote_file, const void *command = extractor.GetData(&offset, stat_len); if (!command) - return Error("Failed to get response command"); + return Status("Failed to get response command"); const char *command_str = static_cast<const char *>(command); if (strncmp(command_str, kSTAT, stat_len)) - return Error("Got invalid stat command: %s", command_str); + return Status("Got invalid stat command: %s", command_str); mode = extractor.GetU32(&offset); size = extractor.GetU32(&offset); mtime = extractor.GetU32(&offset); - return Error(); + return Status(); } -Error AdbClient::SyncService::PullFile(const FileSpec &remote_file, - const FileSpec &local_file) { +Status AdbClient::SyncService::PullFile(const FileSpec &remote_file, + const FileSpec &local_file) { return executeCommand([this, &remote_file, &local_file]() { return internalPullFile(remote_file, local_file); }); } -Error AdbClient::SyncService::PushFile(const FileSpec &local_file, - const FileSpec &remote_file) { +Status AdbClient::SyncService::PushFile(const FileSpec &local_file, + const FileSpec &remote_file) { return executeCommand([this, &local_file, &remote_file]() { return internalPushFile(local_file, remote_file); }); } -Error AdbClient::SyncService::Stat(const FileSpec &remote_file, uint32_t &mode, - uint32_t &size, uint32_t &mtime) { +Status AdbClient::SyncService::Stat(const FileSpec &remote_file, uint32_t &mode, + uint32_t &size, uint32_t &mtime) { return executeCommand([this, &remote_file, &mode, &size, &mtime]() { return internalStat(remote_file, mode, size, mtime); }); @@ -569,10 +572,10 @@ bool AdbClient::SyncService::IsConnected() const { AdbClient::SyncService::SyncService(std::unique_ptr<Connection> &&conn) : m_conn(std::move(conn)) {} -Error AdbClient::SyncService::executeCommand( - const std::function<Error()> &cmd) { +Status +AdbClient::SyncService::executeCommand(const std::function<Status()> &cmd) { if (!m_conn) - return Error("SyncService is disconnected"); + return Status("SyncService is disconnected"); const auto error = cmd(); if (error.Fail()) @@ -583,15 +586,15 @@ Error AdbClient::SyncService::executeCommand( AdbClient::SyncService::~SyncService() {} -Error AdbClient::SyncService::SendSyncRequest(const char *request_id, - const uint32_t data_len, - const void *data) { +Status AdbClient::SyncService::SendSyncRequest(const char *request_id, + const uint32_t data_len, + const void *data) { const DataBufferSP data_sp(new DataBufferHeap(kSyncPacketLen, 0)); DataEncoder encoder(data_sp, eByteOrderLittle, sizeof(void *)); auto offset = encoder.PutData(0, request_id, strlen(request_id)); encoder.PutU32(offset, data_len); - Error error; + Status error; ConnectionStatus status; m_conn->Write(data_sp->GetBytes(), kSyncPacketLen, status, &error); if (error.Fail()) @@ -602,8 +605,8 @@ Error AdbClient::SyncService::SendSyncRequest(const char *request_id, return error; } -Error AdbClient::SyncService::ReadSyncHeader(std::string &response_id, - uint32_t &data_len) { +Status AdbClient::SyncService::ReadSyncHeader(std::string &response_id, + uint32_t &data_len) { char buffer[kSyncPacketLen]; auto error = ReadAllBytes(buffer, kSyncPacketLen); @@ -617,8 +620,8 @@ Error AdbClient::SyncService::ReadSyncHeader(std::string &response_id, return error; } -Error AdbClient::SyncService::PullFileChunk(std::vector<char> &buffer, - bool &eof) { +Status AdbClient::SyncService::PullFileChunk(std::vector<char> &buffer, + bool &eof) { buffer.clear(); std::string response_id; @@ -638,14 +641,14 @@ Error AdbClient::SyncService::PullFileChunk(std::vector<char> &buffer, std::string error_message(data_len, 0); error = ReadAllBytes(&error_message[0], data_len); if (error.Fail()) - return Error("Failed to read pull error message: %s", error.AsCString()); - return Error("Failed to pull file: %s", error_message.c_str()); + return Status("Failed to read pull error message: %s", error.AsCString()); + return Status("Failed to pull file: %s", error_message.c_str()); } else - return Error("Pull failed with unknown response: %s", response_id.c_str()); + return Status("Pull failed with unknown response: %s", response_id.c_str()); - return Error(); + return Status(); } -Error AdbClient::SyncService::ReadAllBytes(void *buffer, size_t size) { +Status AdbClient::SyncService::ReadAllBytes(void *buffer, size_t size) { return ::ReadAllBytes(*m_conn, buffer, size); } diff --git a/source/Plugins/Platform/Android/AdbClient.h b/source/Plugins/Platform/Android/AdbClient.h index 9e8726c93b61e..0d2100fc5663b 100644 --- a/source/Plugins/Platform/Android/AdbClient.h +++ b/source/Plugins/Platform/Android/AdbClient.h @@ -10,7 +10,7 @@ #ifndef liblldb_AdbClient_h_ #define liblldb_AdbClient_h_ -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" #include <chrono> #include <functional> #include <list> @@ -39,42 +39,42 @@ public: public: ~SyncService(); - Error PullFile(const FileSpec &remote_file, const FileSpec &local_file); + Status PullFile(const FileSpec &remote_file, const FileSpec &local_file); - Error PushFile(const FileSpec &local_file, const FileSpec &remote_file); + Status PushFile(const FileSpec &local_file, const FileSpec &remote_file); - Error Stat(const FileSpec &remote_file, uint32_t &mode, uint32_t &size, - uint32_t &mtime); + Status Stat(const FileSpec &remote_file, uint32_t &mode, uint32_t &size, + uint32_t &mtime); bool IsConnected() const; private: explicit SyncService(std::unique_ptr<Connection> &&conn); - Error SendSyncRequest(const char *request_id, const uint32_t data_len, - const void *data); + Status SendSyncRequest(const char *request_id, const uint32_t data_len, + const void *data); - Error ReadSyncHeader(std::string &response_id, uint32_t &data_len); + Status ReadSyncHeader(std::string &response_id, uint32_t &data_len); - Error PullFileChunk(std::vector<char> &buffer, bool &eof); + Status PullFileChunk(std::vector<char> &buffer, bool &eof); - Error ReadAllBytes(void *buffer, size_t size); + Status ReadAllBytes(void *buffer, size_t size); - Error internalPullFile(const FileSpec &remote_file, - const FileSpec &local_file); + Status internalPullFile(const FileSpec &remote_file, + const FileSpec &local_file); - Error internalPushFile(const FileSpec &local_file, - const FileSpec &remote_file); + Status internalPushFile(const FileSpec &local_file, + const FileSpec &remote_file); - Error internalStat(const FileSpec &remote_file, uint32_t &mode, - uint32_t &size, uint32_t &mtime); + Status internalStat(const FileSpec &remote_file, uint32_t &mode, + uint32_t &size, uint32_t &mtime); - Error executeCommand(const std::function<Error()> &cmd); + Status executeCommand(const std::function<Status()> &cmd); std::unique_ptr<Connection> m_conn; }; - static Error CreateByDeviceID(const std::string &device_id, AdbClient &adb); + static Status CreateByDeviceID(const std::string &device_id, AdbClient &adb); AdbClient(); explicit AdbClient(const std::string &device_id); @@ -83,52 +83,53 @@ public: const std::string &GetDeviceID() const; - Error GetDevices(DeviceIDList &device_list); + Status GetDevices(DeviceIDList &device_list); - Error SetPortForwarding(const uint16_t local_port, - const uint16_t remote_port); + Status SetPortForwarding(const uint16_t local_port, + const uint16_t remote_port); - Error SetPortForwarding(const uint16_t local_port, - llvm::StringRef remote_socket_name, - const UnixSocketNamespace socket_namespace); + Status SetPortForwarding(const uint16_t local_port, + llvm::StringRef remote_socket_name, + const UnixSocketNamespace socket_namespace); - Error DeletePortForwarding(const uint16_t local_port); + Status DeletePortForwarding(const uint16_t local_port); - Error Shell(const char *command, std::chrono::milliseconds timeout, - std::string *output); + Status Shell(const char *command, std::chrono::milliseconds timeout, + std::string *output); - Error ShellToFile(const char *command, std::chrono::milliseconds timeout, - const FileSpec &output_file_spec); + Status ShellToFile(const char *command, std::chrono::milliseconds timeout, + const FileSpec &output_file_spec); - std::unique_ptr<SyncService> GetSyncService(Error &error); + std::unique_ptr<SyncService> GetSyncService(Status &error); - Error SwitchDeviceTransport(); + Status SwitchDeviceTransport(); private: - Error Connect(); + Status Connect(); void SetDeviceID(const std::string &device_id); - Error SendMessage(const std::string &packet, const bool reconnect = true); + Status SendMessage(const std::string &packet, const bool reconnect = true); - Error SendDeviceMessage(const std::string &packet); + Status SendDeviceMessage(const std::string &packet); - Error ReadMessage(std::vector<char> &message); + Status ReadMessage(std::vector<char> &message); - Error ReadMessageStream(std::vector<char> &message, std::chrono::milliseconds timeout); + Status ReadMessageStream(std::vector<char> &message, + std::chrono::milliseconds timeout); - Error GetResponseError(const char *response_id); + Status GetResponseError(const char *response_id); - Error ReadResponseStatus(); + Status ReadResponseStatus(); - Error Sync(); + Status Sync(); - Error StartSync(); + Status StartSync(); - Error internalShell(const char *command, std::chrono::milliseconds timeout, - std::vector<char> &output_buf); + Status internalShell(const char *command, std::chrono::milliseconds timeout, + std::vector<char> &output_buf); - Error ReadAllBytes(void *buffer, size_t size); + Status ReadAllBytes(void *buffer, size_t size); std::string m_device_id; std::unique_ptr<Connection> m_conn; diff --git a/source/Plugins/Platform/Android/PlatformAndroid.cpp b/source/Plugins/Platform/Android/PlatformAndroid.cpp index ad3918d4e202b..d896a9f99e638 100644 --- a/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -154,12 +154,12 @@ ConstString PlatformAndroid::GetPluginName() { return GetPluginNameStatic(IsHost()); } -Error PlatformAndroid::ConnectRemote(Args &args) { +Status PlatformAndroid::ConnectRemote(Args &args) { m_device_id.clear(); if (IsHost()) { - return Error("can't connect to the host platform '%s', always connected", - GetPluginName().GetCString()); + return Status("can't connect to the host platform '%s', always connected", + GetPluginName().GetCString()); } if (!m_remote_platform_sp) @@ -169,9 +169,9 @@ Error PlatformAndroid::ConnectRemote(Args &args) { llvm::StringRef scheme, host, path; const char *url = args.GetArgumentAtIndex(0); if (!url) - return Error("URL is null."); + return Status("URL is null."); if (!UriParser::Parse(url, scheme, host, port, path)) - return Error("Invalid URL: %s", url); + return Status("Invalid URL: %s", url); if (host != "localhost") m_device_id = host; @@ -187,8 +187,8 @@ Error PlatformAndroid::ConnectRemote(Args &args) { return error; } -Error PlatformAndroid::GetFile(const FileSpec &source, - const FileSpec &destination) { +Status PlatformAndroid::GetFile(const FileSpec &source, + const FileSpec &destination) { if (IsHost() || !m_remote_platform_sp) return PlatformLinux::GetFile(source, destination); @@ -198,7 +198,7 @@ Error PlatformAndroid::GetFile(const FileSpec &source, source_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent( source_spec.GetCString(false)); - Error error; + Status error; auto sync_service = GetSyncService(error); if (error.Fail()) return error; @@ -219,7 +219,7 @@ Error PlatformAndroid::GetFile(const FileSpec &source, source_file); if (strchr(source_file, '\'') != nullptr) - return Error("Doesn't support single-quotes in filenames"); + return Status("Doesn't support single-quotes in filenames"); // mode == 0 can signify that adbd cannot access the file // due security constraints - try "cat ..." as a fallback. @@ -231,9 +231,9 @@ Error PlatformAndroid::GetFile(const FileSpec &source, return adb.ShellToFile(cmd, minutes(1), destination); } -Error PlatformAndroid::PutFile(const FileSpec &source, - const FileSpec &destination, uint32_t uid, - uint32_t gid) { +Status PlatformAndroid::PutFile(const FileSpec &source, + const FileSpec &destination, uint32_t uid, + uint32_t gid) { if (IsHost() || !m_remote_platform_sp) return PlatformLinux::PutFile(source, destination, uid, gid); @@ -244,7 +244,7 @@ Error PlatformAndroid::PutFile(const FileSpec &source, destination_spec.GetCString(false)); // TODO: Set correct uid and gid on remote file. - Error error; + Status error; auto sync_service = GetSyncService(error); if (error.Fail()) return error; @@ -253,18 +253,18 @@ Error PlatformAndroid::PutFile(const FileSpec &source, const char *PlatformAndroid::GetCacheHostname() { return m_device_id.c_str(); } -Error PlatformAndroid::DownloadModuleSlice(const FileSpec &src_file_spec, - const uint64_t src_offset, - const uint64_t src_size, - const FileSpec &dst_file_spec) { +Status PlatformAndroid::DownloadModuleSlice(const FileSpec &src_file_spec, + const uint64_t src_offset, + const uint64_t src_size, + const FileSpec &dst_file_spec) { if (src_offset != 0) - return Error("Invalid offset - %" PRIu64, src_offset); + return Status("Invalid offset - %" PRIu64, src_offset); return GetFile(src_file_spec, dst_file_spec); } -Error PlatformAndroid::DisconnectRemote() { - Error error = PlatformLinux::DisconnectRemote(); +Status PlatformAndroid::DisconnectRemote() { + Status error = PlatformLinux::DisconnectRemote(); if (error.Success()) { m_device_id.clear(); m_sdk_version = 0; @@ -285,7 +285,7 @@ uint32_t PlatformAndroid::GetSdkVersion() { std::string version_string; AdbClient adb(m_device_id); - Error error = + Status error = adb.Shell("getprop ro.build.version.sdk", seconds(5), &version_string); version_string = llvm::StringRef(version_string).trim().str(); @@ -301,34 +301,34 @@ uint32_t PlatformAndroid::GetSdkVersion() { return m_sdk_version; } -Error PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp, - const FileSpec &dst_file_spec) { +Status PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp, + const FileSpec &dst_file_spec) { // For oat file we can try to fetch additional debug info from the device ConstString extension = module_sp->GetFileSpec().GetFileNameExtension(); if (extension != ConstString("oat") && extension != ConstString("odex")) - return Error( + return Status( "Symbol file downloading only supported for oat and odex files"); // If we have no information about the platform file we can't execute oatdump if (!module_sp->GetPlatformFileSpec()) - return Error("No platform file specified"); + return Status("No platform file specified"); // Symbolizer isn't available before SDK version 23 if (GetSdkVersion() < 23) - return Error("Symbol file generation only supported on SDK 23+"); + return Status("Symbol file generation only supported on SDK 23+"); // If we already have symtab then we don't have to try and generate one if (module_sp->GetSectionList()->FindSectionByName(ConstString(".symtab")) != nullptr) - return Error("Symtab already available in the module"); + return Status("Symtab already available in the module"); AdbClient adb(m_device_id); std::string tmpdir; - Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", - seconds(5), &tmpdir); + Status error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", + seconds(5), &tmpdir); if (error.Fail() || tmpdir.empty()) - return Error("Failed to generate temporary directory on the device (%s)", - error.AsCString()); + return Status("Failed to generate temporary directory on the device (%s)", + error.AsCString()); tmpdir = llvm::StringRef(tmpdir).trim().str(); // Create file remover for the temporary directory created on the device @@ -336,7 +336,7 @@ Error PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp, tmpdir_remover(&tmpdir, [&adb](std::string *s) { StreamString command; command.Printf("rm -rf %s", s->c_str()); - Error error = adb.Shell(command.GetData(), seconds(5), nullptr); + Status error = adb.Shell(command.GetData(), seconds(5), nullptr); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log && error.Fail()) @@ -353,7 +353,7 @@ Error PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp, symfile_platform_filespec.GetCString(false)); error = adb.Shell(command.GetData(), minutes(1), nullptr); if (error.Fail()) - return Error("Oatdump failed: %s", error.AsCString()); + return Status("Oatdump failed: %s", error.AsCString()); // Download the symbolfile from the remote device return GetFile(symfile_platform_filespec, dst_file_spec); @@ -375,7 +375,7 @@ const char *PlatformAndroid::GetLibdlFunctionDeclarations() const { )"; } -AdbClient::SyncService *PlatformAndroid::GetSyncService(Error &error) { +AdbClient::SyncService *PlatformAndroid::GetSyncService(Status &error) { if (m_adb_sync_svc && m_adb_sync_svc->IsConnected()) return m_adb_sync_svc.get(); diff --git a/source/Plugins/Platform/Android/PlatformAndroid.h b/source/Plugins/Platform/Android/PlatformAndroid.h index 8417055733f62..8fb4cc71a69fd 100644 --- a/source/Plugins/Platform/Android/PlatformAndroid.h +++ b/source/Plugins/Platform/Android/PlatformAndroid.h @@ -51,35 +51,35 @@ public: // lldb_private::Platform functions //------------------------------------------------------------ - Error ConnectRemote(Args &args) override; + Status ConnectRemote(Args &args) override; - Error GetFile(const FileSpec &source, const FileSpec &destination) override; + Status GetFile(const FileSpec &source, const FileSpec &destination) override; - Error PutFile(const FileSpec &source, const FileSpec &destination, - uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override; + Status PutFile(const FileSpec &source, const FileSpec &destination, + uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override; uint32_t GetSdkVersion(); bool GetRemoteOSVersion() override; - Error DisconnectRemote() override; + Status DisconnectRemote() override; uint32_t GetDefaultMemoryCacheLineSize() override; protected: const char *GetCacheHostname() override; - Error DownloadModuleSlice(const FileSpec &src_file_spec, - const uint64_t src_offset, const uint64_t src_size, - const FileSpec &dst_file_spec) override; + Status DownloadModuleSlice(const FileSpec &src_file_spec, + const uint64_t src_offset, const uint64_t src_size, + const FileSpec &dst_file_spec) override; - Error DownloadSymbolFile(const lldb::ModuleSP &module_sp, - const FileSpec &dst_file_spec) override; + Status DownloadSymbolFile(const lldb::ModuleSP &module_sp, + const FileSpec &dst_file_spec) override; const char *GetLibdlFunctionDeclarations() const override; private: - AdbClient::SyncService *GetSyncService(Error &error); + AdbClient::SyncService *GetSyncService(Status &error); std::unique_ptr<AdbClient::SyncService> m_adb_sync_svc; std::string m_device_id; diff --git a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp index 034518c1d2e35..dbc74833e2870 100644 --- a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp +++ b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp @@ -10,8 +10,8 @@ // Other libraries and framework includes #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/common/TCPSocket.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/UriParser.h" #include "PlatformAndroidRemoteGDBServer.h" @@ -25,7 +25,7 @@ using namespace platform_android; static const lldb::pid_t g_remote_platform_pid = 0; // Alias for the process id of lldb-platform -static Error ForwardPortWithAdb( +static Status ForwardPortWithAdb( const uint16_t local_port, const uint16_t remote_port, llvm::StringRef remote_socket_name, const llvm::Optional<AdbClient::UnixSocketNamespace> &socket_namespace, @@ -53,20 +53,20 @@ static Error ForwardPortWithAdb( remote_socket_name.str().c_str(), local_port); if (!socket_namespace) - return Error("Invalid socket namespace"); + return Status("Invalid socket namespace"); return adb.SetPortForwarding(local_port, remote_socket_name, *socket_namespace); } -static Error DeleteForwardPortWithAdb(uint16_t local_port, - const std::string &device_id) { +static Status DeleteForwardPortWithAdb(uint16_t local_port, + const std::string &device_id) { AdbClient adb(device_id); return adb.DeletePortForwarding(local_port); } -static Error FindUnusedPort(uint16_t &port) { - Error error; +static Status FindUnusedPort(uint16_t &port) { + Status error; std::unique_ptr<TCPSocket> tcp_socket(new TCPSocket(true, false)); if (error.Fail()) return error; @@ -107,19 +107,20 @@ bool PlatformAndroidRemoteGDBServer::KillSpawnedProcess(lldb::pid_t pid) { return m_gdb_client.KillSpawnedProcess(pid); } -Error PlatformAndroidRemoteGDBServer::ConnectRemote(Args &args) { +Status PlatformAndroidRemoteGDBServer::ConnectRemote(Args &args) { m_device_id.clear(); if (args.GetArgumentCount() != 1) - return Error("\"platform connect\" takes a single argument: <connect-url>"); + return Status( + "\"platform connect\" takes a single argument: <connect-url>"); int remote_port; llvm::StringRef scheme, host, path; const char *url = args.GetArgumentAtIndex(0); if (!url) - return Error("URL is null."); + return Status("URL is null."); if (!UriParser::Parse(url, scheme, host, remote_port, path)) - return Error("Invalid URL: %s", url); + return Status("Invalid URL: %s", url); if (host != "localhost") m_device_id = host; @@ -150,7 +151,7 @@ Error PlatformAndroidRemoteGDBServer::ConnectRemote(Args &args) { return error; } -Error PlatformAndroidRemoteGDBServer::DisconnectRemote() { +Status PlatformAndroidRemoteGDBServer::DisconnectRemote() { DeleteForwardPort(g_remote_platform_pid); return PlatformRemoteGDBServer::DisconnectRemote(); } @@ -173,12 +174,12 @@ void PlatformAndroidRemoteGDBServer::DeleteForwardPort(lldb::pid_t pid) { m_port_forwards.erase(it); } -Error PlatformAndroidRemoteGDBServer::MakeConnectURL( +Status PlatformAndroidRemoteGDBServer::MakeConnectURL( const lldb::pid_t pid, const uint16_t remote_port, llvm::StringRef remote_socket_name, std::string &connect_url) { static const int kAttempsNum = 5; - Error error; + Status error; // There is a race possibility that somebody will occupy // a port while we're in between FindUnusedPort and ForwardPortWithAdb - // adding the loop to mitigate such problem. @@ -205,7 +206,7 @@ Error PlatformAndroidRemoteGDBServer::MakeConnectURL( lldb::ProcessSP PlatformAndroidRemoteGDBServer::ConnectProcess( llvm::StringRef connect_url, llvm::StringRef plugin_name, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) { + lldb_private::Status &error) { // We don't have the pid of the remote gdbserver when it isn't started by us // but we still want // to store the list of port forwards we set up in our port forward map. diff --git a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h index 6d5bfecd99387..1bd13ffe89fea 100644 --- a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h +++ b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h @@ -33,15 +33,15 @@ public: ~PlatformAndroidRemoteGDBServer() override; - Error ConnectRemote(Args &args) override; + Status ConnectRemote(Args &args) override; - Error DisconnectRemote() override; + Status DisconnectRemote() override; lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, llvm::StringRef plugin_name, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) override; + lldb_private::Status &error) override; protected: std::string m_device_id; @@ -54,9 +54,9 @@ protected: void DeleteForwardPort(lldb::pid_t pid); - Error MakeConnectURL(const lldb::pid_t pid, const uint16_t remote_port, - llvm::StringRef remote_socket_name, - std::string &connect_url); + Status MakeConnectURL(const lldb::pid_t pid, const uint16_t remote_port, + llvm::StringRef remote_socket_name, + std::string &connect_url); private: DISALLOW_COPY_AND_ASSIGN(PlatformAndroidRemoteGDBServer); diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index 2a150b5d452b7..53cec45f986e6 100644 --- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -27,9 +27,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" // Define these constants from FreeBSD mman.h for use when targeting @@ -255,8 +255,8 @@ PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode(Target &target, } } -Error PlatformFreeBSD::LaunchProcess(ProcessLaunchInfo &launch_info) { - Error error; +Status PlatformFreeBSD::LaunchProcess(ProcessLaunchInfo &launch_info) { + Status error; if (IsHost()) { error = Platform::LaunchProcess(launch_info); } else { @@ -270,7 +270,7 @@ Error PlatformFreeBSD::LaunchProcess(ProcessLaunchInfo &launch_info) { lldb::ProcessSP PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, - Error &error) { + Status &error) { lldb::ProcessSP process_sp; if (IsHost()) { if (target == NULL) { diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h index c8ac7b29f3a23..4bde2148a4d41 100644 --- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -54,10 +54,10 @@ public: size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site) override; - Error LaunchProcess(ProcessLaunchInfo &launch_info) override; + Status LaunchProcess(ProcessLaunchInfo &launch_info) override; lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, - Target *target, Error &error) override; + Target *target, Status &error) override; void CalculateTrapHandlerSymbolNames() override; diff --git a/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp b/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp index 08a3a6aa6c26c..00327e485bf39 100644 --- a/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp +++ b/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp @@ -22,8 +22,8 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" using namespace lldb; @@ -125,8 +125,8 @@ PlatformKalimba::GetSoftwareBreakpointTrapOpcode(Target & /*target*/, return 0; } -Error PlatformKalimba::LaunchProcess(ProcessLaunchInfo &launch_info) { - Error error; +Status PlatformKalimba::LaunchProcess(ProcessLaunchInfo &launch_info) { + Status error; if (IsHost()) { error.SetErrorString("native execution is not possible"); @@ -138,7 +138,7 @@ Error PlatformKalimba::LaunchProcess(ProcessLaunchInfo &launch_info) { lldb::ProcessSP PlatformKalimba::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, - Error &error) { + Status &error) { lldb::ProcessSP process_sp; if (IsHost()) { error.SetErrorString("native execution is not possible"); diff --git a/source/Plugins/Platform/Kalimba/PlatformKalimba.h b/source/Plugins/Platform/Kalimba/PlatformKalimba.h index 0c94ec9ec8f74..53a8e5594aaa5 100644 --- a/source/Plugins/Platform/Kalimba/PlatformKalimba.h +++ b/source/Plugins/Platform/Kalimba/PlatformKalimba.h @@ -56,11 +56,11 @@ public: size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site) override; - lldb_private::Error + lldb_private::Status LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, - Target *target, Error &error) override; + Target *target, Status &error) override; // Kalimba processes can not be launched by spawning and attaching. bool CanDebugProcess() override { return false; } diff --git a/source/Plugins/Platform/Linux/PlatformLinux.cpp b/source/Plugins/Platform/Linux/PlatformLinux.cpp index 4dd5398fcfa39..0bf00ea307984 100644 --- a/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -25,9 +25,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" // Define these constants from Linux mman.h for use when targeting @@ -278,7 +278,7 @@ lldb::ProcessSP PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new // target, else use existing one - Error &error) { + Status &error) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); LLDB_LOG(log, "target {0}", target); diff --git a/source/Plugins/Platform/Linux/PlatformLinux.h b/source/Plugins/Platform/Linux/PlatformLinux.h index f1386d1e4fe50..bc7b723427f8d 100644 --- a/source/Plugins/Platform/Linux/PlatformLinux.h +++ b/source/Plugins/Platform/Linux/PlatformLinux.h @@ -55,7 +55,7 @@ public: lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, - Error &error) override; + Status &error) override; void CalculateTrapHandlerSymbolNames() override; diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp index 478d482eb0247..0197d27e76ef7 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -21,8 +21,8 @@ // Project includes #include "lldb/Host/PseudoTerminal.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "llvm/Support/Threading.h" @@ -55,14 +55,14 @@ PlatformAppleSimulator::PlatformAppleSimulator() //------------------------------------------------------------------ PlatformAppleSimulator::~PlatformAppleSimulator() {} -lldb_private::Error PlatformAppleSimulator::LaunchProcess( +lldb_private::Status PlatformAppleSimulator::LaunchProcess( lldb_private::ProcessLaunchInfo &launch_info) { #if defined(__APPLE__) LoadCoreSimulator(); CoreSimulatorSupport::Device device(GetSimulatorDevice()); if (device.GetState() != CoreSimulatorSupport::Device::State::Booted) { - Error boot_err; + Status boot_err; device.Boot(boot_err); if (boot_err.Fail()) return boot_err; @@ -72,11 +72,11 @@ lldb_private::Error PlatformAppleSimulator::LaunchProcess( if (spawned) { launch_info.SetProcessID(spawned.GetPID()); - return Error(); + return Status(); } else return spawned.GetError(); #else - Error err; + Status err; err.SetErrorString(UNSUPPORTED_ERROR); return err; #endif @@ -124,9 +124,9 @@ void PlatformAppleSimulator::GetStatus(Stream &strm) { #endif } -Error PlatformAppleSimulator::ConnectRemote(Args &args) { +Status PlatformAppleSimulator::ConnectRemote(Args &args) { #if defined(__APPLE__) - Error error; + Status error; if (args.GetArgumentCount() == 1) { if (m_device) DisconnectRemote(); @@ -156,18 +156,18 @@ Error PlatformAppleSimulator::ConnectRemote(Args &args) { } return error; #else - Error err; + Status err; err.SetErrorString(UNSUPPORTED_ERROR); return err; #endif } -Error PlatformAppleSimulator::DisconnectRemote() { +Status PlatformAppleSimulator::DisconnectRemote() { #if defined(__APPLE__) m_device.reset(); - return Error(); + return Status(); #else - Error err; + Status err; err.SetErrorString(UNSUPPORTED_ERROR); return err; #endif @@ -177,7 +177,7 @@ lldb::ProcessSP PlatformAppleSimulator::DebugProcess( ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use // existing one - Error &error) { + Status &error) { #if defined(__APPLE__) ProcessSP process_sp; // Make sure we stop at the entry point diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h index 34f2ba2d9bfb6..44feb019dc73c 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h @@ -38,19 +38,19 @@ public: virtual ~PlatformAppleSimulator(); - lldb_private::Error + lldb_private::Status LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; void GetStatus(lldb_private::Stream &strm) override; - lldb_private::Error ConnectRemote(lldb_private::Args &args) override; + lldb_private::Status ConnectRemote(lldb_private::Args &args) override; - lldb_private::Error DisconnectRemote() override; + lldb_private::Status DisconnectRemote() override; lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) override; + lldb_private::Status &error) override; protected: std::mutex m_core_sim_path_mutex; diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp index 38fe412c85743..52188eefb3661 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -23,9 +23,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "llvm/Support/FileSystem.h" @@ -171,10 +171,10 @@ void PlatformAppleTVSimulator::GetStatus(Stream &strm) { strm.PutCString(" SDK Path: error: unable to locate SDK\n"); } -Error PlatformAppleTVSimulator::ResolveExecutable( +Status PlatformAppleTVSimulator::ResolveExecutable( const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { - Error error; + Status error; // Nothing special to do here, just use the actual file and architecture ModuleSpec resolved_module_spec(module_spec); @@ -301,10 +301,10 @@ const char *PlatformAppleTVSimulator::GetSDKDirectoryAsCString() { return NULL; } -Error PlatformAppleTVSimulator::GetSymbolFile(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { - Error error; +Status PlatformAppleTVSimulator::GetSymbolFile(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { + Status error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) { char resolved_path[PATH_MAX]; @@ -333,7 +333,7 @@ Error PlatformAppleTVSimulator::GetSymbolFile(const FileSpec &platform_file, return error; } -Error PlatformAppleTVSimulator::GetSharedModule( +Status PlatformAppleTVSimulator::GetSharedModule( const ModuleSpec &module_spec, lldb_private::Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { @@ -341,7 +341,7 @@ Error PlatformAppleTVSimulator::GetSharedModule( // system. So first we ask for the file in the cached SDK, // then we attempt to get a shared module for the right architecture // with the right UUID. - Error error; + Status error; ModuleSpec platform_module_spec(module_spec); const FileSpec &platform_file = module_spec.GetFileSpec(); error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(), diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h index 311ba05d76a22..8cecb4d496ab6 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h @@ -51,7 +51,7 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ - lldb_private::Error ResolveExecutable( + lldb_private::Status ResolveExecutable( const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr) override; @@ -59,12 +59,12 @@ public: void GetStatus(lldb_private::Stream &strm) override; - virtual lldb_private::Error + virtual lldb_private::Status GetSymbolFile(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid_ptr, lldb_private::FileSpec &local_file); - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp index 1ffdc1ab7c8eb..b9f493294a037 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -23,9 +23,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" using namespace lldb; @@ -171,10 +171,10 @@ void PlatformAppleWatchSimulator::GetStatus(Stream &strm) { strm.PutCString(" SDK Path: error: unable to locate SDK\n"); } -Error PlatformAppleWatchSimulator::ResolveExecutable( +Status PlatformAppleWatchSimulator::ResolveExecutable( const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { - Error error; + Status error; // Nothing special to do here, just use the actual file and architecture ModuleSpec resolved_module_spec(module_spec); @@ -301,10 +301,10 @@ const char *PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() { return NULL; } -Error PlatformAppleWatchSimulator::GetSymbolFile(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { - Error error; +Status PlatformAppleWatchSimulator::GetSymbolFile(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { + Status error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) { char resolved_path[PATH_MAX]; @@ -333,7 +333,7 @@ Error PlatformAppleWatchSimulator::GetSymbolFile(const FileSpec &platform_file, return error; } -Error PlatformAppleWatchSimulator::GetSharedModule( +Status PlatformAppleWatchSimulator::GetSharedModule( const ModuleSpec &module_spec, lldb_private::Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { @@ -341,7 +341,7 @@ Error PlatformAppleWatchSimulator::GetSharedModule( // system. So first we ask for the file in the cached SDK, // then we attempt to get a shared module for the right architecture // with the right UUID. - Error error; + Status error; ModuleSpec platform_module_spec(module_spec); const FileSpec &platform_file = module_spec.GetFileSpec(); error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(), diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h index 2b15611df47ba..30aa42c964a55 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h @@ -51,7 +51,7 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ - lldb_private::Error ResolveExecutable( + lldb_private::Status ResolveExecutable( const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr) override; @@ -59,12 +59,12 @@ public: void GetStatus(lldb_private::Stream &strm) override; - virtual lldb_private::Error + virtual lldb_private::Status GetSymbolFile(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid_ptr, lldb_private::FileSpec &local_file); - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 02459045869ad..d69a02e41d514 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -36,8 +36,8 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferLLVM.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" @@ -195,10 +195,10 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( return file_list; } -Error PlatformDarwin::ResolveSymbolFile(Target &target, - const ModuleSpec &sym_spec, - FileSpec &sym_file) { - Error error; +Status PlatformDarwin::ResolveSymbolFile(Target &target, + const ModuleSpec &sym_spec, + FileSpec &sym_file) { + Status error; sym_file = sym_spec.GetSymbolFileSpec(); llvm::sys::fs::file_status st; @@ -219,23 +219,23 @@ Error PlatformDarwin::ResolveSymbolFile(Target &target, return error; } -static lldb_private::Error +static lldb_private::Status MakeCacheFolderForFile(const FileSpec &module_cache_spec) { FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent(); return llvm::sys::fs::create_directory(module_cache_folder.GetPath()); } -static lldb_private::Error +static lldb_private::Status BringInRemoteFile(Platform *platform, const lldb_private::ModuleSpec &module_spec, const FileSpec &module_cache_spec) { MakeCacheFolderForFile(module_cache_spec); - Error err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec); + Status err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec); return err; } -lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( +lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache( const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { @@ -252,7 +252,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( module_spec.GetSymbolFileSpec().GetDirectory().AsCString(), module_spec.GetSymbolFileSpec().GetFilename().AsCString()); - Error err; + Status err; err = ModuleList::GetSharedModule(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, @@ -286,7 +286,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( module_spec.GetArchitecture()); module_sp.reset(new Module(local_spec)); module_sp->SetPlatformFileSpec(module_spec.GetFileSpec()); - return Error(); + return Status(); } } @@ -300,7 +300,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( uint64_t high_local, high_remote, low_local, low_remote; auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.GetPath()); if (!MD5) - return Error(MD5.getError()); + return Status(MD5.getError()); std::tie(high_local, low_local) = MD5->words(); m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(), @@ -314,7 +314,8 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); - Error err = BringInRemoteFile(this, module_spec, module_cache_spec); + Status err = + BringInRemoteFile(this, module_spec, module_cache_spec); if (err.Fail()) return err; } @@ -329,7 +330,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); - return Error(); + return Status(); } // bring in the remote module file @@ -338,7 +339,7 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); - Error err = BringInRemoteFile(this, module_spec, module_cache_spec); + Status err = BringInRemoteFile(this, module_spec, module_cache_spec); if (err.Fail()) return err; if (module_cache_spec.Exists()) { @@ -351,20 +352,20 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache( ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture()); module_sp.reset(new Module(local_spec)); module_sp->SetPlatformFileSpec(module_spec.GetFileSpec()); - return Error(); + return Status(); } else - return Error("unable to obtain valid module file"); + return Status("unable to obtain valid module file"); } else - return Error("no cache path"); + return Status("no cache path"); } else - return Error("unable to resolve module"); + return Status("unable to resolve module"); } -Error PlatformDarwin::GetSharedModule( +Status PlatformDarwin::GetSharedModule( const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { - Error error; + Status error; module_sp.reset(); if (IsRemote()) { @@ -393,7 +394,7 @@ Error PlatformDarwin::GetSharedModule( ModuleSpec new_module_spec(module_spec); new_module_spec.GetFileSpec() = bundle_directory; if (Host::ResolveExecutableInBundle(new_module_spec.GetFileSpec())) { - Error new_error(Platform::GetSharedModule( + Status new_error(Platform::GetSharedModule( new_module_spec, process, module_sp, NULL, old_module_sp_ptr, did_create_ptr)); @@ -420,7 +421,7 @@ Error PlatformDarwin::GetSharedModule( if (new_file_spec.Exists()) { ModuleSpec new_module_spec(module_spec); new_module_spec.GetFileSpec() = new_file_spec; - Error new_error(Platform::GetSharedModule( + Status new_error(Platform::GetSharedModule( new_module_spec, process, module_sp, NULL, old_module_sp_ptr, did_create_ptr)); @@ -1185,7 +1186,7 @@ const char *PlatformDarwin::GetDeveloperDirectory() { int exit_status = -1; int signo = -1; std::string command_output; - Error error = + Status error = Host::RunShellCommand("/usr/bin/xcode-select --print-path", NULL, // current working directory &exit_status, &signo, &command_output, @@ -1361,7 +1362,7 @@ static FileSpec GetXcodeContentsPath() { int signo = 0; std::string output; const char *command = "/usr/bin/xcode-select -p"; - lldb_private::Error error = Host::RunShellCommand( + lldb_private::Status error = Host::RunShellCommand( command, // shell command to run NULL, // current working directory &status, // Put the exit status of the process in here @@ -1739,7 +1740,7 @@ lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) { return FileSpec(); } -lldb_private::Error +lldb_private::Status PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) { // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr // if the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/source/Plugins/Platform/MacOSX/PlatformDarwin.h index 9430c269c27e5..6495609ac495e 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -32,7 +32,7 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ - lldb_private::Error + lldb_private::Status ResolveSymbolFile(lldb_private::Target &target, const lldb_private::ModuleSpec &sym_spec, lldb_private::FileSpec &sym_file) override; @@ -41,7 +41,7 @@ public: lldb_private::Target *target, lldb_private::Module &module, lldb_private::Stream *feedback_stream) override; - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, @@ -79,7 +79,7 @@ public: lldb_private::FileSpec LocateExecutable(const char *basename) override; - lldb_private::Error + lldb_private::Status LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; static std::tuple<uint32_t, uint32_t, uint32_t, llvm::StringRef> @@ -90,7 +90,7 @@ protected: void ReadLibdispatchOffsets(lldb_private::Process *process); - virtual lldb_private::Error GetSharedModuleWithLocalCache( + virtual lldb_private::Status GetSharedModuleWithLocalCache( const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr); diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index 08df0565acc87..f168fb6fda5e8 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -31,9 +31,9 @@ #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "llvm/Support/FileSystem.h" @@ -664,11 +664,11 @@ bool PlatformDarwinKernel::KernelHasdSYMSibling(const FileSpec &kernel_binary) { return false; } -Error PlatformDarwinKernel::GetSharedModule( +Status PlatformDarwinKernel::GetSharedModule( const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { - Error error; + Status error; module_sp.reset(); const FileSpec &platform_file = module_spec.GetFileSpec(); @@ -774,10 +774,10 @@ Error PlatformDarwinKernel::GetSharedModule( old_module_sp_ptr, did_create_ptr); } -Error PlatformDarwinKernel::ExamineKextForMatchingUUID( +Status PlatformDarwinKernel::ExamineKextForMatchingUUID( const FileSpec &kext_bundle_path, const lldb_private::UUID &uuid, const ArchSpec &arch, ModuleSP &exe_module_sp) { - Error error; + Status error; FileSpec exe_file = kext_bundle_path; Host::ResolveExecutableInBundle(exe_file); if (exe_file.Exists()) { diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h index 6ee5916e613a7..9b3ec5e0d7179 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h +++ b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h @@ -66,7 +66,7 @@ public: void GetStatus(lldb_private::Stream &strm) override; - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, @@ -139,7 +139,7 @@ protected: static bool KernelHasdSYMSibling(const lldb_private::FileSpec &kext_bundle_filepath); - lldb_private::Error + lldb_private::Status ExamineKextForMatchingUUID(const lldb_private::FileSpec &kext_bundle_path, const lldb_private::UUID &uuid, const lldb_private::ArchSpec &arch, diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 11d0457a783e4..c08417a80ae42 100644 --- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -27,9 +27,9 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" using namespace lldb; @@ -190,7 +190,7 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { int signo = 0; std::string output; const char *command = "xcrun -sdk macosx --show-sdk-path"; - lldb_private::Error error = RunShellCommand( + lldb_private::Status error = RunShellCommand( command, // shell command to run NULL, // current working directory &status, // Put the exit status of the process in here @@ -235,9 +235,9 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { return ConstString(); } -Error PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { +Status PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { if (IsRemote()) { if (m_remote_platform_sp) return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr, @@ -246,10 +246,10 @@ Error PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file, // Default to the local case local_file = platform_file; - return Error(); + return Status(); } -lldb_private::Error +lldb_private::Status PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid_ptr, lldb_private::FileSpec &local_file) { @@ -263,7 +263,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, if (local_os_build.compare(remote_os_build) == 0) { // same OS version: the local file is good enough local_file = platform_file; - return Error(); + return Status(); } else { // try to find the file in the cache std::string cache_path(GetLocalCacheDirectory()); @@ -272,13 +272,14 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, FileSpec module_cache_spec(cache_path, false); if (module_cache_spec.Exists()) { local_file = module_cache_spec; - return Error(); + return Status(); } // bring in the remote module file FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent(); // try to make the local directory first - Error err(llvm::sys::fs::create_directory(module_cache_folder.GetPath())); + Status err( + llvm::sys::fs::create_directory(module_cache_folder.GetPath())); if (err.Fail()) return err; err = GetFile(platform_file, module_cache_spec); @@ -286,13 +287,13 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, return err; if (module_cache_spec.Exists()) { local_file = module_cache_spec; - return Error(); + return Status(); } else - return Error("unable to obtain valid module file"); + return Status("unable to obtain valid module file"); } } local_file = platform_file; - return Error(); + return Status(); } bool PlatformMacOSX::GetSupportedArchitectureAtIndex(uint32_t idx, @@ -304,12 +305,12 @@ bool PlatformMacOSX::GetSupportedArchitectureAtIndex(uint32_t idx, #endif } -lldb_private::Error PlatformMacOSX::GetSharedModule( +lldb_private::Status PlatformMacOSX::GetSharedModule( const lldb_private::ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { - Error error = GetSharedModuleWithLocalCache( + Status error = GetSharedModuleWithLocalCache( module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr); @@ -324,7 +325,7 @@ lldb_private::Error PlatformMacOSX::GetSharedModule( lldb::ModuleSP x86_64_module_sp; lldb::ModuleSP old_x86_64_module_sp; bool did_create = false; - Error x86_64_error = GetSharedModuleWithLocalCache( + Status x86_64_error = GetSharedModuleWithLocalCache( module_spec_x86_64, x86_64_module_sp, module_search_paths_ptr, &old_x86_64_module_sp, &did_create); if (x86_64_module_sp && x86_64_module_sp->GetObjectFile()) { diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.h b/source/Plugins/Platform/MacOSX/PlatformMacOSX.h index d5b5d69f1fb3e..d1e609258d4d7 100644 --- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.h +++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.h @@ -45,7 +45,7 @@ public: uint32_t GetPluginVersion() override { return 1; } - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, @@ -56,17 +56,18 @@ public: return GetDescriptionStatic(IsHost()); } - lldb_private::Error GetSymbolFile(const lldb_private::FileSpec &platform_file, - const lldb_private::UUID *uuid_ptr, - lldb_private::FileSpec &local_file); + lldb_private::Status + GetSymbolFile(const lldb_private::FileSpec &platform_file, + const lldb_private::UUID *uuid_ptr, + lldb_private::FileSpec &local_file); - lldb_private::Error + lldb_private::Status GetFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination) override { return PlatformDarwin::GetFile(source, destination); } - lldb_private::Error + lldb_private::Status GetFileWithUUID(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid_ptr, lldb_private::FileSpec &local_file) override; diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp index 6fdaa5997b46a..38facc4aa124c 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -25,9 +25,9 @@ #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" using namespace lldb; diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp index 1869264309730..bbd8f16989370 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -25,9 +25,9 @@ #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" using namespace lldb; diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp index 0302e7b3aaf80..f7395fb8cf3d2 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp @@ -22,9 +22,9 @@ #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" using namespace lldb; @@ -75,10 +75,10 @@ void PlatformRemoteDarwinDevice::GetStatus(Stream &strm) { } } -Error PlatformRemoteDarwinDevice::ResolveExecutable( +Status PlatformRemoteDarwinDevice::ResolveExecutable( const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { - Error error; + Status error; // Nothing special to do here, just use the actual file and architecture ModuleSpec resolved_module_spec(ms); @@ -429,11 +429,11 @@ bool PlatformRemoteDarwinDevice::GetFileInSDK(const char *platform_file_path, return false; } -Error PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { +Status PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); - Error error; + Status error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) { char resolved_path[PATH_MAX]; @@ -489,7 +489,7 @@ Error PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, return error; } -Error PlatformRemoteDarwinDevice::GetSharedModule( +Status PlatformRemoteDarwinDevice::GetSharedModule( const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { @@ -500,7 +500,7 @@ Error PlatformRemoteDarwinDevice::GetSharedModule( const FileSpec &platform_file = module_spec.GetFileSpec(); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); - Error error; + Status error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) { @@ -657,7 +657,7 @@ Error PlatformRemoteDarwinDevice::GetSharedModule( if (path_to_try.Exists()) { ModuleSpec new_module_spec(module_spec); new_module_spec.GetFileSpec() = path_to_try; - Error new_error(Platform::GetSharedModule( + Status new_error(Platform::GetSharedModule( new_module_spec, process, module_sp, NULL, old_module_sp_ptr, did_create_ptr)); diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h index 55fb4f920c666..f159e8575d765 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h @@ -30,18 +30,18 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ - lldb_private::Error ResolveExecutable( + lldb_private::Status ResolveExecutable( const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr) override; void GetStatus(lldb_private::Stream &strm) override; - virtual lldb_private::Error + virtual lldb_private::Status GetSymbolFile(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid_ptr, lldb_private::FileSpec &local_file); - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index ec1109fb4b44d..c52b636c8496f 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -22,9 +22,9 @@ #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" using namespace lldb; diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp index 9a082c701f028..3037dd854be70 100644 --- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -24,9 +24,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "llvm/Support/FileSystem.h" @@ -177,10 +177,10 @@ void PlatformiOSSimulator::GetStatus(Stream &strm) { PlatformAppleSimulator::GetStatus(strm); } -Error PlatformiOSSimulator::ResolveExecutable( +Status PlatformiOSSimulator::ResolveExecutable( const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { - Error error; + Status error; // Nothing special to do here, just use the actual file and architecture ModuleSpec resolved_module_spec(module_spec); @@ -306,10 +306,10 @@ const char *PlatformiOSSimulator::GetSDKDirectoryAsCString() { return NULL; } -Error PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { - Error error; +Status PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { + Status error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) { char resolved_path[PATH_MAX]; @@ -338,7 +338,7 @@ Error PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file, return error; } -Error PlatformiOSSimulator::GetSharedModule( +Status PlatformiOSSimulator::GetSharedModule( const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { @@ -346,7 +346,7 @@ Error PlatformiOSSimulator::GetSharedModule( // system. So first we ask for the file in the cached SDK, // then we attempt to get a shared module for the right architecture // with the right UUID. - Error error; + Status error; ModuleSpec platform_module_spec(module_spec); const FileSpec &platform_file = module_spec.GetFileSpec(); error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(), diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h index c8c7872b530db..2d81d6229f73a 100644 --- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h @@ -51,7 +51,7 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ - lldb_private::Error ResolveExecutable( + lldb_private::Status ResolveExecutable( const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr) override; @@ -59,12 +59,12 @@ public: void GetStatus(lldb_private::Stream &strm) override; - virtual lldb_private::Error + virtual lldb_private::Status GetSymbolFile(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid_ptr, lldb_private::FileSpec &local_file); - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h index 2a2a6f73a0e12..31e11a60e4196 100644 --- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h +++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h @@ -27,7 +27,7 @@ typedef void *id; #include "lldb/Interpreter/Args.h" #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" #include "llvm/ADT/Optional.h" @@ -39,17 +39,17 @@ public: explicit operator bool() { return m_pid != LLDB_INVALID_PROCESS_ID; } - lldb_private::Error GetError() { return m_error; } + lldb_private::Status GetError() { return m_error; } private: Process(lldb::pid_t p); - Process(lldb_private::Error error); + Process(lldb_private::Status error); - Process(lldb::pid_t p, lldb_private::Error error); + Process(lldb::pid_t p, lldb_private::Status error); lldb::pid_t m_pid; - lldb_private::Error m_error; + lldb_private::Status m_error; friend class Device; }; @@ -165,9 +165,9 @@ public: State GetState(); - bool Boot(lldb_private::Error &err); + bool Boot(lldb_private::Status &err); - bool Shutdown(lldb_private::Error &err); + bool Shutdown(lldb_private::Status &err); std::string GetUDID() const; diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm index de92aa0de7aaa..6a49b645c1e17 100644 --- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm +++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm @@ -61,10 +61,10 @@ using namespace lldb_utility; CoreSimulatorSupport::Process::Process(lldb::pid_t p) : m_pid(p), m_error() {} -CoreSimulatorSupport::Process::Process(Error error) +CoreSimulatorSupport::Process::Process(Status error) : m_pid(LLDB_INVALID_PROCESS_ID), m_error(error) {} -CoreSimulatorSupport::Process::Process(lldb::pid_t p, Error error) +CoreSimulatorSupport::Process::Process(lldb::pid_t p, Status error) : m_pid(p), m_error(error) {} CoreSimulatorSupport::DeviceType::DeviceType() @@ -345,7 +345,7 @@ operator!=(const CoreSimulatorSupport::ModelIdentifier &lhs, return false; } -bool CoreSimulatorSupport::Device::Boot(Error &err) { +bool CoreSimulatorSupport::Device::Boot(Status &err) { if (m_dev == nil) { err.SetErrorString("no valid simulator instance"); return false; @@ -371,7 +371,7 @@ bool CoreSimulatorSupport::Device::Boot(Error &err) { } } -bool CoreSimulatorSupport::Device::Shutdown(Error &err) { +bool CoreSimulatorSupport::Device::Shutdown(Status &err) { NSError *nserror; if ([m_dev shutdownWithError:&nserror]) { err.Clear(); @@ -382,10 +382,10 @@ bool CoreSimulatorSupport::Device::Shutdown(Error &err) { } } -static Error HandleFileAction(ProcessLaunchInfo &launch_info, - NSMutableDictionary *options, NSString *key, - const int fd, File &file) { - Error error; +static Status HandleFileAction(ProcessLaunchInfo &launch_info, + NSMutableDictionary *options, NSString *key, + const int fd, File &file) { + Status error; const FileAction *file_action = launch_info.GetFileActionForFD(fd); if (file_action) { switch (file_action->GetAction()) { @@ -426,7 +426,7 @@ static Error HandleFileAction(ProcessLaunchInfo &launch_info, } } } - Error posix_error; + Status posix_error; int created_fd = open(file_spec.GetPath().c_str(), file_action->GetActionArgument(), S_IRUSR | S_IWUSR); @@ -499,7 +499,7 @@ CoreSimulatorSupport::Device::Spawn(ProcessLaunchInfo &launch_info) { [options setObject:env_dict forKey:kSimDeviceSpawnEnvironment]; } - Error error; + Status error; File stdin_file; File stdout_file; File stderr_file; diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp index 409f12deefcae..9df5b9fac3805 100644 --- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -25,9 +25,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" // Define these constants from NetBSD mman.h for use when targeting @@ -262,11 +262,11 @@ bool PlatformNetBSD::CanDebugProcess() { // lldb-launch, llgs-attach. This differs from current lldb-launch, // debugserver-attach // approach on MacOSX. -lldb::ProcessSP -PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, - Target *target, // Can be NULL, if NULL create a new - // target, else use existing one - Error &error) { +lldb::ProcessSP PlatformNetBSD::DebugProcess( + ProcessLaunchInfo &launch_info, Debugger &debugger, + Target *target, // Can be NULL, if NULL create a new + // target, else use existing one + Status &error) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) log->Printf("PlatformNetBSD::%s entered (target %p)", __FUNCTION__, diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h index 500c61dab9706..b1aaa4ab5f59c 100644 --- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h +++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h @@ -55,7 +55,7 @@ public: lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, - Error &error) override; + Status &error) override; void CalculateTrapHandlerSymbolNames() override; diff --git a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp index e3816d0276b27..edb8ec951d374 100644 --- a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp +++ b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp @@ -25,9 +25,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" // Define these constants from OpenBSD mman.h for use when targeting diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index 0032c804987c5..f4cf22ad75830 100644 --- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -88,7 +88,7 @@ bool PlatformPOSIX::IsConnected() const { return false; } -lldb_private::Error PlatformPOSIX::RunShellCommand( +lldb_private::Status PlatformPOSIX::RunShellCommand( const char *command, // Shouldn't be NULL const FileSpec & working_dir, // Pass empty FileSpec to use the current working directory @@ -109,14 +109,15 @@ lldb_private::Error PlatformPOSIX::RunShellCommand( status_ptr, signo_ptr, command_output, timeout_sec); else - return Error("unable to run a remote command without a platform"); + return Status("unable to run a remote command without a platform"); } } -Error PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec, - lldb::ModuleSP &exe_module_sp, - const FileSpecList *module_search_paths_ptr) { - Error error; +Status +PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec, + lldb::ModuleSP &exe_module_sp, + const FileSpecList *module_search_paths_ptr) { + Status error; // Nothing special to do here, just use the actual file and architecture char exe_path[PATH_MAX]; @@ -250,16 +251,16 @@ Error PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec, return error; } -Error PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { +Status PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { if (IsRemote() && m_remote_platform_sp) return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr, local_file); // Default to the local case local_file = platform_file; - return Error(); + return Status(); } bool PlatformPOSIX::GetProcessInfo(lldb::pid_t pid, @@ -282,16 +283,16 @@ PlatformPOSIX::FindProcesses(const ProcessInstanceInfoMatch &match_info, return 0; } -Error PlatformPOSIX::MakeDirectory(const FileSpec &file_spec, - uint32_t file_permissions) { +Status PlatformPOSIX::MakeDirectory(const FileSpec &file_spec, + uint32_t file_permissions) { if (m_remote_platform_sp) return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions); else return Platform::MakeDirectory(file_spec, file_permissions); } -Error PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { +Status PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec, + uint32_t &file_permissions) { if (m_remote_platform_sp) return m_remote_platform_sp->GetFilePermissions(file_spec, file_permissions); @@ -299,8 +300,8 @@ Error PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec, return Platform::GetFilePermissions(file_spec, file_permissions); } -Error PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { +Status PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec, + uint32_t file_permissions) { if (m_remote_platform_sp) return m_remote_platform_sp->SetFilePermissions(file_spec, file_permissions); @@ -310,7 +311,7 @@ Error PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec, lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec, uint32_t flags, uint32_t mode, - Error &error) { + Status &error) { if (IsHost()) return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error); else if (m_remote_platform_sp) @@ -319,7 +320,7 @@ lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec, return Platform::OpenFile(file_spec, flags, mode, error); } -bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Error &error) { +bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Status &error) { if (IsHost()) return FileCache::GetInstance().CloseFile(fd, error); else if (m_remote_platform_sp) @@ -329,7 +330,7 @@ bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Error &error) { } uint64_t PlatformPOSIX::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, - uint64_t dst_len, Error &error) { + uint64_t dst_len, Status &error) { if (IsHost()) return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error); else if (m_remote_platform_sp) @@ -340,7 +341,7 @@ uint64_t PlatformPOSIX::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t PlatformPOSIX::WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, - Error &error) { + Status &error) { if (IsHost()) return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error); else if (m_remote_platform_sp) @@ -370,7 +371,7 @@ static uint32_t chown_file(Platform *platform, const char *path, return status; } -lldb_private::Error +lldb_private::Status PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination, uint32_t uid, uint32_t gid) { @@ -378,34 +379,34 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, if (IsHost()) { if (FileSpec::Equal(source, destination, true)) - return Error(); + return Status(); // cp src dst // chown uid:gid dst std::string src_path(source.GetPath()); if (src_path.empty()) - return Error("unable to get file path for source"); + return Status("unable to get file path for source"); std::string dst_path(destination.GetPath()); if (dst_path.empty()) - return Error("unable to get file path for destination"); + return Status("unable to get file path for destination"); StreamString command; command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str()); int status; RunShellCommand(command.GetData(), NULL, &status, NULL, NULL, 10); if (status != 0) - return Error("unable to perform copy"); + return Status("unable to perform copy"); if (uid == UINT32_MAX && gid == UINT32_MAX) - return Error(); + return Status(); if (chown_file(this, dst_path.c_str(), uid, gid) != 0) - return Error("unable to perform chown"); - return Error(); + return Status("unable to perform chown"); + return Status(); } else if (m_remote_platform_sp) { if (GetSupportsRSync()) { std::string src_path(source.GetPath()); if (src_path.empty()) - return Error("unable to get file path for source"); + return Status("unable to get file path for source"); std::string dst_path(destination.GetPath()); if (dst_path.empty()) - return Error("unable to get file path for destination"); + return Status("unable to get file path for destination"); StreamString command; if (GetIgnoresRemoteHostname()) { if (!GetRSyncPrefix()) @@ -424,8 +425,8 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source, if (retcode == 0) { // Don't chown a local file for a remote system // if (chown_file(this,dst_path.c_str(),uid,gid) != 0) - // return Error("unable to perform chown"); - return Error(); + // return Status("unable to perform chown"); + return Status(); } // if we are still here rsync has failed - let's try the slow way before // giving up @@ -446,7 +447,7 @@ lldb::user_id_t PlatformPOSIX::GetFileSize(const FileSpec &file_spec) { return Platform::GetFileSize(file_spec); } -Error PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) { +Status PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) { if (IsHost()) return FileSystem::Symlink(src, dst); else if (m_remote_platform_sp) @@ -464,7 +465,7 @@ bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) { return Platform::GetFileExists(file_spec); } -Error PlatformPOSIX::Unlink(const FileSpec &file_spec) { +Status PlatformPOSIX::Unlink(const FileSpec &file_spec) { if (IsHost()) return llvm::sys::fs::remove(file_spec.GetPath()); else if (m_remote_platform_sp) @@ -473,7 +474,7 @@ Error PlatformPOSIX::Unlink(const FileSpec &file_spec) { return Platform::Unlink(file_spec); } -lldb_private::Error PlatformPOSIX::GetFile( +lldb_private::Status PlatformPOSIX::GetFile( const lldb_private::FileSpec &source, // remote file path const lldb_private::FileSpec &destination) // local file path { @@ -482,22 +483,22 @@ lldb_private::Error PlatformPOSIX::GetFile( // Check the args, first. std::string src_path(source.GetPath()); if (src_path.empty()) - return Error("unable to get file path for source"); + return Status("unable to get file path for source"); std::string dst_path(destination.GetPath()); if (dst_path.empty()) - return Error("unable to get file path for destination"); + return Status("unable to get file path for destination"); if (IsHost()) { if (FileSpec::Equal(source, destination, true)) - return Error("local scenario->source and destination are the same file " - "path: no operation performed"); + return Status("local scenario->source and destination are the same file " + "path: no operation performed"); // cp src dst StreamString cp_command; cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str()); int status; RunShellCommand(cp_command.GetData(), NULL, &status, NULL, NULL, 10); if (status != 0) - return Error("unable to perform copy"); - return Error(); + return Status("unable to perform copy"); + return Status(); } else if (m_remote_platform_sp) { if (GetSupportsRSync()) { StreamString command; @@ -517,7 +518,7 @@ lldb_private::Error PlatformPOSIX::GetFile( int retcode; Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL, 60); if (retcode == 0) - return Error(); + return Status(); // If we are here, rsync has failed - let's try the slow way before giving // up } @@ -527,12 +528,12 @@ lldb_private::Error PlatformPOSIX::GetFile( // close dst if (log) log->Printf("[GetFile] Using block by block transfer....\n"); - Error error; + Status error; user_id_t fd_src = OpenFile(source, File::eOpenOptionRead, lldb::eFilePermissionsFileDefault, error); if (fd_src == UINT64_MAX) - return Error("unable to open source file"); + return Status("unable to open source file"); uint32_t permissions = 0; error = GetFilePermissions(source, permissions); @@ -710,8 +711,8 @@ const char *PlatformPOSIX::GetGroupName(uint32_t gid) { return NULL; } -Error PlatformPOSIX::ConnectRemote(Args &args) { - Error error; +Status PlatformPOSIX::ConnectRemote(Args &args) { + Status error; if (IsHost()) { error.SetErrorStringWithFormat( "can't connect to the host platform '%s', always connected", @@ -753,8 +754,8 @@ Error PlatformPOSIX::ConnectRemote(Args &args) { return error; } -Error PlatformPOSIX::DisconnectRemote() { - Error error; +Status PlatformPOSIX::DisconnectRemote() { + Status error; if (IsHost()) { error.SetErrorStringWithFormat( @@ -769,8 +770,8 @@ Error PlatformPOSIX::DisconnectRemote() { return error; } -Error PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) { - Error error; +Status PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) { + Status error; if (IsHost()) { error = Platform::LaunchProcess(launch_info); @@ -783,19 +784,19 @@ Error PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) { return error; } -lldb_private::Error PlatformPOSIX::KillProcess(const lldb::pid_t pid) { +lldb_private::Status PlatformPOSIX::KillProcess(const lldb::pid_t pid) { if (IsHost()) return Platform::KillProcess(pid); if (m_remote_platform_sp) return m_remote_platform_sp->KillProcess(pid); - return Error("the platform is not currently connected"); + return Status("the platform is not currently connected"); } lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, - Error &error) { + Status &error) { lldb::ProcessSP process_sp; Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); @@ -855,7 +856,7 @@ lldb::ProcessSP PlatformPOSIX::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new // target, else use existing one - Error &error) { + Status &error) { ProcessSP process_sp; if (IsHost()) { @@ -881,23 +882,23 @@ void PlatformPOSIX::CalculateTrapHandlerSymbolNames() { m_trap_handlers.push_back(ConstString("_sigtramp")); } -Error PlatformPOSIX::EvaluateLibdlExpression( +Status PlatformPOSIX::EvaluateLibdlExpression( lldb_private::Process *process, const char *expr_cstr, const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp) { DynamicLoader *loader = process->GetDynamicLoader(); if (loader) { - Error error = loader->CanLoadImage(); + Status error = loader->CanLoadImage(); if (error.Fail()) return error; } ThreadSP thread_sp(process->GetThreadList().GetExpressionExecutionThread()); if (!thread_sp) - return Error("Selected thread isn't valid"); + return Status("Selected thread isn't valid"); StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0)); if (!frame_sp) - return Error("Frame 0 isn't valid"); + return Status("Frame 0 isn't valid"); ExecutionContext exe_ctx; frame_sp->CalculateExecutionContext(exe_ctx); @@ -910,7 +911,7 @@ Error PlatformPOSIX::EvaluateLibdlExpression( // don't do the work to trap them. expr_options.SetTimeout(std::chrono::seconds(2)); - Error expr_error; + Status expr_error; ExpressionResults result = UserExpression::Evaluate(exe_ctx, expr_options, expr_cstr, expr_prefix, result_valobj_sp, expr_error); @@ -919,12 +920,12 @@ Error PlatformPOSIX::EvaluateLibdlExpression( if (result_valobj_sp->GetError().Fail()) return result_valobj_sp->GetError(); - return Error(); + return Status(); } uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process, const lldb_private::FileSpec &remote_file, - lldb_private::Error &error) { + lldb_private::Status &error) { char path[PATH_MAX]; remote_file.GetPath(path, sizeof(path)); @@ -983,18 +984,18 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process, return LLDB_INVALID_IMAGE_TOKEN; } -Error PlatformPOSIX::UnloadImage(lldb_private::Process *process, - uint32_t image_token) { +Status PlatformPOSIX::UnloadImage(lldb_private::Process *process, + uint32_t image_token) { const addr_t image_addr = process->GetImagePtrFromToken(image_token); if (image_addr == LLDB_INVALID_ADDRESS) - return Error("Invalid image token"); + return Status("Invalid image token"); StreamString expr; expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr); const char *prefix = GetLibdlFunctionDeclarations(); lldb::ValueObjectSP result_valobj_sp; - Error error = EvaluateLibdlExpression(process, expr.GetData(), prefix, - result_valobj_sp); + Status error = EvaluateLibdlExpression(process, expr.GetData(), prefix, + result_valobj_sp); if (error.Fail()) return error; @@ -1004,17 +1005,17 @@ Error PlatformPOSIX::UnloadImage(lldb_private::Process *process, Scalar scalar; if (result_valobj_sp->ResolveValue(scalar)) { if (scalar.UInt(1)) - return Error("expression failed: \"%s\"", expr.GetData()); + return Status("expression failed: \"%s\"", expr.GetData()); process->ResetImageToken(image_token); } - return Error(); + return Status(); } lldb::ProcessSP PlatformPOSIX::ConnectProcess(llvm::StringRef connect_url, llvm::StringRef plugin_name, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) { + lldb_private::Status &error) { if (m_remote_platform_sp) return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name, debugger, target, error); @@ -1033,7 +1034,7 @@ const char *PlatformPOSIX::GetLibdlFunctionDeclarations() const { } size_t PlatformPOSIX::ConnectToWaitingProcesses(Debugger &debugger, - Error &error) { + Status &error) { if (m_remote_platform_sp) return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error); return Platform::ConnectToWaitingProcesses(debugger, error); diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h index 6c5c62797a6ed..742702b07b88e 100644 --- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -43,29 +43,30 @@ public: const char *GetGroupName(uint32_t gid) override; - lldb_private::Error PutFile(const lldb_private::FileSpec &source, - const lldb_private::FileSpec &destination, - uint32_t uid = UINT32_MAX, - uint32_t gid = UINT32_MAX) override; + lldb_private::Status PutFile(const lldb_private::FileSpec &source, + const lldb_private::FileSpec &destination, + uint32_t uid = UINT32_MAX, + uint32_t gid = UINT32_MAX) override; lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec, uint32_t flags, uint32_t mode, - lldb_private::Error &error) override; + lldb_private::Status &error) override; - bool CloseFile(lldb::user_id_t fd, lldb_private::Error &error) override; + bool CloseFile(lldb::user_id_t fd, lldb_private::Status &error) override; uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, - uint64_t dst_len, lldb_private::Error &error) override; + uint64_t dst_len, lldb_private::Status &error) override; uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, - uint64_t src_len, lldb_private::Error &error) override; + uint64_t src_len, lldb_private::Status &error) override; lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override; - lldb_private::Error CreateSymlink(const lldb_private::FileSpec &src, - const lldb_private::FileSpec &dst) override; + lldb_private::Status + CreateSymlink(const lldb_private::FileSpec &src, + const lldb_private::FileSpec &dst) override; - lldb_private::Error + lldb_private::Status GetFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination) override; @@ -88,7 +89,7 @@ public: bool IsConnected() const override; - lldb_private::Error RunShellCommand( + lldb_private::Status RunShellCommand( const char *command, // Shouldn't be nullptr const lldb_private::FileSpec &working_dir, // Pass empty FileSpec to use // the current working @@ -101,37 +102,39 @@ public: uint32_t timeout_sec) override; // Timeout in seconds to wait for shell program to finish - lldb_private::Error ResolveExecutable(const lldb_private::ModuleSpec &module_spec, - lldb::ModuleSP &module_sp, + lldb_private::Status ResolveExecutable( + const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr) override; - lldb_private::Error GetFileWithUUID(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid, - lldb_private::FileSpec &local_file) override; + lldb_private::Status + GetFileWithUUID(const lldb_private::FileSpec &platform_file, + const lldb_private::UUID *uuid, + lldb_private::FileSpec &local_file) override; bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override; uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info, lldb_private::ProcessInstanceInfoList &process_infos) override; - lldb_private::Error MakeDirectory(const lldb_private::FileSpec &file_spec, - uint32_t mode) override; + lldb_private::Status MakeDirectory(const lldb_private::FileSpec &file_spec, + uint32_t mode) override; - lldb_private::Error + lldb_private::Status GetFilePermissions(const lldb_private::FileSpec &file_spec, uint32_t &file_permissions) override; - lldb_private::Error + lldb_private::Status SetFilePermissions(const lldb_private::FileSpec &file_spec, uint32_t file_permissions) override; bool GetFileExists(const lldb_private::FileSpec &file_spec) override; - lldb_private::Error Unlink(const lldb_private::FileSpec &file_spec) override; + lldb_private::Status Unlink(const lldb_private::FileSpec &file_spec) override; - lldb_private::Error + lldb_private::Status LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; - lldb_private::Error KillProcess(const lldb::pid_t pid) override; + lldb_private::Status KillProcess(const lldb::pid_t pid) override; lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, @@ -139,7 +142,7 @@ public: // nullptr create a new // target, else use // existing one - lldb_private::Error &error) override; + lldb_private::Status &error) override; lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, @@ -148,7 +151,7 @@ public: // create a new // target, else use // existing one - lldb_private::Error &error) override; + lldb_private::Status &error) override; std::string GetPlatformSpecificConnectionInformation() override; @@ -157,25 +160,25 @@ public: void CalculateTrapHandlerSymbolNames() override; - lldb_private::Error ConnectRemote(lldb_private::Args &args) override; + lldb_private::Status ConnectRemote(lldb_private::Args &args) override; - lldb_private::Error DisconnectRemote() override; + lldb_private::Status DisconnectRemote() override; uint32_t DoLoadImage(lldb_private::Process *process, const lldb_private::FileSpec &remote_file, - lldb_private::Error &error) override; + lldb_private::Status &error) override; - lldb_private::Error UnloadImage(lldb_private::Process *process, - uint32_t image_token) override; + lldb_private::Status UnloadImage(lldb_private::Process *process, + uint32_t image_token) override; lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, llvm::StringRef plugin_name, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) override; + lldb_private::Status &error) override; size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, - lldb_private::Error &error) override; + lldb_private::Status &error) override; lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override; @@ -193,7 +196,7 @@ protected: lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a // remote POSIX-compliant OS - lldb_private::Error + lldb_private::Status EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr, const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp); diff --git a/source/Plugins/Platform/Windows/PlatformWindows.cpp b/source/Plugins/Platform/Windows/PlatformWindows.cpp index f57842ee6e513..3535df0c65ccd 100644 --- a/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -27,7 +27,7 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" using namespace lldb; using namespace lldb_private; @@ -180,10 +180,10 @@ bool PlatformWindows::GetModuleSpec(const FileSpec &module_file_spec, return Platform::GetModuleSpec(module_file_spec, arch, module_spec); } -Error PlatformWindows::ResolveExecutable( +Status PlatformWindows::ResolveExecutable( const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { - Error error; + Status error; // Nothing special to do here, just use the actual file and architecture char exe_path[PATH_MAX]; @@ -323,8 +323,8 @@ bool PlatformWindows::IsConnected() const { return false; } -Error PlatformWindows::ConnectRemote(Args &args) { - Error error; +Status PlatformWindows::ConnectRemote(Args &args) { + Status error; if (IsHost()) { error.SetErrorStringWithFormat( "can't connect to the host platform '%s', always connected", @@ -353,8 +353,8 @@ Error PlatformWindows::ConnectRemote(Args &args) { return error; } -Error PlatformWindows::DisconnectRemote() { - Error error; +Status PlatformWindows::DisconnectRemote() { + Status error; if (IsHost()) { error.SetErrorStringWithFormat( @@ -396,8 +396,8 @@ PlatformWindows::FindProcesses(const ProcessInstanceInfoMatch &match_info, return match_count; } -Error PlatformWindows::LaunchProcess(ProcessLaunchInfo &launch_info) { - Error error; +Status PlatformWindows::LaunchProcess(ProcessLaunchInfo &launch_info) { + Status error; if (IsHost()) { error = Platform::LaunchProcess(launch_info); } else { @@ -411,7 +411,7 @@ Error PlatformWindows::LaunchProcess(ProcessLaunchInfo &launch_info) { ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, - Error &error) { + Status &error) { // Windows has special considerations that must be followed when launching or // attaching to a process. The // key requirement is that when launching or attaching to a process, you must @@ -457,7 +457,7 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info, lldb::ProcessSP PlatformWindows::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, - Error &error) { + Status &error) { error.Clear(); lldb::ProcessSP process_sp; if (!IsHost()) { @@ -516,9 +516,9 @@ const char *PlatformWindows::GetGroupName(uint32_t gid) { return nullptr; } -Error PlatformWindows::GetFileWithUUID(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { +Status PlatformWindows::GetFileWithUUID(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { if (IsRemote()) { if (m_remote_platform_sp) return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr, @@ -527,14 +527,14 @@ Error PlatformWindows::GetFileWithUUID(const FileSpec &platform_file, // Default to the local case local_file = platform_file; - return Error(); + return Status(); } -Error PlatformWindows::GetSharedModule( +Status PlatformWindows::GetSharedModule( const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { - Error error; + Status error; module_sp.reset(); if (IsRemote()) { diff --git a/source/Plugins/Platform/Windows/PlatformWindows.h b/source/Plugins/Platform/Windows/PlatformWindows.h index 375d5c5dad2f7..9af42116680ee 100644 --- a/source/Plugins/Platform/Windows/PlatformWindows.h +++ b/source/Plugins/Platform/Windows/PlatformWindows.h @@ -49,9 +49,10 @@ public: const lldb_private::ArchSpec &arch, lldb_private::ModuleSpec &module_spec) override; - Error ResolveExecutable(const lldb_private::ModuleSpec &module_spec, - lldb::ModuleSP &module_sp, - const FileSpecList *module_search_paths_ptr) override; + Status + ResolveExecutable(const lldb_private::ModuleSpec &module_spec, + lldb::ModuleSP &module_sp, + const FileSpecList *module_search_paths_ptr) override; const char *GetDescription() override { return GetPluginDescriptionStatic(IsHost()); @@ -68,9 +69,9 @@ public: bool IsConnected() const override; - lldb_private::Error ConnectRemote(lldb_private::Args &args) override; + lldb_private::Status ConnectRemote(lldb_private::Args &args) override; - lldb_private::Error DisconnectRemote() override; + lldb_private::Status DisconnectRemote() override; const char *GetHostname() override; @@ -85,25 +86,25 @@ public: FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info, lldb_private::ProcessInstanceInfoList &process_infos) override; - lldb_private::Error + lldb_private::Status LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override; lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) override; + lldb_private::Status &error) override; lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) override; + lldb_private::Status &error) override; - lldb_private::Error + lldb_private::Status GetFileWithUUID(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid, lldb_private::FileSpec &local_file) override; - lldb_private::Error + lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 218c628601149..645bfdfa770da 100644 --- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -25,9 +25,9 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UriParser.h" @@ -93,12 +93,12 @@ const char *PlatformRemoteGDBServer::GetDescription() { return GetDescriptionStatic(); } -Error PlatformRemoteGDBServer::ResolveExecutable( +Status PlatformRemoteGDBServer::ResolveExecutable( const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { // copied from PlatformRemoteiOS - Error error; + Status error; // Nothing special to do here, just use the actual file and architecture ModuleSpec resolved_module_spec(module_spec); @@ -189,12 +189,12 @@ bool PlatformRemoteGDBServer::GetModuleSpec(const FileSpec &module_file_spec, return true; } -Error PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file, - const UUID *uuid_ptr, - FileSpec &local_file) { +Status PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file, + const UUID *uuid_ptr, + FileSpec &local_file) { // Default to the local case local_file = platform_file; - return Error(); + return Status(); } //------------------------------------------------------------------ @@ -291,8 +291,8 @@ bool PlatformRemoteGDBServer::IsConnected() const { return m_gdb_client.IsConnected(); } -Error PlatformRemoteGDBServer::ConnectRemote(Args &args) { - Error error; +Status PlatformRemoteGDBServer::ConnectRemote(Args &args) { + Status error; if (IsConnected()) { error.SetErrorStringWithFormat("the platform is already connected to '%s', " "execute 'platform disconnect' to close the " @@ -306,10 +306,10 @@ Error PlatformRemoteGDBServer::ConnectRemote(Args &args) { std::string path; const char *url = args.GetArgumentAtIndex(0); if (!url) - return Error("URL is null."); + return Status("URL is null."); llvm::StringRef scheme, hostname, pathname; if (!UriParser::Parse(url, scheme, hostname, port, pathname)) - return Error("Invalid URL: %s", url); + return Status("Invalid URL: %s", url); m_platform_scheme = scheme; m_platform_hostname = hostname; path = pathname; @@ -336,8 +336,8 @@ Error PlatformRemoteGDBServer::ConnectRemote(Args &args) { return error; } -Error PlatformRemoteGDBServer::DisconnectRemote() { - Error error; +Status PlatformRemoteGDBServer::DisconnectRemote() { + Status error; m_gdb_client.Disconnect(&error); m_remote_signals_sp.reset(); return error; @@ -386,9 +386,9 @@ bool PlatformRemoteGDBServer::GetProcessInfo( return m_gdb_client.GetProcessInfo(pid, process_info); } -Error PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { +Status PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); - Error error; + Status error; if (log) log->Printf("PlatformRemoteGDBServer::%s() called", __FUNCTION__); @@ -480,17 +480,17 @@ Error PlatformRemoteGDBServer::LaunchProcess(ProcessLaunchInfo &launch_info) { return error; } -Error PlatformRemoteGDBServer::KillProcess(const lldb::pid_t pid) { +Status PlatformRemoteGDBServer::KillProcess(const lldb::pid_t pid) { if (!KillSpawnedProcess(pid)) - return Error("failed to kill remote spawned process"); - return Error(); + return Status("failed to kill remote spawned process"); + return Status(); } lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess( ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use // existing one - Error &error) { + Status &error) { lldb::ProcessSP process_sp; if (IsRemote()) { if (IsConnected()) { @@ -577,7 +577,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach( ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use // existing one - Error &error) { + Status &error) { lldb::ProcessSP process_sp; if (IsRemote()) { if (IsConnected()) { @@ -625,9 +625,9 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach( return process_sp; } -Error PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec, - uint32_t mode) { - Error error = m_gdb_client.MakeDirectory(file_spec, mode); +Status PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec, + uint32_t mode) { + Status error = m_gdb_client.MakeDirectory(file_spec, mode); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); if (log) log->Printf("PlatformRemoteGDBServer::MakeDirectory(path='%s', mode=%o) " @@ -637,9 +637,9 @@ Error PlatformRemoteGDBServer::MakeDirectory(const FileSpec &file_spec, return error; } -Error PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { - Error error = m_gdb_client.GetFilePermissions(file_spec, file_permissions); +Status PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec, + uint32_t &file_permissions) { + Status error = m_gdb_client.GetFilePermissions(file_spec, file_permissions); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); if (log) log->Printf("PlatformRemoteGDBServer::GetFilePermissions(path='%s', " @@ -649,9 +649,9 @@ Error PlatformRemoteGDBServer::GetFilePermissions(const FileSpec &file_spec, return error; } -Error PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { - Error error = m_gdb_client.SetFilePermissions(file_spec, file_permissions); +Status PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec, + uint32_t file_permissions) { + Status error = m_gdb_client.SetFilePermissions(file_spec, file_permissions); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); if (log) log->Printf("PlatformRemoteGDBServer::SetFilePermissions(path='%s', " @@ -663,11 +663,11 @@ Error PlatformRemoteGDBServer::SetFilePermissions(const FileSpec &file_spec, lldb::user_id_t PlatformRemoteGDBServer::OpenFile(const FileSpec &file_spec, uint32_t flags, uint32_t mode, - Error &error) { + Status &error) { return m_gdb_client.OpenFile(file_spec, flags, mode, error); } -bool PlatformRemoteGDBServer::CloseFile(lldb::user_id_t fd, Error &error) { +bool PlatformRemoteGDBServer::CloseFile(lldb::user_id_t fd, Status &error) { return m_gdb_client.CloseFile(fd, error); } @@ -678,27 +678,27 @@ PlatformRemoteGDBServer::GetFileSize(const FileSpec &file_spec) { uint64_t PlatformRemoteGDBServer::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, - Error &error) { + Status &error) { return m_gdb_client.ReadFile(fd, offset, dst, dst_len, error); } uint64_t PlatformRemoteGDBServer::WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, - Error &error) { + Status &error) { return m_gdb_client.WriteFile(fd, offset, src, src_len, error); } -Error PlatformRemoteGDBServer::PutFile(const FileSpec &source, - const FileSpec &destination, - uint32_t uid, uint32_t gid) { +Status PlatformRemoteGDBServer::PutFile(const FileSpec &source, + const FileSpec &destination, + uint32_t uid, uint32_t gid) { return Platform::PutFile(source, destination, uid, gid); } -Error PlatformRemoteGDBServer::CreateSymlink( +Status PlatformRemoteGDBServer::CreateSymlink( const FileSpec &src, // The name of the link is in src const FileSpec &dst) // The symlink points to dst { - Error error = m_gdb_client.CreateSymlink(src, dst); + Status error = m_gdb_client.CreateSymlink(src, dst); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); if (log) log->Printf("PlatformRemoteGDBServer::CreateSymlink(src='%s', dst='%s') " @@ -708,8 +708,8 @@ Error PlatformRemoteGDBServer::CreateSymlink( return error; } -Error PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec) { - Error error = m_gdb_client.Unlink(file_spec); +Status PlatformRemoteGDBServer::Unlink(const FileSpec &file_spec) { + Status error = m_gdb_client.Unlink(file_spec); Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); if (log) log->Printf("PlatformRemoteGDBServer::Unlink(path='%s') error = %u (%s)", @@ -721,7 +721,7 @@ bool PlatformRemoteGDBServer::GetFileExists(const FileSpec &file_spec) { return m_gdb_client.GetFileExists(file_spec); } -Error PlatformRemoteGDBServer::RunShellCommand( +Status PlatformRemoteGDBServer::RunShellCommand( const char *command, // Shouldn't be NULL const FileSpec & working_dir, // Pass empty FileSpec to use the current working directory @@ -784,7 +784,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() { if (!dict->GetValueForKeyAsInteger("signo", signo)) return false; - std::string name; + llvm::StringRef name; if (!dict->GetValueForKeyAsString("name", name)) return false; @@ -809,7 +809,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() { if (object_sp && object_sp->IsValid()) description = object_sp->GetStringValue(); - remote_signals_sp->AddSignal(signo, name.c_str(), suppress, stop, + remote_signals_sp->AddSignal(signo, name.str().c_str(), suppress, stop, notify, description.c_str()); return true; }); @@ -852,7 +852,7 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme, lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess( llvm::StringRef connect_url, llvm::StringRef plugin_name, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) { + lldb_private::Status &error) { if (!IsRemote() || !IsConnected()) { error.SetErrorString("Not connected to remote gdb server"); return nullptr; @@ -862,7 +862,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess( } size_t PlatformRemoteGDBServer::ConnectToWaitingProcesses(Debugger &debugger, - Error &error) { + Status &error) { std::vector<std::string> connection_urls; GetPendingGdbServerList(connection_urls); diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h index edc223a2d7fb6..210544f752e61 100644 --- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -50,38 +50,38 @@ public: //------------------------------------------------------------ // lldb_private::Platform functions //------------------------------------------------------------ - Error ResolveExecutable(const ModuleSpec &module_spec, - lldb::ModuleSP &module_sp, - const FileSpecList *module_search_paths_ptr) override; + Status + ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, + const FileSpecList *module_search_paths_ptr) override; bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec) override; const char *GetDescription() override; - Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid_ptr, - FileSpec &local_file) override; + Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid_ptr, + FileSpec &local_file) override; bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override; uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) override; - Error LaunchProcess(ProcessLaunchInfo &launch_info) override; + Status LaunchProcess(ProcessLaunchInfo &launch_info) override; - Error KillProcess(const lldb::pid_t pid) override; + Status KillProcess(const lldb::pid_t pid) override; lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a // new target, else use existing // one - Error &error) override; + Status &error) override; lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new // target, else use existing one - Error &error) override; + Status &error) override; bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override; @@ -111,42 +111,42 @@ public: bool IsConnected() const override; - Error ConnectRemote(Args &args) override; + Status ConnectRemote(Args &args) override; - Error DisconnectRemote() override; + Status DisconnectRemote() override; - Error MakeDirectory(const FileSpec &file_spec, - uint32_t file_permissions) override; + Status MakeDirectory(const FileSpec &file_spec, + uint32_t file_permissions) override; - Error GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) override; + Status GetFilePermissions(const FileSpec &file_spec, + uint32_t &file_permissions) override; - Error SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) override; + Status SetFilePermissions(const FileSpec &file_spec, + uint32_t file_permissions) override; lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, - uint32_t mode, Error &error) override; + uint32_t mode, Status &error) override; - bool CloseFile(lldb::user_id_t fd, Error &error) override; + bool CloseFile(lldb::user_id_t fd, Status &error) override; uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *data_ptr, - uint64_t len, Error &error) override; + uint64_t len, Status &error) override; uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *data, - uint64_t len, Error &error) override; + uint64_t len, Status &error) override; lldb::user_id_t GetFileSize(const FileSpec &file_spec) override; - Error PutFile(const FileSpec &source, const FileSpec &destination, - uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override; + Status PutFile(const FileSpec &source, const FileSpec &destination, + uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override; - Error CreateSymlink(const FileSpec &src, const FileSpec &dst) override; + Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override; bool GetFileExists(const FileSpec &file_spec) override; - Error Unlink(const FileSpec &path) override; + Status Unlink(const FileSpec &path) override; - Error RunShellCommand( + Status RunShellCommand( const char *command, // Shouldn't be NULL const FileSpec &working_dir, // Pass empty FileSpec to use the current // working directory @@ -166,10 +166,10 @@ public: llvm::StringRef plugin_name, lldb_private::Debugger &debugger, lldb_private::Target *target, - lldb_private::Error &error) override; + lldb_private::Status &error) override; size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, - lldb_private::Error &error) override; + lldb_private::Status &error) override; virtual size_t GetPendingGdbServerList(std::vector<std::string> &connection_urls); |