[PATCH][Linux] compilation fails on linux after revision 196787

The following patch fixes this.

Xavier

diff --git a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
--- a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
+++ b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
@@ -12,6 +12,10 @@
  // Other libraries and framework includes
  // Project includes
  #include "LinuxThread.h"
+#include "lldb/Core/State.h"
+#include "ProcessPOSIX.h"
+#include "ProcessMonitor.h"
+#include "ProcessPOSIXLog.h"

  using namespace lldb;
  using namespace lldb_private;
diff --git a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h
--- a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h
+++ b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h
@@ -33,7 +33,7 @@

      // POSIXThread overrides
      virtual bool
- LinuxThread::Resume();
+ Resume();

      virtual void
      RefreshStateAfterStop();
diff --git a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
--- a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
+++ b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
@@ -182,7 +182,7 @@
      uint32_t thread_count = m_thread_list.GetSize(false);
      for (uint32_t i = 0; i < thread_count; ++i)
      {
- POSIXThread *thread = static_cast<POSIXThread*>(
+ LinuxThread *thread = static_cast<LinuxThread*>(
              m_thread_list.GetThreadAtIndex(i, false).get());
          did_resume = thread->Resume() || did_resume;
      }
diff --git a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h
--- a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h
+++ b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h
@@ -60,6 +60,9 @@
      virtual bool
      UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);

+ virtual lldb_private::Error
+ DoResume();

Looks good.

This has been commited at r196830 and fixes the build but there is still
an issue on linux with r196787.

When lldb is built on linux at r196786 (the previous revision) with the
attached sin_len.patch (to fix temporarily the issue
http://llvm.org/bugs/show_bug.cgi?id=18210 so as to allow the build),
then lldb stops correctly at main in the following simple test:
     breakpoint set --name main
     run

When lldb is built on linux at r196787 with the sin_len.patch and with
the changes made in r196830 applied (same as the patch proposed in the
OP), the above simple test fails and lldb is stuck in a futex syscall.

Xavier

> Looks good.
>
>> The following patch fixes this.
>>
>> Xavier
>>
>> diff --git a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
>> --- a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
>> +++ b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
>> @@ -12,6 +12,10 @@
>> // Other libraries and framework includes
>> // Project includes
>> #include "LinuxThread.h"
>> +#include "lldb/Core/State.h"
>> +#include "ProcessPOSIX.h"
>> +#include "ProcessMonitor.h"
>> +#include "ProcessPOSIXLog.h"
>>
>> using namespace lldb;
>> using namespace lldb_private;
>> diff --git a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h
>> --- a/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h
>> +++ b/tools/lldb/source/Plugins/Process/Linux/LinuxThread.h
>> @@ -33,7 +33,7 @@
>>
>> // POSIXThread overrides
>> virtual bool
>> - LinuxThread::Resume();
>> + Resume();
>>
>> virtual void
>> RefreshStateAfterStop();
>> diff --git a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
>> --- a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
>> +++ b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
>> @@ -182,7 +182,7 @@
>> uint32_t thread_count = m_thread_list.GetSize(false);
>> for (uint32_t i = 0; i < thread_count; ++i)
>> {
>> - POSIXThread *thread = static_cast<POSIXThread*>(
>> + LinuxThread *thread = static_cast<LinuxThread*>(
>> m_thread_list.GetThreadAtIndex(i, false).get());
>> did_resume = thread->Resume() || did_resume;
>> }
>> diff --git a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h
>> --- a/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h
>> +++ b/tools/lldb/source/Plugins/Process/Linux/ProcessLinux.h
>> @@ -60,6 +60,9 @@
>> virtual bool
>> UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);

sin_len.patch (1.13 KB)

Did you try to revert the commits which introduced that ?
Did it fix the freeze ?

Thanks
S

Yes, testing r196786 does not cause lldb to freeze, see my previous
post.

Xavier

To rephrase my question, do you know which commit(s) broke lldb under
GNU/Linux ?
r196786 seems unrelated to me.

Sylvestre

I believe Xavier means 196786 is fine and 196787 fails. I'm looking at it.

I applied the patch from Todd.
We have too many people complaining about the issue.

Sylvestre

I reverted the Linux changes in r196787 yesterday and was unable to
reproduce the issue in a Debian VM. The revert is r197065. Xavier
can you confirm this fixes your issue?

The revert moves three Linux-specific functions back into Plugins/Process/POSIX:

POSIXThread::Resume
ProcessPOSIX::DoResume
ProcessPOSIX::SendMessage

r197065 does fix this issue on archlinux, thanks.

Xavier