Go to the documentation of this file.
19 #include "llvm/Support/Errno.h"
22 #include <sys/types.h>
23 #include <sys/ptrace.h>
24 #include <sys/sysctl.h>
41 process.GetArchitecture(), *this)),
42 m_stop_description() {}
77 const siginfo_t *info) {
79 LLDB_LOG(log,
"tid = {0} in called with signal {1}",
GetID(), signo);
121 std::ostringstream ostr;
183 std::vector<struct kinfo_proc> kp;
184 int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
188 size_t len = kp.size() *
sizeof(
struct kinfo_proc);
189 void *ptr = len == 0 ? nullptr : kp.data();
190 int error = ::sysctl(mib, 4, ptr, &len,
nullptr, 0);
191 if (ptr ==
nullptr || (
error != 0 && errno == ENOMEM)) {
192 kp.resize(len /
sizeof(
struct kinfo_proc));
197 LLDB_LOG(log,
"tid = {0} in state {1} failed to get thread name: {2}",
200 kp.resize(len /
sizeof(
struct kinfo_proc));
204 for (
auto &procinfo : kp) {
205 if (procinfo.ki_tid ==
static_cast<lwpid_t
>(
GetID()))
206 return procinfo.ki_tdname;
237 LLDB_LOG(log,
"tid = {0} in state {1} cannot answer stop reason",
GetID(),
241 llvm_unreachable(
"unhandled StateType!");
250 uint32_t watch_flags,
bool hardware) {
253 return Status(
"not implemented");
260 return Status(
"Setting hardware watchpoint failed.");
273 return Status(
"Clearing hardware watchpoint failed.");
286 return Status(
"Setting hardware breakpoint failed.");
303 return Status(
"Clearing hardware breakpoint failed.");
317 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
321 struct ptrace_lwpinfo info;
323 PT_LWPINFO,
GetID(), &info,
sizeof(info));
324 if (siginfo_err.Fail()) {
325 LLDB_LOG(log,
"PT_LWPINFO failed {0}", siginfo_err);
326 return siginfo_err.ToError();
329 if (info.pl_event != PL_EVENT_SIGNAL)
330 return llvm::createStringError(llvm::inconvertibleErrorCode(),
331 "Thread not signaled");
332 if (!(info.pl_flags & PL_FLAG_SI))
333 return llvm::createStringError(llvm::inconvertibleErrorCode(),
334 "No siginfo for thread");
336 return llvm::MemoryBuffer::getMemBufferCopy(
337 llvm::StringRef(
reinterpret_cast<const char *
>(&info.pl_siginfo),
338 sizeof(info.pl_siginfo)));
llvm::Error CopyWatchpointsFrom(NativeThreadFreeBSD &source)
virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size)
Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override
@ eStateAttaching
Process is currently trying to attach.
lldb::StateType GetState() override
void SetStoppedByFork(lldb::pid_t child_pid, lldb::tid_t child_tid)
void SetStoppedByVForkDone()
NativeProcessProtocol & GetProcess()
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
virtual llvm::Error CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD &source)=0
union lldb_private::ThreadStopInfo::@13 details
std::string m_stop_description
@ eStateExited
Process has exited and can't be examined.
std::string GetName() override
@ eStateStopped
Process or thread is stopped and can be examined.
static llvm::raw_ostream & error(Stream &strm)
bool Success() const
Test for success condition.
@ eStateCrashed
Process or thread has crashed and can be examined.
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr=nullptr, int data=0, int *result=nullptr)
virtual lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index)
Status RemoveHardwareBreakpoint(lldb::addr_t addr) override
ValueType GetError() const
Access the error value.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateLaunching
Process is in the process of launching.
std::unique_ptr< NativeRegisterContextFreeBSD > m_reg_context_up
lldb::pid_t GetID() const
Status RemoveWatchpoint(lldb::addr_t addr) override
@ eStateDetached
Process has been detached and can't be examined.
string(SUBSTRING ${p} 10 -1 pStripped) if($
struct lldb_private::ThreadStopInfo::@13::@14 signal
void SetStoppedWithNoReason()
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override
std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info)
@ eStopReasonExec
Program was re-exec'ed.
void SetStoppedByBreakpoint()
lldb::tid_t GetID() const
bool GetStopReason(ThreadStopInfo &stop_info, std::string &description) override
WatchpointIndexMap m_hw_break_index_map
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
struct lldb_private::ThreadStopInfo::@13::@16 fork
A class that represents a running process on the host machine.
NativeRegisterContextFreeBSD & GetRegisterContext() override
void SetStoppedByWatchpoint(uint32_t wp_index)
void Clear()
Clear the object state.
#define LLDB_INVALID_INDEX32
StateType
Process and Thread States.
llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo() const override
void SetStoppedBySignal(uint32_t signo, const siginfo_t *info=nullptr)
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
virtual uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags)
void SetStoppedByVFork(lldb::pid_t child_pid, lldb::tid_t child_tid)
@ eStateRunning
Process or thread is running and can't be examined.
ThreadStopInfo m_stop_info
WatchpointIndexMap m_watchpoint_index_map
virtual lldb::addr_t GetWatchpointAddress(uint32_t wp_index)
CrashReason GetCrashReason(const siginfo_t &info)