From 55c1c3495d5458f863d453b771d471515b0831a4 Mon Sep 17 00:00:00 2001 From: Chaoren Lin Date: Fri, 5 Jun 2015 22:03:19 +0000 Subject: [PATCH] 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 llvm-svn: 239195 --- .../DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp | 19 +++++++++--------- .../DynamicLoader/POSIX-DYLD/DYLDRendezvous.h | 23 +++++++++++----------- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 14 +++++-------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp index 0be39b1..93b559f 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp @@ -120,9 +120,10 @@ DYLDRendezvous::DYLDRendezvous(Process *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(const SOEntry &entry) 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(lldb::addr_t addr, SOEntry &entry) 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) const 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); diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h index 51fcd9b..ec5af94 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h @@ -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; diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 319c89b..6330b42 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -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::LoadAllCurrentModules() 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::LoadAllCurrentModules() 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); } } -- 2.7.4