19#include "llvm/Support/Errno.h"
23#include <sys/ptrace.h>
30#include <sys/sysctl.h>
40 m_stop_info(), m_reg_context_up(
42), m_stop_description() {}
77 const siginfo_t *info) {
79 LLDB_LOG(log,
"tid = {0} in called with signal {1}",
GetID(), signo);
120 std::ostringstream ostr;
167 const StateType new_state = StateType::eStateStopped;
173 m_state = StateType::eStateRunning;
178 m_state = StateType::eStateStepping;
184 struct ptrace_lwpstatus info = {};
185 info.pl_lwpid =
m_tid;
187 PT_LWPSTATUS,
static_cast<int>(
m_process.
GetID()), &info,
sizeof(info));
193 std::vector<struct kinfo_lwp> infos;
196 int mib[5] = {CTL_KERN, KERN_LWP,
static_cast<int>(
m_process.
GetID()),
197 sizeof(
struct kinfo_lwp), 0};
200 if (::sysctl(mib, 5,
nullptr, &size,
nullptr, 0) == -1 || size == 0) {
201 LLDB_LOG(log,
"sysctl() for LWP info size failed: {0}",
202 llvm::sys::StrError());
206 mib[4] = size /
sizeof(size_t);
207 infos.resize(size /
sizeof(
struct kinfo_lwp));
209 if (sysctl(mib, 5, infos.data(), &size, NULL, 0) == -1 || size == 0) {
210 LLDB_LOG(log,
"sysctl() for LWP info failed: {0}", llvm::sys::StrError());
214 size_t nlwps = size /
sizeof(
struct kinfo_lwp);
215 for (
size_t i = 0; i < nlwps; i++) {
217 return infos[i].l_name;
229 std::string &description) {
251 LLDB_LOG(log,
"tid = {0} in state {1} cannot answer stop reason",
GetID(),
255 llvm_unreachable(
"unhandled StateType!");
264 uint32_t watch_flags,
bool hardware) {
267 return Status(
"not implemented");
274 return Status(
"Setting hardware watchpoint failed.");
283 uint32_t wp_index = wp->second;
287 return Status(
"Clearing hardware watchpoint failed.");
300 return Status(
"Setting hardware breakpoint failed.");
311 uint32_t bp_index = bp->second;
317 return Status(
"Clearing hardware breakpoint failed.");
static llvm::raw_ostream & error(Stream &strm)
std::string GetCrashReasonString(const siginfo_t &info)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
lldb::pid_t GetID() const
virtual lldb::addr_t GetWatchpointAddress(uint32_t wp_index)
virtual lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index)
virtual uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags)
virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size)
NativeProcessProtocol & m_process
lldb::tid_t GetID() const
bool Success() const
Test for success condition.
Manages communication with the inferior (debugee) process.
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr=nullptr, int data=0, int *result=nullptr)
virtual llvm::Error CopyHardwareWatchpointsFrom(NativeRegisterContextNetBSD &source)=0
void SetStoppedByFork(lldb::pid_t child_pid, lldb::tid_t child_tid)
void SetStoppedBySignal(uint32_t signo, const siginfo_t *info=nullptr)
bool GetStopReason(ThreadStopInfo &stop_info, std::string &description) override
void SetStoppedWithNoReason()
std::string m_stop_description
lldb::StateType GetState() override
Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override
Status RemoveHardwareBreakpoint(lldb::addr_t addr) override
std::unique_ptr< NativeRegisterContextNetBSD > m_reg_context_up
std::string GetName() override
Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override
NativeRegisterContextNetBSD & GetRegisterContext() override
WatchpointIndexMap m_watchpoint_index_map
void SetStoppedByVFork(lldb::pid_t child_pid, lldb::tid_t child_tid)
void SetStoppedByVForkDone()
NativeThreadNetBSD(NativeProcessNetBSD &process, lldb::tid_t tid)
Status RemoveWatchpoint(lldb::addr_t addr) override
void SetStoppedByBreakpoint()
llvm::Error CopyWatchpointsFrom(NativeThreadNetBSD &source)
ThreadStopInfo m_stop_info
void SetStoppedByWatchpoint(uint32_t wp_index)
WatchpointIndexMap m_hw_break_index_map
#define LLDB_INVALID_INDEX32
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateLaunching
Process is in the process of launching.
@ eStateAttaching
Process is currently trying to attach.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateCrashed
Process or thread has crashed and can be examined.
struct lldb_private::ThreadStopInfo::@11::@13 fork
union lldb_private::ThreadStopInfo::@11 details