[Lldb-commits] [PATCH] fix for Linux build

dawn at burble.org dawn at burble.org
Mon Oct 10 15:37:15 PDT 2011


This patch fixes the Linux build and has been updated to work 
with the latest sources of llvm, clang and lldb.
Please review.

Note: while it fixes the build on Linux, lldb is still crashing in
pthread_mutex_lock() as it did before.

Thanks in advance,
    -Dawn

On Thu, Oct 06, 2011 at 07:54:01PM -0700, dawn at burble.org wrote:
> 
> The attached patch fixes the Linux build for llvm and clang revs 137311
> (the revs documented in lldb/scripts/build-llvm.pl),
> and is based on lldb rev 141349 (current rev as of this email).
> 
> Would it be OK to commit this?
> 
> Thanks,
>     -Dawn

> Index: source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp
> ===================================================================
> --- source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp	(revision 141349)
> +++ source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp	(working copy)
> @@ -112,7 +112,7 @@
>      executable = m_process->GetTarget().GetExecutableModule();
>      load_offset = ComputeLoadOffset();
>  
> -    if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS)
> +    if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
>      {
>          ModuleList module_list;
>          module_list.Append(executable);
> @@ -132,7 +132,7 @@
>      executable = m_process->GetTarget().GetExecutableModule();
>      load_offset = ComputeLoadOffset();
>  
> -    if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS)
> +    if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
>      {
>          ModuleList module_list;
>          module_list.Append(executable);
> @@ -264,7 +264,7 @@
>          {
>              FileSpec file(I->path.c_str(), true);
>              ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr);
> -            if (!module_sp.empty())
> +            if (module_sp.get())
>                  new_modules.Append(module_sp);
>          }
>          m_process->GetTarget().ModulesDidLoad(new_modules);
> @@ -280,7 +280,7 @@
>              FileSpec file(I->path.c_str(), true);
>              ModuleSP module_sp = 
>                  loaded_modules.FindFirstModuleForFileSpec(file, NULL, NULL);
> -            if (!module_sp.empty())
> +            if (module_sp.get())
>                  old_modules.Append(module_sp);
>          }
>          m_process->GetTarget().ModulesDidUnload(old_modules);
> @@ -355,7 +355,7 @@
>      {
>          FileSpec file(I->path.c_str(), false);
>          ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr);
> -        if (!module_sp.empty())
> +        if (module_sp.get())
>              module_list.Append(module_sp);
>      }
>  
> Index: source/Plugins/Process/Linux/ProcessLinux.cpp
> ===================================================================
> --- source/Plugins/Process/Linux/ProcessLinux.cpp	(revision 141349)
> +++ source/Plugins/Process/Linux/ProcessLinux.cpp	(working copy)
> @@ -437,6 +437,35 @@
>      return m_thread_list.GetSize(false);
>  }
>  
> +uint32_t
> +ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
> +{
> +#if 0 // GetLogIfAllCategoriesSet is in lldb_private
> +    // locker will keep a mutex locked until it goes out of scope
> +    LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (Linux_LOG_THREAD));
> +    if (log && log->GetMask().Test(Linux_LOG_VERBOSE))
> +        log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID());
> +    
> +    // We currently are making only one thread per core and we
> +    // actually don't know about actual threads. Eventually we
> +    // want to get the thread list from memory and note which
> +    // threads are on CPU as those are the only ones that we 
> +    // will be able to resume.
> +    const uint32_t cpu_mask = m_comm.GetCPUMask();
> +    for (uint32_t cpu_mask_bit = 1; cpu_mask_bit & cpu_mask; cpu_mask_bit <<= 1)
> +    {
> +        lldb::tid_t tid = cpu_mask_bit;
> +        ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false));
> +        if (!thread_sp)
> +            thread_sp.reset(new ThreadLinux (*this, tid));
> +        new_thread_list.AddThread(thread_sp);
> +    }
> +    return new_thread_list.GetSize(false);
> +#else
> +    return 0;
> +#endif
> +}
> +
>  ByteOrder
>  ProcessLinux::GetByteOrder() const
>  {
> Index: source/Plugins/Process/Linux/ProcessLinux.h
> ===================================================================
> --- source/Plugins/Process/Linux/ProcessLinux.h	(revision 141349)
> +++ source/Plugins/Process/Linux/ProcessLinux.h	(working copy)
> @@ -129,6 +129,10 @@
>      virtual uint32_t
>      UpdateThreadListIfNeeded();
>  
> +    uint32_t
> +    UpdateThreadList(lldb_private::ThreadList &old_thread_list, 
> +                     lldb_private::ThreadList &new_thread_list);
> +
>      virtual lldb::ByteOrder
>      GetByteOrder() const;
>  
> Index: source/Plugins/Process/Linux/ProcessMonitor.cpp
> ===================================================================
> --- source/Plugins/Process/Linux/ProcessMonitor.cpp	(revision 141349)
> +++ source/Plugins/Process/Linux/ProcessMonitor.cpp	(working copy)
> @@ -241,7 +241,7 @@
>  
>      // Set errno to zero so that we can detect a failed peek.
>      errno = 0;
> -    unsigned long data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL);
> +    uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL);
>  
>      if (data == -1UL && errno)
>          m_result = false;
> Index: source/lldb.cpp
> ===================================================================
> --- source/lldb.cpp	(revision 141349)
> +++ source/lldb.cpp	(working copy)
> @@ -94,7 +94,9 @@
>          UnwindAssemblyInstEmulation::Initialize();
>          UnwindAssembly_x86::Initialize();
>          EmulateInstructionARM::Initialize ();
> +#if !defined (__linux__)
>          ObjectFilePECOFF::Initialize ();
> +#endif
>  #if defined (__APPLE__)
>          //----------------------------------------------------------------------
>          // Apple/Darwin hosted plugins
> @@ -166,7 +168,9 @@
>      UnwindAssembly_x86::Terminate();
>      UnwindAssemblyInstEmulation::Terminate();
>      EmulateInstructionARM::Terminate ();
> +#if !defined (__linux__)
>      ObjectFilePECOFF::Terminate ();
> +#endif
>  
>  #if defined (__APPLE__)
>      DynamicLoaderMacOSXDYLD::Terminate();

> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

-------------- next part --------------
Index: source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp
===================================================================
--- source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp	(revision 141569)
+++ source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp	(working copy)
@@ -112,7 +112,7 @@
     executable = m_process->GetTarget().GetExecutableModule();
     load_offset = ComputeLoadOffset();
 
-    if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS)
+    if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
     {
         ModuleList module_list;
         module_list.Append(executable);
@@ -132,7 +132,7 @@
     executable = m_process->GetTarget().GetExecutableModule();
     load_offset = ComputeLoadOffset();
 
-    if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS)
+    if (executable.get() && load_offset != LLDB_INVALID_ADDRESS)
     {
         ModuleList module_list;
         module_list.Append(executable);
@@ -264,7 +264,7 @@
         {
             FileSpec file(I->path.c_str(), true);
             ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr);
-            if (!module_sp.empty())
+            if (module_sp.get())
                 new_modules.Append(module_sp);
         }
         m_process->GetTarget().ModulesDidLoad(new_modules);
@@ -280,7 +280,7 @@
             FileSpec file(I->path.c_str(), true);
             ModuleSP module_sp = 
                 loaded_modules.FindFirstModuleForFileSpec(file, NULL, NULL);
-            if (!module_sp.empty())
+            if (module_sp.get())
                 old_modules.Append(module_sp);
         }
         m_process->GetTarget().ModulesDidUnload(old_modules);
@@ -355,7 +355,7 @@
     {
         FileSpec file(I->path.c_str(), false);
         ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr);
-        if (!module_sp.empty())
+        if (module_sp.get())
             module_list.Append(module_sp);
     }
 
Index: source/Plugins/Process/Linux/ProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/ProcessLinux.cpp	(revision 141569)
+++ source/Plugins/Process/Linux/ProcessLinux.cpp	(working copy)
@@ -437,6 +437,13 @@
     return m_thread_list.GetSize(false);
 }
 
+uint32_t
+ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
+{
+    // FIXME: Should this be implemented?
+    return 0;
+}
+
 ByteOrder
 ProcessLinux::GetByteOrder() const
 {
Index: source/Plugins/Process/Linux/ProcessLinux.h
===================================================================
--- source/Plugins/Process/Linux/ProcessLinux.h	(revision 141569)
+++ source/Plugins/Process/Linux/ProcessLinux.h	(working copy)
@@ -129,6 +129,10 @@
     virtual uint32_t
     UpdateThreadListIfNeeded();
 
+    uint32_t
+    UpdateThreadList(lldb_private::ThreadList &old_thread_list, 
+                     lldb_private::ThreadList &new_thread_list);
+
     virtual lldb::ByteOrder
     GetByteOrder() const;
 
Index: source/Plugins/Process/Linux/ProcessMonitor.cpp
===================================================================
--- source/Plugins/Process/Linux/ProcessMonitor.cpp	(revision 141569)
+++ source/Plugins/Process/Linux/ProcessMonitor.cpp	(working copy)
@@ -241,7 +241,7 @@
 
     // Set errno to zero so that we can detect a failed peek.
     errno = 0;
-    unsigned long data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL);
+    uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL);
 
     if (data == -1UL && errno)
         m_result = false;
Index: source/lldb.cpp
===================================================================
--- source/lldb.cpp	(revision 141569)
+++ source/lldb.cpp	(working copy)
@@ -94,7 +94,9 @@
         UnwindAssemblyInstEmulation::Initialize();
         UnwindAssembly_x86::Initialize();
         EmulateInstructionARM::Initialize ();
+#if !defined (__linux__)
         ObjectFilePECOFF::Initialize ();
+#endif
 #if defined (__APPLE__)
         //----------------------------------------------------------------------
         // Apple/Darwin hosted plugins
@@ -166,7 +168,9 @@
     UnwindAssembly_x86::Terminate();
     UnwindAssemblyInstEmulation::Terminate();
     EmulateInstructionARM::Terminate ();
+#if !defined (__linux__)
     ObjectFilePECOFF::Terminate ();
+#endif
 
 #if defined (__APPLE__)
     DynamicLoaderMacOSXDYLD::Terminate();


More information about the lldb-commits mailing list