forked from OSchip/llvm-project
PT_CONTINUE and PT_STEP are process-scope on FreeBSD
Although ptrace() can be passed a PID or TID for PT_CONTINUE and PT_STEP, the kernel operates on all threads in the process in both cases. (See the FOREACH_THREAD_IN_PROC in FreeBSD's sys_process.c:kern_ptrace.) Make this clear by using the PID from the ProcessMonitor instance. llvm-svn: 195656
This commit is contained in:
parent
db962e2c45
commit
502f9020a7
|
@ -465,13 +465,12 @@ WriteFPROperation::Execute(ProcessMonitor *monitor)
|
||||||
class ResumeOperation : public Operation
|
class ResumeOperation : public Operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResumeOperation(lldb::tid_t tid, uint32_t signo, bool &result) :
|
ResumeOperation(uint32_t signo, bool &result) :
|
||||||
m_tid(tid), m_signo(signo), m_result(result) { }
|
m_signo(signo), m_result(result) { }
|
||||||
|
|
||||||
void Execute(ProcessMonitor *monitor);
|
void Execute(ProcessMonitor *monitor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lldb::tid_t m_tid;
|
|
||||||
uint32_t m_signo;
|
uint32_t m_signo;
|
||||||
bool &m_result;
|
bool &m_result;
|
||||||
};
|
};
|
||||||
|
@ -479,17 +478,18 @@ private:
|
||||||
void
|
void
|
||||||
ResumeOperation::Execute(ProcessMonitor *monitor)
|
ResumeOperation::Execute(ProcessMonitor *monitor)
|
||||||
{
|
{
|
||||||
|
lldb::pid_t pid = monitor->GetPID();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
|
|
||||||
if (m_signo != LLDB_INVALID_SIGNAL_NUMBER)
|
if (m_signo != LLDB_INVALID_SIGNAL_NUMBER)
|
||||||
data = m_signo;
|
data = m_signo;
|
||||||
|
|
||||||
if (PTRACE(PT_CONTINUE, m_tid, (caddr_t)1, data))
|
if (PTRACE(PT_CONTINUE, pid, (caddr_t)1, data))
|
||||||
{
|
{
|
||||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
|
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
|
||||||
|
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf ("ResumeOperation (%" PRIu64 ") failed: %s", m_tid, strerror(errno));
|
log->Printf ("ResumeOperation (%" PRIu64 ") failed: %s", pid, strerror(errno));
|
||||||
m_result = false;
|
m_result = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -502,13 +502,12 @@ ResumeOperation::Execute(ProcessMonitor *monitor)
|
||||||
class SingleStepOperation : public Operation
|
class SingleStepOperation : public Operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SingleStepOperation(lldb::tid_t tid, uint32_t signo, bool &result)
|
SingleStepOperation(uint32_t signo, bool &result)
|
||||||
: m_tid(tid), m_signo(signo), m_result(result) { }
|
: m_signo(signo), m_result(result) { }
|
||||||
|
|
||||||
void Execute(ProcessMonitor *monitor);
|
void Execute(ProcessMonitor *monitor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lldb::tid_t m_tid;
|
|
||||||
uint32_t m_signo;
|
uint32_t m_signo;
|
||||||
bool &m_result;
|
bool &m_result;
|
||||||
};
|
};
|
||||||
|
@ -516,12 +515,13 @@ private:
|
||||||
void
|
void
|
||||||
SingleStepOperation::Execute(ProcessMonitor *monitor)
|
SingleStepOperation::Execute(ProcessMonitor *monitor)
|
||||||
{
|
{
|
||||||
|
lldb::pid_t pid = monitor->GetPID();
|
||||||
int data = 0;
|
int data = 0;
|
||||||
|
|
||||||
if (m_signo != LLDB_INVALID_SIGNAL_NUMBER)
|
if (m_signo != LLDB_INVALID_SIGNAL_NUMBER)
|
||||||
data = m_signo;
|
data = m_signo;
|
||||||
|
|
||||||
if (PTRACE(PT_STEP, m_tid, NULL, data))
|
if (PTRACE(PT_STEP, pid, NULL, data))
|
||||||
m_result = false;
|
m_result = false;
|
||||||
else
|
else
|
||||||
m_result = true;
|
m_result = true;
|
||||||
|
@ -1467,15 +1467,15 @@ ProcessMonitor::ReadThreadPointer(lldb::tid_t tid, lldb::addr_t &value)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ProcessMonitor::Resume(lldb::tid_t tid, uint32_t signo)
|
ProcessMonitor::Resume(lldb::tid_t unused, uint32_t signo)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
|
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
|
||||||
|
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf ("ProcessMonitor::%s() resuming thread = %" PRIu64 " with signal %s", __FUNCTION__, tid,
|
log->Printf ("ProcessMonitor::%s() resuming pid %" PRIu64 " with signal %s", __FUNCTION__, GetPID(),
|
||||||
m_process->GetUnixSignals().GetSignalAsCString (signo));
|
m_process->GetUnixSignals().GetSignalAsCString (signo));
|
||||||
ResumeOperation op(tid, signo, result);
|
ResumeOperation op(signo, result);
|
||||||
DoOperation(&op);
|
DoOperation(&op);
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf ("ProcessMonitor::%s() resuming result = %s", __FUNCTION__, result ? "true" : "false");
|
log->Printf ("ProcessMonitor::%s() resuming result = %s", __FUNCTION__, result ? "true" : "false");
|
||||||
|
@ -1483,10 +1483,10 @@ ProcessMonitor::Resume(lldb::tid_t tid, uint32_t signo)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ProcessMonitor::SingleStep(lldb::tid_t tid, uint32_t signo)
|
ProcessMonitor::SingleStep(lldb::tid_t unused, uint32_t signo)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
SingleStepOperation op(tid, signo, result);
|
SingleStepOperation op(signo, result);
|
||||||
DoOperation(&op);
|
DoOperation(&op);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,15 +175,15 @@ public:
|
||||||
bool
|
bool
|
||||||
GetEventMessage(lldb::tid_t tid, unsigned long *message);
|
GetEventMessage(lldb::tid_t tid, unsigned long *message);
|
||||||
|
|
||||||
/// Resumes the given thread. If @p signo is anything but
|
/// Resumes the process. If @p signo is anything but
|
||||||
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
|
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the process.
|
||||||
bool
|
bool
|
||||||
Resume(lldb::tid_t tid, uint32_t signo);
|
Resume(lldb::tid_t unused, uint32_t signo);
|
||||||
|
|
||||||
/// Single steps the given thread. 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 thread.
|
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the process.
|
||||||
bool
|
bool
|
||||||
SingleStep(lldb::tid_t tid, uint32_t signo);
|
SingleStep(lldb::tid_t unused, uint32_t signo);
|
||||||
|
|
||||||
/// Sends the inferior process a PTRACE_KILL signal. The inferior will
|
/// Sends the inferior process a PTRACE_KILL signal. The inferior will
|
||||||
/// still exists and can be interrogated. Once resumed it will exit as
|
/// still exists and can be interrogated. Once resumed it will exit as
|
||||||
|
|
Loading…
Reference in New Issue