diff options
author | Zachary Turner <zturner@google.com> | 2017-05-12 04:51:55 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-05-12 04:51:55 +0000 |
commit | 97206d572797bddc1bba71bb1c18c97f19d69053 (patch) | |
tree | fdf21d24485672cf97c800264d135b9d5d2ecdce /lldb/source/Host/common | |
parent | 3086b45a2fae833e8419885e78c598d936cc6429 (diff) | |
download | bcm5719-llvm-97206d572797bddc1bba71bb1c18c97f19d69053.tar.gz bcm5719-llvm-97206d572797bddc1bba71bb1c18c97f19d69053.zip |
Rename Error -> Status.
This renames the LLDB error class to Status, as discussed
on the lldb-dev mailing list.
A change of this magnitude cannot easily be done without
find and replace, but that has potential to catch unwanted
occurrences of common strings such as "Error". Every effort
was made to find all the obvious things such as the word "Error"
appearing in a string, etc, but it's possible there are still
some lingering occurences left around. Hopefully nothing too
serious.
llvm-svn: 302872
Diffstat (limited to 'lldb/source/Host/common')
21 files changed, 305 insertions, 299 deletions
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 851287e7633..7d4b398a171 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/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/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index 1869a6db49c..3de93ebc220 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/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/lldb/source/Host/common/FileCache.cpp b/lldb/source/Host/common/FileCache.cpp index db71813e4ff..b4629255c85 100644 --- a/lldb/source/Host/common/FileCache.cpp +++ b/lldb/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/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 7754d96ad33..da35022c813 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/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/lldb/source/Host/common/HostProcess.cpp b/lldb/source/Host/common/HostProcess.cpp index 2d99d8e1fc9..15403332151 100644 --- a/lldb/source/Host/common/HostProcess.cpp +++ b/lldb/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/lldb/source/Host/common/HostThread.cpp b/lldb/source/Host/common/HostThread.cpp index 738b7ef72f1..02882c52390 100644 --- a/lldb/source/Host/common/HostThread.cpp +++ b/lldb/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/lldb/source/Host/common/LockFileBase.cpp b/lldb/source/Host/common/LockFileBase.cpp index b30acc5d504..a8d7881ab89 100644 --- a/lldb/source/Host/common/LockFileBase.cpp +++ b/lldb/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/lldb/source/Host/common/MainLoop.cpp b/lldb/source/Host/common/MainLoop.cpp index abd52f7f46f..7de6f7fa865 100644 --- a/lldb/source/Host/common/MainLoop.cpp +++ b/lldb/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/lldb/source/Host/common/MonitoringProcessLauncher.cpp b/lldb/source/Host/common/MonitoringProcessLauncher.cpp index 2aa6c7f50b6..f1fcd0b44c1 100644 --- a/lldb/source/Host/common/MonitoringProcessLauncher.cpp +++ b/lldb/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/lldb/source/Host/common/NativeBreakpoint.cpp b/lldb/source/Host/common/NativeBreakpoint.cpp index 8a3ee72179c..5eee3de482c 100644 --- a/lldb/source/Host/common/NativeBreakpoint.cpp +++ b/lldb/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/lldb/source/Host/common/NativeBreakpointList.cpp b/lldb/source/Host/common/NativeBreakpointList.cpp index 60608a0bbc5..ce5eb94a8d1 100644 --- a/lldb/source/Host/common/NativeBreakpointList.cpp +++ b/lldb/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/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp index 9d4149d700b..6f1a9f895b6 100644 --- a/lldb/source/Host/common/NativeProcessProtocol.cpp +++ b/lldb/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/lldb/source/Host/common/NativeRegisterContext.cpp b/lldb/source/Host/common/NativeRegisterContext.cpp index 3bc0a0d9705..2ca95d70796 100644 --- a/lldb/source/Host/common/NativeRegisterContext.cpp +++ b/lldb/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/lldb/source/Host/common/NativeThreadProtocol.cpp b/lldb/source/Host/common/NativeThreadProtocol.cpp index 2e76cff0d67..29e25bbc569 100644 --- a/lldb/source/Host/common/NativeThreadProtocol.cpp +++ b/lldb/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/lldb/source/Host/common/NativeWatchpointList.cpp b/lldb/source/Host/common/NativeWatchpointList.cpp index 168e5b42b96..e6ef7300eb2 100644 --- a/lldb/source/Host/common/NativeWatchpointList.cpp +++ b/lldb/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/lldb/source/Host/common/PipeBase.cpp b/lldb/source/Host/common/PipeBase.cpp index cf7e6c97c3c..632bfcb3a2e 100644 --- a/lldb/source/Host/common/PipeBase.cpp +++ b/lldb/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/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index d73b5d0ad07..0df9dc02c70 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/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/lldb/source/Host/common/SoftwareBreakpoint.cpp b/lldb/source/Host/common/SoftwareBreakpoint.cpp index 436cb2bb112..14dbafd94c0 100644 --- a/lldb/source/Host/common/SoftwareBreakpoint.cpp +++ b/lldb/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/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp index 55db4bb0c45..c013334ce23 100644 --- a/lldb/source/Host/common/TCPSocket.cpp +++ b/lldb/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/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp index 32641efe408..f3401016393 100644 --- a/lldb/source/Host/common/ThreadLauncher.cpp +++ b/lldb/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/lldb/source/Host/common/UDPSocket.cpp b/lldb/source/Host/common/UDPSocket.cpp index ce8d90891b2..21dacbc626e 100644 --- a/lldb/source/Host/common/UDPSocket.cpp +++ b/lldb/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; |