diff options
Diffstat (limited to 'source/Plugins/Process/Linux')
17 files changed, 675 insertions, 655 deletions
diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 914d690ad88c..15e7c9b5f698 100644 --- a/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -40,8 +40,8 @@ #include "lldb/Target/Process.h" #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/StringExtractor.h" #include "NativeThreadLinux.h" @@ -193,8 +193,8 @@ static_assert(sizeof(long) >= k_ptrace_word_size, // 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) { @@ -214,13 +214,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()}; @@ -254,7 +254,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)); @@ -262,7 +262,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; @@ -292,7 +292,7 @@ NativeProcessLinux::NativeProcessLinux() m_pending_notification_tid(LLDB_INVALID_THREAD_ID) {} void NativeProcessLinux::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); @@ -314,9 +314,9 @@ void NativeProcessLinux::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Attach(pid, error); } -Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop, - ProcessLaunchInfo &launch_info) { - Error error; +Status NativeProcessLinux::LaunchInferior(MainLoop &mainloop, + ProcessLaunchInfo &launch_info) { + Status error; m_sigchld_handle = mainloop.RegisterSignal( SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, error); if (!m_sigchld_handle) @@ -402,7 +402,7 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop, return error; } -::pid_t NativeProcessLinux::Attach(lldb::pid_t pid, Error &error) { +::pid_t NativeProcessLinux::Attach(lldb::pid_t pid, Status &error) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); // Use a map to keep track of the threads which we have attached/need to @@ -484,7 +484,7 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop, return pid; } -Error NativeProcessLinux::SetDefaultPtraceOpts(lldb::pid_t pid) { +Status NativeProcessLinux::SetDefaultPtraceOpts(lldb::pid_t pid) { long ptrace_opts = 0; // Have the child raise an event on exit. This is used to keep the child in @@ -857,7 +857,7 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info, { // If a watchpoint was hit, report it uint32_t wp_index; - Error error = thread.GetRegisterContext()->GetWatchpointHitIndex( + Status error = thread.GetRegisterContext()->GetWatchpointHitIndex( wp_index, (uintptr_t)info.si_addr); if (error.Fail()) LLDB_LOG(log, @@ -894,7 +894,7 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info, { // If a watchpoint was hit, report it uint32_t wp_index; - Error error = thread.GetRegisterContext()->GetWatchpointHitIndex( + Status error = thread.GetRegisterContext()->GetWatchpointHitIndex( wp_index, LLDB_INVALID_ADDRESS); if (error.Fail()) LLDB_LOG(log, @@ -950,7 +950,7 @@ void NativeProcessLinux::MonitorBreakpoint(NativeThreadLinux &thread) { // Mark the thread as stopped at breakpoint. thread.SetStoppedByBreakpoint(); - Error error = FixupBreakpointPCAsNeeded(thread); + Status error = FixupBreakpointPCAsNeeded(thread); if (error.Fail()) LLDB_LOG(log, "pid = {0} fixup: {1}", thread.GetID(), error); @@ -1032,7 +1032,7 @@ void NativeProcessLinux::MonitorSignal(const siginfo_t &info, } else { // We can end up here if stop was initiated by LLGS but by this time a // thread stop has occurred - maybe initiated by another event. - Error error = ResumeThread(thread, thread.GetState(), 0); + Status error = ResumeThread(thread, thread.GetState(), 0); if (error.Fail()) LLDB_LOG(log, "failed to resume thread {0}: {1}", thread.GetID(), error); @@ -1108,7 +1108,7 @@ static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, emulator_baton->m_reg_context->GetRegisterInfo( eRegisterKindDWARF, reg_info->kinds[eRegisterKindDWARF]); - Error error = + Status error = emulator_baton->m_reg_context->ReadRegister(full_reg_info, reg_value); if (error.Success()) return true; @@ -1140,9 +1140,9 @@ static lldb::addr_t ReadFlags(NativeRegisterContext *regsiter_context) { LLDB_INVALID_ADDRESS); } -Error NativeProcessLinux::SetupSoftwareSingleStepping( - NativeThreadLinux &thread) { - Error error; +Status +NativeProcessLinux::SetupSoftwareSingleStepping(NativeThreadLinux &thread) { + Status error; NativeRegisterContextSP register_context_sp = thread.GetRegisterContext(); std::unique_ptr<EmulateInstruction> emulator_ap( @@ -1150,7 +1150,7 @@ Error NativeProcessLinux::SetupSoftwareSingleStepping( nullptr)); if (emulator_ap == nullptr) - return Error("Instruction emulator not found!"); + return Status("Instruction emulator not found!"); EmulatorBaton baton(this, register_context_sp.get()); emulator_ap->SetBaton(&baton); @@ -1160,7 +1160,7 @@ Error NativeProcessLinux::SetupSoftwareSingleStepping( emulator_ap->SetWriteRegCallback(&WriteRegisterCallback); if (!emulator_ap->ReadInstruction()) - return Error("Read instruction failed!"); + return Status("Read instruction failed!"); bool emulation_result = emulator_ap->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC); @@ -1198,7 +1198,7 @@ Error NativeProcessLinux::SetupSoftwareSingleStepping( // The instruction emulation failed after it modified the PC. It is an // unknown error where we can't continue because the next instruction is // modifying the PC but we don't know how. - return Error("Instruction emulation failed unexpectedly."); + return Status("Instruction emulation failed unexpectedly."); } if (m_arch.GetMachine() == llvm::Triple::arm) { @@ -1222,13 +1222,13 @@ Error NativeProcessLinux::SetupSoftwareSingleStepping( // If setting the breakpoint fails because next_pc is out of // the address space, ignore it and let the debugee segfault. if (error.GetError() == EIO || error.GetError() == EFAULT) { - return Error(); + return Status(); } else if (error.Fail()) return error; m_threads_stepping_with_breakpoint.insert({thread.GetID(), next_pc}); - return Error(); + return Status(); } bool NativeProcessLinux::SupportHardwareSingleStepping() const { @@ -1241,7 +1241,7 @@ bool NativeProcessLinux::SupportHardwareSingleStepping() const { return true; } -Error NativeProcessLinux::Resume(const ResumeActionList &resume_actions) { +Status NativeProcessLinux::Resume(const ResumeActionList &resume_actions) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); LLDB_LOG(log, "pid {0}", GetID()); @@ -1257,7 +1257,7 @@ Error NativeProcessLinux::Resume(const ResumeActionList &resume_actions) { continue; if (action->state == eStateStepping) { - Error error = SetupSoftwareSingleStepping( + Status error = SetupSoftwareSingleStepping( static_cast<NativeThreadLinux &>(*thread_sp)); if (error.Fail()) return error; @@ -1295,18 +1295,18 @@ Error NativeProcessLinux::Resume(const ResumeActionList &resume_actions) { llvm_unreachable("Unexpected state"); default: - return Error("NativeProcessLinux::%s (): unexpected state %s specified " - "for pid %" PRIu64 ", tid %" PRIu64, - __FUNCTION__, StateAsCString(action->state), GetID(), - thread_sp->GetID()); + return Status("NativeProcessLinux::%s (): unexpected state %s specified " + "for pid %" PRIu64 ", tid %" PRIu64, + __FUNCTION__, StateAsCString(action->state), GetID(), + thread_sp->GetID()); } } - return Error(); + return Status(); } -Error NativeProcessLinux::Halt() { - Error error; +Status NativeProcessLinux::Halt() { + Status error; if (kill(GetID(), SIGSTOP) != 0) error.SetErrorToErrno(); @@ -1314,8 +1314,8 @@ Error NativeProcessLinux::Halt() { return error; } -Error NativeProcessLinux::Detach() { - Error error; +Status NativeProcessLinux::Detach() { + Status error; // Stop monitoring the inferior. m_sigchld_handle.reset(); @@ -1325,7 +1325,7 @@ Error NativeProcessLinux::Detach() { return error; for (auto thread_sp : m_threads) { - Error e = Detach(thread_sp->GetID()); + Status e = Detach(thread_sp->GetID()); if (e.Fail()) error = e; // Save the error, but still attempt to detach from other threads. @@ -1334,8 +1334,8 @@ Error NativeProcessLinux::Detach() { return error; } -Error NativeProcessLinux::Signal(int signo) { - Error error; +Status NativeProcessLinux::Signal(int signo) { + Status error; Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); LLDB_LOG(log, "sending signal {0} ({1}) to pid {1}", signo, @@ -1347,7 +1347,7 @@ Error NativeProcessLinux::Signal(int signo) { return error; } -Error NativeProcessLinux::Interrupt() { +Status NativeProcessLinux::Interrupt() { // Pick a running thread (or if none, a not-dead stopped thread) as // the chosen thread that will be the stop-reason thread. Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); @@ -1375,8 +1375,8 @@ Error NativeProcessLinux::Interrupt() { } if (!running_thread_sp && !stopped_thread_sp) { - Error error("found no running/stepping or live stopped threads as target " - "for interrupt"); + Status error("found no running/stepping or live stopped threads as target " + "for interrupt"); LLDB_LOG(log, "skipping due to error: {0}", error); return error; @@ -1391,14 +1391,14 @@ Error NativeProcessLinux::Interrupt() { StopRunningThreads(deferred_signal_thread_sp->GetID()); - return Error(); + return Status(); } -Error NativeProcessLinux::Kill() { +Status NativeProcessLinux::Kill() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); LLDB_LOG(log, "pid {0}", GetID()); - Error error; + Status error; switch (m_state) { case StateType::eStateInvalid: @@ -1430,7 +1430,7 @@ Error NativeProcessLinux::Kill() { return error; } -static Error +static Status ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, MemoryRegionInfo &memory_region_info) { memory_region_info.Clear(); @@ -1447,7 +1447,7 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, // Parse out hyphen separating start and end address from range. if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != '-')) - return Error( + return Status( "malformed /proc/{pid}/maps entry, missing dash between address range"); // Parse out the ending address @@ -1455,7 +1455,8 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, // Parse out the space after the address. if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != ' ')) - return Error("malformed /proc/{pid}/maps entry, missing space after range"); + return Status( + "malformed /proc/{pid}/maps entry, missing space after range"); // Save the range. memory_region_info.GetRange().SetRangeBase(start_address); @@ -1467,8 +1468,8 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, // Parse out each permission entry. if (line_extractor.GetBytesLeft() < 4) - return Error("malformed /proc/{pid}/maps entry, missing some portion of " - "permissions"); + return Status("malformed /proc/{pid}/maps entry, missing some portion of " + "permissions"); // Handle read permission. const char read_perm_char = line_extractor.GetChar(); @@ -1477,7 +1478,7 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, else if (read_perm_char == '-') memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo); else - return Error("unexpected /proc/{pid}/maps read permission char"); + return Status("unexpected /proc/{pid}/maps read permission char"); // Handle write permission. const char write_perm_char = line_extractor.GetChar(); @@ -1486,7 +1487,7 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, else if (write_perm_char == '-') memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo); else - return Error("unexpected /proc/{pid}/maps write permission char"); + return Status("unexpected /proc/{pid}/maps write permission char"); // Handle execute permission. const char exec_perm_char = line_extractor.GetChar(); @@ -1495,7 +1496,7 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, else if (exec_perm_char == '-') memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo); else - return Error("unexpected /proc/{pid}/maps exec permission char"); + return Status("unexpected /proc/{pid}/maps exec permission char"); line_extractor.GetChar(); // Read the private bit line_extractor.SkipSpaces(); // Skip the separator @@ -1511,11 +1512,11 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, if (name) memory_region_info.SetName(name); - return Error(); + return Status(); } -Error NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr, - MemoryRegionInfo &range_info) { +Status NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr, + MemoryRegionInfo &range_info) { // FIXME review that the final memory region returned extends to the end of // the virtual address space, // with no perms if it is not mapped. @@ -1526,10 +1527,10 @@ Error NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr, 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; } @@ -1585,7 +1586,7 @@ Error NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr, return error; } -Error NativeProcessLinux::PopulateMemoryRegionCache() { +Status NativeProcessLinux::PopulateMemoryRegionCache() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); // If our cache is empty, pull the latest. There should always be at least @@ -1593,7 +1594,7 @@ Error NativeProcessLinux::PopulateMemoryRegionCache() { if (!m_mem_region_cache.empty()) { LLDB_LOG(log, "reusing {0} cached memory region entries", m_mem_region_cache.size()); - return Error(); + return Status(); } auto BufferOrError = getProcFile(GetID(), "maps"); @@ -1606,7 +1607,8 @@ Error NativeProcessLinux::PopulateMemoryRegionCache() { StringRef Line; std::tie(Line, Rest) = Rest.split('\n'); MemoryRegionInfo info; - const Error parse_error = ParseMemoryRegionInfoFromProcMapsLine(Line, info); + const Status parse_error = + ParseMemoryRegionInfoFromProcMapsLine(Line, info); if (parse_error.Fail()) { LLDB_LOG(log, "failed to parse proc maps line '{0}': {1}", Line, parse_error); @@ -1625,7 +1627,7 @@ Error NativeProcessLinux::PopulateMemoryRegionCache() { LLDB_LOG(log, "failed to find any procfs maps entries, assuming no support " "for memory region metadata retrieval"); - return Error("not supported"); + return Status("not supported"); } LLDB_LOG(log, "read {0} memory region entries from /proc/{1}/maps", @@ -1633,7 +1635,7 @@ Error NativeProcessLinux::PopulateMemoryRegionCache() { // We support memory retrieval, remember that. m_supports_mem_region = LazyBool::eLazyBoolYes; - return Error(); + return Status(); } void NativeProcessLinux::DoStopIDBumped(uint32_t newBumpId) { @@ -1644,13 +1646,13 @@ void NativeProcessLinux::DoStopIDBumped(uint32_t newBumpId) { m_mem_region_cache.clear(); } -Error NativeProcessLinux::AllocateMemory(size_t size, uint32_t permissions, - lldb::addr_t &addr) { +Status NativeProcessLinux::AllocateMemory(size_t size, uint32_t permissions, + lldb::addr_t &addr) { // FIXME implementing this requires the equivalent of // InferiorCallPOSIX::InferiorCallMmap, which depends on // functional ThreadPlans working with Native*Protocol. #if 1 - return Error("not implemented yet"); + return Status("not implemented yet"); #else addr = LLDB_INVALID_ADDRESS; @@ -1668,20 +1670,20 @@ Error NativeProcessLinux::AllocateMemory(size_t size, uint32_t permissions, if (InferiorCallMmap(this, addr, 0, size, prot, eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) { m_addr_to_mmap_size[addr] = size; - return Error(); + return Status(); } else { addr = LLDB_INVALID_ADDRESS; - return Error("unable to allocate %" PRIu64 - " bytes of memory with permissions %s", - size, GetPermissionsAsCString(permissions)); + return Status("unable to allocate %" PRIu64 + " bytes of memory with permissions %s", + size, GetPermissionsAsCString(permissions)); } #endif } -Error NativeProcessLinux::DeallocateMemory(lldb::addr_t addr) { +Status NativeProcessLinux::DeallocateMemory(lldb::addr_t addr) { // FIXME see comments in AllocateMemory - required lower-level // bits not in place yet (ThreadPlans) - return Error("not implemented"); + return Status("not implemented"); } lldb::addr_t NativeProcessLinux::GetSharedLibraryInfoAddress() { @@ -1702,7 +1704,7 @@ bool NativeProcessLinux::GetArchitecture(ArchSpec &arch) const { return true; } -Error NativeProcessLinux::GetSoftwareBreakpointPCOffset( +Status NativeProcessLinux::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. @@ -1713,11 +1715,11 @@ Error NativeProcessLinux::GetSoftwareBreakpointPCOffset( case llvm::Triple::x86: case llvm::Triple::x86_64: actual_opcode_size = static_cast<uint32_t>(sizeof(g_i386_opcode)); - return Error(); + return Status(); case llvm::Triple::systemz: actual_opcode_size = static_cast<uint32_t>(sizeof(g_s390x_opcode)); - return Error(); + return Status(); case llvm::Triple::arm: case llvm::Triple::aarch64: @@ -1727,30 +1729,30 @@ Error NativeProcessLinux::GetSoftwareBreakpointPCOffset( case llvm::Triple::mipsel: // On these architectures the PC don't get updated for breakpoint hits actual_opcode_size = 0; - return Error(); + return Status(); default: assert(false && "CPU type not supported!"); - return Error("CPU type not supported"); + return Status("CPU type not supported"); } } -Error NativeProcessLinux::SetBreakpoint(lldb::addr_t addr, uint32_t size, - bool hardware) { +Status NativeProcessLinux::SetBreakpoint(lldb::addr_t addr, uint32_t size, + bool hardware) { if (hardware) return SetHardwareBreakpoint(addr, size); else return SetSoftwareBreakpoint(addr, size); } -Error NativeProcessLinux::RemoveBreakpoint(lldb::addr_t addr, bool hardware) { +Status NativeProcessLinux::RemoveBreakpoint(lldb::addr_t addr, bool hardware) { if (hardware) return RemoveHardwareBreakpoint(addr); else return NativeProcessProtocol::RemoveBreakpoint(addr); } -Error NativeProcessLinux::GetSoftwareBreakpointTrapOpcode( +Status NativeProcessLinux::GetSoftwareBreakpointTrapOpcode( size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) { // FIXME put this behind a breakpoint protocol class that can be set per @@ -1769,49 +1771,49 @@ Error NativeProcessLinux::GetSoftwareBreakpointTrapOpcode( case llvm::Triple::aarch64: trap_opcode_bytes = g_aarch64_opcode; actual_opcode_size = sizeof(g_aarch64_opcode); - return Error(); + return Status(); case llvm::Triple::arm: switch (trap_opcode_size_hint) { case 2: trap_opcode_bytes = g_thumb_breakpoint_opcode; actual_opcode_size = sizeof(g_thumb_breakpoint_opcode); - return Error(); + return Status(); case 4: trap_opcode_bytes = g_arm_breakpoint_opcode; actual_opcode_size = sizeof(g_arm_breakpoint_opcode); - return Error(); + return Status(); default: assert(false && "Unrecognised trap opcode size hint!"); - return Error("Unrecognised trap opcode size hint!"); + return Status("Unrecognised trap opcode size hint!"); } case llvm::Triple::x86: case llvm::Triple::x86_64: trap_opcode_bytes = g_i386_opcode; actual_opcode_size = sizeof(g_i386_opcode); - return Error(); + return Status(); case llvm::Triple::mips: case llvm::Triple::mips64: trap_opcode_bytes = g_mips64_opcode; actual_opcode_size = sizeof(g_mips64_opcode); - return Error(); + return Status(); case llvm::Triple::mipsel: case llvm::Triple::mips64el: trap_opcode_bytes = g_mips64el_opcode; actual_opcode_size = sizeof(g_mips64el_opcode); - return Error(); + return Status(); case llvm::Triple::systemz: trap_opcode_bytes = g_s390x_opcode; actual_opcode_size = sizeof(g_s390x_opcode); - return Error(); + return Status(); default: assert(false && "CPU type not supported!"); - return Error("CPU type not supported"); + return Status("CPU type not supported"); } } @@ -1964,8 +1966,8 @@ NativeProcessLinux::GetCrashReasonForSIGBUS(const siginfo_t *info) } #endif -Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, - size_t &bytes_read) { +Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read) { if (ProcessVmReadvSupported()) { // The process_vm_readv path is about 50 times faster than ptrace api. We // want to use @@ -1989,7 +1991,7 @@ Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, size, addr, success ? "Success" : strerror(errno)); if (success) - return Error(); + return Status(); // else the call failed for some reason, let's retry the read using ptrace // api. } @@ -2002,7 +2004,7 @@ Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); for (bytes_read = 0; bytes_read < size; bytes_read += remainder) { - Error error = NativeProcessLinux::PtraceWrapper( + Status error = NativeProcessLinux::PtraceWrapper( PTRACE_PEEKDATA, GetID(), (void *)addr, nullptr, 0, &data); if (error.Fail()) return error; @@ -2017,23 +2019,23 @@ Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, addr += k_ptrace_word_size; dst += k_ptrace_word_size; } - return Error(); + return Status(); } -Error NativeProcessLinux::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, - size_t size, - size_t &bytes_read) { - Error error = ReadMemory(addr, buf, size, bytes_read); +Status NativeProcessLinux::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 NativeProcessLinux::WriteMemory(lldb::addr_t addr, const void *buf, - size_t size, size_t &bytes_written) { +Status NativeProcessLinux::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); size_t remainder; - Error error; + Status error; Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY)); LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size); @@ -2075,18 +2077,18 @@ Error NativeProcessLinux::WriteMemory(lldb::addr_t addr, const void *buf, return error; } -Error NativeProcessLinux::GetSignalInfo(lldb::tid_t tid, void *siginfo) { +Status NativeProcessLinux::GetSignalInfo(lldb::tid_t tid, void *siginfo) { return PtraceWrapper(PTRACE_GETSIGINFO, tid, nullptr, siginfo); } -Error NativeProcessLinux::GetEventMessage(lldb::tid_t tid, - unsigned long *message) { +Status NativeProcessLinux::GetEventMessage(lldb::tid_t tid, + unsigned long *message) { return PtraceWrapper(PTRACE_GETEVENTMSG, tid, nullptr, message); } -Error NativeProcessLinux::Detach(lldb::tid_t tid) { +Status NativeProcessLinux::Detach(lldb::tid_t tid) { if (tid == LLDB_INVALID_THREAD_ID) - return Error(); + return Status(); return PtraceWrapper(PTRACE_DETACH, tid); } @@ -2137,10 +2139,11 @@ NativeThreadLinuxSP NativeProcessLinux::AddThread(lldb::tid_t thread_id) { return thread_sp; } -Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { +Status +NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &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). @@ -2179,7 +2182,7 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { "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. @@ -2188,7 +2191,7 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { log, "pid {0} breakpoint found at {1:x}, not software, nothing to adjust", GetID(), breakpoint_addr); - return Error(); + return Status(); } // @@ -2202,7 +2205,7 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { "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. @@ -2219,9 +2222,9 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { return error; } -Error NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path, - FileSpec &file_spec) { - Error error = PopulateMemoryRegionCache(); +Status NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path, + FileSpec &file_spec) { + Status error = PopulateMemoryRegionCache(); if (error.Fail()) return error; @@ -2231,17 +2234,17 @@ Error NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path, for (const auto &it : m_mem_region_cache) { if (it.second.GetFilename() == module_file_spec.GetFilename()) { file_spec = it.second; - return Error(); + return Status(); } } - return Error("Module file (%s) not found in /proc/%" PRIu64 "/maps file!", - module_file_spec.GetFilename().AsCString(), GetID()); + return Status("Module file (%s) not found in /proc/%" PRIu64 "/maps file!", + module_file_spec.GetFilename().AsCString(), GetID()); } -Error NativeProcessLinux::GetFileLoadAddress(const llvm::StringRef &file_name, - lldb::addr_t &load_addr) { +Status NativeProcessLinux::GetFileLoadAddress(const llvm::StringRef &file_name, + lldb::addr_t &load_addr) { load_addr = LLDB_INVALID_ADDRESS; - Error error = PopulateMemoryRegionCache(); + Status error = PopulateMemoryRegionCache(); if (error.Fail()) return error; @@ -2249,10 +2252,10 @@ Error NativeProcessLinux::GetFileLoadAddress(const llvm::StringRef &file_name, for (const auto &it : m_mem_region_cache) { if (it.second == file) { load_addr = it.first.GetRange().GetRangeBase(); - return Error(); + return Status(); } } - return Error("No load address found for specified file."); + return Status("No load address found for specified file."); } NativeThreadLinuxSP NativeProcessLinux::GetThreadByID(lldb::tid_t tid) { @@ -2260,8 +2263,8 @@ NativeThreadLinuxSP NativeProcessLinux::GetThreadByID(lldb::tid_t tid) { NativeProcessProtocol::GetThreadByID(tid)); } -Error NativeProcessLinux::ResumeThread(NativeThreadLinux &thread, - lldb::StateType state, int signo) { +Status NativeProcessLinux::ResumeThread(NativeThreadLinux &thread, + lldb::StateType state, int signo) { Log *const log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD); LLDB_LOG(log, "tid: {0}", thread.GetID()); @@ -2336,7 +2339,7 @@ void NativeProcessLinux::SignalIfAllThreadsStopped() { // Clear any temporary breakpoints we used to implement software single // stepping. for (const auto &thread_info : m_threads_stepping_with_breakpoint) { - Error error = RemoveBreakpoint(thread_info.second); + Status error = RemoveBreakpoint(thread_info.second); if (error.Fail()) LLDB_LOG(log, "pid = {0} remove stepping breakpoint: {1}", thread_info.first, error); @@ -2376,7 +2379,7 @@ void NativeProcessLinux::SigchldHandler() { if (errno == EINTR) continue; - Error error(errno, eErrorTypePOSIX); + Status error(errno, eErrorTypePOSIX); LLDB_LOG(log, "waitpid (-1, &status, _) failed: {0}", error); break; } @@ -2414,10 +2417,10 @@ void NativeProcessLinux::SigchldHandler() { // Wrapper for ptrace to catch errors and log calls. // Note that ptrace sets errno on error because -1 can be a valid result (i.e. // for PTRACE_PEEK*) -Error NativeProcessLinux::PtraceWrapper(int req, lldb::pid_t pid, void *addr, - void *data, size_t data_size, - long *result) { - Error error; +Status NativeProcessLinux::PtraceWrapper(int req, lldb::pid_t pid, void *addr, + void *data, size_t data_size, + long *result) { + Status error; long int ret; Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.h b/source/Plugins/Process/Linux/NativeProcessLinux.h index e4809d082b50..98fc88baab6e 100644 --- a/source/Plugins/Process/Linux/NativeProcessLinux.h +++ b/source/Plugins/Process/Linux/NativeProcessLinux.h @@ -26,7 +26,7 @@ #include "lldb/Host/common/NativeProcessProtocol.h" namespace lldb_private { -class Error; +class Status; class Scalar; namespace process_linux { @@ -38,11 +38,11 @@ namespace process_linux { /// /// Changes in the inferior process state are broadcasted. class NativeProcessLinux : 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); @@ -50,34 +50,34 @@ 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 Interrupt() override; + Status Interrupt() 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; @@ -85,17 +85,18 @@ 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 RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override; + Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override; void DoStopIDBumped(uint32_t newBumpId) 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; NativeThreadLinuxSP GetThreadByID(lldb::tid_t id); @@ -107,9 +108,9 @@ public: // --------------------------------------------------------------------- // Interface used by NativeRegisterContext-derived classes. // --------------------------------------------------------------------- - static Error PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, - void *data = nullptr, size_t data_size = 0, - long *result = nullptr); + static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, + void *data = nullptr, size_t data_size = 0, + long *result = nullptr); bool SupportHardwareSingleStepping() const; @@ -117,7 +118,7 @@ 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; @@ -140,15 +141,15 @@ private: // --------------------------------------------------------------------- NativeProcessLinux(); - Error LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info); + Status LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info); /// Attaches to an existing process. Forms the /// implementation of Process::DoAttach - void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Error &error); + void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Status &error); - ::pid_t Attach(lldb::pid_t pid, Error &error); + ::pid_t Attach(lldb::pid_t pid, Status &error); - static Error SetDefaultPtraceOpts(const lldb::pid_t); + static Status SetDefaultPtraceOpts(const lldb::pid_t); static void *MonitorThread(void *baton); @@ -167,7 +168,7 @@ private: void MonitorSignal(const siginfo_t &info, NativeThreadLinux &thread, bool exited); - Error SetupSoftwareSingleStepping(NativeThreadLinux &thread); + Status SetupSoftwareSingleStepping(NativeThreadLinux &thread); #if 0 static ::ProcessMessage::CrashReason @@ -189,22 +190,22 @@ private: NativeThreadLinuxSP AddThread(lldb::tid_t thread_id); - Error GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); + Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); - Error FixupBreakpointPCAsNeeded(NativeThreadLinux &thread); + Status FixupBreakpointPCAsNeeded(NativeThreadLinux &thread); /// Writes a siginfo_t structure corresponding to the given thread ID to the /// memory region pointed to by @p siginfo. - Error GetSignalInfo(lldb::tid_t tid, void *siginfo); + Status GetSignalInfo(lldb::tid_t tid, void *siginfo); /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG) /// corresponding to the given thread ID to the memory pointed to by @p /// message. - Error GetEventMessage(lldb::tid_t tid, unsigned long *message); + Status GetEventMessage(lldb::tid_t tid, unsigned long *message); void NotifyThreadDeath(lldb::tid_t tid); - Error Detach(lldb::tid_t tid); + Status Detach(lldb::tid_t tid); // This method is requests a stop on all threads which are still running. It // sets up a @@ -219,14 +220,14 @@ private: // Resume the given thread, optionally passing it the given signal. The type // of resume // operation (continue, single-step) depends on the state parameter. - Error ResumeThread(NativeThreadLinux &thread, lldb::StateType state, - int signo); + Status ResumeThread(NativeThreadLinux &thread, lldb::StateType state, + int signo); void ThreadWasCreated(NativeThreadLinux &thread); void SigchldHandler(); - Error PopulateMemoryRegionCache(); + Status PopulateMemoryRegionCache(); }; } // namespace process_linux diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp index be256e972215..43253f388019 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp @@ -41,18 +41,19 @@ lldb::ByteOrder NativeRegisterContextLinux::GetByteOrder() const { return byte_order; } -Error NativeRegisterContextLinux::ReadRegisterRaw(uint32_t reg_index, - RegisterValue ®_value) { +Status NativeRegisterContextLinux::ReadRegisterRaw(uint32_t reg_index, + RegisterValue ®_value) { const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index); if (!reg_info) - return Error("register %" PRIu32 " not found", reg_index); + return Status("register %" PRIu32 " not found", reg_index); return DoReadRegisterValue(reg_info->byte_offset, reg_info->name, reg_info->byte_size, reg_value); } -Error NativeRegisterContextLinux::WriteRegisterRaw( - uint32_t reg_index, const RegisterValue ®_value) { +Status +NativeRegisterContextLinux::WriteRegisterRaw(uint32_t reg_index, + const RegisterValue ®_value) { uint32_t reg_to_write = reg_index; RegisterValue value_to_write = reg_value; @@ -60,7 +61,7 @@ Error NativeRegisterContextLinux::WriteRegisterRaw( const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_index); if (reg_info->invalidate_regs && (reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM)) { - Error error; + Status error; RegisterValue full_value; uint32_t full_reg = reg_info->invalidate_regs[0]; @@ -99,71 +100,71 @@ Error NativeRegisterContextLinux::WriteRegisterRaw( assert(register_to_write_info_p && "register to write does not have valid RegisterInfo"); if (!register_to_write_info_p) - return Error("NativeRegisterContextLinux::%s failed to get RegisterInfo " - "for write register index %" PRIu32, - __FUNCTION__, reg_to_write); + return Status("NativeRegisterContextLinux::%s failed to get RegisterInfo " + "for write register index %" PRIu32, + __FUNCTION__, reg_to_write); return DoWriteRegisterValue(reg_info->byte_offset, reg_info->name, reg_value); } -Error NativeRegisterContextLinux::ReadGPR() { +Status NativeRegisterContextLinux::ReadGPR() { void *buf = GetGPRBuffer(); if (!buf) - return Error("GPR buffer is NULL"); + return Status("GPR buffer is NULL"); size_t buf_size = GetGPRSize(); return DoReadGPR(buf, buf_size); } -Error NativeRegisterContextLinux::WriteGPR() { +Status NativeRegisterContextLinux::WriteGPR() { void *buf = GetGPRBuffer(); if (!buf) - return Error("GPR buffer is NULL"); + return Status("GPR buffer is NULL"); size_t buf_size = GetGPRSize(); return DoWriteGPR(buf, buf_size); } -Error NativeRegisterContextLinux::ReadFPR() { +Status NativeRegisterContextLinux::ReadFPR() { void *buf = GetFPRBuffer(); if (!buf) - return Error("FPR buffer is NULL"); + return Status("FPR buffer is NULL"); size_t buf_size = GetFPRSize(); return DoReadFPR(buf, buf_size); } -Error NativeRegisterContextLinux::WriteFPR() { +Status NativeRegisterContextLinux::WriteFPR() { void *buf = GetFPRBuffer(); if (!buf) - return Error("FPR buffer is NULL"); + return Status("FPR buffer is NULL"); size_t buf_size = GetFPRSize(); return DoWriteFPR(buf, buf_size); } -Error NativeRegisterContextLinux::ReadRegisterSet(void *buf, size_t buf_size, - unsigned int regset) { +Status NativeRegisterContextLinux::ReadRegisterSet(void *buf, size_t buf_size, + unsigned int regset) { return NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, m_thread.GetID(), static_cast<void *>(®set), buf, buf_size); } -Error NativeRegisterContextLinux::WriteRegisterSet(void *buf, size_t buf_size, - unsigned int regset) { +Status NativeRegisterContextLinux::WriteRegisterSet(void *buf, size_t buf_size, + unsigned int regset) { return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(), static_cast<void *>(®set), buf, buf_size); } -Error NativeRegisterContextLinux::DoReadRegisterValue(uint32_t offset, - const char *reg_name, - uint32_t size, - RegisterValue &value) { +Status NativeRegisterContextLinux::DoReadRegisterValue(uint32_t offset, + const char *reg_name, + uint32_t size, + RegisterValue &value) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_REGISTERS)); long data; - Error error = NativeProcessLinux::PtraceWrapper( + Status error = NativeProcessLinux::PtraceWrapper( PTRACE_PEEKUSER, m_thread.GetID(), reinterpret_cast<void *>(offset), nullptr, 0, &data); @@ -175,7 +176,7 @@ Error NativeRegisterContextLinux::DoReadRegisterValue(uint32_t offset, return error; } -Error NativeRegisterContextLinux::DoWriteRegisterValue( +Status NativeRegisterContextLinux::DoWriteRegisterValue( uint32_t offset, const char *reg_name, const RegisterValue &value) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_REGISTERS)); @@ -186,22 +187,22 @@ Error NativeRegisterContextLinux::DoWriteRegisterValue( PTRACE_POKEUSER, m_thread.GetID(), reinterpret_cast<void *>(offset), buf); } -Error NativeRegisterContextLinux::DoReadGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux::DoReadGPR(void *buf, size_t buf_size) { return NativeProcessLinux::PtraceWrapper(PTRACE_GETREGS, m_thread.GetID(), nullptr, buf, buf_size); } -Error NativeRegisterContextLinux::DoWriteGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux::DoWriteGPR(void *buf, size_t buf_size) { return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGS, m_thread.GetID(), nullptr, buf, buf_size); } -Error NativeRegisterContextLinux::DoReadFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux::DoReadFPR(void *buf, size_t buf_size) { return NativeProcessLinux::PtraceWrapper(PTRACE_GETFPREGS, m_thread.GetID(), nullptr, buf, buf_size); } -Error NativeRegisterContextLinux::DoWriteFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux::DoWriteFPR(void *buf, size_t buf_size) { return NativeProcessLinux::PtraceWrapper(PTRACE_SETFPREGS, m_thread.GetID(), nullptr, buf, buf_size); } diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux.h index 4dfc5365f357..26074a6ce0e3 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux.h @@ -39,24 +39,24 @@ public: protected: lldb::ByteOrder GetByteOrder() const; - virtual Error ReadRegisterRaw(uint32_t reg_index, RegisterValue ®_value); + virtual Status ReadRegisterRaw(uint32_t reg_index, RegisterValue ®_value); - virtual Error WriteRegisterRaw(uint32_t reg_index, - const RegisterValue ®_value); + virtual Status WriteRegisterRaw(uint32_t reg_index, + const RegisterValue ®_value); - virtual Error ReadRegisterSet(void *buf, size_t buf_size, - unsigned int regset); - - virtual Error WriteRegisterSet(void *buf, size_t buf_size, + virtual Status ReadRegisterSet(void *buf, size_t buf_size, unsigned int regset); - virtual Error ReadGPR(); + virtual Status WriteRegisterSet(void *buf, size_t buf_size, + unsigned int regset); + + virtual Status ReadGPR(); - virtual Error WriteGPR(); + virtual Status WriteGPR(); - virtual Error ReadFPR(); + virtual Status ReadFPR(); - virtual Error WriteFPR(); + virtual Status WriteFPR(); virtual void *GetGPRBuffer() { return nullptr; } @@ -71,19 +71,19 @@ protected: // The Do*** functions are executed on the privileged thread and can perform // ptrace // operations directly. - virtual Error DoReadRegisterValue(uint32_t offset, const char *reg_name, - uint32_t size, RegisterValue &value); + virtual Status DoReadRegisterValue(uint32_t offset, const char *reg_name, + uint32_t size, RegisterValue &value); - virtual Error DoWriteRegisterValue(uint32_t offset, const char *reg_name, - const RegisterValue &value); + virtual Status DoWriteRegisterValue(uint32_t offset, const char *reg_name, + const RegisterValue &value); - virtual Error DoReadGPR(void *buf, size_t buf_size); + virtual Status DoReadGPR(void *buf, size_t buf_size); - virtual Error DoWriteGPR(void *buf, size_t buf_size); + virtual Status DoWriteGPR(void *buf, size_t buf_size); - virtual Error DoReadFPR(void *buf, size_t buf_size); + virtual Status DoReadFPR(void *buf, size_t buf_size); - virtual Error DoWriteFPR(void *buf, size_t buf_size); + virtual Status DoWriteFPR(void *buf, size_t buf_size); }; } // namespace process_linux diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp index 2dd23ad75a03..22b7d10869fe 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -13,8 +13,8 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "Plugins/Process/Linux/Procfs.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" @@ -157,9 +157,10 @@ NativeRegisterContextLinux_arm::GetRegisterSet(uint32_t set_index) const { return nullptr; } -Error NativeRegisterContextLinux_arm::ReadRegister(const RegisterInfo *reg_info, - RegisterValue ®_value) { - Error error; +Status +NativeRegisterContextLinux_arm::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { + Status error; if (!reg_info) { error.SetErrorString("reg_info NULL"); @@ -226,16 +227,17 @@ Error NativeRegisterContextLinux_arm::ReadRegister(const RegisterInfo *reg_info, return error; } -Error NativeRegisterContextLinux_arm::WriteRegister( - const RegisterInfo *reg_info, const RegisterValue ®_value) { +Status +NativeRegisterContextLinux_arm::WriteRegister(const RegisterInfo *reg_info, + const RegisterValue ®_value) { if (!reg_info) - return Error("reg_info NULL"); + return Status("reg_info NULL"); const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB]; if (reg_index == LLDB_INVALID_REGNUM) - return Error("no lldb regnum for %s", reg_info && reg_info->name - ? reg_info->name - : "<unknown register>"); + return Status("no lldb regnum for %s", reg_info && reg_info->name + ? reg_info->name + : "<unknown register>"); if (IsGPR(reg_index)) return WriteRegisterRaw(reg_index, reg_value); @@ -257,29 +259,29 @@ Error NativeRegisterContextLinux_arm::WriteRegister( break; default: assert(false && "Unhandled data size."); - return Error("unhandled register data size %" PRIu32, - reg_info->byte_size); + return Status("unhandled register data size %" PRIu32, + reg_info->byte_size); } - Error error = WriteFPR(); + Status error = WriteFPR(); if (error.Fail()) return error; - return Error(); + return Status(); } - return Error("failed - register wasn't recognized to be a GPR or an FPR, " - "write strategy unknown"); + return Status("failed - register wasn't recognized to be a GPR or an FPR, " + "write strategy unknown"); } -Error NativeRegisterContextLinux_arm::ReadAllRegisterValues( +Status NativeRegisterContextLinux_arm::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { - Error error; + Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); if (!data_sp) - return Error("failed to allocate DataBufferHeap instance of size %" PRIu64, - (uint64_t)REG_CONTEXT_SIZE); + return Status("failed to allocate DataBufferHeap instance of size %" PRIu64, + (uint64_t)REG_CONTEXT_SIZE); error = ReadGPR(); if (error.Fail()) @@ -304,9 +306,9 @@ Error NativeRegisterContextLinux_arm::ReadAllRegisterValues( return error; } -Error NativeRegisterContextLinux_arm::WriteAllRegisterValues( +Status NativeRegisterContextLinux_arm::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - Error error; + Status error; if (!data_sp) { error.SetErrorStringWithFormat( @@ -361,7 +363,7 @@ uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareBreakpoints() { if (log) log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__); - Error error; + Status error; // Read hardware breakpoint and watchpoint information. error = ReadHardwareDebugInfo(); @@ -380,7 +382,7 @@ NativeRegisterContextLinux_arm::SetHardwareBreakpoint(lldb::addr_t addr, LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return LLDB_INVALID_INDEX32; @@ -438,7 +440,7 @@ bool NativeRegisterContextLinux_arm::ClearHardwareBreakpoint(uint32_t hw_idx) { LLDB_LOG(log, "hw_idx: {0}", hw_idx); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return false; @@ -466,7 +468,7 @@ bool NativeRegisterContextLinux_arm::ClearHardwareBreakpoint(uint32_t hw_idx) { return true; } -Error NativeRegisterContextLinux_arm::GetHardwareBreakHitIndex( +Status NativeRegisterContextLinux_arm::GetHardwareBreakHitIndex( uint32_t &bp_index, lldb::addr_t trap_addr) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); @@ -480,21 +482,21 @@ Error NativeRegisterContextLinux_arm::GetHardwareBreakHitIndex( if ((m_hbr_regs[bp_index].control & 0x1) && (trap_addr == break_addr)) { m_hbr_regs[bp_index].hit_addr = trap_addr; - return Error(); + return Status(); } } bp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } -Error NativeRegisterContextLinux_arm::ClearAllHardwareBreakpoints() { +Status NativeRegisterContextLinux_arm::ClearAllHardwareBreakpoints() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); if (log) log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__); - Error error; + Status error; // Read hardware breakpoint and watchpoint information. error = ReadHardwareDebugInfo(); @@ -527,14 +529,14 @@ Error NativeRegisterContextLinux_arm::ClearAllHardwareBreakpoints() { } } - return Error(); + return Status(); } uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareWatchpoints() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return 0; @@ -550,7 +552,7 @@ uint32_t NativeRegisterContextLinux_arm::SetHardwareWatchpoint( watch_flags); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return LLDB_INVALID_INDEX32; @@ -654,7 +656,7 @@ bool NativeRegisterContextLinux_arm::ClearHardwareWatchpoint( LLDB_LOG(log, "wp_index: {0}", wp_index); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return false; @@ -683,9 +685,9 @@ bool NativeRegisterContextLinux_arm::ClearHardwareWatchpoint( return true; } -Error NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() { +Status NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() { // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return error; @@ -715,7 +717,7 @@ Error NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() { } } - return Error(); + return Status(); } uint32_t NativeRegisterContextLinux_arm::GetWatchpointSize(uint32_t wp_index) { @@ -745,8 +747,9 @@ bool NativeRegisterContextLinux_arm::WatchpointIsEnabled(uint32_t wp_index) { return false; } -Error NativeRegisterContextLinux_arm::GetWatchpointHitIndex( - uint32_t &wp_index, lldb::addr_t trap_addr) { +Status +NativeRegisterContextLinux_arm::GetWatchpointHitIndex(uint32_t &wp_index, + lldb::addr_t trap_addr) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); LLDB_LOG(log, "wp_index: {0}, trap_addr: {1:x}", wp_index, trap_addr); @@ -760,12 +763,12 @@ Error NativeRegisterContextLinux_arm::GetWatchpointHitIndex( if (WatchpointIsEnabled(wp_index) && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size) { m_hwp_regs[wp_index].hit_addr = trap_addr; - return Error(); + return Status(); } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } lldb::addr_t @@ -796,11 +799,11 @@ NativeRegisterContextLinux_arm::GetWatchpointHitAddress(uint32_t wp_index) { return LLDB_INVALID_ADDRESS; } -Error NativeRegisterContextLinux_arm::ReadHardwareDebugInfo() { - Error error; +Status NativeRegisterContextLinux_arm::ReadHardwareDebugInfo() { + Status error; if (!m_refresh_hwdebug_info) { - return Error(); + return Status(); } unsigned int cap_val; @@ -819,9 +822,9 @@ Error NativeRegisterContextLinux_arm::ReadHardwareDebugInfo() { return error; } -Error NativeRegisterContextLinux_arm::WriteHardwareDebugRegs(int hwbType, - int hwb_index) { - Error error; +Status NativeRegisterContextLinux_arm::WriteHardwareDebugRegs(int hwbType, + int hwb_index) { + Status error; lldb::addr_t *addr_buf; uint32_t *ctrl_buf; @@ -869,7 +872,7 @@ uint32_t NativeRegisterContextLinux_arm::CalculateFprOffset( GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset; } -Error NativeRegisterContextLinux_arm::DoReadRegisterValue( +Status NativeRegisterContextLinux_arm::DoReadRegisterValue( uint32_t offset, const char *reg_name, uint32_t size, RegisterValue &value) { // PTRACE_PEEKUSER don't work in the aarch64 linux kernel used on android @@ -881,17 +884,17 @@ Error NativeRegisterContextLinux_arm::DoReadRegisterValue( // comparision to processing time in lldb-server. assert(offset % 4 == 0 && "Try to write a register with unaligned offset"); if (offset + sizeof(uint32_t) > sizeof(m_gpr_arm)) - return Error("Register isn't fit into the size of the GPR area"); + return Status("Register isn't fit into the size of the GPR area"); - Error error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); + Status error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); if (error.Fail()) return error; value.SetUInt32(m_gpr_arm[offset / sizeof(uint32_t)]); - return Error(); + return Status(); } -Error NativeRegisterContextLinux_arm::DoWriteRegisterValue( +Status NativeRegisterContextLinux_arm::DoWriteRegisterValue( uint32_t offset, const char *reg_name, const RegisterValue &value) { // PTRACE_POKEUSER don't work in the aarch64 linux kernel used on android // devices (always return @@ -903,9 +906,9 @@ Error NativeRegisterContextLinux_arm::DoWriteRegisterValue( // lldb-server. assert(offset % 4 == 0 && "Try to write a register with unaligned offset"); if (offset + sizeof(uint32_t) > sizeof(m_gpr_arm)) - return Error("Register isn't fit into the size of the GPR area"); + return Status("Register isn't fit into the size of the GPR area"); - Error error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); + Status error = DoReadGPR(m_gpr_arm, sizeof(m_gpr_arm)); if (error.Fail()) return error; @@ -927,7 +930,7 @@ Error NativeRegisterContextLinux_arm::DoWriteRegisterValue( return DoWriteGPR(m_gpr_arm, sizeof(m_gpr_arm)); } -Error NativeRegisterContextLinux_arm::DoReadGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoReadGPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeRegisterContextLinux::DoReadGPR(buf, buf_size); #else // __aarch64__ @@ -939,7 +942,7 @@ Error NativeRegisterContextLinux_arm::DoReadGPR(void *buf, size_t buf_size) { #endif // __arm__ } -Error NativeRegisterContextLinux_arm::DoWriteGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoWriteGPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeRegisterContextLinux::DoWriteGPR(buf, buf_size); #else // __aarch64__ @@ -951,7 +954,7 @@ Error NativeRegisterContextLinux_arm::DoWriteGPR(void *buf, size_t buf_size) { #endif // __arm__ } -Error NativeRegisterContextLinux_arm::DoReadFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoReadFPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeProcessLinux::PtraceWrapper(PTRACE_GETVFPREGS, m_thread.GetID(), nullptr, buf, buf_size); @@ -964,7 +967,7 @@ Error NativeRegisterContextLinux_arm::DoReadFPR(void *buf, size_t buf_size) { #endif // __arm__ } -Error NativeRegisterContextLinux_arm::DoWriteFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm::DoWriteFPR(void *buf, size_t buf_size) { #ifdef __arm__ return NativeProcessLinux::PtraceWrapper(PTRACE_SETVFPREGS, m_thread.GetID(), nullptr, buf, buf_size); diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h index 824ac88ad9ef..ec99c05e1644 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h @@ -32,15 +32,15 @@ public: uint32_t GetUserRegisterCount() 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; //------------------------------------------------------------------ // Hardware breakpoints/watchpoint mangement functions @@ -52,10 +52,10 @@ public: bool ClearHardwareBreakpoint(uint32_t hw_idx) override; - Error ClearAllHardwareBreakpoints() override; + Status ClearAllHardwareBreakpoints() override; - Error GetHardwareBreakHitIndex(uint32_t &bp_index, - lldb::addr_t trap_addr) override; + Status GetHardwareBreakHitIndex(uint32_t &bp_index, + lldb::addr_t trap_addr) override; uint32_t NumSupportedHardwareWatchpoints() override; @@ -64,10 +64,10 @@ public: bool ClearHardwareWatchpoint(uint32_t hw_index) override; - Error ClearAllHardwareWatchpoints() override; + Status ClearAllHardwareWatchpoints() 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; lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override; @@ -81,19 +81,19 @@ public: enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK }; protected: - Error DoReadRegisterValue(uint32_t offset, const char *reg_name, - uint32_t size, RegisterValue &value) override; + Status DoReadRegisterValue(uint32_t offset, const char *reg_name, + uint32_t size, RegisterValue &value) override; - Error DoWriteRegisterValue(uint32_t offset, const char *reg_name, - const RegisterValue &value) override; + Status DoWriteRegisterValue(uint32_t offset, const char *reg_name, + const RegisterValue &value) override; - Error DoReadGPR(void *buf, size_t buf_size) override; + Status DoReadGPR(void *buf, size_t buf_size) override; - Error DoWriteGPR(void *buf, size_t buf_size) override; + Status DoWriteGPR(void *buf, size_t buf_size) override; - Error DoReadFPR(void *buf, size_t buf_size) override; + Status DoReadFPR(void *buf, size_t buf_size) override; - Error DoWriteFPR(void *buf, size_t buf_size) override; + Status DoWriteFPR(void *buf, size_t buf_size) override; void *GetGPRBuffer() override { return &m_gpr_arm; } @@ -155,9 +155,9 @@ private: bool IsFPR(unsigned reg) const; - Error ReadHardwareDebugInfo(); + Status ReadHardwareDebugInfo(); - Error WriteHardwareDebugRegs(int hwbType, int hwb_index); + Status WriteHardwareDebugRegs(int hwbType, int hwb_index); uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const; }; diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index f3715147fa3e..c3b58f16256a 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -19,8 +19,8 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" #include "Plugins/Process/Linux/Procfs.h" @@ -180,9 +180,10 @@ uint32_t NativeRegisterContextLinux_arm64::GetUserRegisterCount() const { return count; } -Error NativeRegisterContextLinux_arm64::ReadRegister( - const RegisterInfo *reg_info, RegisterValue ®_value) { - Error error; +Status +NativeRegisterContextLinux_arm64::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { + Status error; if (!reg_info) { error.SetErrorString("reg_info NULL"); @@ -232,16 +233,16 @@ Error NativeRegisterContextLinux_arm64::ReadRegister( return error; } -Error NativeRegisterContextLinux_arm64::WriteRegister( +Status NativeRegisterContextLinux_arm64::WriteRegister( const RegisterInfo *reg_info, const RegisterValue ®_value) { if (!reg_info) - return Error("reg_info NULL"); + return Status("reg_info NULL"); const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB]; if (reg_index == LLDB_INVALID_REGNUM) - return Error("no lldb regnum for %s", reg_info && reg_info->name - ? reg_info->name - : "<unknown register>"); + return Status("no lldb regnum for %s", reg_info && reg_info->name + ? reg_info->name + : "<unknown register>"); if (IsGPR(reg_index)) return WriteRegisterRaw(reg_index, reg_value); @@ -263,29 +264,29 @@ Error NativeRegisterContextLinux_arm64::WriteRegister( break; default: assert(false && "Unhandled data size."); - return Error("unhandled register data size %" PRIu32, - reg_info->byte_size); + return Status("unhandled register data size %" PRIu32, + reg_info->byte_size); } - Error error = WriteFPR(); + Status error = WriteFPR(); if (error.Fail()) return error; - return Error(); + return Status(); } - return Error("failed - register wasn't recognized to be a GPR or an FPR, " - "write strategy unknown"); + return Status("failed - register wasn't recognized to be a GPR or an FPR, " + "write strategy unknown"); } -Error NativeRegisterContextLinux_arm64::ReadAllRegisterValues( +Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { - Error error; + Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); if (!data_sp) - return Error("failed to allocate DataBufferHeap instance of size %" PRIu64, - REG_CONTEXT_SIZE); + return Status("failed to allocate DataBufferHeap instance of size %" PRIu64, + REG_CONTEXT_SIZE); error = ReadGPR(); if (error.Fail()) @@ -310,9 +311,9 @@ Error NativeRegisterContextLinux_arm64::ReadAllRegisterValues( return error; } -Error NativeRegisterContextLinux_arm64::WriteAllRegisterValues( +Status NativeRegisterContextLinux_arm64::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - Error error; + Status error; if (!data_sp) { error.SetErrorStringWithFormat( @@ -367,7 +368,7 @@ uint32_t NativeRegisterContextLinux_arm64::NumSupportedHardwareBreakpoints() { if (log) log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__); - Error error; + Status error; // Read hardware breakpoint and watchpoint information. error = ReadHardwareDebugInfo(); @@ -385,7 +386,7 @@ NativeRegisterContextLinux_arm64::SetHardwareBreakpoint(lldb::addr_t addr, LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return LLDB_INVALID_INDEX32; @@ -443,7 +444,7 @@ bool NativeRegisterContextLinux_arm64::ClearHardwareBreakpoint( LLDB_LOG(log, "hw_idx: {0}", hw_idx); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return false; @@ -471,7 +472,7 @@ bool NativeRegisterContextLinux_arm64::ClearHardwareBreakpoint( return true; } -Error NativeRegisterContextLinux_arm64::GetHardwareBreakHitIndex( +Status NativeRegisterContextLinux_arm64::GetHardwareBreakHitIndex( uint32_t &bp_index, lldb::addr_t trap_addr) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); @@ -485,21 +486,21 @@ Error NativeRegisterContextLinux_arm64::GetHardwareBreakHitIndex( if ((m_hbr_regs[bp_index].control & 0x1) && (trap_addr == break_addr)) { m_hbr_regs[bp_index].hit_addr = trap_addr; - return Error(); + return Status(); } } bp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } -Error NativeRegisterContextLinux_arm64::ClearAllHardwareBreakpoints() { +Status NativeRegisterContextLinux_arm64::ClearAllHardwareBreakpoints() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); if (log) log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__); - Error error; + Status error; // Read hardware breakpoint and watchpoint information. error = ReadHardwareDebugInfo(); @@ -532,14 +533,14 @@ Error NativeRegisterContextLinux_arm64::ClearAllHardwareBreakpoints() { } } - return Error(); + return Status(); } uint32_t NativeRegisterContextLinux_arm64::NumSupportedHardwareWatchpoints() { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return 0; @@ -555,7 +556,7 @@ uint32_t NativeRegisterContextLinux_arm64::SetHardwareWatchpoint( watch_flags); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return LLDB_INVALID_INDEX32; @@ -642,7 +643,7 @@ bool NativeRegisterContextLinux_arm64::ClearHardwareWatchpoint( LLDB_LOG(log, "wp_index: {0}", wp_index); // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return false; @@ -671,9 +672,9 @@ bool NativeRegisterContextLinux_arm64::ClearHardwareWatchpoint( return true; } -Error NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints() { +Status NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints() { // Read hardware breakpoint and watchpoint information. - Error error = ReadHardwareDebugInfo(); + Status error = ReadHardwareDebugInfo(); if (error.Fail()) return error; @@ -703,7 +704,7 @@ Error NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints() { } } - return Error(); + return Status(); } uint32_t @@ -734,7 +735,7 @@ bool NativeRegisterContextLinux_arm64::WatchpointIsEnabled(uint32_t wp_index) { return false; } -Error NativeRegisterContextLinux_arm64::GetWatchpointHitIndex( +Status NativeRegisterContextLinux_arm64::GetWatchpointHitIndex( uint32_t &wp_index, lldb::addr_t trap_addr) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS)); LLDB_LOG(log, "wp_index: {0}, trap_addr: {1:x}", wp_index, trap_addr); @@ -749,12 +750,12 @@ Error NativeRegisterContextLinux_arm64::GetWatchpointHitIndex( if (WatchpointIsEnabled(wp_index) && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size) { m_hwp_regs[wp_index].hit_addr = trap_addr; - return Error(); + return Status(); } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } lldb::addr_t @@ -785,9 +786,9 @@ NativeRegisterContextLinux_arm64::GetWatchpointHitAddress(uint32_t wp_index) { return LLDB_INVALID_ADDRESS; } -Error NativeRegisterContextLinux_arm64::ReadHardwareDebugInfo() { +Status NativeRegisterContextLinux_arm64::ReadHardwareDebugInfo() { if (!m_refresh_hwdebug_info) { - return Error(); + return Status(); } ::pid_t tid = m_thread.GetID(); @@ -795,7 +796,7 @@ Error NativeRegisterContextLinux_arm64::ReadHardwareDebugInfo() { int regset = NT_ARM_HW_WATCH; struct iovec ioVec; struct user_hwdebug_state dreg_state; - Error error; + Status error; ioVec.iov_base = &dreg_state; ioVec.iov_len = sizeof(dreg_state); @@ -820,10 +821,10 @@ Error NativeRegisterContextLinux_arm64::ReadHardwareDebugInfo() { return error; } -Error NativeRegisterContextLinux_arm64::WriteHardwareDebugRegs(int hwbType) { +Status NativeRegisterContextLinux_arm64::WriteHardwareDebugRegs(int hwbType) { struct iovec ioVec; struct user_hwdebug_state dreg_state; - Error error; + Status error; memset(&dreg_state, 0, sizeof(dreg_state)); ioVec.iov_base = &dreg_state; @@ -852,10 +853,10 @@ Error NativeRegisterContextLinux_arm64::WriteHardwareDebugRegs(int hwbType) { &hwbType, &ioVec, ioVec.iov_len); } -Error NativeRegisterContextLinux_arm64::DoReadRegisterValue( +Status NativeRegisterContextLinux_arm64::DoReadRegisterValue( uint32_t offset, const char *reg_name, uint32_t size, RegisterValue &value) { - Error error; + Status error; if (offset > sizeof(struct user_pt_regs)) { uintptr_t offset = offset - sizeof(struct user_pt_regs); if (offset > sizeof(struct user_fpsimd_state)) { @@ -899,9 +900,9 @@ Error NativeRegisterContextLinux_arm64::DoReadRegisterValue( return error; } -Error NativeRegisterContextLinux_arm64::DoWriteRegisterValue( +Status NativeRegisterContextLinux_arm64::DoWriteRegisterValue( uint32_t offset, const char *reg_name, const RegisterValue &value) { - Error error; + Status error; ::pid_t tid = m_thread.GetID(); if (offset > sizeof(struct user_pt_regs)) { uintptr_t offset = offset - sizeof(struct user_pt_regs); @@ -943,10 +944,10 @@ Error NativeRegisterContextLinux_arm64::DoWriteRegisterValue( return error; } -Error NativeRegisterContextLinux_arm64::DoReadGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm64::DoReadGPR(void *buf, size_t buf_size) { int regset = NT_PRSTATUS; struct iovec ioVec; - Error error; + Status error; ioVec.iov_base = buf; ioVec.iov_len = buf_size; @@ -954,10 +955,11 @@ Error NativeRegisterContextLinux_arm64::DoReadGPR(void *buf, size_t buf_size) { ®set, &ioVec, buf_size); } -Error NativeRegisterContextLinux_arm64::DoWriteGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm64::DoWriteGPR(void *buf, + size_t buf_size) { int regset = NT_PRSTATUS; struct iovec ioVec; - Error error; + Status error; ioVec.iov_base = buf; ioVec.iov_len = buf_size; @@ -965,10 +967,10 @@ Error NativeRegisterContextLinux_arm64::DoWriteGPR(void *buf, size_t buf_size) { ®set, &ioVec, buf_size); } -Error NativeRegisterContextLinux_arm64::DoReadFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm64::DoReadFPR(void *buf, size_t buf_size) { int regset = NT_FPREGSET; struct iovec ioVec; - Error error; + Status error; ioVec.iov_base = buf; ioVec.iov_len = buf_size; @@ -976,10 +978,11 @@ Error NativeRegisterContextLinux_arm64::DoReadFPR(void *buf, size_t buf_size) { ®set, &ioVec, buf_size); } -Error NativeRegisterContextLinux_arm64::DoWriteFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_arm64::DoWriteFPR(void *buf, + size_t buf_size) { int regset = NT_FPREGSET; struct iovec ioVec; - Error error; + Status error; ioVec.iov_base = buf; ioVec.iov_len = buf_size; diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h index 4ffbd97ee33a..9877dec37c48 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h @@ -32,15 +32,15 @@ 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; //------------------------------------------------------------------ // Hardware breakpoints/watchpoint mangement functions @@ -52,10 +52,10 @@ public: bool ClearHardwareBreakpoint(uint32_t hw_idx) override; - Error ClearAllHardwareBreakpoints() override; + Status ClearAllHardwareBreakpoints() override; - Error GetHardwareBreakHitIndex(uint32_t &bp_index, - lldb::addr_t trap_addr) override; + Status GetHardwareBreakHitIndex(uint32_t &bp_index, + lldb::addr_t trap_addr) override; uint32_t NumSupportedHardwareWatchpoints() override; @@ -64,10 +64,10 @@ public: bool ClearHardwareWatchpoint(uint32_t hw_index) override; - Error ClearAllHardwareWatchpoints() override; + Status ClearAllHardwareWatchpoints() 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; lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override; @@ -81,19 +81,19 @@ public: enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK }; protected: - Error DoReadRegisterValue(uint32_t offset, const char *reg_name, - uint32_t size, RegisterValue &value) override; + Status DoReadRegisterValue(uint32_t offset, const char *reg_name, + uint32_t size, RegisterValue &value) override; - Error DoWriteRegisterValue(uint32_t offset, const char *reg_name, - const RegisterValue &value) override; + Status DoWriteRegisterValue(uint32_t offset, const char *reg_name, + const RegisterValue &value) override; - Error DoReadGPR(void *buf, size_t buf_size) override; + Status DoReadGPR(void *buf, size_t buf_size) override; - Error DoWriteGPR(void *buf, size_t buf_size) override; + Status DoWriteGPR(void *buf, size_t buf_size) override; - Error DoReadFPR(void *buf, size_t buf_size) override; + Status DoReadFPR(void *buf, size_t buf_size) override; - Error DoWriteFPR(void *buf, size_t buf_size) override; + Status DoWriteFPR(void *buf, size_t buf_size) override; void *GetGPRBuffer() override { return &m_gpr_arm64; } @@ -155,9 +155,9 @@ private: bool IsFPR(unsigned reg) const; - Error ReadHardwareDebugInfo(); + Status ReadHardwareDebugInfo(); - Error WriteHardwareDebugRegs(int hwbType); + Status WriteHardwareDebugRegs(int hwbType); uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const; }; diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp index 7c5c42477170..dee2c064a346 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp @@ -25,9 +25,9 @@ #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Error.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private-enumerations.h" #define NT_MIPS_MSA 0x600 @@ -178,7 +178,7 @@ uint32_t NativeRegisterContextLinux_mips64::GetRegisterSetCount() const { lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation( lldb::addr_t fail_value) { - Error error; + Status error; RegisterValue pc_value; lldb::addr_t pc = fail_value; Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); @@ -244,10 +244,10 @@ NativeRegisterContextLinux_mips64::GetRegisterSet(uint32_t set_index) const { } } -lldb_private::Error +lldb_private::Status NativeRegisterContextLinux_mips64::ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value) { - Error error; + Status error; if (!reg_info) { error.SetErrorString("reg_info NULL"); @@ -315,18 +315,18 @@ NativeRegisterContextLinux_mips64::ReadRegister(const RegisterInfo *reg_info, return error; } -lldb_private::Error NativeRegisterContextLinux_mips64::WriteRegister( +lldb_private::Status NativeRegisterContextLinux_mips64::WriteRegister( const RegisterInfo *reg_info, const RegisterValue ®_value) { - Error error; + Status error; assert(reg_info && "reg_info is null"); const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB]; if (reg_index == LLDB_INVALID_REGNUM) - return Error("no lldb regnum for %s", reg_info && reg_info->name - ? reg_info->name - : "<unknown register>"); + return Status("no lldb regnum for %s", reg_info && reg_info->name + ? reg_info->name + : "<unknown register>"); if (IsMSA(reg_index) && !IsMSAAvailable()) { error.SetErrorString("MSA not available on this processor"); @@ -383,9 +383,9 @@ lldb_private::Error NativeRegisterContextLinux_mips64::WriteRegister( return error; } -Error NativeRegisterContextLinux_mips64::ReadAllRegisterValues( +Status NativeRegisterContextLinux_mips64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { - Error error; + Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); if (!data_sp) { @@ -426,9 +426,9 @@ Error NativeRegisterContextLinux_mips64::ReadAllRegisterValues( return error; } -Error NativeRegisterContextLinux_mips64::WriteAllRegisterValues( +Status NativeRegisterContextLinux_mips64::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - Error error; + Status error; if (!data_sp) { error.SetErrorStringWithFormat( @@ -481,8 +481,8 @@ Error NativeRegisterContextLinux_mips64::WriteAllRegisterValues( return error; } -Error NativeRegisterContextLinux_mips64::ReadCP1() { - Error error; +Status NativeRegisterContextLinux_mips64::ReadCP1() { + Status error; uint8_t *src = nullptr; uint8_t *dst = nullptr; @@ -529,8 +529,8 @@ NativeRegisterContextLinux_mips64::ReturnFPOffset(uint8_t reg_index, return fp_buffer_ptr; } -Error NativeRegisterContextLinux_mips64::WriteCP1() { - Error error; +Status NativeRegisterContextLinux_mips64::WriteCP1() { + Status error; uint8_t *src = nullptr; uint8_t *dst = nullptr; @@ -740,7 +740,7 @@ bool NativeRegisterContextLinux_mips64::IsMSAAvailable() { MSA_linux_mips msa_buf; unsigned int regset = NT_MIPS_MSA; - Error error = NativeProcessLinux::PtraceWrapper( + Status error = NativeProcessLinux::PtraceWrapper( PTRACE_GETREGSET, Host::GetCurrentProcessID(), static_cast<void *>(®set), &msa_buf, sizeof(MSA_linux_mips)); @@ -751,14 +751,14 @@ bool NativeRegisterContextLinux_mips64::IsMSAAvailable() { return false; } -Error NativeRegisterContextLinux_mips64::IsWatchpointHit(uint32_t wp_index, - bool &is_hit) { +Status NativeRegisterContextLinux_mips64::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"); // reading the current state of watch regs struct pt_watch_regs watch_readback; - Error error = DoReadWatchPointRegisterValue( + Status error = DoReadWatchPointRegisterValue( m_thread.GetID(), static_cast<void *>(&watch_readback)); if (GetWatchHi(&watch_readback, wp_index) & (IRW)) { @@ -775,12 +775,12 @@ Error NativeRegisterContextLinux_mips64::IsWatchpointHit(uint32_t wp_index, return error; } -Error NativeRegisterContextLinux_mips64::GetWatchpointHitIndex( +Status NativeRegisterContextLinux_mips64::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; } else if (is_hit) { @@ -788,15 +788,15 @@ Error NativeRegisterContextLinux_mips64::GetWatchpointHitIndex( } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } -Error NativeRegisterContextLinux_mips64::IsWatchpointVacant(uint32_t wp_index, - bool &is_vacant) { +Status NativeRegisterContextLinux_mips64::IsWatchpointVacant(uint32_t wp_index, + bool &is_vacant) { is_vacant = false; - return Error("MIPS TODO: " - "NativeRegisterContextLinux_mips64::IsWatchpointVacant not " - "implemented"); + return Status("MIPS TODO: " + "NativeRegisterContextLinux_mips64::IsWatchpointVacant not " + "implemented"); } bool NativeRegisterContextLinux_mips64::ClearHardwareWatchpoint( @@ -821,8 +821,8 @@ bool NativeRegisterContextLinux_mips64::ClearHardwareWatchpoint( default_watch_regs.mips64.watch_masks[wp_index]; } - Error error = DoWriteWatchPointRegisterValue(m_thread.GetID(), - static_cast<void *>(®s)); + Status error = DoWriteWatchPointRegisterValue(m_thread.GetID(), + static_cast<void *>(®s)); if (!error.Fail()) { hw_addr_map[wp_index] = LLDB_INVALID_ADDRESS; return true; @@ -830,14 +830,14 @@ bool NativeRegisterContextLinux_mips64::ClearHardwareWatchpoint( return false; } -Error NativeRegisterContextLinux_mips64::ClearAllHardwareWatchpoints() { +Status NativeRegisterContextLinux_mips64::ClearAllHardwareWatchpoints() { return DoWriteWatchPointRegisterValue( m_thread.GetID(), static_cast<void *>(&default_watch_regs)); } -Error NativeRegisterContextLinux_mips64::SetHardwareWatchpointWithIndex( +Status NativeRegisterContextLinux_mips64::SetHardwareWatchpointWithIndex( lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) { - Error error; + Status error; error.SetErrorString("MIPS TODO: " "NativeRegisterContextLinux_mips64::" "SetHardwareWatchpointWithIndex not implemented"); @@ -910,7 +910,7 @@ static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, emulator_baton->m_reg_context->GetRegisterInfo( lldb::eRegisterKindDWARF, reg_info->kinds[lldb::eRegisterKindDWARF]); - Error error = + Status error = emulator_baton->m_reg_context->ReadRegister(full_reg_info, reg_value); if (error.Success()) return true; @@ -991,12 +991,13 @@ uint32_t NativeRegisterContextLinux_mips64::NumSupportedHardwareWatchpoints() { return num_valid; } -Error NativeRegisterContextLinux_mips64::ReadRegisterRaw(uint32_t reg_index, - RegisterValue &value) { +Status +NativeRegisterContextLinux_mips64::ReadRegisterRaw(uint32_t reg_index, + RegisterValue &value) { const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index); if (!reg_info) - return Error("register %" PRIu32 " not found", reg_index); + return Status("register %" PRIu32 " not found", reg_index); uint32_t offset = reg_info->kinds[lldb::eRegisterKindProcessPlugin]; @@ -1008,12 +1009,12 @@ Error NativeRegisterContextLinux_mips64::ReadRegisterRaw(uint32_t reg_index, value); } -Error NativeRegisterContextLinux_mips64::WriteRegisterRaw( +Status NativeRegisterContextLinux_mips64::WriteRegisterRaw( uint32_t reg_index, const RegisterValue &value) { const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index); if (!reg_info) - return Error("register %" PRIu32 " not found", reg_index); + return Status("register %" PRIu32 " not found", reg_index); if (reg_info->invalidate_regs) lldbassert(false && "reg_info->invalidate_regs is unhandled"); @@ -1022,14 +1023,14 @@ Error NativeRegisterContextLinux_mips64::WriteRegisterRaw( return DoWriteRegisterValue(offset, reg_info->name, value); } -Error NativeRegisterContextLinux_mips64::Read_SR_Config(uint32_t offset, - const char *reg_name, - uint32_t size, - RegisterValue &value) { +Status NativeRegisterContextLinux_mips64::Read_SR_Config(uint32_t offset, + const char *reg_name, + uint32_t size, + RegisterValue &value) { GPR_linux_mips regs; ::memset(®s, 0, sizeof(GPR_linux_mips)); - Error error = NativeProcessLinux::PtraceWrapper( + Status error = NativeProcessLinux::PtraceWrapper( PTRACE_GETREGS, m_thread.GetID(), NULL, ®s, sizeof regs); if (error.Success()) { lldb_private::ArchSpec arch; @@ -1043,13 +1044,13 @@ Error NativeRegisterContextLinux_mips64::Read_SR_Config(uint32_t offset, return error; } -Error NativeRegisterContextLinux_mips64::DoReadWatchPointRegisterValue( +Status NativeRegisterContextLinux_mips64::DoReadWatchPointRegisterValue( lldb::tid_t tid, void *watch_readback) { return NativeProcessLinux::PtraceWrapper(PTRACE_GET_WATCH_REGS, m_thread.GetID(), watch_readback); } -Error NativeRegisterContextLinux_mips64::DoWriteWatchPointRegisterValue( +Status NativeRegisterContextLinux_mips64::DoWriteWatchPointRegisterValue( lldb::tid_t tid, void *watch_reg_value) { return NativeProcessLinux::PtraceWrapper(PTRACE_SET_WATCH_REGS, m_thread.GetID(), watch_reg_value); diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h index 1b25609205df..3e14da5a2725 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h @@ -38,35 +38,36 @@ 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 ReadCP1(); + Status ReadCP1(); - Error WriteCP1(); + Status WriteCP1(); uint8_t *ReturnFPOffset(uint8_t reg_index, uint32_t byte_offset); - 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; @@ -78,17 +79,17 @@ public: static bool IsMSAAvailable(); protected: - Error Read_SR_Config(uint32_t offset, const char *reg_name, uint32_t size, - RegisterValue &value); + Status Read_SR_Config(uint32_t offset, const char *reg_name, uint32_t size, + RegisterValue &value); - Error ReadRegisterRaw(uint32_t reg_index, RegisterValue &value) override; + Status ReadRegisterRaw(uint32_t reg_index, RegisterValue &value) override; - Error WriteRegisterRaw(uint32_t reg_index, - const RegisterValue &value) override; + Status WriteRegisterRaw(uint32_t reg_index, + const RegisterValue &value) override; - Error DoReadWatchPointRegisterValue(lldb::tid_t tid, void *watch_readback); + Status DoReadWatchPointRegisterValue(lldb::tid_t tid, void *watch_readback); - Error DoWriteWatchPointRegisterValue(lldb::tid_t tid, void *watch_readback); + Status DoWriteWatchPointRegisterValue(lldb::tid_t tid, void *watch_readback); bool IsFR0(); diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp index 3e782d39f72e..c2a696e08bf9 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.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/RegisterContextLinux_s390x.h" @@ -192,20 +192,21 @@ bool NativeRegisterContextLinux_s390x::IsFPR(uint32_t reg_index) const { reg_index <= m_reg_info.last_fpr); } -Error NativeRegisterContextLinux_s390x::ReadRegister( - const RegisterInfo *reg_info, RegisterValue ®_value) { +Status +NativeRegisterContextLinux_s390x::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { if (!reg_info) - return Error("reg_info NULL"); + return Status("reg_info NULL"); const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB]; if (reg == LLDB_INVALID_REGNUM) - return Error("register \"%s\" is an internal-only lldb register, cannot " - "read directly", - reg_info->name); + return Status("register \"%s\" is an internal-only lldb register, cannot " + "read directly", + reg_info->name); if (IsGPR(reg)) { s390_regs regs; - Error error = DoReadGPR(®s, sizeof(regs)); + Status error = DoReadGPR(®s, sizeof(regs)); if (error.Fail()) return error; @@ -220,14 +221,14 @@ Error NativeRegisterContextLinux_s390x::ReadRegister( break; default: assert(false && "Unhandled data size."); - return Error("unhandled byte size: %" PRIu32, reg_info->byte_size); + return Status("unhandled byte size: %" PRIu32, reg_info->byte_size); } - return Error(); + return Status(); } if (IsFPR(reg)) { s390_fp_regs fp_regs; - Error error = DoReadFPR(&fp_regs, sizeof(fp_regs)); + Status error = DoReadFPR(&fp_regs, sizeof(fp_regs)); if (error.Fail()) return error; @@ -243,48 +244,48 @@ Error NativeRegisterContextLinux_s390x::ReadRegister( break; default: assert(false && "Unhandled data size."); - return Error("unhandled byte size: %" PRIu32, reg_info->byte_size); + return Status("unhandled byte size: %" PRIu32, reg_info->byte_size); } - return Error(); + return Status(); } if (reg == lldb_last_break_s390x) { uint64_t last_break; - Error error = DoReadRegisterSet(NT_S390_LAST_BREAK, &last_break, 8); + Status error = DoReadRegisterSet(NT_S390_LAST_BREAK, &last_break, 8); if (error.Fail()) return error; reg_value.SetUInt64(last_break); - return Error(); + return Status(); } if (reg == lldb_system_call_s390x) { uint32_t system_call; - Error error = DoReadRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4); + Status error = DoReadRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4); if (error.Fail()) return error; reg_value.SetUInt32(system_call); - return Error(); + return Status(); } - return Error("failed - register wasn't recognized"); + return Status("failed - register wasn't recognized"); } -Error NativeRegisterContextLinux_s390x::WriteRegister( +Status NativeRegisterContextLinux_s390x::WriteRegister( const RegisterInfo *reg_info, const RegisterValue ®_value) { if (!reg_info) - return Error("reg_info NULL"); + return Status("reg_info NULL"); const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB]; if (reg == LLDB_INVALID_REGNUM) - return Error("register \"%s\" is an internal-only lldb register, cannot " - "write directly", - reg_info->name); + return Status("register \"%s\" is an internal-only lldb register, cannot " + "write directly", + reg_info->name); if (IsGPR(reg)) { s390_regs regs; - Error error = DoReadGPR(®s, sizeof(regs)); + Status error = DoReadGPR(®s, sizeof(regs)); if (error.Fail()) return error; @@ -299,14 +300,14 @@ Error NativeRegisterContextLinux_s390x::WriteRegister( break; default: assert(false && "Unhandled data size."); - return Error("unhandled byte size: %" PRIu32, reg_info->byte_size); + return Status("unhandled byte size: %" PRIu32, reg_info->byte_size); } return DoWriteGPR(®s, sizeof(regs)); } if (IsFPR(reg)) { s390_fp_regs fp_regs; - Error error = DoReadFPR(&fp_regs, sizeof(fp_regs)); + Status error = DoReadFPR(&fp_regs, sizeof(fp_regs)); if (error.Fail()) return error; @@ -322,13 +323,13 @@ Error NativeRegisterContextLinux_s390x::WriteRegister( break; default: assert(false && "Unhandled data size."); - return Error("unhandled byte size: %" PRIu32, reg_info->byte_size); + return Status("unhandled byte size: %" PRIu32, reg_info->byte_size); } return DoWriteFPR(&fp_regs, sizeof(fp_regs)); } if (reg == lldb_last_break_s390x) { - return Error("The last break address is read-only"); + return Status("The last break address is read-only"); } if (reg == lldb_system_call_s390x) { @@ -336,12 +337,12 @@ Error NativeRegisterContextLinux_s390x::WriteRegister( return DoWriteRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4); } - return Error("failed - register wasn't recognized"); + return Status("failed - register wasn't recognized"); } -Error NativeRegisterContextLinux_s390x::ReadAllRegisterValues( +Status NativeRegisterContextLinux_s390x::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { - Error error; + Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); if (!data_sp) { @@ -383,9 +384,9 @@ Error NativeRegisterContextLinux_s390x::ReadAllRegisterValues( return error; } -Error NativeRegisterContextLinux_s390x::WriteAllRegisterValues( +Status NativeRegisterContextLinux_s390x::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - Error error; + Status error; if (!data_sp) { error.SetErrorStringWithFormat( @@ -428,19 +429,20 @@ Error NativeRegisterContextLinux_s390x::WriteAllRegisterValues( return error; } -Error NativeRegisterContextLinux_s390x::DoReadRegisterValue( +Status NativeRegisterContextLinux_s390x::DoReadRegisterValue( uint32_t offset, const char *reg_name, uint32_t size, RegisterValue &value) { - return Error("DoReadRegisterValue unsupported"); + return Status("DoReadRegisterValue unsupported"); } -Error NativeRegisterContextLinux_s390x::DoWriteRegisterValue( +Status NativeRegisterContextLinux_s390x::DoWriteRegisterValue( uint32_t offset, const char *reg_name, const RegisterValue &value) { - return Error("DoWriteRegisterValue unsupported"); + return Status("DoWriteRegisterValue unsupported"); } -Error NativeRegisterContextLinux_s390x::PeekUserArea(uint32_t offset, void *buf, - size_t buf_size) { +Status NativeRegisterContextLinux_s390x::PeekUserArea(uint32_t offset, + void *buf, + size_t buf_size) { ptrace_area parea; parea.len = buf_size; parea.process_addr = (addr_t)buf; @@ -450,9 +452,9 @@ Error NativeRegisterContextLinux_s390x::PeekUserArea(uint32_t offset, void *buf, m_thread.GetID(), &parea); } -Error NativeRegisterContextLinux_s390x::PokeUserArea(uint32_t offset, - const void *buf, - size_t buf_size) { +Status NativeRegisterContextLinux_s390x::PokeUserArea(uint32_t offset, + const void *buf, + size_t buf_size) { ptrace_area parea; parea.len = buf_size; parea.process_addr = (addr_t)buf; @@ -462,29 +464,31 @@ Error NativeRegisterContextLinux_s390x::PokeUserArea(uint32_t offset, m_thread.GetID(), &parea); } -Error NativeRegisterContextLinux_s390x::DoReadGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_s390x::DoReadGPR(void *buf, size_t buf_size) { assert(buf_size == sizeof(s390_regs)); return PeekUserArea(offsetof(user_regs_struct, psw), buf, buf_size); } -Error NativeRegisterContextLinux_s390x::DoWriteGPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_s390x::DoWriteGPR(void *buf, + size_t buf_size) { assert(buf_size == sizeof(s390_regs)); return PokeUserArea(offsetof(user_regs_struct, psw), buf, buf_size); } -Error NativeRegisterContextLinux_s390x::DoReadFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_s390x::DoReadFPR(void *buf, size_t buf_size) { assert(buf_size == sizeof(s390_fp_regs)); return PeekUserArea(offsetof(user_regs_struct, fp_regs), buf, buf_size); } -Error NativeRegisterContextLinux_s390x::DoWriteFPR(void *buf, size_t buf_size) { +Status NativeRegisterContextLinux_s390x::DoWriteFPR(void *buf, + size_t buf_size) { assert(buf_size == sizeof(s390_fp_regs)); return PokeUserArea(offsetof(user_regs_struct, fp_regs), buf, buf_size); } -Error NativeRegisterContextLinux_s390x::DoReadRegisterSet(uint32_t regset, - void *buf, - size_t buf_size) { +Status NativeRegisterContextLinux_s390x::DoReadRegisterSet(uint32_t regset, + void *buf, + size_t buf_size) { struct iovec iov; iov.iov_base = buf; iov.iov_len = buf_size; @@ -492,9 +496,9 @@ Error NativeRegisterContextLinux_s390x::DoReadRegisterSet(uint32_t regset, return ReadRegisterSet(&iov, buf_size, regset); } -Error NativeRegisterContextLinux_s390x::DoWriteRegisterSet(uint32_t regset, - const void *buf, - size_t buf_size) { +Status NativeRegisterContextLinux_s390x::DoWriteRegisterSet(uint32_t regset, + const void *buf, + size_t buf_size) { struct iovec iov; iov.iov_base = const_cast<void *>(buf); iov.iov_len = buf_size; @@ -502,20 +506,20 @@ Error NativeRegisterContextLinux_s390x::DoWriteRegisterSet(uint32_t regset, return WriteRegisterSet(&iov, buf_size, regset); } -Error NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index, - bool &is_hit) { +Status NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index, + bool &is_hit) { per_lowcore_bits per_lowcore; if (wp_index >= NumSupportedHardwareWatchpoints()) - return Error("Watchpoint index out of range"); + return Status("Watchpoint index out of range"); if (m_watchpoint_addr == LLDB_INVALID_ADDRESS) { is_hit = false; - return Error(); + return Status(); } - Error error = PeekUserArea(offsetof(user_regs_struct, per_info.lowcore), - &per_lowcore, sizeof(per_lowcore)); + Status error = PeekUserArea(offsetof(user_regs_struct, per_info.lowcore), + &per_lowcore, sizeof(per_lowcore)); if (error.Fail()) { is_hit = false; return error; @@ -531,15 +535,15 @@ Error NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index, sizeof(per_lowcore)); } - return Error(); + return Status(); } -Error NativeRegisterContextLinux_s390x::GetWatchpointHitIndex( +Status NativeRegisterContextLinux_s390x::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; @@ -548,17 +552,17 @@ Error NativeRegisterContextLinux_s390x::GetWatchpointHitIndex( } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } -Error NativeRegisterContextLinux_s390x::IsWatchpointVacant(uint32_t wp_index, - bool &is_vacant) { +Status NativeRegisterContextLinux_s390x::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"); is_vacant = m_watchpoint_addr == LLDB_INVALID_ADDRESS; - return Error(); + return Status(); } bool NativeRegisterContextLinux_s390x::ClearHardwareWatchpoint( @@ -568,8 +572,8 @@ bool NativeRegisterContextLinux_s390x::ClearHardwareWatchpoint( if (wp_index >= NumSupportedHardwareWatchpoints()) return false; - Error error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info, - sizeof(per_info)); + Status error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info, + sizeof(per_info)); if (error.Fail()) return false; @@ -587,10 +591,10 @@ bool NativeRegisterContextLinux_s390x::ClearHardwareWatchpoint( return true; } -Error NativeRegisterContextLinux_s390x::ClearAllHardwareWatchpoints() { +Status NativeRegisterContextLinux_s390x::ClearAllHardwareWatchpoints() { if (ClearHardwareWatchpoint(0)) - return Error(); - return Error("Clearing all hardware watchpoints failed."); + return Status(); + return Status("Clearing all hardware watchpoints failed."); } uint32_t NativeRegisterContextLinux_s390x::SetHardwareWatchpoint( @@ -603,8 +607,8 @@ uint32_t NativeRegisterContextLinux_s390x::SetHardwareWatchpoint( if (m_watchpoint_addr != LLDB_INVALID_ADDRESS) return LLDB_INVALID_INDEX32; - Error error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info, - sizeof(per_info)); + Status error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info, + sizeof(per_info)); if (error.Fail()) return LLDB_INVALID_INDEX32; diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h index 4bd737767fa4..3ffbaeeb0bba 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h @@ -33,26 +33,26 @@ public: uint32_t GetUserRegisterCount() 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; uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags) override; @@ -62,19 +62,19 @@ public: uint32_t NumSupportedHardwareWatchpoints() override; protected: - Error DoReadRegisterValue(uint32_t offset, const char *reg_name, - uint32_t size, RegisterValue &value) override; + Status DoReadRegisterValue(uint32_t offset, const char *reg_name, + uint32_t size, RegisterValue &value) override; - Error DoWriteRegisterValue(uint32_t offset, const char *reg_name, - const RegisterValue &value) override; + Status DoWriteRegisterValue(uint32_t offset, const char *reg_name, + const RegisterValue &value) override; - Error DoReadGPR(void *buf, size_t buf_size) override; + Status DoReadGPR(void *buf, size_t buf_size) override; - Error DoWriteGPR(void *buf, size_t buf_size) override; + Status DoWriteGPR(void *buf, size_t buf_size) override; - Error DoReadFPR(void *buf, size_t buf_size) override; + Status DoReadFPR(void *buf, size_t buf_size) override; - Error DoWriteFPR(void *buf, size_t buf_size) override; + Status DoWriteFPR(void *buf, size_t buf_size) override; private: // Info about register ranges. @@ -99,13 +99,13 @@ private: bool IsFPR(uint32_t reg_index) const; - Error PeekUserArea(uint32_t offset, void *buf, size_t buf_size); + Status PeekUserArea(uint32_t offset, void *buf, size_t buf_size); - Error PokeUserArea(uint32_t offset, const void *buf, size_t buf_size); + Status PokeUserArea(uint32_t offset, const void *buf, size_t buf_size); - Error DoReadRegisterSet(uint32_t regset, void *buf, size_t buf_size); + Status DoReadRegisterSet(uint32_t regset, void *buf, size_t buf_size); - Error DoWriteRegisterSet(uint32_t regset, const void *buf, size_t buf_size); + Status DoWriteRegisterSet(uint32_t regset, const void *buf, size_t buf_size); }; } // namespace process_linux diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp index dd35705a8ae8..59dc9e9f7d45 100755 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_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/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" @@ -385,9 +385,10 @@ NativeRegisterContextLinux_x86_64::GetRegisterSet(uint32_t set_index) const { return nullptr; } -Error NativeRegisterContextLinux_x86_64::ReadRegister( - const RegisterInfo *reg_info, RegisterValue ®_value) { - Error error; +Status +NativeRegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { + Status error; if (!reg_info) { error.SetErrorString("reg_info NULL"); @@ -529,15 +530,15 @@ Error NativeRegisterContextLinux_x86_64::ReadRegister( return error; } -Error NativeRegisterContextLinux_x86_64::WriteRegister( +Status NativeRegisterContextLinux_x86_64::WriteRegister( const RegisterInfo *reg_info, const RegisterValue ®_value) { assert(reg_info && "reg_info is null"); const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB]; if (reg_index == LLDB_INVALID_REGNUM) - return Error("no lldb regnum for %s", reg_info && reg_info->name - ? reg_info->name - : "<unknown register>"); + return Status("no lldb regnum for %s", reg_info && reg_info->name + ? reg_info->name + : "<unknown register>"); if (IsGPR(reg_index)) return WriteRegisterRaw(reg_index, reg_value); @@ -566,7 +567,7 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister( ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes, reg_value.GetBytes(), reg_value.GetByteSize()); if (!CopyYMMtoXSTATE(reg_index, GetByteOrder())) - return Error("CopyYMMtoXSTATE() failed"); + return Status("CopyYMMtoXSTATE() failed"); } if (reg_index >= m_reg_info.first_mpxr && @@ -574,7 +575,7 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister( ::memcpy(m_mpx_set.mpxr[reg_index - m_reg_info.first_mpxr].bytes, reg_value.GetBytes(), reg_value.GetByteSize()); if (!CopyMPXtoXSTATE(reg_index)) - return Error("CopyMPXtoXSTATE() failed"); + return Status("CopyMPXtoXSTATE() failed"); } if (reg_index >= m_reg_info.first_mpxc && @@ -582,7 +583,7 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister( ::memcpy(m_mpx_set.mpxc[reg_index - m_reg_info.first_mpxc].bytes, reg_value.GetBytes(), reg_value.GetByteSize()); if (!CopyMPXtoXSTATE(reg_index)) - return Error("CopyMPXtoXSTATE() failed"); + return Status("CopyMPXtoXSTATE() failed"); } } else { // Get pointer to m_fpr.xstate.fxsave variable and set the data to it. @@ -616,33 +617,33 @@ Error NativeRegisterContextLinux_x86_64::WriteRegister( break; default: assert(false && "Unhandled data size."); - return Error("unhandled register data size %" PRIu32, - reg_info->byte_size); + return Status("unhandled register data size %" PRIu32, + reg_info->byte_size); } } - Error error = WriteFPR(); + Status error = WriteFPR(); if (error.Fail()) return error; if (IsAVX(reg_index)) { if (!CopyYMMtoXSTATE(reg_index, GetByteOrder())) - return Error("CopyYMMtoXSTATE() failed"); + return Status("CopyYMMtoXSTATE() failed"); } if (IsMPX(reg_index)) { if (!CopyMPXtoXSTATE(reg_index)) - return Error("CopyMPXtoXSTATE() failed"); + return Status("CopyMPXtoXSTATE() failed"); } - return Error(); + return Status(); } - return Error("failed - register wasn't recognized to be a GPR or an FPR, " - "write strategy unknown"); + return Status("failed - register wasn't recognized to be a GPR or an FPR, " + "write strategy unknown"); } -Error NativeRegisterContextLinux_x86_64::ReadAllRegisterValues( +Status NativeRegisterContextLinux_x86_64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { - Error error; + Status error; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); if (!data_sp) { @@ -728,9 +729,9 @@ Error NativeRegisterContextLinux_x86_64::ReadAllRegisterValues( return error; } -Error NativeRegisterContextLinux_x86_64::WriteAllRegisterValues( +Status NativeRegisterContextLinux_x86_64::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - Error error; + Status error; if (!data_sp) { error.SetErrorStringWithFormat( @@ -857,7 +858,7 @@ bool NativeRegisterContextLinux_x86_64::IsFPR(uint32_t reg_index) const { reg_index <= m_reg_info.last_fpr); } -Error NativeRegisterContextLinux_x86_64::WriteFPR() { +Status NativeRegisterContextLinux_x86_64::WriteFPR() { switch (m_xstate_type) { case XStateType::FXSAVE: return WriteRegisterSet( @@ -867,7 +868,7 @@ Error NativeRegisterContextLinux_x86_64::WriteFPR() { return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_X86_XSTATE); default: - return Error("Unrecognized FPR type."); + return Status("Unrecognized FPR type."); } } @@ -954,8 +955,8 @@ size_t NativeRegisterContextLinux_x86_64::GetFPRSize() { } } -Error NativeRegisterContextLinux_x86_64::ReadFPR() { - Error error; +Status NativeRegisterContextLinux_x86_64::ReadFPR() { + Status error; // Probe XSAVE and if it is not supported fall back to FXSAVE. if (m_xstate_type != XStateType::FXSAVE) { @@ -973,7 +974,7 @@ Error NativeRegisterContextLinux_x86_64::ReadFPR() { m_xstate_type = XStateType::FXSAVE; return error; } - return Error("Unrecognized FPR type."); + return Status("Unrecognized FPR type."); } bool NativeRegisterContextLinux_x86_64::IsMPX(uint32_t reg_index) const { @@ -1013,13 +1014,13 @@ bool NativeRegisterContextLinux_x86_64::CopyMPXtoXSTATE(uint32_t reg) { return true; } -Error NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index, - bool &is_hit) { +Status NativeRegisterContextLinux_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; - Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value); + Status error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value); if (error.Fail()) { is_hit = false; return error; @@ -1032,12 +1033,12 @@ Error NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index, return error; } -Error NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex( +Status NativeRegisterContextLinux_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; @@ -1046,16 +1047,16 @@ Error NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex( } } wp_index = LLDB_INVALID_INDEX32; - return Error(); + return Status(); } -Error NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index, - bool &is_vacant) { +Status NativeRegisterContextLinux_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; - Error error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value); + Status error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value); if (error.Fail()) { is_vacant = false; return error; @@ -1068,11 +1069,11 @@ Error NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index, return error; } -Error NativeRegisterContextLinux_x86_64::SetHardwareWatchpointWithIndex( +Status NativeRegisterContextLinux_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. @@ -1082,17 +1083,17 @@ Error NativeRegisterContextLinux_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; error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value); @@ -1140,7 +1141,7 @@ bool NativeRegisterContextLinux_x86_64::ClearHardwareWatchpoint( // for watchpoints 0, 1, 2, or 3, respectively, // clear bits 0, 1, 2, or 3 of the debug status register (DR6) - Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value); + Status error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value); if (error.Fail()) return false; uint64_t bit_mask = 1 << wp_index; @@ -1161,11 +1162,11 @@ bool NativeRegisterContextLinux_x86_64::ClearHardwareWatchpoint( .Success(); } -Error NativeRegisterContextLinux_x86_64::ClearAllHardwareWatchpoints() { +Status NativeRegisterContextLinux_x86_64::ClearAllHardwareWatchpoints() { RegisterValue reg_value; // clear bits {0-4} of the debug status register (DR6) - Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value); + Status error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value); if (error.Fail()) return error; uint64_t bit_mask = 0xF; @@ -1189,7 +1190,7 @@ uint32_t NativeRegisterContextLinux_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/Linux/NativeRegisterContextLinux_x86_64.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h index cc05ec06b297..abb0dba4d91c 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h @@ -33,29 +33,30 @@ public: uint32_t GetUserRegisterCount() 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; @@ -71,9 +72,9 @@ protected: size_t GetFPRSize() override; - Error ReadFPR() override; + Status ReadFPR() override; - Error WriteFPR() override; + Status WriteFPR() override; private: // Private member types. diff --git a/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/source/Plugins/Process/Linux/NativeThreadLinux.cpp index 04b6fe6d71e9..b1d13668f327 100644 --- a/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -160,39 +160,40 @@ NativeRegisterContextSP NativeThreadLinux::GetRegisterContext() { return m_reg_context_sp; } -Error NativeThreadLinux::SetWatchpoint(lldb::addr_t addr, size_t size, - uint32_t watch_flags, bool hardware) { +Status NativeThreadLinux::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 NativeThreadLinux::RemoveWatchpoint(lldb::addr_t addr) { +Status NativeThreadLinux::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 NativeThreadLinux::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) { +Status NativeThreadLinux::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; @@ -200,27 +201,27 @@ Error NativeThreadLinux::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) { 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 NativeThreadLinux::RemoveHardwareBreakpoint(lldb::addr_t addr) { +Status NativeThreadLinux::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."); } -Error NativeThreadLinux::Resume(uint32_t signo) { +Status NativeThreadLinux::Resume(uint32_t signo) { const StateType new_state = StateType::eStateRunning; MaybeLogStateChange(new_state); m_state = new_state; @@ -262,7 +263,7 @@ Error NativeThreadLinux::Resume(uint32_t signo) { reinterpret_cast<void *>(data)); } -Error NativeThreadLinux::SingleStep(uint32_t signo) { +Status NativeThreadLinux::SingleStep(uint32_t signo) { const StateType new_state = StateType::eStateStepping; MaybeLogStateChange(new_state); m_state = new_state; @@ -422,7 +423,7 @@ void NativeThreadLinux::SetExited() { m_stop_info.reason = StopReason::eStopReasonThreadExiting; } -Error NativeThreadLinux::RequestStop() { +Status NativeThreadLinux::RequestStop() { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); NativeProcessLinux &process = GetProcess(); @@ -435,7 +436,7 @@ Error NativeThreadLinux::RequestStop() { ", tid: %" PRIu64 ")", __FUNCTION__, pid, tid); - Error err; + Status err; errno = 0; if (::tgkill(pid, tid, SIGSTOP) != 0) { err.SetErrorToErrno(); diff --git a/source/Plugins/Process/Linux/NativeThreadLinux.h b/source/Plugins/Process/Linux/NativeThreadLinux.h index 42697497c0af..b9126b3752a0 100644 --- a/source/Plugins/Process/Linux/NativeThreadLinux.h +++ b/source/Plugins/Process/Linux/NativeThreadLinux.h @@ -41,14 +41,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: // --------------------------------------------------------------------- @@ -57,11 +57,11 @@ private: /// Resumes the thread. If @p signo is anything but /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. - Error Resume(uint32_t signo); + Status Resume(uint32_t signo); /// Single steps the thread. If @p signo is anything but /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. - Error SingleStep(uint32_t signo); + Status SingleStep(uint32_t signo); void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr); @@ -86,7 +86,7 @@ private: void SetExited(); - Error RequestStop(); + Status RequestStop(); // --------------------------------------------------------------------- // Private interface diff --git a/source/Plugins/Process/Linux/SingleStepCheck.cpp b/source/Plugins/Process/Linux/SingleStepCheck.cpp index 4e979bd45532..251cb4b2f10a 100644 --- a/source/Plugins/Process/Linux/SingleStepCheck.cpp +++ b/source/Plugins/Process/Linux/SingleStepCheck.cpp @@ -20,7 +20,7 @@ #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #include "lldb/Host/linux/Ptrace.h" -#include "lldb/Utility/Error.h" +#include "lldb/Utility/Status.h" using namespace lldb; using namespace lldb_private; @@ -66,7 +66,7 @@ bool WorkaroundNeeded() { Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD); ::pid_t child_pid = fork(); if (child_pid == -1) { - LLDB_LOG(log, "failed to fork(): {0}", Error(errno, eErrorTypePOSIX)); + LLDB_LOG(log, "failed to fork(): {0}", Status(errno, eErrorTypePOSIX)); return false; } if (child_pid == 0) @@ -77,7 +77,7 @@ bool WorkaroundNeeded() { if (sched_getaffinity(child_pid, sizeof available_cpus, &available_cpus) == -1) { LLDB_LOG(log, "failed to get available cpus: {0}", - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); return false; } @@ -85,7 +85,7 @@ bool WorkaroundNeeded() { ::pid_t wpid = waitpid(child_pid, &status, __WALL); if (wpid != child_pid || !WIFSTOPPED(status)) { LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status, - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); return false; } @@ -99,12 +99,12 @@ bool WorkaroundNeeded() { CPU_SET(cpu, &cpus); if (sched_setaffinity(child_pid, sizeof cpus, &cpus) == -1) { LLDB_LOG(log, "failed to switch to cpu {0}: {1}", cpu, - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); continue; } int status; - Error error = + Status error = NativeProcessLinux::PtraceWrapper(PTRACE_SINGLESTEP, child_pid); if (error.Fail()) { LLDB_LOG(log, "single step failed: {0}", error); @@ -114,7 +114,7 @@ bool WorkaroundNeeded() { wpid = waitpid(child_pid, &status, __WALL); if (wpid != child_pid || !WIFSTOPPED(status)) { LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status, - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); break; } if (WSTOPSIG(status) != SIGTRAP) { @@ -152,7 +152,7 @@ std::unique_ptr<SingleStepWorkaround> SingleStepWorkaround::Get(::pid_t tid) { if (sched_getaffinity(tid, sizeof original_set, &original_set) != 0) { // This should really not fail. But, just in case... LLDB_LOG(log, "Unable to get cpu affinity for thread {0}: {1}", tid, - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); return nullptr; } @@ -164,7 +164,7 @@ std::unique_ptr<SingleStepWorkaround> SingleStepWorkaround::Get(::pid_t tid) { // to run on cpu 0. If that happens, only thing we can do is it log it and // continue... LLDB_LOG(log, "Unable to set cpu affinity for thread {0}: {1}", tid, - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); } LLDB_LOG(log, "workaround for thread {0} prepared", tid); @@ -176,7 +176,7 @@ SingleStepWorkaround::~SingleStepWorkaround() { LLDB_LOG(log, "Removing workaround"); if (sched_setaffinity(m_tid, sizeof m_original_set, &m_original_set) != 0) { LLDB_LOG(log, "Unable to reset cpu affinity for thread {0}: {1}", m_tid, - Error(errno, eErrorTypePOSIX)); + Status(errno, eErrorTypePOSIX)); } } #endif |