[Lldb-commits] [lldb] r239195 - Fix TestNamespace and TestThreadJump for remote Windows to Android.

Chaoren Lin chaorenl at google.com
Fri Jun 5 15:03:19 PDT 2015


Author: chaoren
Date: Fri Jun  5 17:03:19 2015
New Revision: 239195

URL: http://llvm.org/viewvc/llvm-project?rev=239195&view=rev
Log:
Fix TestNamespace and TestThreadJump for remote Windows to Android.

Summary:
Update DYLDRendezvous and SOEntry to use FileSpecs instead of storing paths as
strings, which caused incorrect comparison results due to denormalization.

Reviewers: clayborg, vharron, ovyalov

Reviewed By: ovyalov

Subscribers: jwolfe, emaste, tberghammer, lldb-commits

Differential Revision: http://reviews.llvm.org/D10267

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

Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp?rev=239195&r1=239194&r2=239195&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp Fri Jun  5 17:03:19 2015
@@ -120,9 +120,10 @@ DYLDRendezvous::DYLDRendezvous(Process *
         Module *exe_mod = m_process->GetTarget().GetExecutableModulePointer();
         if (exe_mod)
         {
-            exe_mod->GetPlatformFileSpec().GetPath(m_exe_path, PATH_MAX);
+            m_exe_file_spec = exe_mod->GetPlatformFileSpec();
             if (log)
-                log->Printf ("DYLDRendezvous::%s exe module executable path set: '%s'", __FUNCTION__, m_exe_path);
+                log->Printf ("DYLDRendezvous::%s exe module executable path set: '%s'",
+                        __FUNCTION__, m_exe_file_spec.GetCString());
         }
         else
         {
@@ -294,13 +295,13 @@ DYLDRendezvous::SOEntryIsMainExecutable(
 
     switch (os_type) {
         case llvm::Triple::FreeBSD:
-            return ::strcmp(entry.path.c_str(), m_exe_path) == 0;
+            return entry.file_spec == m_exe_file_spec;
         case llvm::Triple::Linux:
             switch (env_type) {
                 case llvm::Triple::Android:
-                    return ::strcmp(entry.path.c_str(), m_exe_path) == 0;
+                    return entry.file_spec == m_exe_file_spec;
                 default:
-                    return entry.path.empty();
+                    return !entry.file_spec;
             }
         default:
             return false;
@@ -405,9 +406,9 @@ DYLDRendezvous::ReadSOEntryFromMemory(ll
     
     if (!(addr = ReadPointer(addr, &entry.prev)))
         return false;
-    
-    entry.path = ReadStringFromMemory(entry.path_addr);
-    
+
+    entry.file_spec.SetFile(ReadStringFromMemory(entry.path_addr), false);
+
     return true;
 }
 
@@ -483,7 +484,7 @@ DYLDRendezvous::DumpToLog(Log *log) cons
     
     for (int i = 1; I != E; ++I, ++i) 
     {
-        log->Printf("\n   SOEntry [%d] %s", i, I->path.c_str());
+        log->Printf("\n   SOEntry [%d] %s", i, I->file_spec.GetCString());
         log->Printf("      Base : %" PRIx64, I->base_addr);
         log->Printf("      Path : %" PRIx64, I->path_addr);
         log->Printf("      Dyn  : %" PRIx64, I->dyn_addr);

Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h?rev=239195&r1=239194&r2=239195&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h Fri Jun  5 17:03:19 2015
@@ -18,6 +18,7 @@
 // Other libraries and framework includes
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
+#include "lldb/Host/FileSpec.h"
 
 namespace lldb_private {
 class Process;
@@ -142,18 +143,18 @@ public:
     /// This object is a rough analogue to the struct link_map object which
     /// actually lives in the inferiors memory.
     struct SOEntry {
-        lldb::addr_t link_addr; ///< Address of this link_map.
-        lldb::addr_t base_addr; ///< Base address of the loaded object.
-        lldb::addr_t path_addr; ///< String naming the shared object.
-        lldb::addr_t dyn_addr;  ///< Dynamic section of shared object.
-        lldb::addr_t next;      ///< Address of next so_entry.
-        lldb::addr_t prev;      ///< Address of previous so_entry.
-        std::string  path;      ///< File name of shared object.
+        lldb::addr_t link_addr;           ///< Address of this link_map.
+        lldb::addr_t base_addr;           ///< Base address of the loaded object.
+        lldb::addr_t path_addr;           ///< String naming the shared object.
+        lldb::addr_t dyn_addr;            ///< Dynamic section of shared object.
+        lldb::addr_t next;                ///< Address of next so_entry.
+        lldb::addr_t prev;                ///< Address of previous so_entry.
+        lldb_private::FileSpec file_spec; ///< File spec of shared object.
 
         SOEntry() { clear(); }
 
         bool operator ==(const SOEntry &entry) {
-            return this->path == entry.path;
+            return file_spec == entry.file_spec;
         }
 
         void clear() {
@@ -163,7 +164,7 @@ public:
             dyn_addr  = 0;
             next = 0;
             prev = 0;
-            path.clear();
+            file_spec.Clear();
         }
     };
 
@@ -190,8 +191,8 @@ public:
 protected:
     lldb_private::Process *m_process;
 
-    // Cached copy of executable pathname
-    char m_exe_path[PATH_MAX];
+    // Cached copy of executable file spec
+    lldb_private::FileSpec m_exe_file_spec;
 
     /// Location of the r_debug structure in the inferiors address space.
     lldb::addr_t m_rendezvous_addr;

Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=239195&r1=239194&r2=239195&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Fri Jun  5 17:03:19 2015
@@ -414,8 +414,7 @@ DynamicLoaderPOSIXDYLD::RefreshModules()
         E = m_rendezvous.loaded_end();
         for (I = m_rendezvous.loaded_begin(); I != E; ++I)
         {
-            FileSpec file(I->path.c_str(), true);
-            ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr);
+            ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr);
             if (module_sp.get())
             {
                 loaded_modules.AppendIfNeeded(module_sp);
@@ -432,9 +431,8 @@ DynamicLoaderPOSIXDYLD::RefreshModules()
         E = m_rendezvous.unloaded_end();
         for (I = m_rendezvous.unloaded_begin(); I != E; ++I)
         {
-            FileSpec file(I->path.c_str(), true);
-            ModuleSpec module_spec (file);
-            ModuleSP module_sp = 
+            ModuleSpec module_spec{I->file_spec};
+            ModuleSP module_sp =
                 loaded_modules.FindFirstModule (module_spec);
 
             if (module_sp.get())
@@ -525,9 +523,7 @@ DynamicLoaderPOSIXDYLD::LoadAllCurrentMo
 
     for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I)
     {
-        const char *module_path = I->path.c_str();
-        FileSpec file(module_path, false);
-        ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr);
+        ModuleSP module_sp = LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr);
         if (module_sp.get())
         {
             module_list.Append(module_sp);
@@ -537,7 +533,7 @@ DynamicLoaderPOSIXDYLD::LoadAllCurrentMo
             Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
             if (log)
                 log->Printf("DynamicLoaderPOSIXDYLD::%s failed loading module %s at 0x%" PRIx64,
-                            __FUNCTION__, module_path, I->base_addr);
+                            __FUNCTION__, I->file_spec.GetCString(), I->base_addr);
         }
     }
 





More information about the lldb-commits mailing list