@@ -251,19 +251,42 @@ void ModuleList::Append(const ModuleSP &module_sp, bool notify) {
251251void ModuleList::ReplaceEquivalent (
252252 const ModuleSP &module_sp,
253253 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules) {
254+ Log *log (GetLog (LLDBLog::Object | LLDBLog::Modules));
255+ LLDB_LOGF (log," ReplaceEquivalent module_sp %s" ,module_sp->GetObjectName ().AsCString ());
254256 if (module_sp) {
255257 std::lock_guard<std::recursive_mutex> guard (m_modules_mutex);
256258
259+ // llvm::SmallString<256> path_with_object;
260+
261+ LLDB_LOGF (log," Before ReplaceEquivalent module_sp dis %s" ,module_sp->GetFileSpec ().GetPath ().c_str ());
262+
263+ llvm::SmallString<128 > path;
264+ module_sp->GetFileSpec ().GetPath (path);
265+ llvm::SmallString<128 > obj_name ;
266+ obj_name = module_sp->GetObjectName ().AsCString ();
267+
268+ llvm::SmallString<256 > full_path;
269+ full_path = llvm::Twine (path + llvm::Twine (" (" ) + llvm::Twine (obj_name) + llvm::Twine (" )" )).str ();
270+ // std::string full_path = module_sp->GetFileSpec().GetPath().c_str() + "("
271+ // + module_sp->GetObjectName().AsCString() + ")";
272+
273+ // module_sp->GetFileSpec().SetPath(full_path);
274+
275+
276+ LLDB_LOGF (log," After ReplaceEquivalent module_sp dis %s" ,module_sp->GetFileSpec ().GetPath ().c_str ());
257277 // First remove any equivalent modules. Equivalent modules are modules
258278 // whose path, platform path and architecture match.
259279 ModuleSpec equivalent_module_spec (module_sp->GetFileSpec (),
260280 module_sp->GetArchitecture ());
281+ LLDB_LOGF (log," ReplaceEquivalent equivalent.module_sp %s" ,equivalent_module_spec.GetObjectName ().AsCString ());
261282 equivalent_module_spec.GetPlatformFileSpec () =
262283 module_sp->GetPlatformFileSpec ();
263284
264285 size_t idx = 0 ;
265286 while (idx < m_modules.size ()) {
287+ LLDB_LOGF (log," ReplaceEquivalent index : %d" ,idx);
266288 ModuleSP test_module_sp (m_modules[idx]);
289+ LLDB_LOGF (log," ReplaceEquivalent test_module_sp : %s" ,test_module_sp->GetObjectName ().AsCString ());
267290 if (test_module_sp->MatchesModuleSpec (equivalent_module_spec)) {
268291 if (old_modules)
269292 old_modules->push_back (test_module_sp);
@@ -795,6 +818,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
795818 shared_module_list.m_modules_mutex );
796819 char path[PATH_MAX];
797820
821+ Log *log = GetLog (LLDBLog::Modules);
798822 Status error;
799823
800824 module_sp.reset ();
@@ -810,21 +834,22 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
810834 // function is actively working on it by doing an extra lock on the global
811835 // mutex list.
812836 if (!always_create) {
837+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
813838 ModuleList matching_module_list;
814839 shared_module_list.FindModules (module_spec, matching_module_list);
815840 const size_t num_matching_modules = matching_module_list.GetSize ();
816841
842+ LLDB_LOGF (log," GetSharedModule %d %d" ,__LINE__,num_matching_modules);
817843 if (num_matching_modules > 0 ) {
818844 for (size_t module_idx = 0 ; module_idx < num_matching_modules;
819845 ++module_idx) {
820846 module_sp = matching_module_list.GetModuleAtIndex (module_idx);
821847
822848 // Make sure the file for the module hasn't been modified
823849 if (module_sp->FileHasChanged ()) {
824- if (old_modules)
850+ if (old_modules)
825851 old_modules->push_back (module_sp);
826-
827- Log *log = GetLog (LLDBLog::Modules);
852+
828853 if (log != nullptr )
829854 LLDB_LOGF (
830855 log, " %p '%s' module changed: removing from global module list" ,
@@ -850,9 +875,11 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
850875 // valid file path with an architecture that might not be in that file. By
851876 // getting the object file we can guarantee that the architecture matches
852877 if (module_sp->GetObjectFile ()) {
878+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
853879 // If we get in here we got the correct arch, now we just need to verify
854880 // the UUID if one was given
855881 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID ()) {
882+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
856883 module_sp.reset ();
857884 } else {
858885 if (module_sp->GetObjectFile () &&
@@ -863,7 +890,10 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
863890 if (did_create_ptr) {
864891 *did_create_ptr = true ;
865892 }
866-
893+ if (module_sp)
894+ LLDB_LOGF (log," module File Name: %s" ,module_sp->GetFileSpec ().GetFilename ().AsCString ());
895+ if (old_modules)
896+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
867897 shared_module_list.ReplaceEquivalent (module_sp, old_modules);
868898 return error;
869899 }
@@ -901,6 +931,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
901931 if (did_create_ptr)
902932 *did_create_ptr = true ;
903933
934+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
904935 shared_module_list.ReplaceEquivalent (module_sp, old_modules);
905936 return Status ();
906937 }
@@ -969,13 +1000,15 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
9691000 if (!matching_module_list.IsEmpty ()) {
9701001 module_sp = matching_module_list.GetModuleAtIndex (0 );
9711002
1003+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
9721004 // If we didn't have a UUID in mind when looking for the object file,
9731005 // then we should make sure the modification time hasn't changed!
9741006 if (platform_module_spec.GetUUIDPtr () == nullptr ) {
9751007 auto file_spec_mod_time = FileSystem::Instance ().GetModificationTime (
9761008 located_binary_modulespec.GetFileSpec ());
9771009 if (file_spec_mod_time != llvm::sys::TimePoint<>()) {
9781010 if (file_spec_mod_time != module_sp->GetModificationTime ()) {
1011+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
9791012 if (old_modules)
9801013 old_modules->push_back (module_sp);
9811014 shared_module_list.Remove (module_sp);
@@ -986,6 +1019,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
9861019 }
9871020
9881021 if (!module_sp) {
1022+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
9891023 module_sp = std::make_shared<Module>(platform_module_spec);
9901024 // Make sure there are a module and an object file since we can specify a
9911025 // valid file path with an architecture that might not be in that file.
@@ -999,6 +1033,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
9991033 if (did_create_ptr)
10001034 *did_create_ptr = true ;
10011035
1036+ LLDB_LOGF (log," GetSharedModule %d" ,__LINE__);
10021037 shared_module_list.ReplaceEquivalent (module_sp, old_modules);
10031038 }
10041039 } else {
0 commit comments