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:
Ed Maste 2013-11-25 16:31:23 +00:00
parent db962e2c45
commit 502f9020a7
2 changed files with 20 additions and 20 deletions

View File

@ -465,13 +465,12 @@ WriteFPROperation::Execute(ProcessMonitor *monitor)
class ResumeOperation : public Operation
{
public:
ResumeOperation(lldb::tid_t tid, uint32_t signo, bool &result) :
m_tid(tid), m_signo(signo), m_result(result) { }
ResumeOperation(uint32_t signo, bool &result) :
m_signo(signo), m_result(result) { }
void Execute(ProcessMonitor *monitor);
private:
lldb::tid_t m_tid;
uint32_t m_signo;
bool &m_result;
};
@ -479,17 +478,18 @@ private:
void
ResumeOperation::Execute(ProcessMonitor *monitor)
{
lldb::pid_t pid = monitor->GetPID();
int data = 0;
if (m_signo != LLDB_INVALID_SIGNAL_NUMBER)
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));
if (log)
log->Printf ("ResumeOperation (%" PRIu64 ") failed: %s", m_tid, strerror(errno));
log->Printf ("ResumeOperation (%" PRIu64 ") failed: %s", pid, strerror(errno));
m_result = false;
}
else
@ -502,13 +502,12 @@ ResumeOperation::Execute(ProcessMonitor *monitor)
class SingleStepOperation : public Operation
{
public:
SingleStepOperation(lldb::tid_t tid, uint32_t signo, bool &result)
: m_tid(tid), m_signo(signo), m_result(result) { }
SingleStepOperation(uint32_t signo, bool &result)
: m_signo(signo), m_result(result) { }
void Execute(ProcessMonitor *monitor);
private:
lldb::tid_t m_tid;
uint32_t m_signo;
bool &m_result;
};
@ -516,12 +515,13 @@ private:
void
SingleStepOperation::Execute(ProcessMonitor *monitor)
{
lldb::pid_t pid = monitor->GetPID();
int data = 0;
if (m_signo != LLDB_INVALID_SIGNAL_NUMBER)
data = m_signo;
if (PTRACE(PT_STEP, m_tid, NULL, data))
if (PTRACE(PT_STEP, pid, NULL, data))
m_result = false;
else
m_result = true;
@ -1467,15 +1467,15 @@ ProcessMonitor::ReadThreadPointer(lldb::tid_t tid, lldb::addr_t &value)
}
bool
ProcessMonitor::Resume(lldb::tid_t tid, uint32_t signo)
ProcessMonitor::Resume(lldb::tid_t unused, uint32_t signo)
{
bool result;
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
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));
ResumeOperation op(tid, signo, result);
ResumeOperation op(signo, result);
DoOperation(&op);
if (log)
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
ProcessMonitor::SingleStep(lldb::tid_t tid, uint32_t signo)
ProcessMonitor::SingleStep(lldb::tid_t unused, uint32_t signo)
{
bool result;
SingleStepOperation op(tid, signo, result);
SingleStepOperation op(signo, result);
DoOperation(&op);
return result;
}

View File

@ -175,15 +175,15 @@ public:
bool
GetEventMessage(lldb::tid_t tid, unsigned long *message);
/// Resumes the given thread. If @p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
/// Resumes the process. If @p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the process.
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
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
/// 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 tid, uint32_t signo);
SingleStep(lldb::tid_t unused, uint32_t signo);
/// Sends the inferior process a PTRACE_KILL signal. The inferior will
/// still exists and can be interrogated. Once resumed it will exit as