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/Host | |
parent | 8b4000f13b303cc154136abc74c55670673e2a96 (diff) |
Notes
Diffstat (limited to 'source/Host')
45 files changed, 523 insertions, 513 deletions
diff --git a/source/Host/common/Editline.cpp b/source/Host/common/Editline.cpp index 851287e763312..7d4b398a171da 100644 --- a/source/Host/common/Editline.cpp +++ b/source/Host/common/Editline.cpp @@ -14,10 +14,10 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Editline.h" #include "lldb/Host/Host.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/SelectHelper.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringList.h" #include "lldb/Utility/Timeout.h" diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp index 1869a6db49c93..3de93ebc220b5 100644 --- a/source/Host/common/File.cpp +++ b/source/Host/common/File.cpp @@ -157,8 +157,8 @@ void File::SetStream(FILE *fh, bool transfer_ownership) { m_own_stream = transfer_ownership; } -Error File::Open(const char *path, uint32_t options, uint32_t permissions) { - Error error; +Status File::Open(const char *path, uint32_t options, uint32_t permissions) { + Status error; if (IsValid()) Close(); @@ -246,20 +246,20 @@ Error File::Open(const char *path, uint32_t options, uint32_t permissions) { return error; } -uint32_t File::GetPermissions(const FileSpec &file_spec, Error &error) { +uint32_t File::GetPermissions(const FileSpec &file_spec, Status &error) { if (file_spec) { error.Clear(); auto Perms = llvm::sys::fs::getPermissions(file_spec.GetPath()); if (Perms) return *Perms; - error = Error(Perms.getError()); + error = Status(Perms.getError()); return 0; } else error.SetErrorString("empty file spec"); return 0; } -uint32_t File::GetPermissions(Error &error) const { +uint32_t File::GetPermissions(Status &error) const { int fd = GetDescriptor(); if (fd != kInvalidDescriptor) { struct stat file_stats; @@ -275,8 +275,8 @@ uint32_t File::GetPermissions(Error &error) const { return 0; } -Error File::Close() { - Error error; +Status File::Close() { + Status error; if (StreamIsValid() && m_own_stream) { if (::fclose(m_stream) == EOF) error.SetErrorToErrno(); @@ -305,8 +305,8 @@ void File::Clear() { eLazyBoolCalculate; } -Error File::GetFileSpec(FileSpec &file_spec) const { - Error error; +Status File::GetFileSpec(FileSpec &file_spec) const { + Status error; #ifdef F_GETPATH if (IsValid()) { char path[PATH_MAX]; @@ -340,7 +340,7 @@ Error File::GetFileSpec(FileSpec &file_spec) const { return error; } -off_t File::SeekFromStart(off_t offset, Error *error_ptr) { +off_t File::SeekFromStart(off_t offset, Status *error_ptr) { off_t result = 0; if (DescriptorIsValid()) { result = ::lseek(m_descriptor, offset, SEEK_SET); @@ -366,7 +366,7 @@ off_t File::SeekFromStart(off_t offset, Error *error_ptr) { return result; } -off_t File::SeekFromCurrent(off_t offset, Error *error_ptr) { +off_t File::SeekFromCurrent(off_t offset, Status *error_ptr) { off_t result = -1; if (DescriptorIsValid()) { result = ::lseek(m_descriptor, offset, SEEK_CUR); @@ -392,7 +392,7 @@ off_t File::SeekFromCurrent(off_t offset, Error *error_ptr) { return result; } -off_t File::SeekFromEnd(off_t offset, Error *error_ptr) { +off_t File::SeekFromEnd(off_t offset, Status *error_ptr) { off_t result = -1; if (DescriptorIsValid()) { result = ::lseek(m_descriptor, offset, SEEK_END); @@ -418,8 +418,8 @@ off_t File::SeekFromEnd(off_t offset, Error *error_ptr) { return result; } -Error File::Flush() { - Error error; +Status File::Flush() { + Status error; if (StreamIsValid()) { int err = 0; do { @@ -434,8 +434,8 @@ Error File::Flush() { return error; } -Error File::Sync() { - Error error; +Status File::Sync() { + Status error; if (DescriptorIsValid()) { #ifdef _WIN32 int err = FlushFileBuffers((HANDLE)_get_osfhandle(m_descriptor)); @@ -462,8 +462,8 @@ Error File::Sync() { #define MAX_WRITE_SIZE INT_MAX #endif -Error File::Read(void *buf, size_t &num_bytes) { - Error error; +Status File::Read(void *buf, size_t &num_bytes) { + Status error; #if defined(MAX_READ_SIZE) if (num_bytes > MAX_READ_SIZE) { @@ -524,8 +524,8 @@ Error File::Read(void *buf, size_t &num_bytes) { return error; } -Error File::Write(const void *buf, size_t &num_bytes) { - Error error; +Status File::Write(const void *buf, size_t &num_bytes) { + Status error; #if defined(MAX_WRITE_SIZE) if (num_bytes > MAX_WRITE_SIZE) { @@ -588,8 +588,8 @@ Error File::Write(const void *buf, size_t &num_bytes) { return error; } -Error File::Read(void *buf, size_t &num_bytes, off_t &offset) { - Error error; +Status File::Read(void *buf, size_t &num_bytes, off_t &offset) { + Status error; #if defined(MAX_READ_SIZE) if (num_bytes > MAX_READ_SIZE) { @@ -650,9 +650,9 @@ Error File::Read(void *buf, size_t &num_bytes, off_t &offset) { return error; } -Error File::Read(size_t &num_bytes, off_t &offset, bool null_terminate, - DataBufferSP &data_buffer_sp) { - Error error; +Status File::Read(size_t &num_bytes, off_t &offset, bool null_terminate, + DataBufferSP &data_buffer_sp) { + Status error; if (num_bytes > 0) { int fd = GetDescriptor(); @@ -694,8 +694,8 @@ Error File::Read(size_t &num_bytes, off_t &offset, bool null_terminate, return error; } -Error File::Write(const void *buf, size_t &num_bytes, off_t &offset) { - Error error; +Status File::Write(const void *buf, size_t &num_bytes, off_t &offset) { + Status error; #if defined(MAX_WRITE_SIZE) if (num_bytes > MAX_WRITE_SIZE) { diff --git a/source/Host/common/FileCache.cpp b/source/Host/common/FileCache.cpp index db71813e4ffb1..b4629255c8529 100644 --- a/source/Host/common/FileCache.cpp +++ b/source/Host/common/FileCache.cpp @@ -24,7 +24,7 @@ FileCache &FileCache::GetInstance() { } lldb::user_id_t FileCache::OpenFile(const FileSpec &file_spec, uint32_t flags, - uint32_t mode, Error &error) { + uint32_t mode, Status &error) { std::string path(file_spec.GetPath()); if (path.empty()) { error.SetErrorString("empty path"); @@ -39,7 +39,7 @@ lldb::user_id_t FileCache::OpenFile(const FileSpec &file_spec, uint32_t flags, return fd; } -bool FileCache::CloseFile(lldb::user_id_t fd, Error &error) { +bool FileCache::CloseFile(lldb::user_id_t fd, Status &error) { if (fd == UINT64_MAX) { error.SetErrorString("invalid file descriptor"); return false; @@ -60,7 +60,8 @@ bool FileCache::CloseFile(lldb::user_id_t fd, Error &error) { } uint64_t FileCache::WriteFile(lldb::user_id_t fd, uint64_t offset, - const void *src, uint64_t src_len, Error &error) { + const void *src, uint64_t src_len, + Status &error) { if (fd == UINT64_MAX) { error.SetErrorString("invalid file descriptor"); return UINT64_MAX; @@ -86,7 +87,7 @@ uint64_t FileCache::WriteFile(lldb::user_id_t fd, uint64_t offset, } uint64_t FileCache::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, - uint64_t dst_len, Error &error) { + uint64_t dst_len, Status &error) { if (fd == UINT64_MAX) { error.SetErrorString("invalid file descriptor"); return UINT64_MAX; diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp index 7754d96ad3315..da35022c813cb 100644 --- a/source/Host/common/Host.cpp +++ b/source/Host/common/Host.cpp @@ -63,9 +63,9 @@ #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/DataBufferLLVM.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/lldb-private-forward.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" @@ -484,19 +484,19 @@ MonitorShellCommand(std::shared_ptr<ShellInfo> shell_info, lldb::pid_t pid, return true; } -Error Host::RunShellCommand(const char *command, const FileSpec &working_dir, - int *status_ptr, int *signo_ptr, - std::string *command_output_ptr, - uint32_t timeout_sec, bool run_in_default_shell) { +Status Host::RunShellCommand(const char *command, const FileSpec &working_dir, + int *status_ptr, int *signo_ptr, + std::string *command_output_ptr, + uint32_t timeout_sec, bool run_in_default_shell) { return RunShellCommand(Args(command), working_dir, status_ptr, signo_ptr, command_output_ptr, timeout_sec, run_in_default_shell); } -Error Host::RunShellCommand(const Args &args, const FileSpec &working_dir, - int *status_ptr, int *signo_ptr, - std::string *command_output_ptr, - uint32_t timeout_sec, bool run_in_default_shell) { - Error error; +Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir, + int *status_ptr, int *signo_ptr, + std::string *command_output_ptr, + uint32_t timeout_sec, bool run_in_default_shell) { + Status error; ProcessLaunchInfo launch_info; launch_info.SetArchitecture(HostInfo::GetArchitecture()); if (run_in_default_shell) { @@ -654,10 +654,10 @@ short Host::GetPosixspawnFlags(const ProcessLaunchInfo &launch_info) { return flags; } -Error Host::LaunchProcessPosixSpawn(const char *exe_path, - const ProcessLaunchInfo &launch_info, - lldb::pid_t &pid) { - Error error; +Status Host::LaunchProcessPosixSpawn(const char *exe_path, + const ProcessLaunchInfo &launch_info, + lldb::pid_t &pid) { + Status error; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS)); @@ -866,7 +866,7 @@ Error Host::LaunchProcessPosixSpawn(const char *exe_path, } bool Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info, - Log *log, Error &error) { + Log *log, Status &error) { if (info == NULL) return false; @@ -947,7 +947,7 @@ bool Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info, // The functions below implement process launching via posix_spawn() for Linux, // FreeBSD and NetBSD. -Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) { +Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) { std::unique_ptr<ProcessLauncher> delegate_launcher; #if defined(_WIN32) delegate_launcher.reset(new ProcessLauncherWindows()); @@ -958,7 +958,7 @@ Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) { #endif MonitoringProcessLauncher launcher(std::move(delegate_launcher)); - Error error; + Status error; HostProcess process = launcher.LaunchProcess(launch_info, error); // TODO(zturner): It would be better if the entire HostProcess were returned diff --git a/source/Host/common/HostProcess.cpp b/source/Host/common/HostProcess.cpp index 2d99d8e1fc997..1540333215143 100644 --- a/source/Host/common/HostProcess.cpp +++ b/source/Host/common/HostProcess.cpp @@ -21,9 +21,9 @@ HostProcess::HostProcess(lldb::process_t process) HostProcess::~HostProcess() {} -Error HostProcess::Terminate() { return m_native_process->Terminate(); } +Status HostProcess::Terminate() { return m_native_process->Terminate(); } -Error HostProcess::GetMainModule(FileSpec &file_spec) const { +Status HostProcess::GetMainModule(FileSpec &file_spec) const { return m_native_process->GetMainModule(file_spec); } diff --git a/source/Host/common/HostThread.cpp b/source/Host/common/HostThread.cpp index 738b7ef72f166..02882c523908c 100644 --- a/source/Host/common/HostThread.cpp +++ b/source/Host/common/HostThread.cpp @@ -18,11 +18,11 @@ HostThread::HostThread() : m_native_thread(new HostNativeThread) {} HostThread::HostThread(lldb::thread_t thread) : m_native_thread(new HostNativeThread(thread)) {} -Error HostThread::Join(lldb::thread_result_t *result) { +Status HostThread::Join(lldb::thread_result_t *result) { return m_native_thread->Join(result); } -Error HostThread::Cancel() { return m_native_thread->Cancel(); } +Status HostThread::Cancel() { return m_native_thread->Cancel(); } void HostThread::Reset() { return m_native_thread->Reset(); } diff --git a/source/Host/common/LockFileBase.cpp b/source/Host/common/LockFileBase.cpp index b30acc5d50447..a8d7881ab8963 100644 --- a/source/Host/common/LockFileBase.cpp +++ b/source/Host/common/LockFileBase.cpp @@ -14,9 +14,9 @@ using namespace lldb_private; namespace { -Error AlreadyLocked() { return Error("Already locked"); } +Status AlreadyLocked() { return Status("Already locked"); } -Error NotLocked() { return Error("Not locked"); } +Status NotLocked() { return Status("Not locked"); } } LockFileBase::LockFileBase(int fd) @@ -24,31 +24,31 @@ LockFileBase::LockFileBase(int fd) bool LockFileBase::IsLocked() const { return m_locked; } -Error LockFileBase::WriteLock(const uint64_t start, const uint64_t len) { +Status LockFileBase::WriteLock(const uint64_t start, const uint64_t len) { return DoLock([&](const uint64_t start, const uint64_t len) { return DoWriteLock(start, len); }, start, len); } -Error LockFileBase::TryWriteLock(const uint64_t start, const uint64_t len) { +Status LockFileBase::TryWriteLock(const uint64_t start, const uint64_t len) { return DoLock([&](const uint64_t start, const uint64_t len) { return DoTryWriteLock(start, len); }, start, len); } -Error LockFileBase::ReadLock(const uint64_t start, const uint64_t len) { +Status LockFileBase::ReadLock(const uint64_t start, const uint64_t len) { return DoLock([&](const uint64_t start, const uint64_t len) { return DoReadLock(start, len); }, start, len); } -Error LockFileBase::TryReadLock(const uint64_t start, const uint64_t len) { +Status LockFileBase::TryReadLock(const uint64_t start, const uint64_t len) { return DoLock([&](const uint64_t start, const uint64_t len) { return DoTryReadLock(start, len); }, start, len); } -Error LockFileBase::Unlock() { +Status LockFileBase::Unlock() { if (!IsLocked()) return NotLocked(); @@ -63,10 +63,10 @@ Error LockFileBase::Unlock() { bool LockFileBase::IsValidFile() const { return m_fd != -1; } -Error LockFileBase::DoLock(const Locker &locker, const uint64_t start, - const uint64_t len) { +Status LockFileBase::DoLock(const Locker &locker, const uint64_t start, + const uint64_t len) { if (!IsValidFile()) - return Error("File is invalid"); + return Status("File is invalid"); if (IsLocked()) return AlreadyLocked(); diff --git a/source/Host/common/MainLoop.cpp b/source/Host/common/MainLoop.cpp index abd52f7f46fb3..7de6f7fa865d7 100644 --- a/source/Host/common/MainLoop.cpp +++ b/source/Host/common/MainLoop.cpp @@ -10,13 +10,13 @@ #include "llvm/Config/llvm-config.h" #include "lldb/Host/MainLoop.h" -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" #include <algorithm> #include <cassert> #include <cerrno> #include <csignal> -#include <vector> #include <time.h> +#include <vector> // Multiplexing is implemented using kqueue on systems that support it (BSD // variants including OSX). On linux we use ppoll, while android uses pselect @@ -73,7 +73,7 @@ public: RunImpl(MainLoop &loop); ~RunImpl() = default; - Error Poll(); + Status Poll(); void ProcessEvents(); private: @@ -100,7 +100,7 @@ MainLoop::RunImpl::RunImpl(MainLoop &loop) : loop(loop) { in_events.reserve(loop.m_read_fds.size()); } -Error MainLoop::RunImpl::Poll() { +Status MainLoop::RunImpl::Poll() { in_events.resize(loop.m_read_fds.size()); unsigned i = 0; for (auto &fd : loop.m_read_fds) @@ -110,8 +110,8 @@ Error MainLoop::RunImpl::Poll() { out_events, llvm::array_lengthof(out_events), nullptr); if (num_events < 0) - return Error("kevent() failed with error %d\n", num_events); - return Error(); + return Status("kevent() failed with error %d\n", num_events); + return Status(); } void MainLoop::RunImpl::ProcessEvents() { @@ -154,7 +154,7 @@ sigset_t MainLoop::RunImpl::get_sigmask() { } #ifdef FORCE_PSELECT -Error MainLoop::RunImpl::Poll() { +Status MainLoop::RunImpl::Poll() { FD_ZERO(&read_fd_set); int nfds = 0; for (const auto &fd : loop.m_read_fds) { @@ -165,12 +165,12 @@ Error MainLoop::RunImpl::Poll() { sigset_t sigmask = get_sigmask(); if (pselect(nfds, &read_fd_set, nullptr, nullptr, nullptr, &sigmask) == -1 && errno != EINTR) - return Error(errno, eErrorTypePOSIX); + return Status(errno, eErrorTypePOSIX); - return Error(); + return Status(); } #else -Error MainLoop::RunImpl::Poll() { +Status MainLoop::RunImpl::Poll() { read_fds.clear(); sigset_t sigmask = get_sigmask(); @@ -185,9 +185,9 @@ Error MainLoop::RunImpl::Poll() { if (ppoll(read_fds.data(), read_fds.size(), nullptr, &sigmask) == -1 && errno != EINTR) - return Error(errno, eErrorTypePOSIX); + return Status(errno, eErrorTypePOSIX); - return Error(); + return Status(); } #endif @@ -234,9 +234,9 @@ MainLoop::~MainLoop() { assert(m_signals.size() == 0); } -MainLoop::ReadHandleUP -MainLoop::RegisterReadObject(const IOObjectSP &object_sp, - const Callback &callback, Error &error) { +MainLoop::ReadHandleUP MainLoop::RegisterReadObject(const IOObjectSP &object_sp, + const Callback &callback, + Status &error) { #ifdef LLVM_ON_WIN32 if (object_sp->GetFdType() != IOObject:: eFDTypeSocket) { error.SetErrorString("MainLoop: non-socket types unsupported on Windows"); @@ -263,8 +263,7 @@ MainLoop::RegisterReadObject(const IOObjectSP &object_sp, // be unblocked in // the Run() function to check for signal delivery. MainLoop::SignalHandleUP -MainLoop::RegisterSignal(int signo, const Callback &callback, - Error &error) { +MainLoop::RegisterSignal(int signo, const Callback &callback, Status &error) { #ifdef SIGNAL_POLLING_UNSUPPORTED error.SetErrorString("Signal polling is not supported on this platform."); return nullptr; @@ -318,7 +317,7 @@ void MainLoop::UnregisterReadObject(IOObject::WaitableHandle handle) { void MainLoop::UnregisterSignal(int signo) { #if SIGNAL_POLLING_UNSUPPORTED - Error("Signal polling is not supported on this platform."); + Status("Signal polling is not supported on this platform."); #else auto it = m_signals.find(signo); assert(it != m_signals.end()); @@ -344,10 +343,10 @@ void MainLoop::UnregisterSignal(int signo) { #endif } -Error MainLoop::Run() { +Status MainLoop::Run() { m_terminate_request = false; - - Error error; + + Status error; RunImpl impl(*this); // run until termination or until we run out of things to listen to @@ -360,9 +359,9 @@ Error MainLoop::Run() { impl.ProcessEvents(); if (m_terminate_request) - return Error(); + return Status(); } - return Error(); + return Status(); } void MainLoop::ProcessSignal(int signo) { diff --git a/source/Host/common/MonitoringProcessLauncher.cpp b/source/Host/common/MonitoringProcessLauncher.cpp index 2aa6c7f50b668..f1fcd0b44c150 100644 --- a/source/Host/common/MonitoringProcessLauncher.cpp +++ b/source/Host/common/MonitoringProcessLauncher.cpp @@ -14,8 +14,8 @@ #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/ProcessLaunchInfo.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "llvm/Support/FileSystem.h" @@ -28,7 +28,7 @@ MonitoringProcessLauncher::MonitoringProcessLauncher( HostProcess MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info, - Error &error) { + Status &error) { ProcessLaunchInfo resolved_info(launch_info); error.Clear(); diff --git a/source/Host/common/NativeBreakpoint.cpp b/source/Host/common/NativeBreakpoint.cpp index 8a3ee72179c3b..5eee3de482c18 100644 --- a/source/Host/common/NativeBreakpoint.cpp +++ b/source/Host/common/NativeBreakpoint.cpp @@ -9,8 +9,8 @@ #include "lldb/Host/common/NativeBreakpoint.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" using namespace lldb_private; @@ -44,7 +44,7 @@ int32_t NativeBreakpoint::DecRef() { return m_ref_count; } -Error NativeBreakpoint::Enable() { +Status NativeBreakpoint::Enable() { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (m_enabled) { @@ -53,7 +53,7 @@ Error NativeBreakpoint::Enable() { log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " already enabled, ignoring.", __FUNCTION__, m_addr); - return Error(); + return Status(); } // Log and enable. @@ -61,7 +61,7 @@ Error NativeBreakpoint::Enable() { log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enabling...", __FUNCTION__, m_addr); - Error error = DoEnable(); + Status error = DoEnable(); if (error.Success()) { m_enabled = true; if (log) @@ -76,7 +76,7 @@ Error NativeBreakpoint::Enable() { return error; } -Error NativeBreakpoint::Disable() { +Status NativeBreakpoint::Disable() { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (!m_enabled) { @@ -85,7 +85,7 @@ Error NativeBreakpoint::Disable() { log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " already disabled, ignoring.", __FUNCTION__, m_addr); - return Error(); + return Status(); } // Log and disable. @@ -93,7 +93,7 @@ Error NativeBreakpoint::Disable() { log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disabling...", __FUNCTION__, m_addr); - Error error = DoDisable(); + Status error = DoDisable(); if (error.Success()) { m_enabled = false; if (log) diff --git a/source/Host/common/NativeBreakpointList.cpp b/source/Host/common/NativeBreakpointList.cpp index 60608a0bbc55e..ce5eb94a8d1fb 100644 --- a/source/Host/common/NativeBreakpointList.cpp +++ b/source/Host/common/NativeBreakpointList.cpp @@ -19,9 +19,9 @@ using namespace lldb_private; NativeBreakpointList::NativeBreakpointList() : m_mutex() {} -Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint, - bool hardware, - CreateBreakpointFunc create_func) { +Status NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint, + bool hardware, + CreateBreakpointFunc create_func) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 @@ -40,7 +40,7 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint, __FUNCTION__, addr); iter->second->AddRef(); - return Error(); + return Status(); } // Create a new breakpoint using the given create func. @@ -51,7 +51,7 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint, __FUNCTION__, addr, size_hint, hardware ? "true" : "false"); NativeBreakpointSP breakpoint_sp; - Error error = create_func(addr, size_hint, hardware, breakpoint_sp); + Status error = create_func(addr, size_hint, hardware, breakpoint_sp); if (error.Fail()) { if (log) log->Printf( @@ -70,8 +70,8 @@ Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint, return error; } -Error NativeBreakpointList::DecRef(lldb::addr_t addr) { - Error error; +Status NativeBreakpointList::DecRef(lldb::addr_t addr) { + Status error; Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) @@ -142,7 +142,7 @@ Error NativeBreakpointList::DecRef(lldb::addr_t addr) { return error; } -Error NativeBreakpointList::EnableBreakpoint(lldb::addr_t addr) { +Status NativeBreakpointList::EnableBreakpoint(lldb::addr_t addr) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, @@ -157,14 +157,14 @@ Error NativeBreakpointList::EnableBreakpoint(lldb::addr_t addr) { if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", __FUNCTION__, addr); - return Error("breakpoint not found"); + return Status("breakpoint not found"); } // Enable it. return iter->second->Enable(); } -Error NativeBreakpointList::DisableBreakpoint(lldb::addr_t addr) { +Status NativeBreakpointList::DisableBreakpoint(lldb::addr_t addr) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, @@ -179,15 +179,15 @@ Error NativeBreakpointList::DisableBreakpoint(lldb::addr_t addr) { if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", __FUNCTION__, addr); - return Error("breakpoint not found"); + return Status("breakpoint not found"); } // Disable it. return iter->second->Disable(); } -Error NativeBreakpointList::GetBreakpoint(lldb::addr_t addr, - NativeBreakpointSP &breakpoint_sp) { +Status NativeBreakpointList::GetBreakpoint(lldb::addr_t addr, + NativeBreakpointSP &breakpoint_sp) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, @@ -200,16 +200,16 @@ Error NativeBreakpointList::GetBreakpoint(lldb::addr_t addr, if (iter == m_breakpoints.end()) { // Not found! breakpoint_sp.reset(); - return Error("breakpoint not found"); + return Status("breakpoint not found"); } // Disable it. breakpoint_sp = iter->second; - return Error(); + return Status(); } -Error NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, - size_t size) const { +Status NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, + size_t size) const { for (const auto &map : m_breakpoints) { lldb::addr_t bp_addr = map.first; // Breapoint not in range, ignore @@ -225,5 +225,5 @@ Error NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, auto opcode_size = software_bp_sp->m_opcode_size; ::memcpy(opcode_addr, saved_opcodes, opcode_size); } - return Error(); + return Status(); } diff --git a/source/Host/common/NativeProcessProtocol.cpp b/source/Host/common/NativeProcessProtocol.cpp index 9d4149d700ba1..6f1a9f895b618 100644 --- a/source/Host/common/NativeProcessProtocol.cpp +++ b/source/Host/common/NativeProcessProtocol.cpp @@ -36,8 +36,8 @@ NativeProcessProtocol::NativeProcessProtocol(lldb::pid_t pid) m_delegates_mutex(), m_delegates(), m_breakpoint_list(), m_watchpoint_list(), m_terminal_fd(-1), m_stop_id(0) {} -lldb_private::Error NativeProcessProtocol::Interrupt() { - Error error; +lldb_private::Status NativeProcessProtocol::Interrupt() { + Status error; #if !defined(SIGSTOP) error.SetErrorString("local host does not support signaling"); return error; @@ -46,17 +46,17 @@ lldb_private::Error NativeProcessProtocol::Interrupt() { #endif } -Error NativeProcessProtocol::IgnoreSignals(llvm::ArrayRef<int> signals) { +Status NativeProcessProtocol::IgnoreSignals(llvm::ArrayRef<int> signals) { m_signals_to_ignore.clear(); m_signals_to_ignore.insert(signals.begin(), signals.end()); - return Error(); + return Status(); } -lldb_private::Error +lldb_private::Status NativeProcessProtocol::GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { // Default: not implemented. - return Error("not implemented"); + return Status("not implemented"); } bool NativeProcessProtocol::GetExitStatus(ExitType *exit_type, int *status, @@ -173,9 +173,9 @@ NativeProcessProtocol::GetHardwareDebugSupportInfo() const { reg_ctx_sp->NumSupportedHardwareWatchpoints()); } -Error NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, - uint32_t watch_flags, - bool hardware) { +Status NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, + uint32_t watch_flags, + bool hardware) { // This default implementation assumes setting the watchpoint for // the process will require setting the watchpoint for each of the // threads. Furthermore, it will track watchpoints set for the @@ -205,7 +205,7 @@ Error NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, if (!thread_sp) continue; - Error thread_error = + Status thread_error = thread_sp->SetWatchpoint(addr, size, watch_flags, hardware); if (thread_error.Fail() && hardware) { // Try software watchpoints since we failed on hardware watchpoint setting @@ -227,7 +227,7 @@ Error NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, // set so that we get back to a consistent state of "not // set" for the watchpoint. for (auto unwatch_thread_sp : watchpoint_established_threads) { - Error remove_error = unwatch_thread_sp->RemoveWatchpoint(addr); + Status remove_error = unwatch_thread_sp->RemoveWatchpoint(addr); if (remove_error.Fail() && log) { log->Warning("NativeProcessProtocol::%s (): RemoveWatchpoint failed " "for pid=%" PRIu64 ", tid=%" PRIu64 ": %s", @@ -242,11 +242,11 @@ Error NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, return m_watchpoint_list.Add(addr, size, watch_flags, hardware); } -Error NativeProcessProtocol::RemoveWatchpoint(lldb::addr_t addr) { +Status NativeProcessProtocol::RemoveWatchpoint(lldb::addr_t addr) { // Update the thread list UpdateThreads(); - Error overall_error; + Status overall_error; std::lock_guard<std::recursive_mutex> guard(m_threads_mutex); for (auto thread_sp : m_threads) { @@ -254,7 +254,7 @@ Error NativeProcessProtocol::RemoveWatchpoint(lldb::addr_t addr) { if (!thread_sp) continue; - const Error thread_error = thread_sp->RemoveWatchpoint(addr); + const Status thread_error = thread_sp->RemoveWatchpoint(addr); if (thread_error.Fail()) { // Keep track of the first thread error if any threads // fail. We want to try to remove the watchpoint from @@ -263,7 +263,7 @@ Error NativeProcessProtocol::RemoveWatchpoint(lldb::addr_t addr) { overall_error = thread_error; } } - const Error error = m_watchpoint_list.Remove(addr); + const Status error = m_watchpoint_list.Remove(addr); return overall_error.Fail() ? overall_error : error; } @@ -272,8 +272,8 @@ NativeProcessProtocol::GetHardwareBreakpointMap() const { return m_hw_breakpoints_map; } -Error NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, - size_t size) { +Status NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, + size_t size) { // This default implementation assumes setting a hardware breakpoint for // this process will require setting same hardware breakpoint for each // of its existing threads. New thread will do the same once created. @@ -287,7 +287,7 @@ Error NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, if (hw_debug_cap == llvm::None || hw_debug_cap->first == 0 || hw_debug_cap->first <= m_hw_breakpoints_map.size()) - return Error("Target does not have required no of hardware breakpoints"); + return Status("Target does not have required no of hardware breakpoints"); // Vector below stores all thread pointer for which we have we successfully // set this hardware breakpoint. If any of the current process threads fails @@ -302,7 +302,7 @@ Error NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, if (!thread_sp) continue; - Error thread_error = thread_sp->SetHardwareBreakpoint(addr, size); + Status thread_error = thread_sp->SetHardwareBreakpoint(addr, size); if (thread_error.Success()) { // Remember that we set this breakpoint successfully in // case we need to clear it later. @@ -312,7 +312,8 @@ Error NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, // set so that we get back to a consistent state of "not // set" for this hardware breakpoint. for (auto rollback_thread_sp : breakpoint_established_threads) { - Error remove_error = rollback_thread_sp->RemoveHardwareBreakpoint(addr); + Status remove_error = + rollback_thread_sp->RemoveHardwareBreakpoint(addr); if (remove_error.Fail() && log) { log->Warning("NativeProcessProtocol::%s (): RemoveHardwareBreakpoint" " failed for pid=%" PRIu64 ", tid=%" PRIu64 ": %s", @@ -329,14 +330,14 @@ Error NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, // process. m_hw_breakpoints_map[addr] = {addr, size}; - return Error(); + return Status(); } -Error NativeProcessProtocol::RemoveHardwareBreakpoint(lldb::addr_t addr) { +Status NativeProcessProtocol::RemoveHardwareBreakpoint(lldb::addr_t addr) { // Update the thread list UpdateThreads(); - Error error; + Status error; std::lock_guard<std::recursive_mutex> guard(m_threads_mutex); for (auto thread_sp : m_threads) { @@ -413,8 +414,8 @@ void NativeProcessProtocol::NotifyDidExec() { } } -Error NativeProcessProtocol::SetSoftwareBreakpoint(lldb::addr_t addr, - uint32_t size_hint) { +Status NativeProcessProtocol::SetSoftwareBreakpoint(lldb::addr_t addr, + uint32_t size_hint) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) log->Printf("NativeProcessProtocol::%s addr = 0x%" PRIx64, __FUNCTION__, @@ -423,25 +424,25 @@ Error NativeProcessProtocol::SetSoftwareBreakpoint(lldb::addr_t addr, return m_breakpoint_list.AddRef( addr, size_hint, false, [this](lldb::addr_t addr, size_t size_hint, bool /* hardware */, - NativeBreakpointSP &breakpoint_sp) -> Error { + NativeBreakpointSP &breakpoint_sp) -> Status { return SoftwareBreakpoint::CreateSoftwareBreakpoint( *this, addr, size_hint, breakpoint_sp); }); } -Error NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr, - bool hardware) { +Status NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr, + bool hardware) { if (hardware) return RemoveHardwareBreakpoint(addr); else return m_breakpoint_list.DecRef(addr); } -Error NativeProcessProtocol::EnableBreakpoint(lldb::addr_t addr) { +Status NativeProcessProtocol::EnableBreakpoint(lldb::addr_t addr) { return m_breakpoint_list.EnableBreakpoint(addr); } -Error NativeProcessProtocol::DisableBreakpoint(lldb::addr_t addr) { +Status NativeProcessProtocol::DisableBreakpoint(lldb::addr_t addr) { return m_breakpoint_list.DisableBreakpoint(addr); } @@ -483,25 +484,26 @@ void NativeProcessProtocol::DoStopIDBumped(uint32_t /* newBumpId */) { // Default implementation does nothing. } -Error NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid, - ArchSpec &arch) { +Status NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid, + ArchSpec &arch) { // Grab process info for the running process. ProcessInstanceInfo process_info; if (!Host::GetProcessInfo(pid, process_info)) - return Error("failed to get process info"); + return Status("failed to get process info"); // Resolve the executable module. ModuleSpecList module_specs; if (!ObjectFile::GetModuleSpecifications(process_info.GetExecutableFile(), 0, 0, module_specs)) - return Error("failed to get module specifications"); + return Status("failed to get module specifications"); lldbassert(module_specs.GetSize() == 1); arch = module_specs.GetModuleSpecRefAtIndex(0).GetArchitecture(); if (arch.IsValid()) - return Error(); + return Status(); else - return Error("failed to retrieve a valid architecture from the exe module"); + return Status( + "failed to retrieve a valid architecture from the exe module"); } #if !defined(__linux__) && !defined(__NetBSD__) @@ -509,17 +511,17 @@ Error NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid, // Stubs are // provided to make the rest of the code link on non-supported platforms. -Error NativeProcessProtocol::Launch(ProcessLaunchInfo &launch_info, - NativeDelegate &native_delegate, - MainLoop &mainloop, - NativeProcessProtocolSP &process_sp) { +Status NativeProcessProtocol::Launch(ProcessLaunchInfo &launch_info, + NativeDelegate &native_delegate, + MainLoop &mainloop, + NativeProcessProtocolSP &process_sp) { llvm_unreachable("Platform has no NativeProcessProtocol support"); } -Error NativeProcessProtocol::Attach(lldb::pid_t pid, - NativeDelegate &native_delegate, - MainLoop &mainloop, - NativeProcessProtocolSP &process_sp) { +Status NativeProcessProtocol::Attach(lldb::pid_t pid, + NativeDelegate &native_delegate, + MainLoop &mainloop, + NativeProcessProtocolSP &process_sp) { llvm_unreachable("Platform has no NativeProcessProtocol support"); } diff --git a/source/Host/common/NativeRegisterContext.cpp b/source/Host/common/NativeRegisterContext.cpp index 3bc0a0d9705c6..2ca95d7079638 100644 --- a/source/Host/common/NativeRegisterContext.cpp +++ b/source/Host/common/NativeRegisterContext.cpp @@ -138,7 +138,7 @@ NativeRegisterContext::GetPCfromBreakpointLocation(lldb::addr_t fail_value) { return GetPC(fail_value); } -Error NativeRegisterContext::SetPC(lldb::addr_t pc) { +Status NativeRegisterContext::SetPC(lldb::addr_t pc) { uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); return WriteRegisterFromUnsigned(reg, pc); @@ -150,7 +150,7 @@ lldb::addr_t NativeRegisterContext::GetSP(lldb::addr_t fail_value) { return ReadRegisterAsUnsigned(reg, fail_value); } -Error NativeRegisterContext::SetSP(lldb::addr_t sp) { +Status NativeRegisterContext::SetSP(lldb::addr_t sp) { uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); return WriteRegisterFromUnsigned(reg, sp); @@ -162,7 +162,7 @@ lldb::addr_t NativeRegisterContext::GetFP(lldb::addr_t fail_value) { return ReadRegisterAsUnsigned(reg, fail_value); } -Error NativeRegisterContext::SetFP(lldb::addr_t fp) { +Status NativeRegisterContext::SetFP(lldb::addr_t fp) { uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); return WriteRegisterFromUnsigned(reg, fp); @@ -195,7 +195,7 @@ NativeRegisterContext::ReadRegisterAsUnsigned(const RegisterInfo *reg_info, if (reg_info) { RegisterValue value; - Error error = ReadRegister(reg_info, value); + Status error = ReadRegister(reg_info, value); if (error.Success()) { if (log) log->Printf("NativeRegisterContext::%s ReadRegister() succeeded, value " @@ -215,22 +215,23 @@ NativeRegisterContext::ReadRegisterAsUnsigned(const RegisterInfo *reg_info, return fail_value; } -Error NativeRegisterContext::WriteRegisterFromUnsigned(uint32_t reg, - uint64_t uval) { +Status NativeRegisterContext::WriteRegisterFromUnsigned(uint32_t reg, + uint64_t uval) { if (reg == LLDB_INVALID_REGNUM) - return Error("NativeRegisterContext::%s (): reg is invalid", __FUNCTION__); + return Status("NativeRegisterContext::%s (): reg is invalid", __FUNCTION__); return WriteRegisterFromUnsigned(GetRegisterInfoAtIndex(reg), uval); } -Error NativeRegisterContext::WriteRegisterFromUnsigned( - const RegisterInfo *reg_info, uint64_t uval) { +Status +NativeRegisterContext::WriteRegisterFromUnsigned(const RegisterInfo *reg_info, + uint64_t uval) { assert(reg_info); if (!reg_info) - return Error("reg_info is nullptr"); + return Status("reg_info is nullptr"); RegisterValue value; if (!value.SetUInt(uval, reg_info->byte_size)) - return Error("RegisterValue::SetUInt () failed"); + return Status("RegisterValue::SetUInt () failed"); return WriteRegister(reg_info, value); } @@ -246,18 +247,18 @@ uint32_t NativeRegisterContext::SetHardwareBreakpoint(lldb::addr_t addr, return LLDB_INVALID_INDEX32; } -Error NativeRegisterContext::ClearAllHardwareBreakpoints() { - return Error("not implemented"); +Status NativeRegisterContext::ClearAllHardwareBreakpoints() { + return Status("not implemented"); } bool NativeRegisterContext::ClearHardwareBreakpoint(uint32_t hw_idx) { return false; } -Error NativeRegisterContext::GetHardwareBreakHitIndex(uint32_t &bp_index, - lldb::addr_t trap_addr) { +Status NativeRegisterContext::GetHardwareBreakHitIndex(uint32_t &bp_index, + lldb::addr_t trap_addr) { bp_index = LLDB_INVALID_INDEX32; - return Error("not implemented"); + return Status("not implemented"); } uint32_t NativeRegisterContext::NumSupportedHardwareWatchpoints() { return 0; } @@ -272,25 +273,25 @@ bool NativeRegisterContext::ClearHardwareWatchpoint(uint32_t hw_index) { return false; } -Error NativeRegisterContext::ClearAllHardwareWatchpoints() { - return Error("not implemented"); +Status NativeRegisterContext::ClearAllHardwareWatchpoints() { + return Status("not implemented"); } -Error NativeRegisterContext::IsWatchpointHit(uint32_t wp_index, bool &is_hit) { +Status NativeRegisterContext::IsWatchpointHit(uint32_t wp_index, bool &is_hit) { is_hit = false; - return Error("not implemented"); + return Status("not implemented"); } -Error NativeRegisterContext::GetWatchpointHitIndex(uint32_t &wp_index, - lldb::addr_t trap_addr) { +Status NativeRegisterContext::GetWatchpointHitIndex(uint32_t &wp_index, + lldb::addr_t trap_addr) { wp_index = LLDB_INVALID_INDEX32; - return Error("not implemented"); + return Status("not implemented"); } -Error NativeRegisterContext::IsWatchpointVacant(uint32_t wp_index, - bool &is_vacant) { +Status NativeRegisterContext::IsWatchpointVacant(uint32_t wp_index, + bool &is_vacant) { is_vacant = false; - return Error("not implemented"); + return Status("not implemented"); } lldb::addr_t NativeRegisterContext::GetWatchpointAddress(uint32_t wp_index) { @@ -303,10 +304,10 @@ lldb::addr_t NativeRegisterContext::GetWatchpointHitAddress(uint32_t wp_index) { bool NativeRegisterContext::HardwareSingleStep(bool enable) { return false; } -Error NativeRegisterContext::ReadRegisterValueFromMemory( +Status NativeRegisterContext::ReadRegisterValueFromMemory( const RegisterInfo *reg_info, lldb::addr_t src_addr, size_t src_len, RegisterValue ®_value) { - Error error; + Status error; if (reg_info == nullptr) { error.SetErrorString("invalid register info argument."); return error; @@ -321,7 +322,7 @@ Error NativeRegisterContext::ReadRegisterValueFromMemory( // // Case 2: src_len > dst_len // - // Error! (The register should always be big enough to hold the data) + // Status! (The register should always be big enough to hold the data) // // Case 3: src_len < dst_len // @@ -383,13 +384,13 @@ Error NativeRegisterContext::ReadRegisterValueFromMemory( return error; } -Error NativeRegisterContext::WriteRegisterValueToMemory( +Status NativeRegisterContext::WriteRegisterValueToMemory( const RegisterInfo *reg_info, lldb::addr_t dst_addr, size_t dst_len, const RegisterValue ®_value) { uint8_t dst[RegisterValue::kMaxRegisterByteSize]; - Error error; + Status error; NativeProcessProtocolSP process_sp(m_thread.GetProcess()); if (process_sp) { @@ -400,7 +401,7 @@ Error NativeRegisterContext::WriteRegisterValueToMemory( // they are the same. lldb::ByteOrder byte_order; if (!process_sp->GetByteOrder(byte_order)) - return Error("NativeProcessProtocol::GetByteOrder () failed"); + return Status("NativeProcessProtocol::GetByteOrder () failed"); const size_t bytes_copied = reg_value.GetAsMemoryData(reg_info, dst, dst_len, byte_order, error); diff --git a/source/Host/common/NativeThreadProtocol.cpp b/source/Host/common/NativeThreadProtocol.cpp index 2e76cff0d670f..29e25bbc56927 100644 --- a/source/Host/common/NativeThreadProtocol.cpp +++ b/source/Host/common/NativeThreadProtocol.cpp @@ -20,46 +20,46 @@ NativeThreadProtocol::NativeThreadProtocol(NativeProcessProtocol *process, lldb::tid_t tid) : m_process_wp(process->shared_from_this()), m_tid(tid) {} -Error NativeThreadProtocol::ReadRegister(uint32_t reg, - RegisterValue ®_value) { +Status NativeThreadProtocol::ReadRegister(uint32_t reg, + RegisterValue ®_value) { NativeRegisterContextSP register_context_sp = GetRegisterContext(); if (!register_context_sp) - return Error("no register context"); + return Status("no register context"); const RegisterInfo *const reg_info = register_context_sp->GetRegisterInfoAtIndex(reg); if (!reg_info) - return Error("no register info for reg num %" PRIu32, reg); + return Status("no register info for reg num %" PRIu32, reg); return register_context_sp->ReadRegister(reg_info, reg_value); ; } -Error NativeThreadProtocol::WriteRegister(uint32_t reg, - const RegisterValue ®_value) { +Status NativeThreadProtocol::WriteRegister(uint32_t reg, + const RegisterValue ®_value) { NativeRegisterContextSP register_context_sp = GetRegisterContext(); if (!register_context_sp) - return Error("no register context"); + return Status("no register context"); const RegisterInfo *const reg_info = register_context_sp->GetRegisterInfoAtIndex(reg); if (!reg_info) - return Error("no register info for reg num %" PRIu32, reg); + return Status("no register info for reg num %" PRIu32, reg); return register_context_sp->WriteRegister(reg_info, reg_value); } -Error NativeThreadProtocol::SaveAllRegisters(lldb::DataBufferSP &data_sp) { +Status NativeThreadProtocol::SaveAllRegisters(lldb::DataBufferSP &data_sp) { NativeRegisterContextSP register_context_sp = GetRegisterContext(); if (!register_context_sp) - return Error("no register context"); + return Status("no register context"); return register_context_sp->WriteAllRegisterValues(data_sp); } -Error NativeThreadProtocol::RestoreAllRegisters(lldb::DataBufferSP &data_sp) { +Status NativeThreadProtocol::RestoreAllRegisters(lldb::DataBufferSP &data_sp) { NativeRegisterContextSP register_context_sp = GetRegisterContext(); if (!register_context_sp) - return Error("no register context"); + return Status("no register context"); return register_context_sp->ReadAllRegisterValues(data_sp); } diff --git a/source/Host/common/NativeWatchpointList.cpp b/source/Host/common/NativeWatchpointList.cpp index 168e5b42b961c..e6ef7300eb22a 100644 --- a/source/Host/common/NativeWatchpointList.cpp +++ b/source/Host/common/NativeWatchpointList.cpp @@ -14,15 +14,15 @@ using namespace lldb; using namespace lldb_private; -Error NativeWatchpointList::Add(addr_t addr, size_t size, uint32_t watch_flags, - bool hardware) { +Status NativeWatchpointList::Add(addr_t addr, size_t size, uint32_t watch_flags, + bool hardware) { m_watchpoints[addr] = {addr, size, watch_flags, hardware}; - return Error(); + return Status(); } -Error NativeWatchpointList::Remove(addr_t addr) { +Status NativeWatchpointList::Remove(addr_t addr) { m_watchpoints.erase(addr); - return Error(); + return Status(); } const NativeWatchpointList::WatchpointMap & diff --git a/source/Host/common/PipeBase.cpp b/source/Host/common/PipeBase.cpp index cf7e6c97c3c3f..632bfcb3a2e0e 100644 --- a/source/Host/common/PipeBase.cpp +++ b/source/Host/common/PipeBase.cpp @@ -13,12 +13,13 @@ using namespace lldb_private; PipeBase::~PipeBase() = default; -Error PipeBase::OpenAsWriter(llvm::StringRef name, bool child_process_inherit) { +Status PipeBase::OpenAsWriter(llvm::StringRef name, + bool child_process_inherit) { return OpenAsWriterWithTimeout(name, child_process_inherit, std::chrono::microseconds::zero()); } -Error PipeBase::Read(void *buf, size_t size, size_t &bytes_read) { +Status PipeBase::Read(void *buf, size_t size, size_t &bytes_read) { return ReadWithTimeout(buf, size, std::chrono::microseconds::zero(), bytes_read); } diff --git a/source/Host/common/Socket.cpp b/source/Host/common/Socket.cpp index d73b5d0ad0732..0df9dc02c70fb 100644 --- a/source/Host/common/Socket.cpp +++ b/source/Host/common/Socket.cpp @@ -79,7 +79,7 @@ Socket::~Socket() { Close(); } std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol, bool child_processes_inherit, - Error &error) { + Status &error) { error.Clear(); std::unique_ptr<Socket> socket_up; @@ -118,14 +118,14 @@ std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol, return socket_up; } -Error Socket::TcpConnect(llvm::StringRef host_and_port, - bool child_processes_inherit, Socket *&socket) { +Status Socket::TcpConnect(llvm::StringRef host_and_port, + bool child_processes_inherit, Socket *&socket) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION)); if (log) log->Printf("Socket::%s (host/port = %s)", __FUNCTION__, host_and_port.data()); - Error error; + Status error; std::unique_ptr<Socket> connect_socket( Create(ProtocolTcp, child_processes_inherit, error)); if (error.Fail()) @@ -138,14 +138,14 @@ Error Socket::TcpConnect(llvm::StringRef host_and_port, return error; } -Error Socket::TcpListen(llvm::StringRef host_and_port, - bool child_processes_inherit, Socket *&socket, - Predicate<uint16_t> *predicate, int backlog) { +Status Socket::TcpListen(llvm::StringRef host_and_port, + bool child_processes_inherit, Socket *&socket, + Predicate<uint16_t> *predicate, int backlog) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("Socket::%s (%s)", __FUNCTION__, host_and_port.data()); - Error error; + Status error; std::string host_str; std::string port_str; int32_t port = INT32_MIN; @@ -179,8 +179,8 @@ Error Socket::TcpListen(llvm::StringRef host_and_port, return error; } -Error Socket::UdpConnect(llvm::StringRef host_and_port, - bool child_processes_inherit, Socket *&socket) { +Status Socket::UdpConnect(llvm::StringRef host_and_port, + bool child_processes_inherit, Socket *&socket) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("Socket::%s (host/port = %s)", __FUNCTION__, @@ -189,9 +189,10 @@ Error Socket::UdpConnect(llvm::StringRef host_and_port, return UDPSocket::Connect(host_and_port, child_processes_inherit, socket); } -Error Socket::UnixDomainConnect(llvm::StringRef name, - bool child_processes_inherit, Socket *&socket) { - Error error; +Status Socket::UnixDomainConnect(llvm::StringRef name, + bool child_processes_inherit, + Socket *&socket) { + Status error; std::unique_ptr<Socket> connect_socket( Create(ProtocolUnixDomain, child_processes_inherit, error)); if (error.Fail()) @@ -204,9 +205,9 @@ Error Socket::UnixDomainConnect(llvm::StringRef name, return error; } -Error Socket::UnixDomainAccept(llvm::StringRef name, - bool child_processes_inherit, Socket *&socket) { - Error error; +Status Socket::UnixDomainAccept(llvm::StringRef name, + bool child_processes_inherit, Socket *&socket) { + Status error; std::unique_ptr<Socket> listen_socket( Create(ProtocolUnixDomain, child_processes_inherit, error)); if (error.Fail()) @@ -220,10 +221,10 @@ Error Socket::UnixDomainAccept(llvm::StringRef name, return error; } -Error Socket::UnixAbstractConnect(llvm::StringRef name, - bool child_processes_inherit, - Socket *&socket) { - Error error; +Status Socket::UnixAbstractConnect(llvm::StringRef name, + bool child_processes_inherit, + Socket *&socket) { + Status error; std::unique_ptr<Socket> connect_socket( Create(ProtocolUnixAbstract, child_processes_inherit, error)); if (error.Fail()) @@ -235,10 +236,10 @@ Error Socket::UnixAbstractConnect(llvm::StringRef name, return error; } -Error Socket::UnixAbstractAccept(llvm::StringRef name, - bool child_processes_inherit, - Socket *&socket) { - Error error; +Status Socket::UnixAbstractAccept(llvm::StringRef name, + bool child_processes_inherit, + Socket *&socket) { + Status error; std::unique_ptr<Socket> listen_socket( Create(ProtocolUnixAbstract, child_processes_inherit, error)); if (error.Fail()) @@ -254,7 +255,7 @@ Error Socket::UnixAbstractAccept(llvm::StringRef name, bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port, std::string &host_str, std::string &port_str, - int32_t &port, Error *error_ptr) { + int32_t &port, Status *error_ptr) { static RegularExpression g_regex( llvm::StringRef("([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)")); RegularExpression::Match regex_match(2); @@ -304,8 +305,8 @@ IOObject::WaitableHandle Socket::GetWaitableHandle() { return m_socket; } -Error Socket::Read(void *buf, size_t &num_bytes) { - Error error; +Status Socket::Read(void *buf, size_t &num_bytes) { + Status error; int bytes_received = 0; do { bytes_received = ::recv(m_socket, static_cast<char *>(buf), num_bytes, 0); @@ -330,8 +331,8 @@ Error Socket::Read(void *buf, size_t &num_bytes) { return error; } -Error Socket::Write(const void *buf, size_t &num_bytes) { - Error error; +Status Socket::Write(const void *buf, size_t &num_bytes) { + Status error; int bytes_sent = 0; do { bytes_sent = Send(buf, num_bytes); @@ -356,13 +357,13 @@ Error Socket::Write(const void *buf, size_t &num_bytes) { return error; } -Error Socket::PreDisconnect() { - Error error; +Status Socket::PreDisconnect() { + Status error; return error; } -Error Socket::Close() { - Error error; +Status Socket::Close() { + Status error; if (!IsValid() || !m_should_close_fd) return error; @@ -404,7 +405,7 @@ size_t Socket::Send(const void *buf, const size_t num_bytes) { return ::send(m_socket, static_cast<const char *>(buf), num_bytes, 0); } -void Socket::SetLastError(Error &error) { +void Socket::SetLastError(Status &error) { #if defined(_WIN32) error.SetError(::WSAGetLastError(), lldb::eErrorTypeWin32); #else @@ -414,7 +415,7 @@ void Socket::SetLastError(Error &error) { NativeSocket Socket::CreateSocket(const int domain, const int type, const int protocol, - bool child_processes_inherit, Error &error) { + bool child_processes_inherit, Status &error) { error.Clear(); auto socket_type = type; #ifdef SOCK_CLOEXEC @@ -430,7 +431,7 @@ NativeSocket Socket::CreateSocket(const int domain, const int type, NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, - bool child_processes_inherit, Error &error) { + bool child_processes_inherit, Status &error) { error.Clear(); #if defined(ANDROID_USE_ACCEPT_WORKAROUND) // Hack: diff --git a/source/Host/common/SoftwareBreakpoint.cpp b/source/Host/common/SoftwareBreakpoint.cpp index 436cb2bb112ee..14dbafd94c039 100644 --- a/source/Host/common/SoftwareBreakpoint.cpp +++ b/source/Host/common/SoftwareBreakpoint.cpp @@ -10,8 +10,8 @@ #include "lldb/Host/common/SoftwareBreakpoint.h" #include "lldb/Host/Debug.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Host/common/NativeProcessProtocol.h" @@ -21,7 +21,7 @@ using namespace lldb_private; // static members // ------------------------------------------------------------------- -Error SoftwareBreakpoint::CreateSoftwareBreakpoint( +Status SoftwareBreakpoint::CreateSoftwareBreakpoint( NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint, NativeBreakpointSP &breakpoint_sp) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); @@ -30,15 +30,15 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint( // Validate the address. if (addr == LLDB_INVALID_ADDRESS) - return Error("SoftwareBreakpoint::%s invalid load address specified.", - __FUNCTION__); + return Status("SoftwareBreakpoint::%s invalid load address specified.", + __FUNCTION__); // Ask the NativeProcessProtocol subclass to fill in the correct software // breakpoint // trap for the breakpoint site. size_t bp_opcode_size = 0; const uint8_t *bp_opcode_bytes = NULL; - Error error = process.GetSoftwareBreakpointTrapOpcode( + Status error = process.GetSoftwareBreakpointTrapOpcode( size_hint, bp_opcode_size, bp_opcode_bytes); if (error.Fail()) { @@ -54,10 +54,10 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint( if (log) log->Printf("SoftwareBreakpoint::%s failed to retrieve any trap opcodes", __FUNCTION__); - return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " - "returned zero, unable to get breakpoint trap for address " - "0x%" PRIx64, - addr); + return Status("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " + "returned zero, unable to get breakpoint trap for address " + "0x%" PRIx64, + addr); } if (bp_opcode_size > MAX_TRAP_OPCODE_SIZE) { @@ -65,10 +65,10 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint( log->Printf("SoftwareBreakpoint::%s cannot support %zu trapcode bytes, " "max size is %zu", __FUNCTION__, bp_opcode_size, MAX_TRAP_OPCODE_SIZE); - return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " - "returned too many trap opcode bytes: requires %zu but we " - "only support a max of %zu", - bp_opcode_size, MAX_TRAP_OPCODE_SIZE); + return Status("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " + "returned too many trap opcode bytes: requires %zu but we " + "only support a max of %zu", + bp_opcode_size, MAX_TRAP_OPCODE_SIZE); } // Validate that we received opcodes. @@ -76,10 +76,10 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint( if (log) log->Printf("SoftwareBreakpoint::%s failed to retrieve trap opcode bytes", __FUNCTION__); - return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " - "returned NULL trap opcode bytes, unable to get breakpoint " - "trap for address 0x%" PRIx64, - addr); + return Status("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " + "returned NULL trap opcode bytes, unable to get breakpoint " + "trap for address 0x%" PRIx64, + addr); } // Enable the breakpoint. @@ -103,10 +103,10 @@ Error SoftwareBreakpoint::CreateSoftwareBreakpoint( // breakpoint. breakpoint_sp.reset(new SoftwareBreakpoint(process, addr, saved_opcode_bytes, bp_opcode_bytes, bp_opcode_size)); - return Error(); + return Status(); } -Error SoftwareBreakpoint::EnableSoftwareBreakpoint( +Status SoftwareBreakpoint::EnableSoftwareBreakpoint( NativeProcessProtocol &process, lldb::addr_t addr, size_t bp_opcode_size, const uint8_t *bp_opcode_bytes, uint8_t *saved_opcode_bytes) { assert(bp_opcode_size <= MAX_TRAP_OPCODE_SIZE && @@ -121,7 +121,7 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint( // Save the original opcodes by reading them so we can restore later. size_t bytes_read = 0; - Error error = + Status error = process.ReadMemory(addr, saved_opcode_bytes, bp_opcode_size, bytes_read); if (error.Fail()) { if (log) @@ -138,10 +138,10 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint( "attempting to set breakpoint: attempted to read %zu bytes " "but only read %zu", __FUNCTION__, bp_opcode_size, bytes_read); - return Error("SoftwareBreakpoint::%s failed to read memory while " - "attempting to set breakpoint: attempted to read %zu bytes " - "but only read %zu", - __FUNCTION__, bp_opcode_size, bytes_read); + return Status("SoftwareBreakpoint::%s failed to read memory while " + "attempting to set breakpoint: attempted to read %zu bytes " + "but only read %zu", + __FUNCTION__, bp_opcode_size, bytes_read); } // Log what we read. @@ -197,10 +197,11 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint( "attempting to verify breakpoint: attempted to read %zu " "bytes but only read %zu", __FUNCTION__, bp_opcode_size, verify_bytes_read); - return Error("SoftwareBreakpoint::%s failed to read memory while " - "attempting to verify breakpoint: attempted to read %zu bytes " - "but only read %zu", - __FUNCTION__, bp_opcode_size, verify_bytes_read); + return Status( + "SoftwareBreakpoint::%s failed to read memory while " + "attempting to verify breakpoint: attempted to read %zu bytes " + "but only read %zu", + __FUNCTION__, bp_opcode_size, verify_bytes_read); } if (::memcmp(bp_opcode_bytes, verify_bp_opcode_bytes, bp_opcode_size) != 0) { @@ -209,17 +210,17 @@ Error SoftwareBreakpoint::EnableSoftwareBreakpoint( "writing failed - trap opcodes not successfully read back " "after writing when setting breakpoint at 0x%" PRIx64, __FUNCTION__, addr); - return Error("SoftwareBreakpoint::%s: verification of software breakpoint " - "writing failed - trap opcodes not successfully read back " - "after writing when setting breakpoint at 0x%" PRIx64, - __FUNCTION__, addr); + return Status("SoftwareBreakpoint::%s: verification of software breakpoint " + "writing failed - trap opcodes not successfully read back " + "after writing when setting breakpoint at 0x%" PRIx64, + __FUNCTION__, addr); } if (log) log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", __FUNCTION__, addr); - return Error(); + return Status(); } // ------------------------------------------------------------------- @@ -240,13 +241,13 @@ SoftwareBreakpoint::SoftwareBreakpoint(NativeProcessProtocol &process, ::memcpy(m_trap_opcodes, trap_opcodes, opcode_size); } -Error SoftwareBreakpoint::DoEnable() { +Status SoftwareBreakpoint::DoEnable() { return EnableSoftwareBreakpoint(m_process, m_addr, m_opcode_size, m_trap_opcodes, m_saved_opcodes); } -Error SoftwareBreakpoint::DoDisable() { - Error error; +Status SoftwareBreakpoint::DoDisable() { + Status error; assert(m_addr && (m_addr != LLDB_INVALID_ADDRESS) && "can't remove a software breakpoint for an invalid address"); diff --git a/source/Host/common/Symbols.cpp b/source/Host/common/Symbols.cpp index 9e0a3b5bf4dfa..1d9180bf528ef 100644 --- a/source/Host/common/Symbols.cpp +++ b/source/Host/common/Symbols.cpp @@ -151,8 +151,9 @@ FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) { const ArchSpec *arch = module_spec.GetArchitecturePtr(); const UUID *uuid = module_spec.GetUUIDPtr(); + static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer( - LLVM_PRETTY_FUNCTION, + func_cat, "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)", exec_fspec ? exec_fspec->GetFilename().AsCString("<NULL>") : "<NULL>", arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid); @@ -175,9 +176,9 @@ ModuleSpec Symbols::LocateExecutableObjectFile(const ModuleSpec &module_spec) { const FileSpec *exec_fspec = module_spec.GetFileSpecPtr(); const ArchSpec *arch = module_spec.GetArchitecturePtr(); const UUID *uuid = module_spec.GetUUIDPtr(); + static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer( - LLVM_PRETTY_FUNCTION, - "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)", + func_cat, "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)", exec_fspec ? exec_fspec->GetFilename().AsCString("<NULL>") : "<NULL>", arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid); diff --git a/source/Host/common/TCPSocket.cpp b/source/Host/common/TCPSocket.cpp index 55db4bb0c4562..c013334ce23af 100644 --- a/source/Host/common/TCPSocket.cpp +++ b/source/Host/common/TCPSocket.cpp @@ -117,8 +117,8 @@ std::string TCPSocket::GetRemoteIPAddress() const { return ""; } -Error TCPSocket::CreateSocket(int domain) { - Error error; +Status TCPSocket::CreateSocket(int domain) { + Status error; if (IsValid()) error = Close(); if (error.Fail()) @@ -128,13 +128,13 @@ Error TCPSocket::CreateSocket(int domain) { return error; } -Error TCPSocket::Connect(llvm::StringRef name) { +Status TCPSocket::Connect(llvm::StringRef name) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION)); if (log) log->Printf("TCPSocket::%s (host/port = %s)", __FUNCTION__, name.data()); - Error error; + Status error; std::string host_str; std::string port_str; int32_t port = INT32_MIN; @@ -166,12 +166,12 @@ Error TCPSocket::Connect(llvm::StringRef name) { return error; } -Error TCPSocket::Listen(llvm::StringRef name, int backlog) { +Status TCPSocket::Listen(llvm::StringRef name, int backlog) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("TCPSocket::%s (%s)", __FUNCTION__, name.data()); - Error error; + Status error; std::string host_str; std::string port_str; int32_t port = INT32_MIN; @@ -227,8 +227,8 @@ void TCPSocket::CloseListenSockets() { m_listen_sockets.clear(); } -Error TCPSocket::Accept(Socket *&conn_socket) { - Error error; +Status TCPSocket::Accept(Socket *&conn_socket) { + Status error; if (m_listen_sockets.size() == 0) { error.SetErrorString("No open listening sockets!"); return error; diff --git a/source/Host/common/ThreadLauncher.cpp b/source/Host/common/ThreadLauncher.cpp index 32641efe408a2..f3401016393f3 100644 --- a/source/Host/common/ThreadLauncher.cpp +++ b/source/Host/common/ThreadLauncher.cpp @@ -24,9 +24,9 @@ using namespace lldb_private; HostThread ThreadLauncher::LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, lldb::thread_arg_t thread_arg, - Error *error_ptr, + Status *error_ptr, size_t min_stack_byte_size) { - Error error; + Status error; if (error_ptr) error_ptr->Clear(); diff --git a/source/Host/common/UDPSocket.cpp b/source/Host/common/UDPSocket.cpp index ce8d90891b2bf..21dacbc626eee 100644 --- a/source/Host/common/UDPSocket.cpp +++ b/source/Host/common/UDPSocket.cpp @@ -42,27 +42,27 @@ size_t UDPSocket::Send(const void *buf, const size_t num_bytes) { m_sockaddr, m_sockaddr.GetLength()); } -Error UDPSocket::Connect(llvm::StringRef name) { - return Error("%s", g_not_supported_error); +Status UDPSocket::Connect(llvm::StringRef name) { + return Status("%s", g_not_supported_error); } -Error UDPSocket::Listen(llvm::StringRef name, int backlog) { - return Error("%s", g_not_supported_error); +Status UDPSocket::Listen(llvm::StringRef name, int backlog) { + return Status("%s", g_not_supported_error); } -Error UDPSocket::Accept(Socket *&socket) { - return Error("%s", g_not_supported_error); +Status UDPSocket::Accept(Socket *&socket) { + return Status("%s", g_not_supported_error); } -Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit, - Socket *&socket) { +Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit, + Socket *&socket) { std::unique_ptr<UDPSocket> final_socket; Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("UDPSocket::%s (host/port = %s)", __FUNCTION__, name.data()); - Error error; + Status error; std::string host_str; std::string port_str; int32_t port = INT32_MIN; diff --git a/source/Host/freebsd/Host.cpp b/source/Host/freebsd/Host.cpp index f1abb49055e56..bd547bbeb9c53 100644 --- a/source/Host/freebsd/Host.cpp +++ b/source/Host/freebsd/Host.cpp @@ -34,8 +34,8 @@ #include "lldb/Target/Process.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/CleanUp.h" @@ -248,6 +248,6 @@ size_t Host::GetEnvironment(StringList &env) { return i; } -Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { - return Error("unimplemented"); +Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { + return Status("unimplemented"); } diff --git a/source/Host/linux/Host.cpp b/source/Host/linux/Host.cpp index 810222cbbf2f8..486d4e3f0b81f 100644 --- a/source/Host/linux/Host.cpp +++ b/source/Host/linux/Host.cpp @@ -22,8 +22,8 @@ #include "llvm/Support/ScopedPrinter.h" // Project includes #include "lldb/Target/Process.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" @@ -162,7 +162,7 @@ static bool GetProcessAndStatInfo(::pid_t pid, ssize_t len = readlink(ProcExe.c_str(), &ExePath[0], PATH_MAX); if (len <= 0) { LLDB_LOG(log, "failed to read link exe link for {0}: {1}", pid, - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); return false; } ExePath.resize(len); @@ -305,6 +305,6 @@ size_t Host::GetEnvironment(StringList &env) { return i; } -Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { - return Error("unimplemented"); +Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { + return Status("unimplemented"); } diff --git a/source/Host/macosx/Host.mm b/source/Host/macosx/Host.mm index 4c51e8ff154b3..be205f953862b 100644 --- a/source/Host/macosx/Host.mm +++ b/source/Host/macosx/Host.mm @@ -140,7 +140,7 @@ bool Host::ResolveExecutableInBundle(FileSpec &file) { static void *AcceptPIDFromInferior(void *arg) { const char *connect_url = (const char *)arg; ConnectionFileDescriptor file_conn; - Error error; + Status error; if (file_conn.Connect(connect_url, &error) == eConnectionStatusSuccess) { char pid_str[256]; ::memset(pid_str, 0, sizeof(pid_str)); @@ -310,7 +310,7 @@ static bool WaitForProcessToSIGSTOP(const lldb::pid_t pid, // // lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; // -// Error lldb_error; +// Status lldb_error; // // Sleep and wait a bit for debugserver to start to listen... // char connect_url[128]; // ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", @@ -377,10 +377,10 @@ tell application \"Terminal\"\n\ do script the_shell_script\n\ end tell\n"; -static Error +static Status LaunchInNewTerminalWithAppleScript(const char *exe_path, ProcessLaunchInfo &launch_info) { - Error error; + Status error; char unix_socket_name[PATH_MAX] = "/tmp/XXXXXX"; if (::mktemp(unix_socket_name) == NULL) { error.SetErrorString("failed to make temporary path for a unix socket"); @@ -500,7 +500,7 @@ LaunchInNewTerminalWithAppleScript(const char *exe_path, lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; - Error lldb_error; + Status lldb_error; // Sleep and wait a bit for debugserver to start to listen... ConnectionFileDescriptor file_conn; char connect_url[128]; @@ -946,8 +946,8 @@ static void PackageXPCArguments(xpc_object_t message, const char *prefix, Once obtained, it will be valid for as long as the process lives. */ static AuthorizationRef authorizationRef = NULL; -static Error getXPCAuthorization(ProcessLaunchInfo &launch_info) { - Error error; +static Status getXPCAuthorization(ProcessLaunchInfo &launch_info) { + Status error; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS)); @@ -1024,11 +1024,11 @@ static Error getXPCAuthorization(ProcessLaunchInfo &launch_info) { } #endif -static Error LaunchProcessXPC(const char *exe_path, - ProcessLaunchInfo &launch_info, - lldb::pid_t &pid) { +static Status LaunchProcessXPC(const char *exe_path, + ProcessLaunchInfo &launch_info, + lldb::pid_t &pid) { #if !NO_XPC_SERVICES - Error error = getXPCAuthorization(launch_info); + Status error = getXPCAuthorization(launch_info); if (error.Fail()) return error; @@ -1156,7 +1156,7 @@ static Error LaunchProcessXPC(const char *exe_path, return error; #else - Error error; + Status error; return error; #endif } @@ -1177,8 +1177,8 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) { return result; } -Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) { - Error error; +Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) { + Status error; char exe_path[PATH_MAX]; PlatformSP host_platform_sp(Platform::GetHostPlatform()); @@ -1246,8 +1246,8 @@ Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) { return error; } -Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { - Error error; +Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { + Status error; if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) { FileSpec expand_tool_spec; if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir, @@ -1328,8 +1328,7 @@ Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { if (!str_sp) continue; - launch_info.GetArguments().AppendArgument( - llvm::StringRef(str_sp->GetValue().c_str())); + launch_info.GetArguments().AppendArgument(str_sp->GetValue()); } } diff --git a/source/Host/macosx/Symbols.cpp b/source/Host/macosx/Symbols.cpp index a5085681495d2..20508a6585634 100644 --- a/source/Host/macosx/Symbols.cpp +++ b/source/Host/macosx/Symbols.cpp @@ -536,7 +536,7 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec, log->Printf("Calling %s with file %s to find dSYM", g_dsym_for_uuid_exe_path, file_path); } - Error error = Host::RunShellCommand( + Status error = Host::RunShellCommand( command.GetData(), NULL, // current working directory &exit_status, // Exit status diff --git a/source/Host/netbsd/Host.cpp b/source/Host/netbsd/Host.cpp index 6a6b8ab51a172..bbe34a83d9992 100644 --- a/source/Host/netbsd/Host.cpp +++ b/source/Host/netbsd/Host.cpp @@ -33,8 +33,8 @@ #include "lldb/Target/Process.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/CleanUp.h" @@ -254,6 +254,6 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) { return false; } -Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { - return Error("unimplemented"); +Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { + return Status("unimplemented"); } diff --git a/source/Host/openbsd/Host.cpp b/source/Host/openbsd/Host.cpp index c9ff69366c2f3..7e4a64fbd9ae4 100644 --- a/source/Host/openbsd/Host.cpp +++ b/source/Host/openbsd/Host.cpp @@ -30,8 +30,8 @@ #include "lldb/Target/Process.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/CleanUp.h" @@ -220,6 +220,6 @@ bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) { return false; } -Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { - return Error("unimplemented"); +Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { + return Status("unimplemented"); } diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp index befc847d8a864..7a0c92b44918e 100644 --- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -123,7 +123,7 @@ void ConnectionFileDescriptor::OpenCommandPipe() { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); // Make the command file descriptor here: - Error result = m_pipe.CreateNew(m_child_processes_inherit); + Status result = m_pipe.CreateNew(m_child_processes_inherit); if (!result.Success()) { if (log) log->Printf("%p ConnectionFileDescriptor::OpenCommandPipe () - could not " @@ -153,7 +153,7 @@ bool ConnectionFileDescriptor::IsConnected() const { } ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path, - Error *error_ptr) { + Status *error_ptr) { std::lock_guard<std::recursive_mutex> guard(m_mutex); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) @@ -299,11 +299,11 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path, bool ConnectionFileDescriptor::InterruptRead() { size_t bytes_written = 0; - Error result = m_pipe.Write("i", 1, bytes_written); + Status result = m_pipe.Write("i", 1, bytes_written); return result.Success(); } -ConnectionStatus ConnectionFileDescriptor::Disconnect(Error *error_ptr) { +ConnectionStatus ConnectionFileDescriptor::Disconnect(Status *error_ptr) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("%p ConnectionFileDescriptor::Disconnect ()", @@ -337,7 +337,7 @@ ConnectionStatus ConnectionFileDescriptor::Disconnect(Error *error_ptr) { if (!locker.try_lock()) { if (m_pipe.CanWrite()) { size_t bytes_written = 0; - Error result = m_pipe.Write("q", 1, bytes_written); + Status result = m_pipe.Write("q", 1, bytes_written); if (log) log->Printf("%p ConnectionFileDescriptor::Disconnect(): Couldn't get " "the lock, sent 'q' to %d, error = '%s'.", @@ -351,8 +351,8 @@ ConnectionStatus ConnectionFileDescriptor::Disconnect(Error *error_ptr) { locker.lock(); } - Error error = m_read_sp->Close(); - Error error2 = m_write_sp->Close(); + Status error = m_read_sp->Close(); + Status error2 = m_write_sp->Close(); if (error.Fail() || error2.Fail()) status = eConnectionStatusError; if (error_ptr) @@ -369,7 +369,7 @@ ConnectionStatus ConnectionFileDescriptor::Disconnect(Error *error_ptr) { size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout, ConnectionStatus &status, - Error *error_ptr) { + Status *error_ptr) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); std::unique_lock<std::recursive_mutex> locker(m_mutex, std::defer_lock); @@ -394,7 +394,7 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, if (status != eConnectionStatusSuccess) return 0; - Error error; + Status error; size_t bytes_read = dst_len; error = m_read_sp->Read(dst, bytes_read); @@ -476,7 +476,7 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, size_t ConnectionFileDescriptor::Write(const void *src, size_t src_len, ConnectionStatus &status, - Error *error_ptr) { + Status *error_ptr) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf( @@ -491,7 +491,7 @@ size_t ConnectionFileDescriptor::Write(const void *src, size_t src_len, return 0; } - Error error; + Status error; size_t bytes_sent = src_len; error = m_write_sp->Write(src, bytes_sent); @@ -553,7 +553,7 @@ std::string ConnectionFileDescriptor::GetURI() { return m_uri; } ConnectionStatus ConnectionFileDescriptor::BytesAvailable(const Timeout<std::micro> &timeout, - Error *error_ptr) { + Status *error_ptr) { // Don't need to take the mutex here separately since we are only called from // Read. If we // ever get used more generally we will need to lock here as well. @@ -588,7 +588,7 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout<std::micro> &timeout, while (handle == m_read_sp->GetWaitableHandle()) { - Error error = select_helper.Select(); + Status error = select_helper.Select(); if (error_ptr) *error_ptr = error; @@ -653,9 +653,9 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout<std::micro> &timeout, ConnectionStatus ConnectionFileDescriptor::NamedSocketAccept(llvm::StringRef socket_name, - Error *error_ptr) { + Status *error_ptr) { Socket *socket = nullptr; - Error error = + Status error = Socket::UnixDomainAccept(socket_name, m_child_processes_inherit, socket); if (error_ptr) *error_ptr = error; @@ -670,9 +670,9 @@ ConnectionFileDescriptor::NamedSocketAccept(llvm::StringRef socket_name, ConnectionStatus ConnectionFileDescriptor::NamedSocketConnect(llvm::StringRef socket_name, - Error *error_ptr) { + Status *error_ptr) { Socket *socket = nullptr; - Error error = + Status error = Socket::UnixDomainConnect(socket_name, m_child_processes_inherit, socket); if (error_ptr) *error_ptr = error; @@ -687,10 +687,10 @@ ConnectionFileDescriptor::NamedSocketConnect(llvm::StringRef socket_name, lldb::ConnectionStatus ConnectionFileDescriptor::UnixAbstractSocketConnect(llvm::StringRef socket_name, - Error *error_ptr) { + Status *error_ptr) { Socket *socket = nullptr; - Error error = Socket::UnixAbstractConnect(socket_name, - m_child_processes_inherit, socket); + Status error = Socket::UnixAbstractConnect(socket_name, + m_child_processes_inherit, socket); if (error_ptr) *error_ptr = error; m_write_sp.reset(socket); @@ -704,13 +704,13 @@ ConnectionFileDescriptor::UnixAbstractSocketConnect(llvm::StringRef socket_name, ConnectionStatus ConnectionFileDescriptor::SocketListenAndAccept(llvm::StringRef s, - Error *error_ptr) { + Status *error_ptr) { m_port_predicate.SetValue(0, eBroadcastNever); Socket *socket = nullptr; m_waiting_for_accept = true; - Error error = Socket::TcpListen(s, m_child_processes_inherit, socket, - &m_port_predicate); + Status error = Socket::TcpListen(s, m_child_processes_inherit, socket, + &m_port_predicate); if (error_ptr) *error_ptr = error; if (error.Fail()) @@ -732,9 +732,9 @@ ConnectionFileDescriptor::SocketListenAndAccept(llvm::StringRef s, } ConnectionStatus ConnectionFileDescriptor::ConnectTCP(llvm::StringRef s, - Error *error_ptr) { + Status *error_ptr) { Socket *socket = nullptr; - Error error = Socket::TcpConnect(s, m_child_processes_inherit, socket); + Status error = Socket::TcpConnect(s, m_child_processes_inherit, socket); if (error_ptr) *error_ptr = error; m_write_sp.reset(socket); @@ -747,9 +747,9 @@ ConnectionStatus ConnectionFileDescriptor::ConnectTCP(llvm::StringRef s, } ConnectionStatus ConnectionFileDescriptor::ConnectUDP(llvm::StringRef s, - Error *error_ptr) { + Status *error_ptr) { Socket *socket = nullptr; - Error error = Socket::UdpConnect(s, m_child_processes_inherit, socket); + Status error = Socket::UdpConnect(s, m_child_processes_inherit, socket); if (error_ptr) *error_ptr = error; m_write_sp.reset(socket); diff --git a/source/Host/posix/DomainSocket.cpp b/source/Host/posix/DomainSocket.cpp index 33c71268c2e32..3e3abadc2e5a3 100644 --- a/source/Host/posix/DomainSocket.cpp +++ b/source/Host/posix/DomainSocket.cpp @@ -72,13 +72,13 @@ DomainSocket::DomainSocket(NativeSocket socket, m_socket = socket; } -Error DomainSocket::Connect(llvm::StringRef name) { +Status DomainSocket::Connect(llvm::StringRef name) { sockaddr_un saddr_un; socklen_t saddr_un_len; if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len)) - return Error("Failed to set socket address"); + return Status("Failed to set socket address"); - Error error; + Status error; m_socket = CreateSocket(kDomain, kType, 0, m_child_processes_inherit, error); if (error.Fail()) return error; @@ -89,15 +89,15 @@ Error DomainSocket::Connect(llvm::StringRef name) { return error; } -Error DomainSocket::Listen(llvm::StringRef name, int backlog) { +Status DomainSocket::Listen(llvm::StringRef name, int backlog) { sockaddr_un saddr_un; socklen_t saddr_un_len; if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len)) - return Error("Failed to set socket address"); + return Status("Failed to set socket address"); DeleteSocketFile(name); - Error error; + Status error; m_socket = CreateSocket(kDomain, kType, 0, m_child_processes_inherit, error); if (error.Fail()) return error; @@ -110,8 +110,8 @@ Error DomainSocket::Listen(llvm::StringRef name, int backlog) { return error; } -Error DomainSocket::Accept(Socket *&socket) { - Error error; +Status DomainSocket::Accept(Socket *&socket) { + Status error; auto conn_fd = AcceptSocket(GetNativeSocket(), nullptr, nullptr, m_child_processes_inherit, error); if (error.Success()) diff --git a/source/Host/posix/FileSystem.cpp b/source/Host/posix/FileSystem.cpp index 22f337fcfec50..e5a99e1aa7543 100644 --- a/source/Host/posix/FileSystem.cpp +++ b/source/Host/posix/FileSystem.cpp @@ -26,7 +26,7 @@ // lldb Includes #include "lldb/Host/Host.h" -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "llvm/Support/FileSystem.h" @@ -36,15 +36,15 @@ using namespace lldb_private; const char *FileSystem::DEV_NULL = "/dev/null"; -Error FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) { - Error error; +Status FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) { + Status error; if (::symlink(dst.GetCString(), src.GetCString()) == -1) error.SetErrorToErrno(); return error; } -Error FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { - Error error; +Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { + Status error; char buf[PATH_MAX]; ssize_t count = ::readlink(src.GetCString(), buf, sizeof(buf) - 1); if (count < 0) @@ -56,22 +56,22 @@ Error FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { return error; } -Error FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) { +Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) { char resolved_path[PATH_MAX]; if (!src.GetPath(resolved_path, sizeof(resolved_path))) { - return Error("Couldn't get the canonical path for %s", src.GetCString()); + return Status("Couldn't get the canonical path for %s", src.GetCString()); } char real_path[PATH_MAX + 1]; if (realpath(resolved_path, real_path) == nullptr) { - Error err; + Status err; err.SetErrorToErrno(); return err; } dst = FileSpec(real_path, false); - return Error(); + return Status(); } FILE *FileSystem::Fopen(const char *path, const char *mode) { diff --git a/source/Host/posix/HostProcessPosix.cpp b/source/Host/posix/HostProcessPosix.cpp index 9dd9fef94cdb0..b5505dbec65b5 100644 --- a/source/Host/posix/HostProcessPosix.cpp +++ b/source/Host/posix/HostProcessPosix.cpp @@ -29,9 +29,9 @@ HostProcessPosix::HostProcessPosix(lldb::process_t process) HostProcessPosix::~HostProcessPosix() {} -Error HostProcessPosix::Signal(int signo) const { +Status HostProcessPosix::Signal(int signo) const { if (m_process == kInvalidPosixProcess) { - Error error; + Status error; error.SetErrorString("HostProcessPosix refers to an invalid process"); return error; } @@ -39,8 +39,8 @@ Error HostProcessPosix::Signal(int signo) const { return HostProcessPosix::Signal(m_process, signo); } -Error HostProcessPosix::Signal(lldb::process_t process, int signo) { - Error error; +Status HostProcessPosix::Signal(lldb::process_t process, int signo) { + Status error; if (-1 == ::kill(process, signo)) error.SetErrorToErrno(); @@ -48,10 +48,10 @@ Error HostProcessPosix::Signal(lldb::process_t process, int signo) { return error; } -Error HostProcessPosix::Terminate() { return Signal(SIGKILL); } +Status HostProcessPosix::Terminate() { return Signal(SIGKILL); } -Error HostProcessPosix::GetMainModule(FileSpec &file_spec) const { - Error error; +Status HostProcessPosix::GetMainModule(FileSpec &file_spec) const { + Status error; // Use special code here because proc/[pid]/exe is a symbolic link. char link_path[PATH_MAX]; @@ -82,7 +82,7 @@ bool HostProcessPosix::IsRunning() const { return false; // Send this process the null signal. If it succeeds the process is running. - Error error = Signal(0); + Status error = Signal(0); return error.Success(); } diff --git a/source/Host/posix/HostThreadPosix.cpp b/source/Host/posix/HostThreadPosix.cpp index 073b7b0b11e8c..0f4434d25e2eb 100644 --- a/source/Host/posix/HostThreadPosix.cpp +++ b/source/Host/posix/HostThreadPosix.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/posix/HostThreadPosix.h" -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" #include <errno.h> #include <pthread.h> @@ -23,8 +23,8 @@ HostThreadPosix::HostThreadPosix(lldb::thread_t thread) HostThreadPosix::~HostThreadPosix() {} -Error HostThreadPosix::Join(lldb::thread_result_t *result) { - Error error; +Status HostThreadPosix::Join(lldb::thread_result_t *result) { + Status error; if (IsJoinable()) { int err = ::pthread_join(m_thread, result); error.SetError(err, lldb::eErrorTypePOSIX); @@ -38,8 +38,8 @@ Error HostThreadPosix::Join(lldb::thread_result_t *result) { return error; } -Error HostThreadPosix::Cancel() { - Error error; +Status HostThreadPosix::Cancel() { + Status error; if (IsJoinable()) { #ifndef __ANDROID__ #ifndef __FreeBSD__ @@ -54,8 +54,8 @@ Error HostThreadPosix::Cancel() { return error; } -Error HostThreadPosix::Detach() { - Error error; +Status HostThreadPosix::Detach() { + Status error; if (IsJoinable()) { int err = ::pthread_detach(m_thread); error.SetError(err, eErrorTypePOSIX); diff --git a/source/Host/posix/LockFilePosix.cpp b/source/Host/posix/LockFilePosix.cpp index d1cc617146d00..2b7d548a021c7 100644 --- a/source/Host/posix/LockFilePosix.cpp +++ b/source/Host/posix/LockFilePosix.cpp @@ -16,8 +16,8 @@ using namespace lldb_private; namespace { -Error fileLock(int fd, int cmd, int lock_type, const uint64_t start, - const uint64_t len) { +Status fileLock(int fd, int cmd, int lock_type, const uint64_t start, + const uint64_t len) { struct flock fl; fl.l_type = lock_type; @@ -26,7 +26,7 @@ Error fileLock(int fd, int cmd, int lock_type, const uint64_t start, fl.l_len = len; fl.l_pid = ::getpid(); - Error error; + Status error; if (::fcntl(fd, cmd, &fl) == -1) error.SetErrorToErrno(); @@ -39,22 +39,22 @@ LockFilePosix::LockFilePosix(int fd) : LockFileBase(fd) {} LockFilePosix::~LockFilePosix() { Unlock(); } -Error LockFilePosix::DoWriteLock(const uint64_t start, const uint64_t len) { +Status LockFilePosix::DoWriteLock(const uint64_t start, const uint64_t len) { return fileLock(m_fd, F_SETLKW, F_WRLCK, start, len); } -Error LockFilePosix::DoTryWriteLock(const uint64_t start, const uint64_t len) { +Status LockFilePosix::DoTryWriteLock(const uint64_t start, const uint64_t len) { return fileLock(m_fd, F_SETLK, F_WRLCK, start, len); } -Error LockFilePosix::DoReadLock(const uint64_t start, const uint64_t len) { +Status LockFilePosix::DoReadLock(const uint64_t start, const uint64_t len) { return fileLock(m_fd, F_SETLKW, F_RDLCK, start, len); } -Error LockFilePosix::DoTryReadLock(const uint64_t start, const uint64_t len) { +Status LockFilePosix::DoTryReadLock(const uint64_t start, const uint64_t len) { return fileLock(m_fd, F_SETLK, F_RDLCK, start, len); } -Error LockFilePosix::DoUnlock() { +Status LockFilePosix::DoUnlock() { return fileLock(m_fd, F_SETLK, F_UNLCK, m_start, m_len); } diff --git a/source/Host/posix/PipePosix.cpp b/source/Host/posix/PipePosix.cpp index 3ac5d480de899..da99fd702424e 100644 --- a/source/Host/posix/PipePosix.cpp +++ b/source/Host/posix/PipePosix.cpp @@ -82,11 +82,11 @@ PipePosix &PipePosix::operator=(PipePosix &&pipe_posix) { PipePosix::~PipePosix() { Close(); } -Error PipePosix::CreateNew(bool child_processes_inherit) { +Status PipePosix::CreateNew(bool child_processes_inherit) { if (CanRead() || CanWrite()) - return Error(EINVAL, eErrorTypePOSIX); + return Status(EINVAL, eErrorTypePOSIX); - Error error; + Status error; #if PIPE2_SUPPORTED if (::pipe2(m_fds, (child_processes_inherit) ? 0 : O_CLOEXEC) == 0) return error; @@ -111,20 +111,20 @@ Error PipePosix::CreateNew(bool child_processes_inherit) { return error; } -Error PipePosix::CreateNew(llvm::StringRef name, bool child_process_inherit) { +Status PipePosix::CreateNew(llvm::StringRef name, bool child_process_inherit) { if (CanRead() || CanWrite()) - return Error("Pipe is already opened"); + return Status("Pipe is already opened"); - Error error; + Status error; if (::mkfifo(name.data(), 0660) != 0) error.SetErrorToErrno(); return error; } -Error PipePosix::CreateWithUniqueName(llvm::StringRef prefix, - bool child_process_inherit, - llvm::SmallVectorImpl<char> &name) { +Status PipePosix::CreateWithUniqueName(llvm::StringRef prefix, + bool child_process_inherit, + llvm::SmallVectorImpl<char> &name) { llvm::SmallString<PATH_MAX> named_pipe_path; llvm::SmallString<PATH_MAX> pipe_spec((prefix + ".%%%%%%").str()); FileSpec tmpdir_file_spec; @@ -139,7 +139,7 @@ Error PipePosix::CreateWithUniqueName(llvm::StringRef prefix, // It's possible that another process creates the target path after we've // verified it's available but before we create it, in which case we // should try again. - Error error; + Status error; do { llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath(), named_pipe_path); @@ -151,16 +151,16 @@ Error PipePosix::CreateWithUniqueName(llvm::StringRef prefix, return error; } -Error PipePosix::OpenAsReader(llvm::StringRef name, - bool child_process_inherit) { +Status PipePosix::OpenAsReader(llvm::StringRef name, + bool child_process_inherit) { if (CanRead() || CanWrite()) - return Error("Pipe is already opened"); + return Status("Pipe is already opened"); int flags = O_RDONLY | O_NONBLOCK; if (!child_process_inherit) flags |= O_CLOEXEC; - Error error; + Status error; int fd = ::open(name.data(), flags); if (fd != -1) m_fds[READ] = fd; @@ -170,11 +170,12 @@ Error PipePosix::OpenAsReader(llvm::StringRef name, return error; } -Error PipePosix::OpenAsWriterWithTimeout( - llvm::StringRef name, bool child_process_inherit, - const std::chrono::microseconds &timeout) { +Status +PipePosix::OpenAsWriterWithTimeout(llvm::StringRef name, + bool child_process_inherit, + const std::chrono::microseconds &timeout) { if (CanRead() || CanWrite()) - return Error("Pipe is already opened"); + return Status("Pipe is already opened"); int flags = O_WRONLY | O_NONBLOCK; if (!child_process_inherit) @@ -187,7 +188,7 @@ Error PipePosix::OpenAsWriterWithTimeout( if (timeout != microseconds::zero()) { const auto dur = duration_cast<microseconds>(finish_time - Now()).count(); if (dur <= 0) - return Error("timeout exceeded - reader hasn't opened so far"); + return Status("timeout exceeded - reader hasn't opened so far"); } errno = 0; @@ -196,7 +197,7 @@ Error PipePosix::OpenAsWriterWithTimeout( const auto errno_copy = errno; // We may get ENXIO if a reader side of the pipe hasn't opened yet. if (errno_copy != ENXIO) - return Error(errno_copy, eErrorTypePOSIX); + return Status(errno_copy, eErrorTypePOSIX); std::this_thread::sleep_for( milliseconds(OPEN_WRITER_SLEEP_TIMEOUT_MSECS)); @@ -205,7 +206,7 @@ Error PipePosix::OpenAsWriterWithTimeout( } } - return Error(); + return Status(); } int PipePosix::GetReadFileDescriptor() const { return m_fds[READ]; } @@ -229,7 +230,7 @@ void PipePosix::Close() { CloseWriteFileDescriptor(); } -Error PipePosix::Delete(llvm::StringRef name) { +Status PipePosix::Delete(llvm::StringRef name) { return llvm::sys::fs::remove(name); } @@ -255,12 +256,12 @@ void PipePosix::CloseWriteFileDescriptor() { } } -Error PipePosix::ReadWithTimeout(void *buf, size_t size, - const std::chrono::microseconds &timeout, - size_t &bytes_read) { +Status PipePosix::ReadWithTimeout(void *buf, size_t size, + const std::chrono::microseconds &timeout, + size_t &bytes_read) { bytes_read = 0; if (!CanRead()) - return Error(EINVAL, eErrorTypePOSIX); + return Status(EINVAL, eErrorTypePOSIX); const int fd = GetReadFileDescriptor(); @@ -268,7 +269,7 @@ Error PipePosix::ReadWithTimeout(void *buf, size_t size, select_helper.SetTimeout(timeout); select_helper.FDSetRead(fd); - Error error; + Status error; while (error.Success()) { error = select_helper.Select(); if (error.Success()) { @@ -287,17 +288,17 @@ Error PipePosix::ReadWithTimeout(void *buf, size_t size, return error; } -Error PipePosix::Write(const void *buf, size_t size, size_t &bytes_written) { +Status PipePosix::Write(const void *buf, size_t size, size_t &bytes_written) { bytes_written = 0; if (!CanWrite()) - return Error(EINVAL, eErrorTypePOSIX); + return Status(EINVAL, eErrorTypePOSIX); const int fd = GetWriteFileDescriptor(); SelectHelper select_helper; select_helper.SetTimeout(std::chrono::seconds(0)); select_helper.FDSetWrite(fd); - Error error; + Status error; while (error.Success()) { error = select_helper.Select(); if (error.Success()) { diff --git a/source/Host/posix/ProcessLauncherPosix.cpp b/source/Host/posix/ProcessLauncherPosix.cpp index f90bf0cd88a20..6d07be1eec64c 100644 --- a/source/Host/posix/ProcessLauncherPosix.cpp +++ b/source/Host/posix/ProcessLauncherPosix.cpp @@ -20,7 +20,7 @@ using namespace lldb_private; HostProcess ProcessLauncherPosix::LaunchProcess(const ProcessLaunchInfo &launch_info, - Error &error) { + Status &error) { lldb::pid_t pid; char exe_path[PATH_MAX]; diff --git a/source/Host/posix/ProcessLauncherPosixFork.cpp b/source/Host/posix/ProcessLauncherPosixFork.cpp index 91c32d6e64265..378670cd2a9ad 100644 --- a/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -190,7 +190,7 @@ static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd, HostProcess ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info, - Error &error) { + Status &error) { char exe_path[PATH_MAX]; launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path)); diff --git a/source/Host/windows/ConnectionGenericFileWindows.cpp b/source/Host/windows/ConnectionGenericFileWindows.cpp index 8fc038f3f9b6f..41bdb5f41fb6a 100644 --- a/source/Host/windows/ConnectionGenericFileWindows.cpp +++ b/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/windows/ConnectionGenericFileWindows.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/Timeout.h" #include "llvm/ADT/STLExtras.h" @@ -43,10 +43,10 @@ public: size_t GetBytes() const { return m_bytes; } ConnectionStatus GetStatus() const { return m_status; } - const Error &GetError() const { return m_error; } + const Status &GetError() const { return m_error; } private: - Error m_error; + Status m_error; size_t m_bytes; ConnectionStatus m_status; }; @@ -94,7 +94,7 @@ bool ConnectionGenericFile::IsConnected() const { } lldb::ConnectionStatus ConnectionGenericFile::Connect(llvm::StringRef path, - Error *error_ptr) { + Status *error_ptr) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("%p ConnectionGenericFile::Connect (url = '%s')", @@ -137,7 +137,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Connect(llvm::StringRef path, return eConnectionStatusSuccess; } -lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Error *error_ptr) { +lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Status *error_ptr) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("%p ConnectionGenericFile::Disconnect ()", @@ -171,7 +171,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Error *error_ptr) { size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, const Timeout<std::micro> &timeout, lldb::ConnectionStatus &status, - Error *error_ptr) { + Status *error_ptr) { ReturnInfo return_info; BOOL result = 0; DWORD bytes_read = 0; @@ -269,7 +269,7 @@ finish: size_t ConnectionGenericFile::Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, - Error *error_ptr) { + Status *error_ptr) { ReturnInfo return_info; DWORD bytes_written = 0; BOOL result = 0; diff --git a/source/Host/windows/FileSystem.cpp b/source/Host/windows/FileSystem.cpp index 092b70b1f4dc8..02b7e550f86cd 100644 --- a/source/Host/windows/FileSystem.cpp +++ b/source/Host/windows/FileSystem.cpp @@ -27,8 +27,8 @@ const char *FileSystem::DEV_NULL = "nul"; const char *FileSystem::PATH_CONVERSION_ERROR = "Error converting path between UTF-8 and native encoding"; -Error FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) { - Error error; +Status FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) { + Status error; std::wstring wsrc, wdst; if (!llvm::ConvertUTF8toWide(src.GetCString(), wsrc) || !llvm::ConvertUTF8toWide(dst.GetCString(), wdst)) @@ -48,8 +48,8 @@ Error FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) { return error; } -Error FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { - Error error; +Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { + Status error; std::wstring wsrc; if (!llvm::ConvertUTF8toWide(src.GetCString(), wsrc)) { error.SetErrorString(PATH_CONVERSION_ERROR); @@ -81,8 +81,8 @@ Error FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { return error; } -Error FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) { - return Error("ResolveSymbolicLink() isn't implemented on Windows"); +Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) { + return Status("ResolveSymbolicLink() isn't implemented on Windows"); } FILE *FileSystem::Fopen(const char *path, const char *mode) { diff --git a/source/Host/windows/Host.cpp b/source/Host/windows/Host.cpp index 9a6957b2a1ff0..e1acd23d5c815 100644 --- a/source/Host/windows/Host.cpp +++ b/source/Host/windows/Host.cpp @@ -16,8 +16,8 @@ // Other libraries and framework includes // Project includes #include "lldb/Target/Process.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredData.h" @@ -50,7 +50,7 @@ bool GetTripleForProcess(const FileSpec &executable, llvm::Triple &triple) { imageBinary.SeekFromStart(peOffset); imageBinary.Read(&peHead, readSize); if (peHead != 0x00004550) // "PE\0\0", little-endian - return false; // Error: Can't find PE header + return false; // Status: Can't find PE header readSize = 2; imageBinary.Read(&machineType, readSize); triple.setVendor(llvm::Triple::PC); @@ -196,8 +196,8 @@ HostThread Host::StartMonitoringChildProcess( return HostThread(); } -Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { - Error error; +Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { + Status error; if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) { FileSpec expand_tool_spec; if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir, diff --git a/source/Host/windows/HostProcessWindows.cpp b/source/Host/windows/HostProcessWindows.cpp index 3bbc84a4ca59d..49d42ce054223 100644 --- a/source/Host/windows/HostProcessWindows.cpp +++ b/source/Host/windows/HostProcessWindows.cpp @@ -37,8 +37,8 @@ HostProcessWindows::~HostProcessWindows() { Close(); } void HostProcessWindows::SetOwnsHandle(bool owns) { m_owns_handle = owns; } -Error HostProcessWindows::Terminate() { - Error error; +Status HostProcessWindows::Terminate() { + Status error; if (m_process == nullptr) error.SetError(ERROR_INVALID_HANDLE, lldb::eErrorTypeWin32); @@ -48,8 +48,8 @@ Error HostProcessWindows::Terminate() { return error; } -Error HostProcessWindows::GetMainModule(FileSpec &file_spec) const { - Error error; +Status HostProcessWindows::GetMainModule(FileSpec &file_spec) const { + Status error; if (m_process == nullptr) error.SetError(ERROR_INVALID_HANDLE, lldb::eErrorTypeWin32); diff --git a/source/Host/windows/HostThreadWindows.cpp b/source/Host/windows/HostThreadWindows.cpp index aa791714c338a..3d603ff616634 100644 --- a/source/Host/windows/HostThreadWindows.cpp +++ b/source/Host/windows/HostThreadWindows.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" #include "lldb/Host/windows/HostThreadWindows.h" #include "lldb/Host/windows/windows.h" @@ -33,8 +33,8 @@ HostThreadWindows::~HostThreadWindows() { Reset(); } void HostThreadWindows::SetOwnsHandle(bool owns) { m_owns_handle = owns; } -Error HostThreadWindows::Join(lldb::thread_result_t *result) { - Error error; +Status HostThreadWindows::Join(lldb::thread_result_t *result) { + Status error; if (IsJoinable()) { DWORD wait_result = ::WaitForSingleObject(m_thread, INFINITE); if (WAIT_OBJECT_0 == wait_result && result) { @@ -51,8 +51,8 @@ Error HostThreadWindows::Join(lldb::thread_result_t *result) { return error; } -Error HostThreadWindows::Cancel() { - Error error; +Status HostThreadWindows::Cancel() { + Status error; DWORD result = ::QueueUserAPC(::ExitThreadProxy, m_thread, 0); error.SetError(result, eErrorTypeWin32); diff --git a/source/Host/windows/LockFileWindows.cpp b/source/Host/windows/LockFileWindows.cpp index 0e7f595e6cfd1..2178fd1f5f6cf 100644 --- a/source/Host/windows/LockFileWindows.cpp +++ b/source/Host/windows/LockFileWindows.cpp @@ -16,22 +16,22 @@ using namespace lldb_private; namespace { -Error fileLock(HANDLE file_handle, DWORD flags, const uint64_t start, - const uint64_t len) { +Status fileLock(HANDLE file_handle, DWORD flags, const uint64_t start, + const uint64_t len) { if (start != 0) - return Error("Non-zero start lock regions are not supported"); + return Status("Non-zero start lock regions are not supported"); OVERLAPPED overlapped = {}; if (!::LockFileEx(file_handle, flags, 0, len, 0, &overlapped) && ::GetLastError() != ERROR_IO_PENDING) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); DWORD bytes; if (!::GetOverlappedResult(file_handle, &overlapped, &bytes, TRUE)) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); - return Error(); + return Status(); } } // namespace @@ -45,34 +45,35 @@ bool LockFileWindows::IsValidFile() const { return LockFileBase::IsValidFile() && m_file != INVALID_HANDLE_VALUE; } -Error LockFileWindows::DoWriteLock(const uint64_t start, const uint64_t len) { +Status LockFileWindows::DoWriteLock(const uint64_t start, const uint64_t len) { return fileLock(m_file, LOCKFILE_EXCLUSIVE_LOCK, start, len); } -Error LockFileWindows::DoTryWriteLock(const uint64_t start, - const uint64_t len) { +Status LockFileWindows::DoTryWriteLock(const uint64_t start, + const uint64_t len) { return fileLock(m_file, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, start, len); } -Error LockFileWindows::DoReadLock(const uint64_t start, const uint64_t len) { +Status LockFileWindows::DoReadLock(const uint64_t start, const uint64_t len) { return fileLock(m_file, 0, start, len); } -Error LockFileWindows::DoTryReadLock(const uint64_t start, const uint64_t len) { +Status LockFileWindows::DoTryReadLock(const uint64_t start, + const uint64_t len) { return fileLock(m_file, LOCKFILE_FAIL_IMMEDIATELY, start, len); } -Error LockFileWindows::DoUnlock() { +Status LockFileWindows::DoUnlock() { OVERLAPPED overlapped = {}; if (!::UnlockFileEx(m_file, 0, m_len, 0, &overlapped) && ::GetLastError() != ERROR_IO_PENDING) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); DWORD bytes; if (!::GetOverlappedResult(m_file, &overlapped, &bytes, TRUE)) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); - return Error(); + return Status(); } diff --git a/source/Host/windows/PipeWindows.cpp b/source/Host/windows/PipeWindows.cpp index 407f0468e6cb0..e8f4753d11e2c 100644 --- a/source/Host/windows/PipeWindows.cpp +++ b/source/Host/windows/PipeWindows.cpp @@ -39,7 +39,7 @@ PipeWindows::PipeWindows() { PipeWindows::~PipeWindows() { Close(); } -Error PipeWindows::CreateNew(bool child_process_inherit) { +Status PipeWindows::CreateNew(bool child_process_inherit) { // Even for anonymous pipes, we open a named pipe. This is because you cannot // get // overlapped i/o on Windows without using a named pipe. So we synthesize a @@ -54,12 +54,13 @@ Error PipeWindows::CreateNew(bool child_process_inherit) { return CreateNew(pipe_name.c_str(), child_process_inherit); } -Error PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit) { +Status PipeWindows::CreateNew(llvm::StringRef name, + bool child_process_inherit) { if (name.empty()) - return Error(ERROR_INVALID_PARAMETER, eErrorTypeWin32); + return Status(ERROR_INVALID_PARAMETER, eErrorTypeWin32); if (CanRead() || CanWrite()) - return Error(ERROR_ALREADY_EXISTS, eErrorTypeWin32); + return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); std::string pipe_path = "\\\\.\\Pipe\\"; pipe_path.append(name); @@ -71,13 +72,13 @@ Error PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit) { pipe_path.c_str(), PIPE_ACCESS_INBOUND | read_mode, PIPE_TYPE_BYTE | PIPE_WAIT, 1, 1024, 1024, 120 * 1000, NULL); if (INVALID_HANDLE_VALUE == m_read) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); m_read_fd = _open_osfhandle((intptr_t)m_read, _O_RDONLY); ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); m_read_overlapped.hEvent = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); // Open the write end of the pipe. - Error result = OpenNamedPipe(name, child_process_inherit, false); + Status result = OpenNamedPipe(name, child_process_inherit, false); if (!result.Success()) { CloseReadFileDescriptor(); return result; @@ -86,11 +87,11 @@ Error PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit) { return result; } -Error PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, - bool child_process_inherit, - llvm::SmallVectorImpl<char> &name) { +Status PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, + bool child_process_inherit, + llvm::SmallVectorImpl<char> &name) { llvm::SmallString<128> pipe_name; - Error error; + Status error; ::UUID unique_id; RPC_CSTR unique_string; RPC_STATUS status = ::UuidCreate(&unique_id); @@ -110,27 +111,28 @@ Error PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, return error; } -Error PipeWindows::OpenAsReader(llvm::StringRef name, - bool child_process_inherit) { +Status PipeWindows::OpenAsReader(llvm::StringRef name, + bool child_process_inherit) { if (CanRead() || CanWrite()) - return Error(ERROR_ALREADY_EXISTS, eErrorTypeWin32); + return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); return OpenNamedPipe(name, child_process_inherit, true); } -Error PipeWindows::OpenAsWriterWithTimeout( - llvm::StringRef name, bool child_process_inherit, - const std::chrono::microseconds &timeout) { +Status +PipeWindows::OpenAsWriterWithTimeout(llvm::StringRef name, + bool child_process_inherit, + const std::chrono::microseconds &timeout) { if (CanRead() || CanWrite()) - return Error(ERROR_ALREADY_EXISTS, eErrorTypeWin32); + return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); return OpenNamedPipe(name, child_process_inherit, false); } -Error PipeWindows::OpenNamedPipe(llvm::StringRef name, - bool child_process_inherit, bool is_read) { +Status PipeWindows::OpenNamedPipe(llvm::StringRef name, + bool child_process_inherit, bool is_read) { if (name.empty()) - return Error(ERROR_INVALID_PARAMETER, eErrorTypeWin32); + return Status(ERROR_INVALID_PARAMETER, eErrorTypeWin32); assert(is_read ? !CanRead() : !CanWrite()); @@ -144,7 +146,7 @@ Error PipeWindows::OpenNamedPipe(llvm::StringRef name, m_read = ::CreateFileA(pipe_path.c_str(), GENERIC_READ, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (INVALID_HANDLE_VALUE == m_read) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); m_read_fd = _open_osfhandle((intptr_t)m_read, _O_RDONLY); @@ -154,14 +156,14 @@ Error PipeWindows::OpenNamedPipe(llvm::StringRef name, m_write = ::CreateFileA(pipe_path.c_str(), GENERIC_WRITE, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (INVALID_HANDLE_VALUE == m_write) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); } - return Error(); + return Status(); } int PipeWindows::GetReadFileDescriptor() const { return m_read_fd; } @@ -217,7 +219,7 @@ void PipeWindows::Close() { CloseWriteFileDescriptor(); } -Error PipeWindows::Delete(llvm::StringRef name) { return Error(); } +Status PipeWindows::Delete(llvm::StringRef name) { return Status(); } bool PipeWindows::CanRead() const { return (m_read != INVALID_HANDLE_VALUE); } @@ -229,18 +231,18 @@ PipeWindows::GetReadNativeHandle() { return m_read; } HANDLE PipeWindows::GetWriteNativeHandle() { return m_write; } -Error PipeWindows::ReadWithTimeout(void *buf, size_t size, - const std::chrono::microseconds &duration, - size_t &bytes_read) { +Status PipeWindows::ReadWithTimeout(void *buf, size_t size, + const std::chrono::microseconds &duration, + size_t &bytes_read) { if (!CanRead()) - return Error(ERROR_INVALID_HANDLE, eErrorTypeWin32); + return Status(ERROR_INVALID_HANDLE, eErrorTypeWin32); bytes_read = 0; DWORD sys_bytes_read = size; BOOL result = ::ReadFile(m_read, buf, sys_bytes_read, &sys_bytes_read, &m_read_overlapped); if (!result && GetLastError() != ERROR_IO_PENDING) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); DWORD timeout = (duration == std::chrono::microseconds::zero()) ? INFINITE @@ -263,33 +265,33 @@ Error PipeWindows::ReadWithTimeout(void *buf, size_t size, failed = false; } if (failed) - return Error(failure_error, eErrorTypeWin32); + return Status(failure_error, eErrorTypeWin32); } // Now we call GetOverlappedResult setting bWait to false, since we've already // waited // as long as we're willing to. if (!GetOverlappedResult(m_read, &m_read_overlapped, &sys_bytes_read, FALSE)) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); bytes_read = sys_bytes_read; - return Error(); + return Status(); } -Error PipeWindows::Write(const void *buf, size_t num_bytes, - size_t &bytes_written) { +Status PipeWindows::Write(const void *buf, size_t num_bytes, + size_t &bytes_written) { if (!CanWrite()) - return Error(ERROR_INVALID_HANDLE, eErrorTypeWin32); + return Status(ERROR_INVALID_HANDLE, eErrorTypeWin32); DWORD sys_bytes_written = 0; BOOL write_result = ::WriteFile(m_write, buf, num_bytes, &sys_bytes_written, &m_write_overlapped); if (!write_result && GetLastError() != ERROR_IO_PENDING) - return Error(::GetLastError(), eErrorTypeWin32); + return Status(::GetLastError(), eErrorTypeWin32); BOOL result = GetOverlappedResult(m_write, &m_write_overlapped, &sys_bytes_written, TRUE); if (!result) - return Error(::GetLastError(), eErrorTypeWin32); - return Error(); + return Status(::GetLastError(), eErrorTypeWin32); + return Status(); } diff --git a/source/Host/windows/ProcessLauncherWindows.cpp b/source/Host/windows/ProcessLauncherWindows.cpp index 16805ba7df889..56089742f0932 100644 --- a/source/Host/windows/ProcessLauncherWindows.cpp +++ b/source/Host/windows/ProcessLauncherWindows.cpp @@ -41,7 +41,7 @@ void CreateEnvironmentBuffer(const Args &env, std::vector<char> &buffer) { HostProcess ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info, - Error &error) { + Status &error) { error.Clear(); std::string executable; |