int Section::Compare (const Section& a, const Section& b) { if (&a == &b) return 0; const ModuleSP a_module_sp = a.GetModule(); const ModuleSP b_module_sp = b.GetModule(); if (a_module_sp == b_module_sp) { user_id_t a_sect_uid = a.GetID(); user_id_t b_sect_uid = b.GetID(); if (a_sect_uid < b_sect_uid) return -1; if (a_sect_uid > b_sect_uid) return 1; return 0; } else { // The modules are different, just compare the module pointers if (a_module_sp.get() < b_module_sp.get()) return -1; else return 1; // We already know the modules aren't equal } }
Error PlatformDarwinKernel::GetSharedModule (const ModuleSpec &module_spec, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { Error error; module_sp.reset(); const FileSpec &platform_file = module_spec.GetFileSpec(); // Treat the file's path as a kext bundle ID (e.g. "com.apple.driver.AppleIRController") and search our kext index. std::string kext_bundle_id = platform_file.GetPath(); if (!kext_bundle_id.empty()) { ConstString kext_bundle_cs(kext_bundle_id.c_str()); if (m_name_to_kext_path_map.count(kext_bundle_cs) > 0) { for (BundleIDToKextIterator it = m_name_to_kext_path_map.begin (); it != m_name_to_kext_path_map.end (); ++it) { if (it->first == kext_bundle_cs) { error = ExamineKextForMatchingUUID (it->second, module_spec.GetUUID(), module_spec.GetArchitecture(), module_sp); if (module_sp.get()) { return error; } } } } } // Else fall back to treating the file's path as an actual file path - defer to PlatformDarwin's GetSharedModule. return PlatformDarwin::GetSharedModule (module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr); }
ModuleSP DynamicLoader::GetTargetExecutable() { Target &target = m_process->GetTarget(); ModuleSP executable = target.GetExecutableModule(); if (executable) { if (FileSystem::Instance().Exists(executable->GetFileSpec())) { ModuleSpec module_spec(executable->GetFileSpec(), executable->GetArchitecture()); auto module_sp = std::make_shared<Module>(module_spec); // Check if the executable has changed and set it to the target // executable if they differ. if (module_sp && module_sp->GetUUID().IsValid() && executable->GetUUID().IsValid()) { if (module_sp->GetUUID() != executable->GetUUID()) executable.reset(); } else if (executable->FileHasChanged()) { executable.reset(); } if (!executable) { executable = target.GetOrCreateModule(module_spec, true /* notify */); if (executable.get() != target.GetExecutableModulePointer()) { // Don't load dependent images since we are in dyld where we will // know and find out about all images that are loaded target.SetExecutableModule(executable, eLoadDependentsNo); } } } } return executable; }
void DynamicLoaderPOSIXDYLD::DidLaunch() { Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); if (log) log->Printf ("DynamicLoaderPOSIXDYLD::%s()", __FUNCTION__); ModuleSP executable; addr_t load_offset; m_auxv.reset(new AuxVector(m_process)); executable = GetTargetExecutable(); load_offset = ComputeLoadOffset(); if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) { ModuleList module_list; module_list.Append(executable); UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset); if (log) log->Printf ("DynamicLoaderPOSIXDYLD::%s about to call ProbeEntry()", __FUNCTION__); ProbeEntry(); m_process->GetTarget().ModulesDidLoad(module_list); } }
// Find the load address of a symbol static lldb::addr_t findSymbolAddress( Process *proc, ConstString findName ) { assert( proc != nullptr ); ModuleSP module = proc->GetTarget().GetExecutableModule(); assert( module.get() != nullptr ); ObjectFile *exe = module->GetObjectFile(); assert( exe != nullptr ); lldb_private::Symtab *symtab = exe->GetSymtab( ); assert( symtab != nullptr ); for ( size_t i = 0; i < symtab->GetNumSymbols( ); i++ ) { const Symbol* sym = symtab->SymbolAtIndex( i ); assert( sym != nullptr ); const ConstString &symName = sym->GetName( ); if ( ConstString::Compare( findName, symName ) == 0 ) { Address addr = sym->GetAddress(); return addr.GetLoadAddress( & proc->GetTarget() ); } } return LLDB_INVALID_ADDRESS; }
Error PlatformDarwinKernel::GetSharedModule (const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { Error error; module_sp.reset(); const FileSpec &platform_file = module_spec.GetFileSpec(); // Treat the file's path as a kext bundle ID (e.g. "com.apple.driver.AppleIRController") and search our kext index. std::string kext_bundle_id = platform_file.GetPath(); if (!kext_bundle_id.empty()) { ConstString kext_bundle_cs(kext_bundle_id.c_str()); if (m_name_to_kext_path_map.count(kext_bundle_cs) > 0) { for (BundleIDToKextIterator it = m_name_to_kext_path_map.begin (); it != m_name_to_kext_path_map.end (); ++it) { if (it->first == kext_bundle_cs) { error = ExamineKextForMatchingUUID (it->second, module_spec.GetUUID(), module_spec.GetArchitecture(), module_sp); if (module_sp.get()) { return error; } } } } } if (kext_bundle_id.compare("mach_kernel") == 0 && module_spec.GetUUID().IsValid()) { for (auto possible_kernel : m_kernel_binaries) { if (possible_kernel.Exists()) { ModuleSpec kern_spec (possible_kernel); kern_spec.GetUUID() = module_spec.GetUUID(); ModuleSP module_sp (new Module (kern_spec)); if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (kern_spec)) { Error error; error = ModuleList::GetSharedModule (kern_spec, module_sp, NULL, NULL, NULL); if (module_sp && module_sp->GetObjectFile()) { return error; } } } } } // Else fall back to treating the file's path as an actual file path - defer to PlatformDarwin's GetSharedModule. return PlatformDarwin::GetSharedModule (module_spec, process, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr); }
/// Checks to see if the target module has changed, updates the target /// accordingly and returns the target executable module. ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() { Target &target = m_process->GetTarget(); ModuleSP executable = target.GetExecutableModule(); // There is no executable if (! executable.get()) return executable; // The target executable file does not exits if (! executable->GetFileSpec().Exists()) return executable; // Prep module for loading ModuleSpec module_spec(executable->GetFileSpec(), executable->GetArchitecture()); ModuleSP module_sp (new Module (module_spec)); // Check if the executable has changed and set it to the target executable if they differ. if (module_sp.get() && module_sp->GetUUID().IsValid() && executable->GetUUID().IsValid()) { // if the executable has changed ?? if (module_sp->GetUUID() != executable->GetUUID()) executable.reset(); } else if (executable->FileHasChanged()) executable.reset(); if ( executable.get( ) ) return executable; // TODO: What case is this code used? executable = target.GetSharedModule(module_spec); if (executable.get() != target.GetExecutableModulePointer()) { // Don't load dependent images since we are in dyld where we will know // and find out about all images that are loaded const bool get_dependent_images = false; target.SetExecutableModule(executable, get_dependent_images); } return executable; }
void DynamicLoaderHexagonDYLD::DidAttach() { ModuleSP executable; addr_t load_offset; executable = GetTargetExecutable(); // Find the difference between the desired load address in the elf file // and the real load address in memory load_offset = ComputeLoadOffset(); // Check that there is a valid executable if ( executable.get( ) == nullptr ) return; // Disable JIT for hexagon targets because its not supported m_process->SetCanJIT(false); // Enable Interpreting of function call expressions m_process->SetCanInterpretFunctionCalls(true); // Add the current executable to the module list ModuleList module_list; module_list.Append(executable); // Map the loaded sections of this executable if ( load_offset != LLDB_INVALID_ADDRESS ) UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_offset, true); // AD: confirm this? // Load into LLDB all of the currently loaded executables in the stub LoadAllCurrentModules(); // AD: confirm this? // Callback for the target to give it the loaded module list m_process->GetTarget().ModulesDidLoad(module_list); // Try to set a breakpoint at the rendezvous breakpoint. // DidLaunch uses ProbeEntry() instead. That sets a breakpoint, // at the dyld breakpoint address, with a callback so that when hit, // the dyld structure can be parsed. if (! SetRendezvousBreakpoint() ) { // fail } }
bool ModuleList::AppendIfNeeded (const ModuleSP &module_sp) { if (module_sp) { Mutex::Locker locker(m_modules_mutex); collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { if (pos->get() == module_sp.get()) return false; // Already in the list } // Only push module_sp on the list if it wasn't already in there. Append(module_sp); return true; } return false; }
bool ModuleList::Remove (const ModuleSP &module_sp) { if (module_sp) { Mutex::Locker locker(m_modules_mutex); collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { if (pos->get() == module_sp.get()) { m_modules.erase (pos); return true; } } } return false; }
void DynamicLoaderPOSIXDYLD::DidLaunch() { ModuleSP executable; addr_t load_offset; m_auxv.reset(new AuxVector(m_process)); executable = GetTargetExecutable(); load_offset = ComputeLoadOffset(); if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) { ModuleList module_list; module_list.Append(executable); UpdateLoadedSections(executable, load_offset); ProbeEntry(); m_process->GetTarget().ModulesDidLoad(module_list); } }
bool ModuleList::RemoveImpl (const ModuleSP &module_sp, bool use_notifier) { if (module_sp) { Mutex::Locker locker(m_modules_mutex); collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { if (pos->get() == module_sp.get()) { m_modules.erase (pos); if (use_notifier && m_notifier) m_notifier->ModuleRemoved(*this, module_sp); return true; } } } return false; }
static void ModuleSharedPtrLogger(void* p, const ModuleSP& sp, bool will_decrement) { if (sp.get()) { const char *module_basename = sp->GetFileSpec().GetFilename().GetCString(); // If "p" is set, then it is the basename of a module to watch for. This // basename MUST be uniqued first by getting it from a ConstString or this // won't work. if (p && p != module_basename) { return; } long use_count = sp.use_count(); if (will_decrement) --use_count; printf("\nModuleSP(%p): %c %p {%lu} %s/%s\n", &sp, will_decrement ? '-' : '+', sp.get(), use_count, sp->GetFileSpec().GetDirectory().GetCString(), module_basename); StreamFile stdout_strm(stdout, false); Host::Backtrace (stdout_strm, 512); } }
Error ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr, bool always_create) { ModuleList &shared_module_list = GetSharedModuleList (); Mutex::Locker locker(shared_module_list.m_modules_mutex); char path[PATH_MAX]; Error error; module_sp.reset(); if (did_create_ptr) *did_create_ptr = false; if (old_module_sp_ptr) old_module_sp_ptr->reset(); const UUID *uuid_ptr = module_spec.GetUUIDPtr(); const FileSpec &module_file_spec = module_spec.GetFileSpec(); const ArchSpec &arch = module_spec.GetArchitecture(); // Make sure no one else can try and get or create a module while this // function is actively working on it by doing an extra lock on the // global mutex list. if (!always_create) { ModuleList matching_module_list; const size_t num_matching_modules = shared_module_list.FindModules (module_spec, matching_module_list); if (num_matching_modules > 0) { for (size_t module_idx = 0; module_idx < num_matching_modules; ++module_idx) { module_sp = matching_module_list.GetModuleAtIndex(module_idx); // Make sure the file for the module hasn't been modified if (module_sp->FileHasChanged()) { if (old_module_sp_ptr && !*old_module_sp_ptr) *old_module_sp_ptr = module_sp; Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_MODULES)); if (log != nullptr) log->Printf("module changed: %p, removing from global module list", static_cast<void*>(module_sp.get())); shared_module_list.Remove (module_sp); module_sp.reset(); } else { // The module matches and the module was not modified from // when it was last loaded. return error; } } } } if (module_sp) return error; module_sp.reset (new Module (module_spec)); // Make sure there are a module and an object file since we can specify // a valid file path with an architecture that might not be in that file. // By getting the object file we can guarantee that the architecture matches if (module_sp->GetObjectFile()) { // If we get in here we got the correct arch, now we just need // to verify the UUID if one was given if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) { module_sp.reset(); } else { if (module_sp->GetObjectFile() && module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary) { module_sp.reset(); } else { if (did_create_ptr) { *did_create_ptr = true; } shared_module_list.ReplaceEquivalent(module_sp); return error; } } } else { module_sp.reset(); } if (module_search_paths_ptr) { const auto num_directories = module_search_paths_ptr->GetSize(); for (size_t idx = 0; idx < num_directories; ++idx) { auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx); if (!search_path_spec.ResolvePath()) continue; if (!search_path_spec.Exists() || !search_path_spec.IsDirectory()) continue; search_path_spec.AppendPathComponent(module_spec.GetFileSpec().GetFilename().AsCString()); if (!search_path_spec.Exists()) continue; auto resolved_module_spec(module_spec); resolved_module_spec.GetFileSpec() = search_path_spec; module_sp.reset (new Module (resolved_module_spec)); if (module_sp->GetObjectFile()) { // If we get in here we got the correct arch, now we just need // to verify the UUID if one was given if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) { module_sp.reset(); } else { if (module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary) { module_sp.reset(); } else { if (did_create_ptr) *did_create_ptr = true; shared_module_list.ReplaceEquivalent(module_sp); return Error(); } } } else { module_sp.reset(); } } } // Either the file didn't exist where at the path, or no path was given, so // we now have to use more extreme measures to try and find the appropriate // module. // Fixup the incoming path in case the path points to a valid file, yet // the arch or UUID (if one was passed in) don't match. ModuleSpec located_binary_modulespec = Symbols::LocateExecutableObjectFile (module_spec); // Don't look for the file if it appears to be the same one we already // checked for above... if (located_binary_modulespec.GetFileSpec() != module_file_spec) { if (!located_binary_modulespec.GetFileSpec().Exists()) { located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path)); if (path[0] == '\0') module_file_spec.GetPath(path, sizeof(path)); // How can this check ever be true? This branch it is false, and we haven't modified file_spec. if (located_binary_modulespec.GetFileSpec().Exists()) { std::string uuid_str; if (uuid_ptr && uuid_ptr->IsValid()) uuid_str = uuid_ptr->GetAsString(); if (arch.IsValid()) { if (!uuid_str.empty()) error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_str.c_str()); else error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.", path, arch.GetArchitectureName()); } } else { error.SetErrorStringWithFormat("'%s' does not exist", path); } if (error.Fail()) module_sp.reset(); return error; } // Make sure no one else can try and get or create a module while this // function is actively working on it by doing an extra lock on the // global mutex list. ModuleSpec platform_module_spec(module_spec); platform_module_spec.GetFileSpec() = located_binary_modulespec.GetFileSpec(); platform_module_spec.GetPlatformFileSpec() = located_binary_modulespec.GetFileSpec(); platform_module_spec.GetSymbolFileSpec() = located_binary_modulespec.GetSymbolFileSpec(); ModuleList matching_module_list; if (shared_module_list.FindModules (platform_module_spec, matching_module_list) > 0) { module_sp = matching_module_list.GetModuleAtIndex(0); // If we didn't have a UUID in mind when looking for the object file, // then we should make sure the modification time hasn't changed! if (platform_module_spec.GetUUIDPtr() == nullptr) { TimeValue file_spec_mod_time(located_binary_modulespec.GetFileSpec().GetModificationTime()); if (file_spec_mod_time.IsValid()) { if (file_spec_mod_time != module_sp->GetModificationTime()) { if (old_module_sp_ptr) *old_module_sp_ptr = module_sp; shared_module_list.Remove (module_sp); module_sp.reset(); } } } } if (!module_sp) { module_sp.reset (new Module (platform_module_spec)); // Make sure there are a module and an object file since we can specify // a valid file path with an architecture that might not be in that file. // By getting the object file we can guarantee that the architecture matches if (module_sp && module_sp->GetObjectFile()) { if (module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary) { module_sp.reset(); } else { if (did_create_ptr) *did_create_ptr = true; shared_module_list.ReplaceEquivalent(module_sp); } } else { located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path)); if (located_binary_modulespec.GetFileSpec()) { if (arch.IsValid()) error.SetErrorStringWithFormat("unable to open %s architecture in '%s'", arch.GetArchitectureName(), path); else error.SetErrorStringWithFormat("unable to open '%s'", path); } else { std::string uuid_str; if (uuid_ptr && uuid_ptr->IsValid()) uuid_str = uuid_ptr->GetAsString(); if (!uuid_str.empty()) error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_str.c_str()); else error.SetErrorStringWithFormat("cannot locate a module"); } } } } return error; }
void Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) { m_images.Clear(); m_scratch_ast_context_ap.reset(); if (executable_sp.get()) { Timer scoped_timer (__PRETTY_FUNCTION__, "Target::SetExecutableModule (executable = '%s/%s')", executable_sp->GetFileSpec().GetDirectory().AsCString(), executable_sp->GetFileSpec().GetFilename().AsCString()); m_images.Append(executable_sp); // The first image is our exectuable file ArchSpec exe_arch = executable_sp->GetArchitecture(); // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module. if (!m_arch_spec.IsValid()) m_arch_spec = exe_arch; FileSpecList dependent_files; ObjectFile * executable_objfile = executable_sp->GetObjectFile(); if (executable_objfile == NULL) { FileSpec bundle_executable(executable_sp->GetFileSpec()); if (Host::ResolveExecutableInBundle (bundle_executable)) { ModuleSP bundle_exe_module_sp(GetSharedModule(bundle_executable, exe_arch)); SetExecutableModule (bundle_exe_module_sp, get_dependent_files); if (bundle_exe_module_sp->GetObjectFile() != NULL) executable_sp = bundle_exe_module_sp; return; } } if (executable_objfile) { executable_objfile->GetDependentModules(dependent_files); for (uint32_t i=0; i<dependent_files.GetSize(); i++) { ModuleSP image_module_sp(GetSharedModule(dependent_files.GetFileSpecPointerAtIndex(i), exe_arch)); if (image_module_sp.get()) { //image_module_sp->Dump(&s);// REMOVE THIS, DEBUG ONLY ObjectFile *objfile = image_module_sp->GetObjectFile(); if (objfile) objfile->GetDependentModules(dependent_files); } } } // Now see if we know the target triple, and if so, create our scratch AST context: if (m_arch_spec.IsValid()) { m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch_spec.GetTriple().str().c_str())); } } UpdateInstanceName(); }
Error ModuleList::GetSharedModule ( const FileSpec& in_file_spec, const ArchSpec& arch, const lldb_private::UUID *uuid_ptr, const ConstString *object_name_ptr, off_t object_offset, ModuleSP &module_sp, ModuleSP *old_module_sp_ptr, bool *did_create_ptr, bool always_create ) { ModuleList &shared_module_list = GetSharedModuleList (); Mutex::Locker locker(shared_module_list.m_modules_mutex); char path[PATH_MAX]; char uuid_cstr[64]; Error error; module_sp.reset(); if (did_create_ptr) *did_create_ptr = false; if (old_module_sp_ptr) old_module_sp_ptr->reset(); // First just try and get the file where it purports to be (path in // in_file_spec), then check and uuid. if (in_file_spec) { // Make sure no one else can try and get or create a module while this // function is actively working on it by doing an extra lock on the // global mutex list. if (always_create == false) { ModuleList matching_module_list; const size_t num_matching_modules = shared_module_list.FindModules (&in_file_spec, &arch, NULL, object_name_ptr, matching_module_list); if (num_matching_modules > 0) { for (uint32_t module_idx = 0; module_idx < num_matching_modules; ++module_idx) { module_sp = matching_module_list.GetModuleAtIndex(module_idx); if (uuid_ptr && uuid_ptr->IsValid()) { // We found the module we were looking for. if (module_sp->GetUUID() == *uuid_ptr) return error; } else { // If we didn't have a UUID in mind when looking for the object file, // then we should make sure the modification time hasn't changed! TimeValue file_spec_mod_time(in_file_spec.GetModificationTime()); if (file_spec_mod_time.IsValid()) { if (file_spec_mod_time == module_sp->GetModificationTime()) return error; } } if (old_module_sp_ptr && !old_module_sp_ptr->get()) *old_module_sp_ptr = module_sp; shared_module_list.Remove (module_sp); module_sp.reset(); } } } if (module_sp) return error; else { #if defined ENABLE_MODULE_SP_LOGGING ModuleSP logging_module_sp (new Module (in_file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, (void *)ConstString("a.out").GetCString()); module_sp = logging_module_sp; #else module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset)); #endif // Make sure there are a module and an object file since we can specify // a valid file path with an architecture that might not be in that file. // By getting the object file we can guarantee that the architecture matches if (module_sp && module_sp->GetObjectFile()) { // If we get in here we got the correct arch, now we just need // to verify the UUID if one was given if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) module_sp.reset(); else { if (did_create_ptr) *did_create_ptr = true; shared_module_list.Append(module_sp); return error; } } } } // Either the file didn't exist where at the path, or no path was given, so // we now have to use more extreme measures to try and find the appropriate // module. // Fixup the incoming path in case the path points to a valid file, yet // the arch or UUID (if one was passed in) don't match. FileSpec file_spec = Symbols::LocateExecutableObjectFile (in_file_spec ? &in_file_spec : NULL, arch.IsValid() ? &arch : NULL, uuid_ptr); // Don't look for the file if it appears to be the same one we already // checked for above... if (file_spec != in_file_spec) { if (!file_spec.Exists()) { file_spec.GetPath(path, sizeof(path)); if (file_spec.Exists()) { if (uuid_ptr && uuid_ptr->IsValid()) uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr)); else uuid_cstr[0] = '\0'; if (arch.IsValid()) { if (uuid_cstr[0]) error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_cstr); else error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.", path, arch.GetArchitectureName()); } } else { error.SetErrorStringWithFormat("'%s' does not exist", path); } return error; } // Make sure no one else can try and get or create a module while this // function is actively working on it by doing an extra lock on the // global mutex list. ModuleList matching_module_list; if (shared_module_list.FindModules (&file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list) > 0) { module_sp = matching_module_list.GetModuleAtIndex(0); // If we didn't have a UUID in mind when looking for the object file, // then we should make sure the modification time hasn't changed! if (uuid_ptr == NULL) { TimeValue file_spec_mod_time(file_spec.GetModificationTime()); if (file_spec_mod_time.IsValid()) { if (file_spec_mod_time != module_sp->GetModificationTime()) { if (old_module_sp_ptr) *old_module_sp_ptr = module_sp; shared_module_list.Remove (module_sp); module_sp.reset(); } } } } if (module_sp.get() == NULL) { #if defined ENABLE_MODULE_SP_LOGGING ModuleSP logging_module_sp (new Module (file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, 0); module_sp = logging_module_sp; #else module_sp.reset (new Module (file_spec, arch, object_name_ptr, object_offset)); #endif // Make sure there are a module and an object file since we can specify // a valid file path with an architecture that might not be in that file. // By getting the object file we can guarantee that the architecture matches if (module_sp && module_sp->GetObjectFile()) { if (did_create_ptr) *did_create_ptr = true; shared_module_list.Append(module_sp); } else { file_spec.GetPath(path, sizeof(path)); if (file_spec) { if (arch.IsValid()) error.SetErrorStringWithFormat("unable to open %s architecture in '%s'", arch.GetArchitectureName(), path); else error.SetErrorStringWithFormat("unable to open '%s'", path); } else { if (uuid_ptr && uuid_ptr->IsValid()) uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr)); else uuid_cstr[0] = '\0'; if (uuid_cstr[0]) error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_cstr); else error.SetErrorStringWithFormat("cannot locate a module"); } } } } return error; }