[Lldb-commits] [lldb] r195656 - PT_CONTINUE and PT_STEP are process-scope on FreeBSD

Ed Maste emaste at freebsd.org
Mon Nov 25 08:31:23 PST 2013


Author: emaste
Date: Mon Nov 25 10:31:23 2013
New Revision: 195656

URL: http://llvm.org/viewvc/llvm-project?rev=195656&view=rev
Log:
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.

Modified:
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=195656&r1=195655&r2=195656&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Mon Nov 25 10:31:23 2013
@@ -465,13 +465,12 @@ WriteFPROperation::Execute(ProcessMonito
 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
 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::
 }
 
 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,
 }
 
 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;
 }

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h?rev=195656&r1=195655&r2=195656&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.h Mon Nov 25 10:31:23 2013
@@ -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





More information about the lldb-commits mailing list