[Lldb-commits] [PATCH] Use basename of main executable in POSIX-DYLD on Android.

Stephane Sezer sas at fb.com
Tue Feb 3 14:50:17 PST 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7188

Files:
  lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h

Index: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
===================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -19,6 +19,8 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
+#include "llvm/Support/Path.h"
+
 #include "DYLDRendezvous.h"
 
 using namespace lldb;
@@ -238,9 +240,7 @@
             return false;
 
         // Only add shared libraries and not the executable.
-        // On Linux this is indicated by an empty path in the entry.
-        // On FreeBSD it is the name of the executable.
-        if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0)
+        if (SOEntryIsMainExecutable(entry))
             continue;
 
         pos = std::find(m_soentries.begin(), m_soentries.end(), entry);
@@ -277,6 +277,28 @@
 }
 
 bool
+DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry)
+{
+    // On Linux the executable is indicated by an empty path in the entry. On
+    // FreeBSD it is the full path to the executable. On Android, it is the
+    // basename of the executable.
+
+    auto triple = m_process->GetTarget().GetArchitecture().GetTriple();
+    auto os_type = triple.getOS();
+    auto env_type = triple.getEnvironment();
+
+    switch (os_type) {
+        case llvm::Triple::FreeBSD:
+            return ::strcmp(entry.path.c_str(), m_exe_path) == 0;
+        case llvm::Triple::Linux:
+            return entry.path.empty() || (env_type == llvm::Triple::Android &&
+                   llvm::sys::path::filename(m_exe_path) == entry.path);
+        default:
+            return false;
+    }
+}
+
+bool
 DYLDRendezvous::TakeSnapshot(SOEntryList &entry_list)
 {
     SOEntry entry;
@@ -290,9 +312,7 @@
             return false;
 
         // Only add shared libraries and not the executable.
-        // On Linux this is indicated by an empty path in the entry.
-        // On FreeBSD it is the name of the executable.
-        if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0)
+        if (SOEntryIsMainExecutable(entry))
             continue;
 
         entry_list.push_back(entry);
Index: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
===================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
@@ -247,6 +247,9 @@
     bool
     UpdateSOEntriesForDeletion();
 
+    bool
+    SOEntryIsMainExecutable(const SOEntry &entry);
+
     /// Reads the current list of shared objects according to the link map
     /// supplied by the runtime linker.
     bool

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7188.19276.patch
Type: text/x-patch
Size: 2811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150203/d40cde62/attachment.bin>


More information about the lldb-commits mailing list