diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
| commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
| tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Plugins/Process/FreeBSD | |
| parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) | |
Notes
Diffstat (limited to 'source/Plugins/Process/FreeBSD')
19 files changed, 138 insertions, 198 deletions
diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp index fce0be22678e..749835531279 100644 --- a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp +++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp @@ -1,9 +1,8 @@ //===-- FreeBSDThread.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -52,7 +51,7 @@ using namespace lldb; using namespace lldb_private; FreeBSDThread::FreeBSDThread(Process &process, lldb::tid_t tid) - : Thread(process, tid), m_frame_ap(), m_breakpoint(), + : Thread(process, tid), m_frame_up(), m_breakpoint(), m_thread_name_valid(false), m_thread_name(), m_posix_thread(nullptr) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD)); LLDB_LOGV(log, "tid = {0}", tid); @@ -277,10 +276,10 @@ bool FreeBSDThread::CalculateStopInfo() { } Unwind *FreeBSDThread::GetUnwinder() { - if (!m_unwinder_ap) - m_unwinder_ap.reset(new UnwindLLDB(*this)); + if (!m_unwinder_up) + m_unwinder_up.reset(new UnwindLLDB(*this)); - return m_unwinder_ap.get(); + return m_unwinder_up.get(); } void FreeBSDThread::DidStop() { diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.h b/source/Plugins/Process/FreeBSD/FreeBSDThread.h index a8559fe8b2ca..6d3c253a519e 100644 --- a/source/Plugins/Process/FreeBSD/FreeBSDThread.h +++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.h @@ -1,9 +1,8 @@ //===-- FreeBSDThread.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,14 +19,11 @@ class ProcessMessage; class ProcessMonitor; class POSIXBreakpointProtocol; -//------------------------------------------------------------------------------ // @class FreeBSDThread // Abstraction of a FreeBSD thread. class FreeBSDThread : public lldb_private::Thread { public: - //------------------------------------------------------------------ // Constructors and destructors - //------------------------------------------------------------------ FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid); virtual ~FreeBSDThread(); @@ -51,7 +47,6 @@ public: lldb::addr_t GetThreadPointer() override; - //-------------------------------------------------------------------------- // These functions provide a mapping from the register offset // back to the register index or name for use in debugging or log // output. @@ -62,14 +57,12 @@ public: const char *GetRegisterNameFromOffset(unsigned offset); - //-------------------------------------------------------------------------- // These methods form a specialized interface to POSIX threads. // bool Resume(); void Notify(const ProcessMessage &message); - //-------------------------------------------------------------------------- // These methods provide an interface to watchpoints // bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp); @@ -87,7 +80,7 @@ protected: return m_posix_thread; } - std::unique_ptr<lldb_private::StackFrame> m_frame_ap; + std::unique_ptr<lldb_private::StackFrame> m_frame_up; lldb::BreakpointSiteSP m_breakpoint; @@ -111,7 +104,6 @@ protected: lldb_private::Unwind *GetUnwinder() override; - //-------------------------------------------------------------------------- // FreeBSDThread internal API. // POSIXThread override diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp index 9c75c26e379b..71f012944a9a 100644 --- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp +++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp @@ -1,9 +1,8 @@ //===-- POSIXStopInfo.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h index ff3693107170..88fb7f31fe06 100644 --- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h +++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h @@ -1,9 +1,8 @@ //===-- POSIXStopInfo.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,7 +15,7 @@ #include <string> //===----------------------------------------------------------------------===// -/// @class POSIXStopInfo +/// \class POSIXStopInfo /// Simple base class for all POSIX-specific StopInfo objects. /// class POSIXStopInfo : public lldb_private::StopInfo { @@ -26,7 +25,7 @@ public: }; //===----------------------------------------------------------------------===// -/// @class POSIXLimboStopInfo +/// \class POSIXLimboStopInfo /// Represents the stop state of a process ready to exit. /// class POSIXLimboStopInfo : public POSIXStopInfo { @@ -45,7 +44,7 @@ public: }; //===----------------------------------------------------------------------===// -/// @class POSIXNewThreadStopInfo +/// \class POSIXNewThreadStopInfo /// Represents the stop state of process when a new thread is spawned. /// diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index a13d4bcc4ecb..770794569f72 100644 --- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -1,10 +1,9 @@ //===-- ProcessFreeBSD.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -65,7 +64,6 @@ UnixSignalsSP &GetFreeBSDSignals() { } } -//------------------------------------------------------------------------------ // Static functions. lldb::ProcessSP @@ -97,7 +95,6 @@ const char *ProcessFreeBSD::GetPluginDescriptionStatic() { return "Process plugin for FreeBSD"; } -//------------------------------------------------------------------------------ // ProcessInterface protocol. lldb_private::ConstString ProcessFreeBSD::GetPluginName() { @@ -251,7 +248,6 @@ void ProcessFreeBSD::SendMessage(const ProcessMessage &message) { m_message_queue.push(message); } -//------------------------------------------------------------------------------ // Constructors and destructors. ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp, @@ -270,7 +266,6 @@ ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp, ProcessFreeBSD::~ProcessFreeBSD() { delete m_monitor; } -//------------------------------------------------------------------------------ // Process protocol. void ProcessFreeBSD::Finalize() { Process::Finalize(); @@ -836,7 +831,6 @@ size_t ProcessFreeBSD::PutSTDIN(const char *buf, size_t len, Status &error) { return status; } -//------------------------------------------------------------------------------ // Utility functions. bool ProcessFreeBSD::HasExited() { @@ -882,7 +876,7 @@ bool ProcessFreeBSD::IsAThreadRunning() { return is_running; } -const DataBufferSP ProcessFreeBSD::GetAuxvData() { +lldb_private::DataExtractor ProcessFreeBSD::GetAuxvData() { // If we're the local platform, we can ask the host for auxv data. PlatformSP platform_sp = GetTarget().GetPlatform(); assert(platform_sp && platform_sp->IsHost()); @@ -896,7 +890,7 @@ const DataBufferSP ProcessFreeBSD::GetAuxvData() { buf_sp.reset(); } - return buf_sp; + return DataExtractor(buf_sp, GetByteOrder(), GetAddressByteSize()); } struct EmulatorBaton { @@ -1026,21 +1020,17 @@ bool ProcessFreeBSD::IsSoftwareStepBreakpoint(lldb::tid_t tid) { bool ProcessFreeBSD::SupportHardwareSingleStepping() const { lldb_private::ArchSpec arch = GetTarget().GetArchitecture(); - if (arch.GetMachine() == llvm::Triple::arm || - arch.GetMachine() == llvm::Triple::mips64 || - arch.GetMachine() == llvm::Triple::mips64el || - arch.GetMachine() == llvm::Triple::mips || - arch.GetMachine() == llvm::Triple::mipsel) + if (arch.GetMachine() == llvm::Triple::arm || arch.IsMIPS()) return false; return true; } Status ProcessFreeBSD::SetupSoftwareSingleStepping(lldb::tid_t tid) { - std::unique_ptr<EmulateInstruction> emulator_ap( + std::unique_ptr<EmulateInstruction> emulator_up( EmulateInstruction::FindPlugin(GetTarget().GetArchitecture(), eInstructionTypePCModifying, nullptr)); - if (emulator_ap == nullptr) + if (emulator_up == nullptr) return Status("Instruction emulator not found!"); FreeBSDThread *thread = static_cast<FreeBSDThread *>( @@ -1051,17 +1041,17 @@ Status ProcessFreeBSD::SetupSoftwareSingleStepping(lldb::tid_t tid) { lldb::RegisterContextSP register_context_sp = thread->GetRegisterContext(); EmulatorBaton baton(this, register_context_sp.get()); - emulator_ap->SetBaton(&baton); - emulator_ap->SetReadMemCallback(&ReadMemoryCallback); - emulator_ap->SetReadRegCallback(&ReadRegisterCallback); - emulator_ap->SetWriteMemCallback(&WriteMemoryCallback); - emulator_ap->SetWriteRegCallback(&WriteRegisterCallback); + emulator_up->SetBaton(&baton); + emulator_up->SetReadMemCallback(&ReadMemoryCallback); + emulator_up->SetReadRegCallback(&ReadRegisterCallback); + emulator_up->SetWriteMemCallback(&WriteMemoryCallback); + emulator_up->SetWriteRegCallback(&WriteRegisterCallback); - if (!emulator_ap->ReadInstruction()) + if (!emulator_up->ReadInstruction()) return Status("Read instruction failed!"); bool emulation_result = - emulator_ap->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC); + emulator_up->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC); const RegisterInfo *reg_info_pc = register_context_sp->GetRegisterInfo( eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); auto pc_it = @@ -1078,7 +1068,7 @@ Status ProcessFreeBSD::SetupSoftwareSingleStepping(lldb::tid_t tid) { // PC modifying instruction should be successful. The failure most // likely caused by a not supported instruction which don't modify PC. next_pc = - register_context_sp->GetPC() + emulator_ap->GetOpcode().GetByteSize(); + register_context_sp->GetPC() + emulator_up->GetOpcode().GetByteSize(); } else { // The instruction emulation failed after it modified the PC. It is an // unknown error where we can't continue because the next instruction is diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h index 7ed2a56cd549..536da0c0aa70 100644 --- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h +++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h @@ -1,10 +1,9 @@ //===-- ProcessFreeBSD.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,9 +23,7 @@ class FreeBSDThread; class ProcessFreeBSD : public lldb_private::Process { public: - //------------------------------------------------------------------ // Static functions. - //------------------------------------------------------------------ static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const lldb_private::FileSpec *crash_file_path); @@ -39,9 +36,7 @@ public: static const char *GetPluginDescriptionStatic(); - //------------------------------------------------------------------ // Constructors and destructors - //------------------------------------------------------------------ ProcessFreeBSD(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, lldb::UnixSignalsSP &unix_signals_sp); @@ -49,17 +44,13 @@ public: virtual lldb_private::Status WillResume() override; - //------------------------------------------------------------------ // PluginInterface protocol - //------------------------------------------------------------------ virtual lldb_private::ConstString GetPluginName() override; virtual uint32_t GetPluginVersion() override; public: - //------------------------------------------------------------------ // Process protocol. - //------------------------------------------------------------------ void Finalize() override; bool CanDebug(lldb::TargetSP target_sp, @@ -136,9 +127,8 @@ public: size_t PutSTDIN(const char *buf, size_t len, lldb_private::Status &error) override; - const lldb::DataBufferSP GetAuxvData() override; + lldb_private::DataExtractor GetAuxvData() override; - //-------------------------------------------------------------------------- // ProcessFreeBSD internal API. /// Registers the given message with this process. diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp index 617ae3030f10..4b9225db5e39 100644 --- a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -1,9 +1,8 @@ //===-- ProcessMonitor.cpp ------------------------------------ -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -141,7 +140,6 @@ extern long PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data) { PtraceWrapper((req), (pid), (addr), (data)) #endif -//------------------------------------------------------------------------------ // Static implementations of ProcessMonitor::ReadMemory and // ProcessMonitor::WriteMemory. This enables mutual recursion between these // functions without needed to go thru the thread funnel. @@ -168,7 +166,7 @@ static size_t DoWriteMemory(lldb::pid_t pid, lldb::addr_t vm_addr, pi_desc.piod_op = PIOD_WRITE_D; pi_desc.piod_offs = (void *)vm_addr; - pi_desc.piod_addr = (void *)buf; + pi_desc.piod_addr = const_cast<void *>(buf); pi_desc.piod_len = size; if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0) { @@ -196,8 +194,7 @@ static bool EnsureFDFlags(int fd, int flags, Status &error) { return true; } -//------------------------------------------------------------------------------ -/// @class Operation +/// \class Operation /// Represents a ProcessMonitor operation. /// /// Under FreeBSD, it is not possible to ptrace() from any other thread but @@ -214,8 +211,7 @@ public: virtual void Execute(ProcessMonitor *monitor) = 0; }; -//------------------------------------------------------------------------------ -/// @class ReadOperation +/// \class ReadOperation /// Implements ProcessMonitor::ReadMemory. class ReadOperation : public Operation { public: @@ -240,8 +236,7 @@ void ReadOperation::Execute(ProcessMonitor *monitor) { m_result = DoReadMemory(pid, m_addr, m_buff, m_size, m_error); } -//------------------------------------------------------------------------------ -/// @class WriteOperation +/// \class WriteOperation /// Implements ProcessMonitor::WriteMemory. class WriteOperation : public Operation { public: @@ -266,8 +261,7 @@ void WriteOperation::Execute(ProcessMonitor *monitor) { m_result = DoWriteMemory(pid, m_addr, m_buff, m_size, m_error); } -//------------------------------------------------------------------------------ -/// @class ReadRegOperation +/// \class ReadRegOperation /// Implements ProcessMonitor::ReadRegisterValue. class ReadRegOperation : public Operation { public: @@ -306,8 +300,7 @@ void ReadRegOperation::Execute(ProcessMonitor *monitor) { } } -//------------------------------------------------------------------------------ -/// @class WriteRegOperation +/// \class WriteRegOperation /// Implements ProcessMonitor::WriteRegisterValue. class WriteRegOperation : public Operation { public: @@ -339,8 +332,7 @@ void WriteRegOperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class ReadDebugRegOperation +/// \class ReadDebugRegOperation /// Implements ProcessMonitor::ReadDebugRegisterValue. class ReadDebugRegOperation : public Operation { public: @@ -374,8 +366,7 @@ void ReadDebugRegOperation::Execute(ProcessMonitor *monitor) { } } -//------------------------------------------------------------------------------ -/// @class WriteDebugRegOperation +/// \class WriteDebugRegOperation /// Implements ProcessMonitor::WriteDebugRegisterValue. class WriteDebugRegOperation : public Operation { public: @@ -407,8 +398,7 @@ void WriteDebugRegOperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class ReadGPROperation +/// \class ReadGPROperation /// Implements ProcessMonitor::ReadGPR. class ReadGPROperation : public Operation { public: @@ -434,8 +424,7 @@ void ReadGPROperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class ReadFPROperation +/// \class ReadFPROperation /// Implements ProcessMonitor::ReadFPR. class ReadFPROperation : public Operation { public: @@ -457,8 +446,7 @@ void ReadFPROperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class WriteGPROperation +/// \class WriteGPROperation /// Implements ProcessMonitor::WriteGPR. class WriteGPROperation : public Operation { public: @@ -480,8 +468,7 @@ void WriteGPROperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class WriteFPROperation +/// \class WriteFPROperation /// Implements ProcessMonitor::WriteFPR. class WriteFPROperation : public Operation { public: @@ -503,8 +490,7 @@ void WriteFPROperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class ResumeOperation +/// \class ResumeOperation /// Implements ProcessMonitor::Resume. class ResumeOperation : public Operation { public: @@ -534,8 +520,7 @@ void ResumeOperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class SingleStepOperation +/// \class SingleStepOperation /// Implements ProcessMonitor::SingleStep. class SingleStepOperation : public Operation { public: @@ -562,8 +547,7 @@ void SingleStepOperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class LwpInfoOperation +/// \class LwpInfoOperation /// Implements ProcessMonitor::GetLwpInfo. class LwpInfoOperation : public Operation { public: @@ -591,8 +575,7 @@ void LwpInfoOperation::Execute(ProcessMonitor *monitor) { } } -//------------------------------------------------------------------------------ -/// @class ThreadSuspendOperation +/// \class ThreadSuspendOperation /// Implements ProcessMonitor::ThreadSuspend. class ThreadSuspendOperation : public Operation { public: @@ -611,8 +594,7 @@ void ThreadSuspendOperation::Execute(ProcessMonitor *monitor) { m_result = !PTRACE(m_suspend ? PT_SUSPEND : PT_RESUME, m_tid, NULL, 0); } -//------------------------------------------------------------------------------ -/// @class EventMessageOperation +/// \class EventMessageOperation /// Implements ProcessMonitor::GetEventMessage. class EventMessageOperation : public Operation { public: @@ -641,8 +623,7 @@ void EventMessageOperation::Execute(ProcessMonitor *monitor) { } } -//------------------------------------------------------------------------------ -/// @class KillOperation +/// \class KillOperation /// Implements ProcessMonitor::Kill. class KillOperation : public Operation { public: @@ -663,8 +644,7 @@ void KillOperation::Execute(ProcessMonitor *monitor) { m_result = true; } -//------------------------------------------------------------------------------ -/// @class DetachOperation +/// \class DetachOperation /// Implements ProcessMonitor::Detach. class DetachOperation : public Operation { public: @@ -709,7 +689,6 @@ ProcessMonitor::AttachArgs::AttachArgs(ProcessMonitor *monitor, lldb::pid_t pid) ProcessMonitor::AttachArgs::~AttachArgs() {} -//------------------------------------------------------------------------------ /// The basic design of the ProcessMonitor is built around two threads. /// /// One thread (@see SignalThread) simply blocks on a call to waitpid() @@ -729,7 +708,7 @@ ProcessMonitor::ProcessMonitor( const lldb_private::ProcessLaunchInfo & /* launch_info */, lldb_private::Status &error) : m_process(static_cast<ProcessFreeBSD *>(process)), - m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) { + m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) { using namespace std::placeholders; std::unique_ptr<LaunchArgs> args( @@ -759,7 +738,7 @@ ProcessMonitor::ProcessMonitor( m_monitor_thread = Host::StartMonitoringChildProcess( std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4), GetPID(), true); - if (!m_monitor_thread.IsJoinable()) { + if (!m_monitor_thread->IsJoinable()) { error.SetErrorToGenericError(); error.SetErrorString("Process launch failed."); return; @@ -768,8 +747,8 @@ ProcessMonitor::ProcessMonitor( ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid, lldb_private::Status &error) - : m_process(static_cast<ProcessFreeBSD *>(process)), m_pid(pid), - m_terminal_fd(-1), m_operation(0) { + : m_process(static_cast<ProcessFreeBSD *>(process)), + m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(pid), m_terminal_fd(-1), m_operation(0) { using namespace std::placeholders; sem_init(&m_operation_pending, 0, 0); @@ -797,7 +776,7 @@ ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid, m_monitor_thread = Host::StartMonitoringChildProcess( std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4), GetPID(), true); - if (!m_monitor_thread.IsJoinable()) { + if (!m_monitor_thread->IsJoinable()) { error.SetErrorToGenericError(); error.SetErrorString("Process attach failed."); return; @@ -806,16 +785,17 @@ ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid, ProcessMonitor::~ProcessMonitor() { StopMonitor(); } -//------------------------------------------------------------------------------ // Thread setup and tear down. void ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Status &error) { static const char *g_thread_name = "lldb.process.freebsd.operation"; - if (m_operation_thread.IsJoinable()) + if (m_operation_thread->IsJoinable()) return; m_operation_thread = - ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error); + ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args); + if (!m_operation_thread) + error = m_operation_thread.takeError(); } void *ProcessMonitor::LaunchOpThread(void *arg) { @@ -977,11 +957,14 @@ void ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Status &error) { static const char *g_thread_name = "lldb.process.freebsd.operation"; - if (m_operation_thread.IsJoinable()) + if (m_operation_thread->IsJoinable()) return; m_operation_thread = - ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error); + ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args); + + if (!m_operation_thread) + error = m_operation_thread.takeError(); } void *ProcessMonitor::AttachOpThread(void *arg) { @@ -1388,7 +1371,8 @@ lldb_private::Status ProcessMonitor::Detach(lldb::tid_t tid) { bool ProcessMonitor::DupDescriptor(const FileSpec &file_spec, int fd, int flags) { - int target_fd = open(file_spec.GetCString(), flags, 0666); + int target_fd = llvm::sys::RetryAfterSignal(-1, open, + file_spec.GetCString(), flags, 0666); if (target_fd == -1) return false; @@ -1400,10 +1384,10 @@ bool ProcessMonitor::DupDescriptor(const FileSpec &file_spec, int fd, } void ProcessMonitor::StopMonitoringChildProcess() { - if (m_monitor_thread.IsJoinable()) { - m_monitor_thread.Cancel(); - m_monitor_thread.Join(nullptr); - m_monitor_thread.Reset(); + if (m_monitor_thread->IsJoinable()) { + m_monitor_thread->Cancel(); + m_monitor_thread->Join(nullptr); + m_monitor_thread->Reset(); } } @@ -1438,10 +1422,10 @@ void ProcessMonitor::StopMonitor() { bool ProcessMonitor::WaitForInitialTIDStop(lldb::tid_t tid) { return true; } void ProcessMonitor::StopOpThread() { - if (!m_operation_thread.IsJoinable()) + if (!m_operation_thread->IsJoinable()) return; - m_operation_thread.Cancel(); - m_operation_thread.Join(nullptr); - m_operation_thread.Reset(); + m_operation_thread->Cancel(); + m_operation_thread->Join(nullptr); + m_operation_thread->Reset(); } diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/source/Plugins/Process/FreeBSD/ProcessMonitor.h index ca7c4e03966c..2adcc449c5c6 100644 --- a/source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -1,9 +1,8 @@ //===-- ProcessMonitor.h -------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -28,7 +27,7 @@ class Scalar; class ProcessFreeBSD; class Operation; -/// @class ProcessMonitor +/// \class ProcessMonitor /// Manages communication with the inferior (debugee) process. /// /// Upon construction, this class prepares and launches an inferior process @@ -77,14 +76,14 @@ public: /// -1. int GetTerminalFD() const { return m_terminal_fd; } - /// Reads @p size bytes from address @vm_adder in the inferior process + /// Reads \p size bytes from address @vm_adder in the inferior process /// address space. /// /// This method is provided to implement Process::DoReadMemory. size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, lldb_private::Status &error); - /// Writes @p size bytes from address @p vm_adder in the inferior process + /// Writes \p size bytes from address \p vm_adder in the inferior process /// address space. /// /// This method is provided to implement Process::DoWriteMemory. @@ -152,7 +151,7 @@ public: size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids); /// Writes a ptrace_lwpinfo structure corresponding to the given thread ID - /// to the memory region pointed to by @p lwpinfo. + /// to the memory region pointed to by \p lwpinfo. bool GetLwpInfo(lldb::tid_t tid, void *lwpinfo, int &error_no); /// Suspends or unsuspends a thread prior to process resume or step. @@ -163,11 +162,11 @@ public: /// message. bool GetEventMessage(lldb::tid_t tid, unsigned long *message); - /// Resumes the process. If @p signo is anything but + /// Resumes the process. If \p signo is anything but /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the process. bool Resume(lldb::tid_t unused, uint32_t signo); - /// Single steps the process. If @p signo is anything but + /// Single steps the process. If \p signo is anything but /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the process. bool SingleStep(lldb::tid_t unused, uint32_t signo); @@ -184,8 +183,8 @@ public: private: ProcessFreeBSD *m_process; - lldb_private::HostThread m_operation_thread; - lldb_private::HostThread m_monitor_thread; + llvm::Expected<lldb_private::HostThread> m_operation_thread; + llvm::Expected<lldb_private::HostThread> m_monitor_thread; lldb::pid_t m_pid; int m_terminal_fd; @@ -209,7 +208,7 @@ private: lldb_private::Status m_error; // Set if process operation failed. }; - /// @class LauchArgs + /// \class LauchArgs /// /// Simple structure to pass data to the thread responsible for launching a /// child process. diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h index 32973abd9207..cf52a065232c 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIX.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,8 +13,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/ArchSpec.h" -//------------------------------------------------------------------------------ -/// @class POSIXBreakpointProtocol +/// \class POSIXBreakpointProtocol /// /// Extends RegisterClass with a few virtual operations useful on POSIX. class POSIXBreakpointProtocol { @@ -28,7 +26,7 @@ public: /// implementation simply returns true for architectures which do not /// require any update. /// - /// @return + /// \return /// True if the operation succeeded and false otherwise. virtual bool UpdateAfterBreakpoint() = 0; diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp index 0642a30ade70..f0c4526357cc 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_arm.cpp -----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===---------------------------------------------------------------------===// @@ -156,7 +155,7 @@ bool RegisterContextPOSIXProcessMonitor_arm::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h index 6aa71c24f1cd..b376967df99c 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_arm.h --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp index b35ee18d6a96..147f4b56a804 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_arm64.cpp -----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===---------------------------------------------------------------------===// @@ -165,7 +164,7 @@ bool RegisterContextPOSIXProcessMonitor_arm64::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { bool success = false; data_sp.reset(new lldb_private::DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h index 8591c83be541..d54d34e89cad 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_arm64.h --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp index 17df44cf85ee..db9b5a6a038c 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_mips64.cpp -----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -161,7 +160,7 @@ bool RegisterContextPOSIXProcessMonitor_mips64::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h index 6f57b0d9cd65..a482cd3f1e1c 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_mips64.h -------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp index a8d75963ea6b..77694733fa39 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_powerpc.cpp ----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -171,7 +170,7 @@ bool RegisterContextPOSIXProcessMonitor_powerpc::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h index 188ddea7d473..17b649feebf1 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h @@ -1,10 +1,9 @@ //===-- RegisterContextPOSIXProcessMonitor_powerpc.h -------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp index 68fd5ac13bb0..3046d97f153c 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_x86.cpp --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -345,7 +344,7 @@ bool RegisterContextPOSIXProcessMonitor_x86_64::ReadAllRegisterValues( DataBufferSP &data_sp) { bool success = false; data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0)); - if (data_sp && ReadGPR() && ReadFPR()) { + if (ReadGPR() && ReadFPR()) { uint8_t *dst = data_sp->GetBytes(); success = dst != 0; diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h index 8c654f97dcd9..c9dc02a88e01 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_x86.h ----------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// |
