[lldb-dev] [PATCH] Typo in ProcessMonitor::WaitForInitialTIDStop? for linux

Matthew Gardiner mg11 at csr.com
Fri Feb 21 05:58:21 PST 2014


Hi,

I'm trying to discover why a tracer stop gets reported as process exit
by 32-bit linux lldb. I happened upon this piece of code:

bool
ProcessMonitor::WaitForInitialTIDStop(lldb::tid_t tid)
{
     Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
     if (log)
         log->Printf ("ProcessMonitor::%s(%" PRIu64 ") waiting for thread to stop...", __FUNCTION__, tid);

     // Wait for the thread to stop
     while (true)
     {
         int status = -1;
         if (log)
             log->Printf ("ProcessMonitor::%s(%" PRIu64 ") waitpid...", __FUNCTION__, tid);
         lldb::pid_t wait_pid = waitpid(tid, &status, __WALL);
         if (status == -1)
         {
             // If we got interrupted by a signal (in our process, not the
             // inferior) try again.
             if (errno == EINTR)
                 continue;

Surely this line is wrong "if (status == -1)" ?? We should checking the
return value of waitpid not the optional status field.

Patch attached.

Index: source/Plugins/Process/Linux/ProcessMonitor.cpp
===================================================================
--- source/Plugins/Process/Linux/ProcessMonitor.cpp	(revision 201779)
+++ source/Plugins/Process/Linux/ProcessMonitor.cpp	(working copy)
@@ -1700,7 +1700,7 @@
          if (log)
              log->Printf ("ProcessMonitor::%s(%" PRIu64 ") waitpid...", __FUNCTION__, tid);
          lldb::pid_t wait_pid = waitpid(tid, &status, __WALL);
-        if (status == -1)
+        if (-1 == wait_pid)
          {
              // If we got interrupted by a signal (in our process, not the
              // inferior) try again.


thanks
Matt


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, www.youtube.com/user/CSRplc, Facebook, www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at www.aptx.com.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ProcessMonitor.cpp.diff
Type: text/x-patch
Size: 634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140221/147192e8/attachment.bin>


More information about the lldb-dev mailing list