diff options
Diffstat (limited to 'source/Plugins/Process/NetBSD')
8 files changed, 220 insertions, 217 deletions
diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 347c12943bd5..80751147b4f5 100644 --- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -68,8 +68,8 @@ static int convert_pid_status_to_return_code(int status) { // Simple helper function to ensure flags are enabled on the given file // descriptor. -static Error EnsureFDFlags(int fd, int flags) { - Error error; +static Status EnsureFDFlags(int fd, int flags) { + Status error; int status = fcntl(fd, F_GETFL); if (status == -1) { @@ -89,13 +89,13 @@ static Error EnsureFDFlags(int fd, int flags) { // Public Static Methods // ----------------------------------------------------------------------------- -Error NativeProcessProtocol::Launch( +Status NativeProcessProtocol::Launch( ProcessLaunchInfo &launch_info, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); - Error error; + Status error; // Verify the working directory is valid if one was specified. FileSpec working_dir{launch_info.GetWorkingDirectory()}; @@ -129,7 +129,7 @@ Error NativeProcessProtocol::Launch( return error; } -Error NativeProcessProtocol::Attach( +Status NativeProcessProtocol::Attach( lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); @@ -137,7 +137,7 @@ Error NativeProcessProtocol::Attach( // Retrieve the architecture for the running process. ArchSpec process_arch; - Error error = ResolveProcessArchitecture(pid, process_arch); + Status error = ResolveProcessArchitecture(pid, process_arch); if (!error.Success()) return error; @@ -245,7 +245,7 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) { SetState(StateType::eStateStopped, true); break; case TRAP_EXEC: { - Error error = ReinitializeThreads(); + Status error = ReinitializeThreads(); if (error.Fail()) { SetState(StateType::eStateInvalid); return; @@ -262,7 +262,7 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) { case TRAP_DBREG: { // If a watchpoint was hit, report it uint32_t wp_index; - Error error = + Status error = static_pointer_cast<NativeThreadNetBSD>(m_threads[info.psi_lwpid]) ->GetRegisterContext() ->GetWatchpointHitIndex(wp_index, @@ -318,10 +318,10 @@ void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) { SetState(StateType::eStateStopped, true); } -Error NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, - int data, int *result) { +Status NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, + int data, int *result) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); - Error error; + Status error; int ret; errno = 0; @@ -341,7 +341,7 @@ Error NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, return error; } -Error NativeProcessNetBSD::GetSoftwareBreakpointPCOffset( +Status NativeProcessNetBSD::GetSoftwareBreakpointPCOffset( uint32_t &actual_opcode_size) { // FIXME put this behind a breakpoint protocol class that can be // set per architecture. Need ARM, MIPS support here. @@ -349,17 +349,17 @@ Error NativeProcessNetBSD::GetSoftwareBreakpointPCOffset( switch (m_arch.GetMachine()) { case llvm::Triple::x86_64: actual_opcode_size = static_cast<uint32_t>(sizeof(g_i386_opcode)); - return Error(); + return Status(); default: assert(false && "CPU type not supported!"); - return Error("CPU type not supported"); + return Status("CPU type not supported"); } } -Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded( - NativeThreadNetBSD &thread) { +Status +NativeProcessNetBSD::FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); - Error error; + Status error; // Find out the size of a breakpoint (might depend on where we are in the // code). NativeRegisterContextSP context_sp = thread.GetRegisterContext(); @@ -394,7 +394,7 @@ Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded( "pid {0} no lldb breakpoint found at current pc with " "adjustment: {1}", GetID(), breakpoint_addr); - return Error(); + return Status(); } // If the breakpoint is not a software breakpoint, nothing to do. if (!breakpoint_sp->IsSoftwareBreakpoint()) { @@ -402,7 +402,7 @@ Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded( log, "pid {0} breakpoint found at {1:x}, not software, nothing to adjust", GetID(), breakpoint_addr); - return Error(); + return Status(); } // // We have a software breakpoint and need to adjust the PC. @@ -414,7 +414,7 @@ Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded( "pid {0} breakpoint found at {1:x}, it is software, but the " "size is zero, nothing to do (unexpected)", GetID(), breakpoint_addr); - return Error(); + return Status(); } // // We have a software breakpoint and need to adjust the PC. @@ -426,7 +426,7 @@ Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded( "pid {0} breakpoint found at {1:x}, it is software, but the " "size is zero, nothing to do (unexpected)", GetID(), breakpoint_addr); - return Error(); + return Status(); } // Change the program counter. LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(), @@ -440,7 +440,7 @@ Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded( return error; } -Error NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { +Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); LLDB_LOG(log, "pid {0}", GetID()); @@ -451,10 +451,10 @@ Error NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { if (action == nullptr) { LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(), thread_sp->GetID()); - return Error(); + return Status(); } - Error error; + Status error; switch (action->state) { case eStateRunning: { @@ -486,17 +486,17 @@ Error NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { llvm_unreachable("Unexpected state"); default: - return Error("NativeProcessNetBSD::%s (): unexpected state %s specified " - "for pid %" PRIu64 ", tid %" PRIu64, - __FUNCTION__, StateAsCString(action->state), GetID(), - thread_sp->GetID()); + return Status("NativeProcessNetBSD::%s (): unexpected state %s specified " + "for pid %" PRIu64 ", tid %" PRIu64, + __FUNCTION__, StateAsCString(action->state), GetID(), + thread_sp->GetID()); } - return Error(); + return Status(); } -Error NativeProcessNetBSD::Halt() { - Error error; +Status NativeProcessNetBSD::Halt() { + Status error; if (kill(GetID(), SIGSTOP) != 0) error.SetErrorToErrno(); @@ -504,8 +504,8 @@ Error NativeProcessNetBSD::Halt() { return error; } -Error NativeProcessNetBSD::Detach() { - Error error; +Status NativeProcessNetBSD::Detach() { + Status error; // Stop monitoring the inferior. m_sigchld_handle.reset(); @@ -517,8 +517,8 @@ Error NativeProcessNetBSD::Detach() { return PtraceWrapper(PT_DETACH, GetID()); } -Error NativeProcessNetBSD::Signal(int signo) { - Error error; +Status NativeProcessNetBSD::Signal(int signo) { + Status error; if (kill(GetID(), signo)) error.SetErrorToErrno(); @@ -526,11 +526,11 @@ Error NativeProcessNetBSD::Signal(int signo) { return error; } -Error NativeProcessNetBSD::Kill() { +Status NativeProcessNetBSD::Kill() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); LLDB_LOG(log, "pid {0}", GetID()); - Error error; + Status error; switch (m_state) { case StateType::eStateInvalid: @@ -562,15 +562,15 @@ Error NativeProcessNetBSD::Kill() { return error; } -Error NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo &range_info) { +Status NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) { if (m_supports_mem_region == LazyBool::eLazyBoolNo) { // We're done. - return Error("unsupported"); + return Status("unsupported"); } - Error error = PopulateMemoryRegionCache(); + Status error = PopulateMemoryRegionCache(); if (error.Fail()) { return error; } @@ -619,14 +619,14 @@ Error NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr, return error; } -Error NativeProcessNetBSD::PopulateMemoryRegionCache() { +Status NativeProcessNetBSD::PopulateMemoryRegionCache() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); // If our cache is empty, pull the latest. There should always be at least // one memory region if memory region handling is supported. if (!m_mem_region_cache.empty()) { LLDB_LOG(log, "reusing {0} cached memory region entries", m_mem_region_cache.size()); - return Error(); + return Status(); } struct kinfo_vmentry *vm; @@ -634,7 +634,7 @@ Error NativeProcessNetBSD::PopulateMemoryRegionCache() { vm = kinfo_getvmmap(GetID(), &count); if (vm == NULL) { m_supports_mem_region = LazyBool::eLazyBoolNo; - Error error; + Status error; error.SetErrorString("not supported"); return error; } @@ -674,7 +674,7 @@ Error NativeProcessNetBSD::PopulateMemoryRegionCache() { LLDB_LOG(log, "failed to find any vmmap entries, assuming no support " "for memory region metadata retrieval"); m_supports_mem_region = LazyBool::eLazyBoolNo; - Error error; + Status error; error.SetErrorString("not supported"); return error; } @@ -682,16 +682,16 @@ Error NativeProcessNetBSD::PopulateMemoryRegionCache() { m_mem_region_cache.size(), GetID()); // We support memory retrieval, remember that. m_supports_mem_region = LazyBool::eLazyBoolYes; - return Error(); + return Status(); } -Error NativeProcessNetBSD::AllocateMemory(size_t size, uint32_t permissions, - lldb::addr_t &addr) { - return Error("Unimplemented"); +Status NativeProcessNetBSD::AllocateMemory(size_t size, uint32_t permissions, + lldb::addr_t &addr) { + return Status("Unimplemented"); } -Error NativeProcessNetBSD::DeallocateMemory(lldb::addr_t addr) { - return Error("Unimplemented"); +Status NativeProcessNetBSD::DeallocateMemory(lldb::addr_t addr) { + return Status("Unimplemented"); } lldb::addr_t NativeProcessNetBSD::GetSharedLibraryInfoAddress() { @@ -706,15 +706,15 @@ bool NativeProcessNetBSD::GetArchitecture(ArchSpec &arch) const { return true; } -Error NativeProcessNetBSD::SetBreakpoint(lldb::addr_t addr, uint32_t size, - bool hardware) { +Status NativeProcessNetBSD::SetBreakpoint(lldb::addr_t addr, uint32_t size, + bool hardware) { if (hardware) - return Error("NativeProcessNetBSD does not support hardware breakpoints"); + return Status("NativeProcessNetBSD does not support hardware breakpoints"); else return SetSoftwareBreakpoint(addr, size); } -Error NativeProcessNetBSD::GetSoftwareBreakpointTrapOpcode( +Status NativeProcessNetBSD::GetSoftwareBreakpointTrapOpcode( size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) { static const uint8_t g_i386_opcode[] = {0xCC}; @@ -724,27 +724,27 @@ Error NativeProcessNetBSD::GetSoftwareBreakpointTrapOpcode( case llvm::Triple::x86_64: trap_opcode_bytes = g_i386_opcode; actual_opcode_size = sizeof(g_i386_opcode); - return Error(); + return Status(); default: assert(false && "CPU type not supported!"); - return Error("CPU type not supported"); + return Status("CPU type not supported"); } } -Error NativeProcessNetBSD::GetLoadedModuleFileSpec(const char *module_path, - FileSpec &file_spec) { - return Error("Unimplemented"); +Status NativeProcessNetBSD::GetLoadedModuleFileSpec(const char *module_path, + FileSpec &file_spec) { + return Status("Unimplemented"); } -Error NativeProcessNetBSD::GetFileLoadAddress(const llvm::StringRef &file_name, - lldb::addr_t &load_addr) { +Status NativeProcessNetBSD::GetFileLoadAddress(const llvm::StringRef &file_name, + lldb::addr_t &load_addr) { load_addr = LLDB_INVALID_ADDRESS; - return Error(); + return Status(); } -Error NativeProcessNetBSD::LaunchInferior(MainLoop &mainloop, - ProcessLaunchInfo &launch_info) { - Error error; +Status NativeProcessNetBSD::LaunchInferior(MainLoop &mainloop, + ProcessLaunchInfo &launch_info) { + Status error; m_sigchld_handle = mainloop.RegisterSignal( SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, error); if (!m_sigchld_handle) @@ -826,7 +826,7 @@ Error NativeProcessNetBSD::LaunchInferior(MainLoop &mainloop, } void NativeProcessNetBSD::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, - Error &error) { + Status &error) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); LLDB_LOG(log, "pid = {0:x}", pid); @@ -862,7 +862,7 @@ void NativeProcessNetBSD::SigchldHandler() { if (errno == EINTR) return; - Error error(errno, eErrorTypePOSIX); + Status error(errno, eErrorTypePOSIX); LLDB_LOG(log, "waitpid ({0}, &status, _) failed: {1}", GetID(), error); } @@ -915,7 +915,7 @@ NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) { return thread_sp; } -::pid_t NativeProcessNetBSD::Attach(lldb::pid_t pid, Error &error) { +::pid_t NativeProcessNetBSD::Attach(lldb::pid_t pid, Status &error) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); if (pid <= 1) { @@ -956,8 +956,8 @@ NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) { return pid; } -Error NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, size_t size, - size_t &bytes_read) { +Status NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, + size_t size, size_t &bytes_read) { unsigned char *dst = static_cast<unsigned char *>(buf); struct ptrace_io_desc io; @@ -972,7 +972,7 @@ Error NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, size_t size, io.piod_offs = (void *)(addr + bytes_read); io.piod_addr = dst + bytes_read; - Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); + Status error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); if (error.Fail()) return error; @@ -980,22 +980,22 @@ Error NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, size_t size, io.piod_len = size - bytes_read; } while (bytes_read < size); - return Error(); + return Status(); } -Error NativeProcessNetBSD::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, - size_t size, - size_t &bytes_read) { - Error error = ReadMemory(addr, buf, size, bytes_read); +Status NativeProcessNetBSD::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, + size_t size, + size_t &bytes_read) { + Status error = ReadMemory(addr, buf, size, bytes_read); if (error.Fail()) return error; return m_breakpoint_list.RemoveTrapsFromBuffer(addr, buf, size); } -Error NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf, - size_t size, size_t &bytes_written) { +Status NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf, + size_t size, size_t &bytes_written) { const unsigned char *src = static_cast<const unsigned char *>(buf); - Error error; + Status error; struct ptrace_io_desc io; Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); @@ -1009,7 +1009,7 @@ Error NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf, io.piod_addr = (void *)(src + bytes_written); io.piod_offs = (void *)(addr + bytes_written); - Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); + Status error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); if (error.Fail()) return error; @@ -1039,7 +1039,7 @@ NativeProcessNetBSD::GetAuxvData() const { .piod_addr = (void *)buf.get()->getBufferStart(), .piod_len = auxv_size}; - Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); + Status error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io); if (error.Fail()) return std::error_code(error.GetError(), std::generic_category()); @@ -1050,13 +1050,13 @@ NativeProcessNetBSD::GetAuxvData() const { return buf; } -Error NativeProcessNetBSD::ReinitializeThreads() { +Status NativeProcessNetBSD::ReinitializeThreads() { // Clear old threads m_threads.clear(); // Initialize new thread struct ptrace_lwpinfo info = {}; - Error error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info)); + Status error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info)); if (error.Fail()) { return error; } diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h index ae946a8e004d..e18ba162e523 100644 --- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h +++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h @@ -31,11 +31,11 @@ namespace process_netbsd { /// /// Changes in the inferior process state are broadcasted. class NativeProcessNetBSD : public NativeProcessProtocol { - friend Error NativeProcessProtocol::Launch( + friend Status NativeProcessProtocol::Launch( ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate, MainLoop &mainloop, NativeProcessProtocolSP &process_sp); - friend Error NativeProcessProtocol::Attach( + friend Status NativeProcessProtocol::Attach( lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop, NativeProcessProtocolSP &process_sp); @@ -43,32 +43,32 @@ public: // --------------------------------------------------------------------- // NativeProcessProtocol Interface // --------------------------------------------------------------------- - Error Resume(const ResumeActionList &resume_actions) override; + Status Resume(const ResumeActionList &resume_actions) override; - Error Halt() override; + Status Halt() override; - Error Detach() override; + Status Detach() override; - Error Signal(int signo) override; + Status Signal(int signo) override; - Error Kill() override; + Status Kill() override; - Error GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo &range_info) override; + Status GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) override; - Error ReadMemory(lldb::addr_t addr, void *buf, size_t size, - size_t &bytes_read) override; + Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read) override; - Error ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, - size_t &bytes_read) override; + Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read) override; - Error WriteMemory(lldb::addr_t addr, const void *buf, size_t size, - size_t &bytes_written) override; + Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, + size_t &bytes_written) override; - Error AllocateMemory(size_t size, uint32_t permissions, - lldb::addr_t &addr) override; + Status AllocateMemory(size_t size, uint32_t permissions, + lldb::addr_t &addr) override; - Error DeallocateMemory(lldb::addr_t addr) override; + Status DeallocateMemory(lldb::addr_t addr) override; lldb::addr_t GetSharedLibraryInfoAddress() override; @@ -76,13 +76,14 @@ public: bool GetArchitecture(ArchSpec &arch) const override; - Error SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override; + Status SetBreakpoint(lldb::addr_t addr, uint32_t size, + bool hardware) override; - Error GetLoadedModuleFileSpec(const char *module_path, - FileSpec &file_spec) override; + Status GetLoadedModuleFileSpec(const char *module_path, + FileSpec &file_spec) override; - Error GetFileLoadAddress(const llvm::StringRef &file_name, - lldb::addr_t &load_addr) override; + Status GetFileLoadAddress(const llvm::StringRef &file_name, + lldb::addr_t &load_addr) override; llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> GetAuxvData() const override; @@ -90,15 +91,15 @@ public: // --------------------------------------------------------------------- // Interface used by NativeRegisterContext-derived classes. // --------------------------------------------------------------------- - static Error PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, - int data = 0, int *result = nullptr); + static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, + int data = 0, int *result = nullptr); protected: // --------------------------------------------------------------------- // NativeProcessProtocol protected interface // --------------------------------------------------------------------- - Error + Status GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) override; @@ -116,8 +117,8 @@ private: NativeThreadNetBSDSP AddThread(lldb::tid_t thread_id); - Error LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info); - void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Error &error); + Status LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info); + void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Status &error); void MonitorCallback(lldb::pid_t pid, int signal); void MonitorExited(lldb::pid_t pid, int signal, int status); @@ -125,14 +126,14 @@ private: void MonitorSIGTRAP(lldb::pid_t pid); void MonitorSignal(lldb::pid_t pid, int signal); - Error GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); - Error FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread); - Error PopulateMemoryRegionCache(); + Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); + Status FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread); + Status PopulateMemoryRegionCache(); void SigchldHandler(); - ::pid_t Attach(lldb::pid_t pid, Error &error); + ::pid_t Attach(lldb::pid_t pid, Status &error); - Error ReinitializeThreads(); + Status ReinitializeThreads(); }; } // namespace process_netbsd diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp index cd47deac73ad..b442fc3462cc 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp @@ -25,80 +25,80 @@ NativeRegisterContextNetBSD::NativeRegisterContextNetBSD( : NativeRegisterContextRegisterInfo(native_thread, concrete_frame_idx, reg_info_interface_p) {} -Error NativeRegisterContextNetBSD::ReadGPR() { +Status NativeRegisterContextNetBSD::ReadGPR() { void *buf = GetGPRBuffer(); if (!buf) - return Error("GPR buffer is NULL"); + return Status("GPR buffer is NULL"); return DoReadGPR(buf); } -Error NativeRegisterContextNetBSD::WriteGPR() { +Status NativeRegisterContextNetBSD::WriteGPR() { void *buf = GetGPRBuffer(); if (!buf) - return Error("GPR buffer is NULL"); + return Status("GPR buffer is NULL"); return DoWriteGPR(buf); } -Error NativeRegisterContextNetBSD::ReadFPR() { +Status NativeRegisterContextNetBSD::ReadFPR() { void *buf = GetFPRBuffer(); if (!buf) - return Error("FPR buffer is NULL"); + return Status("FPR buffer is NULL"); return DoReadFPR(buf); } -Error NativeRegisterContextNetBSD::WriteFPR() { +Status NativeRegisterContextNetBSD::WriteFPR() { void *buf = GetFPRBuffer(); if (!buf) - return Error("FPR buffer is NULL"); + return Status("FPR buffer is NULL"); return DoWriteFPR(buf); } -Error NativeRegisterContextNetBSD::ReadDBR() { +Status NativeRegisterContextNetBSD::ReadDBR() { void *buf = GetDBRBuffer(); if (!buf) - return Error("DBR buffer is NULL"); + return Status("DBR buffer is NULL"); return DoReadDBR(buf); } -Error NativeRegisterContextNetBSD::WriteDBR() { +Status NativeRegisterContextNetBSD::WriteDBR() { void *buf = GetDBRBuffer(); if (!buf) - return Error("DBR buffer is NULL"); + return Status("DBR buffer is NULL"); return DoWriteDBR(buf); } -Error NativeRegisterContextNetBSD::DoReadGPR(void *buf) { +Status NativeRegisterContextNetBSD::DoReadGPR(void *buf) { return NativeProcessNetBSD::PtraceWrapper(PT_GETREGS, GetProcessPid(), buf, m_thread.GetID()); } -Error NativeRegisterContextNetBSD::DoWriteGPR(void *buf) { +Status NativeRegisterContextNetBSD::DoWriteGPR(void *buf) { return NativeProcessNetBSD::PtraceWrapper(PT_SETREGS, GetProcessPid(), buf, m_thread.GetID()); } -Error NativeRegisterContextNetBSD::DoReadFPR(void *buf) { +Status NativeRegisterContextNetBSD::DoReadFPR(void *buf) { return NativeProcessNetBSD::PtraceWrapper(PT_GETFPREGS, GetProcessPid(), buf, m_thread.GetID()); } -Error NativeRegisterContextNetBSD::DoWriteFPR(void *buf) { +Status NativeRegisterContextNetBSD::DoWriteFPR(void *buf) { return NativeProcessNetBSD::PtraceWrapper(PT_SETFPREGS, GetProcessPid(), buf, m_thread.GetID()); } -Error NativeRegisterContextNetBSD::DoReadDBR(void *buf) { +Status NativeRegisterContextNetBSD::DoReadDBR(void *buf) { return NativeProcessNetBSD::PtraceWrapper(PT_GETDBREGS, GetProcessPid(), buf, m_thread.GetID()); } -Error NativeRegisterContextNetBSD::DoWriteDBR(void *buf) { +Status NativeRegisterContextNetBSD::DoWriteDBR(void *buf) { return NativeProcessNetBSD::PtraceWrapper(PT_SETDBREGS, GetProcessPid(), buf, m_thread.GetID()); } diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h index d820baac3afa..d96b7aea0048 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h @@ -35,14 +35,14 @@ public: uint32_t concrete_frame_idx); protected: - virtual Error ReadGPR(); - virtual Error WriteGPR(); + virtual Status ReadGPR(); + virtual Status WriteGPR(); - virtual Error ReadFPR(); - virtual Error WriteFPR(); + virtual Status ReadFPR(); + virtual Status WriteFPR(); - virtual Error ReadDBR(); - virtual Error WriteDBR(); + virtual Status ReadDBR(); + virtual Status WriteDBR(); virtual void *GetGPRBuffer() { return nullptr; } virtual size_t GetGPRSize() { @@ -55,14 +55,14 @@ protected: virtual void *GetDBRBuffer() { return nullptr; } virtual size_t GetDBRSize() { return 0; } - virtual Error DoReadGPR(void *buf); - virtual Error DoWriteGPR(void *buf); + virtual Status DoReadGPR(void *buf); + virtual Status DoWriteGPR(void *buf); - virtual Error DoReadFPR(void *buf); - virtual Error DoWriteFPR(void *buf); + virtual Status DoReadFPR(void *buf); + virtual Status DoWriteFPR(void *buf); - virtual Error DoReadDBR(void *buf); - virtual Error DoWriteDBR(void *buf); + virtual Status DoReadDBR(void *buf); + virtual Status DoWriteDBR(void *buf); virtual NativeProcessNetBSD &GetProcess(); virtual ::pid_t GetProcessPid(); diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp index dc37be7b934b..9690da0e1374 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -14,8 +14,8 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h" @@ -251,9 +251,10 @@ int NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) { return -1; } -Error NativeRegisterContextNetBSD_x86_64::ReadRegister( - const RegisterInfo *reg_info, RegisterValue ®_value) { - Error error; +Status +NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { + Status error; if (!reg_info) { error.SetErrorString("reg_info NULL"); @@ -446,10 +447,10 @@ Error NativeRegisterContextNetBSD_x86_64::ReadRegister( return error; } -Error NativeRegisterContextNetBSD_x86_64::WriteRegister( +Status NativeRegisterContextNetBSD_x86_64::WriteRegister( const RegisterInfo *reg_info, const RegisterValue ®_value) { - Error error; + Status error; if (!reg_info) { error.SetErrorString("reg_info NULL"); @@ -645,9 +646,9 @@ Error NativeRegisterContextNetBSD_x86_64::WriteRegister( return error; } -Error NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues( +Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { - Error error; + Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); if (!data_sp) { @@ -680,9 +681,9 @@ Error NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues( return error; } -Error NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues( +Status NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - Error error; + Status error; if (!data_sp) { error.SetErrorStringWithFormat( @@ -717,14 +718,14 @@ Error NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues( return error; } -Error NativeRegisterContextNetBSD_x86_64::IsWatchpointHit(uint32_t wp_index, - bool &is_hit) { +Status NativeRegisterContextNetBSD_x86_64::IsWatchpointHit(uint32_t wp_index, + bool &is_hit) { if (wp_index >= NumSupportedHardwareWatchpoints()) - return Error("Watchpoint index out of range"); + return Status("Watchpoint index out of range"); RegisterValue reg_value; const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(lldb_dr6_x86_64); - Error error = ReadRegister(reg_info, reg_value); + Status error = ReadRegister(reg_info, reg_value); if (error.Fail()) { is_hit = false; return error; @@ -737,12 +738,12 @@ Error NativeRegisterContextNetBSD_x86_64::IsWatchpointHit(uint32_t wp_index, return error; } -Error NativeRegisterContextNetBSD_x86_64::GetWatchpointHitIndex( +Status NativeRegisterContextNetBSD_x86_64::GetWatchpointHitIndex( uint32_t &wp_index, lldb::addr_t trap_addr) { uint32_t num_hw_wps = NumSupportedHardwareWatchpoints(); for (wp_index = 0; wp_index < num_hw_wps; ++wp_index) { bool is_hit; - Error error = IsWatchpointHit(wp_index, is_hit); + Status error = IsWatchpointHit(wp_index, is_hit); if (error.Fail()) { wp_index = LLDB_INVALID_INDEX32; return error; @@ -751,17 +752,17 @@ Error NativeRegisterContextNetBSD_x86_64::GetWatchpointHitIndex( } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } -Error NativeRegisterContextNetBSD_x86_64::IsWatchpointVacant(uint32_t wp_index, - bool &is_vacant) { +Status NativeRegisterContextNetBSD_x86_64::IsWatchpointVacant(uint32_t wp_index, + bool &is_vacant) { if (wp_index >= NumSupportedHardwareWatchpoints()) - return Error("Watchpoint index out of range"); + return Status("Watchpoint index out of range"); RegisterValue reg_value; const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(lldb_dr7_x86_64); - Error error = ReadRegister(reg_info, reg_value); + Status error = ReadRegister(reg_info, reg_value); if (error.Fail()) { is_vacant = false; return error; @@ -774,11 +775,11 @@ Error NativeRegisterContextNetBSD_x86_64::IsWatchpointVacant(uint32_t wp_index, return error; } -Error NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpointWithIndex( +Status NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpointWithIndex( lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) { if (wp_index >= NumSupportedHardwareWatchpoints()) - return Error("Watchpoint index out of range"); + return Status("Watchpoint index out of range"); // Read only watchpoints aren't supported on x86_64. Fall back to read/write // waitchpoints instead. @@ -788,17 +789,17 @@ Error NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpointWithIndex( watch_flags = 0x3; if (watch_flags != 0x1 && watch_flags != 0x3) - return Error("Invalid read/write bits for watchpoint"); + return Status("Invalid read/write bits for watchpoint"); if (size != 1 && size != 2 && size != 4 && size != 8) - return Error("Invalid size for watchpoint"); + return Status("Invalid size for watchpoint"); bool is_vacant; - Error error = IsWatchpointVacant(wp_index, is_vacant); + Status error = IsWatchpointVacant(wp_index, is_vacant); if (error.Fail()) return error; if (!is_vacant) - return Error("Watchpoint index not vacant"); + return Status("Watchpoint index not vacant"); RegisterValue reg_value; const RegisterInfo *const reg_info_dr7 = @@ -851,7 +852,7 @@ bool NativeRegisterContextNetBSD_x86_64::ClearHardwareWatchpoint( // clear bits 0, 1, 2, or 3 of the debug status register (DR6) const RegisterInfo *const reg_info_dr6 = GetRegisterInfoAtIndex(lldb_dr6_x86_64); - Error error = ReadRegister(reg_info_dr6, reg_value); + Status error = ReadRegister(reg_info_dr6, reg_value); if (error.Fail()) return false; uint64_t bit_mask = 1 << wp_index; @@ -873,13 +874,13 @@ bool NativeRegisterContextNetBSD_x86_64::ClearHardwareWatchpoint( return WriteRegister(reg_info_dr7, RegisterValue(control_bits)).Success(); } -Error NativeRegisterContextNetBSD_x86_64::ClearAllHardwareWatchpoints() { +Status NativeRegisterContextNetBSD_x86_64::ClearAllHardwareWatchpoints() { RegisterValue reg_value; // clear bits {0-4} of the debug status register (DR6) const RegisterInfo *const reg_info_dr6 = GetRegisterInfoAtIndex(lldb_dr6_x86_64); - Error error = ReadRegister(reg_info_dr6, reg_value); + Status error = ReadRegister(reg_info_dr6, reg_value); if (error.Fail()) return error; uint64_t bit_mask = 0xF; @@ -905,7 +906,7 @@ uint32_t NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpoint( const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints(); for (uint32_t wp_index = 0; wp_index < num_hw_watchpoints; ++wp_index) { bool is_vacant; - Error error = IsWatchpointVacant(wp_index, is_vacant); + Status error = IsWatchpointVacant(wp_index, is_vacant); if (is_vacant) { error = SetHardwareWatchpointWithIndex(addr, size, watch_flags, wp_index); if (error.Success()) diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h index 35b7cf1c2f19..5f5a6a0792e4 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h @@ -36,29 +36,30 @@ public: const RegisterSet *GetRegisterSet(uint32_t set_index) const override; - Error ReadRegister(const RegisterInfo *reg_info, - RegisterValue ®_value) override; + Status ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) override; - Error WriteRegister(const RegisterInfo *reg_info, - const RegisterValue ®_value) override; + Status WriteRegister(const RegisterInfo *reg_info, + const RegisterValue ®_value) override; - Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; + Status ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; - Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; + Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; - Error IsWatchpointHit(uint32_t wp_index, bool &is_hit) override; + Status IsWatchpointHit(uint32_t wp_index, bool &is_hit) override; - Error GetWatchpointHitIndex(uint32_t &wp_index, - lldb::addr_t trap_addr) override; + Status GetWatchpointHitIndex(uint32_t &wp_index, + lldb::addr_t trap_addr) override; - Error IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override; + Status IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override; bool ClearHardwareWatchpoint(uint32_t wp_index) override; - Error ClearAllHardwareWatchpoints() override; + Status ClearAllHardwareWatchpoints() override; - Error SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size, - uint32_t watch_flags, uint32_t wp_index); + Status SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size, + uint32_t watch_flags, + uint32_t wp_index); uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags) override; diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp index 9beb65288c2f..8a16431b016d 100644 --- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp +++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -160,40 +160,40 @@ NativeRegisterContextSP NativeThreadNetBSD::GetRegisterContext() { return m_reg_context_sp; } -Error NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size, - uint32_t watch_flags, bool hardware) { +Status NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size, + uint32_t watch_flags, bool hardware) { if (!hardware) - return Error("not implemented"); + return Status("not implemented"); if (m_state == eStateLaunching) - return Error(); - Error error = RemoveWatchpoint(addr); + return Status(); + Status error = RemoveWatchpoint(addr); if (error.Fail()) return error; NativeRegisterContextSP reg_ctx = GetRegisterContext(); uint32_t wp_index = reg_ctx->SetHardwareWatchpoint(addr, size, watch_flags); if (wp_index == LLDB_INVALID_INDEX32) - return Error("Setting hardware watchpoint failed."); + return Status("Setting hardware watchpoint failed."); m_watchpoint_index_map.insert({addr, wp_index}); - return Error(); + return Status(); } -Error NativeThreadNetBSD::RemoveWatchpoint(lldb::addr_t addr) { +Status NativeThreadNetBSD::RemoveWatchpoint(lldb::addr_t addr) { auto wp = m_watchpoint_index_map.find(addr); if (wp == m_watchpoint_index_map.end()) - return Error(); + return Status(); uint32_t wp_index = wp->second; m_watchpoint_index_map.erase(wp); if (GetRegisterContext()->ClearHardwareWatchpoint(wp_index)) - return Error(); - return Error("Clearing hardware watchpoint failed."); + return Status(); + return Status("Clearing hardware watchpoint failed."); } -Error NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr, - size_t size) { +Status NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr, + size_t size) { if (m_state == eStateLaunching) - return Error(); + return Status(); - Error error = RemoveHardwareBreakpoint(addr); + Status error = RemoveHardwareBreakpoint(addr); if (error.Fail()) return error; @@ -201,22 +201,22 @@ Error NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr, uint32_t bp_index = reg_ctx->SetHardwareBreakpoint(addr, size); if (bp_index == LLDB_INVALID_INDEX32) - return Error("Setting hardware breakpoint failed."); + return Status("Setting hardware breakpoint failed."); m_hw_break_index_map.insert({addr, bp_index}); - return Error(); + return Status(); } -Error NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) { +Status NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) { auto bp = m_hw_break_index_map.find(addr); if (bp == m_hw_break_index_map.end()) - return Error(); + return Status(); uint32_t bp_index = bp->second; if (GetRegisterContext()->ClearHardwareBreakpoint(bp_index)) { m_hw_break_index_map.erase(bp); - return Error(); + return Status(); } - return Error("Clearing hardware breakpoint failed."); + return Status("Clearing hardware breakpoint failed."); } diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h index 96d7fd0ce03b..dcd360cdd310 100644 --- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h +++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -38,14 +38,14 @@ public: NativeRegisterContextSP GetRegisterContext() override; - Error SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, - bool hardware) override; + Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, + bool hardware) override; - Error RemoveWatchpoint(lldb::addr_t addr) override; + Status RemoveWatchpoint(lldb::addr_t addr) override; - Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override; + Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override; - Error RemoveHardwareBreakpoint(lldb::addr_t addr) override; + Status RemoveHardwareBreakpoint(lldb::addr_t addr) override; private: // --------------------------------------------------------------------- |