1 //===-- ModuleList.cpp ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/ModuleList.h"
14 // Other libraries and framework includes
16 #include "lldb/Core/Log.h"
17 #include "lldb/Core/Module.h"
18 #include "lldb/Core/ModuleSpec.h"
19 #include "lldb/Host/Host.h"
20 #include "lldb/Host/Symbols.h"
21 #include "lldb/Symbol/ClangNamespaceDecl.h"
22 #include "lldb/Symbol/ObjectFile.h"
23 #include "lldb/Symbol/VariableList.h"
26 using namespace lldb_private;
28 //----------------------------------------------------------------------
29 // ModuleList constructor
30 //----------------------------------------------------------------------
31 ModuleList::ModuleList() :
33 m_modules_mutex (Mutex::eMutexTypeRecursive),
38 //----------------------------------------------------------------------
40 //----------------------------------------------------------------------
41 ModuleList::ModuleList(const ModuleList& rhs) :
43 m_modules_mutex (Mutex::eMutexTypeRecursive)
45 Mutex::Locker lhs_locker(m_modules_mutex);
46 Mutex::Locker rhs_locker(rhs.m_modules_mutex);
47 m_modules = rhs.m_modules;
50 ModuleList::ModuleList (ModuleList::Notifier* notifier) :
52 m_modules_mutex (Mutex::eMutexTypeRecursive),
57 //----------------------------------------------------------------------
58 // Assignment operator
59 //----------------------------------------------------------------------
61 ModuleList::operator= (const ModuleList& rhs)
65 Mutex::Locker lhs_locker(m_modules_mutex);
66 Mutex::Locker rhs_locker(rhs.m_modules_mutex);
67 m_modules = rhs.m_modules;
72 //----------------------------------------------------------------------
74 //----------------------------------------------------------------------
75 ModuleList::~ModuleList()
80 ModuleList::AppendImpl (const ModuleSP &module_sp, bool use_notifier)
84 Mutex::Locker locker(m_modules_mutex);
85 m_modules.push_back(module_sp);
86 if (use_notifier && m_notifier)
87 m_notifier->ModuleAdded(*this, module_sp);
92 ModuleList::Append (const ModuleSP &module_sp)
94 AppendImpl (module_sp);
98 ModuleList::ReplaceEquivalent (const ModuleSP &module_sp)
102 Mutex::Locker locker(m_modules_mutex);
104 // First remove any equivalent modules. Equivalent modules are modules
105 // whose path, platform path and architecture match.
106 ModuleSpec equivalent_module_spec (module_sp->GetFileSpec(), module_sp->GetArchitecture());
107 equivalent_module_spec.GetPlatformFileSpec() = module_sp->GetPlatformFileSpec();
110 while (idx < m_modules.size())
112 ModuleSP module_sp (m_modules[idx]);
113 if (module_sp->MatchesModuleSpec (equivalent_module_spec))
114 RemoveImpl(m_modules.begin() + idx);
118 // Now add the new module to the list
124 ModuleList::AppendIfNeeded (const ModuleSP &module_sp)
128 Mutex::Locker locker(m_modules_mutex);
129 collection::iterator pos, end = m_modules.end();
130 for (pos = m_modules.begin(); pos != end; ++pos)
132 if (pos->get() == module_sp.get())
133 return false; // Already in the list
135 // Only push module_sp on the list if it wasn't already in there.
143 ModuleList::Append (const ModuleList& module_list)
145 for (auto pos : module_list.m_modules)
150 ModuleList::AppendIfNeeded (const ModuleList& module_list)
153 for (auto pos : module_list.m_modules)
155 if (AppendIfNeeded(pos))
162 ModuleList::RemoveImpl (const ModuleSP &module_sp, bool use_notifier)
166 Mutex::Locker locker(m_modules_mutex);
167 collection::iterator pos, end = m_modules.end();
168 for (pos = m_modules.begin(); pos != end; ++pos)
170 if (pos->get() == module_sp.get())
172 m_modules.erase (pos);
173 if (use_notifier && m_notifier)
174 m_notifier->ModuleRemoved(*this, module_sp);
182 ModuleList::collection::iterator
183 ModuleList::RemoveImpl (ModuleList::collection::iterator pos, bool use_notifier)
185 ModuleSP module_sp(*pos);
186 collection::iterator retval = m_modules.erase(pos);
187 if (use_notifier && m_notifier)
188 m_notifier->ModuleRemoved(*this, module_sp);
193 ModuleList::Remove (const ModuleSP &module_sp)
195 return RemoveImpl (module_sp);
199 ModuleList::ReplaceModule (const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp)
201 if (!RemoveImpl(old_module_sp, false))
203 AppendImpl (new_module_sp, false);
205 m_notifier->ModuleUpdated(*this, old_module_sp,new_module_sp);
210 ModuleList::RemoveIfOrphaned (const Module *module_ptr)
214 Mutex::Locker locker(m_modules_mutex);
215 collection::iterator pos, end = m_modules.end();
216 for (pos = m_modules.begin(); pos != end; ++pos)
218 if (pos->get() == module_ptr)
222 pos = RemoveImpl(pos);
234 ModuleList::RemoveOrphans (bool mandatory)
236 Mutex::Locker locker;
240 locker.Lock (m_modules_mutex);
244 // Not mandatory, remove orphans if we can get the mutex
245 if (!locker.TryLock(m_modules_mutex))
248 collection::iterator pos = m_modules.begin();
249 size_t remove_count = 0;
250 while (pos != m_modules.end())
254 pos = RemoveImpl(pos);
266 ModuleList::Remove (ModuleList &module_list)
268 Mutex::Locker locker(m_modules_mutex);
269 size_t num_removed = 0;
270 collection::iterator pos, end = module_list.m_modules.end();
271 for (pos = module_list.m_modules.begin(); pos != end; ++pos)
287 ModuleList::Destroy()
293 ModuleList::ClearImpl (bool use_notifier)
295 Mutex::Locker locker(m_modules_mutex);
296 if (use_notifier && m_notifier)
297 m_notifier->WillClearList(*this);
302 ModuleList::GetModulePointerAtIndex (size_t idx) const
304 Mutex::Locker locker(m_modules_mutex);
305 return GetModulePointerAtIndexUnlocked(idx);
309 ModuleList::GetModulePointerAtIndexUnlocked (size_t idx) const
311 if (idx < m_modules.size())
312 return m_modules[idx].get();
317 ModuleList::GetModuleAtIndex(size_t idx) const
319 Mutex::Locker locker(m_modules_mutex);
320 return GetModuleAtIndexUnlocked(idx);
324 ModuleList::GetModuleAtIndexUnlocked(size_t idx) const
327 if (idx < m_modules.size())
328 module_sp = m_modules[idx];
333 ModuleList::FindFunctions (const ConstString &name,
334 uint32_t name_type_mask,
335 bool include_symbols,
336 bool include_inlines,
338 SymbolContextList &sc_list) const
343 const size_t old_size = sc_list.GetSize();
345 if (name_type_mask & eFunctionNameTypeAuto)
347 ConstString lookup_name;
348 uint32_t lookup_name_type_mask = 0;
349 bool match_name_after_lookup = false;
350 Module::PrepareForFunctionNameLookup (name, name_type_mask,
352 lookup_name_type_mask,
353 match_name_after_lookup);
355 Mutex::Locker locker(m_modules_mutex);
356 collection::const_iterator pos, end = m_modules.end();
357 for (pos = m_modules.begin(); pos != end; ++pos)
359 (*pos)->FindFunctions (lookup_name,
361 lookup_name_type_mask,
368 if (match_name_after_lookup)
372 while (i<sc_list.GetSize())
374 if (sc_list.GetContextAtIndex(i, sc))
376 const char *func_name = sc.GetFunctionName().GetCString();
377 if (func_name && strstr (func_name, name.GetCString()) == NULL)
379 // Remove the current context
380 sc_list.RemoveContextAtIndex(i);
381 // Don't increment i and continue in the loop
392 Mutex::Locker locker(m_modules_mutex);
393 collection::const_iterator pos, end = m_modules.end();
394 for (pos = m_modules.begin(); pos != end; ++pos)
396 (*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
399 return sc_list.GetSize() - old_size;
403 ModuleList::FindFunctionSymbols (const ConstString &name,
404 uint32_t name_type_mask,
405 SymbolContextList& sc_list)
407 const size_t old_size = sc_list.GetSize();
409 if (name_type_mask & eFunctionNameTypeAuto)
411 ConstString lookup_name;
412 uint32_t lookup_name_type_mask = 0;
413 bool match_name_after_lookup = false;
414 Module::PrepareForFunctionNameLookup (name, name_type_mask,
416 lookup_name_type_mask,
417 match_name_after_lookup);
419 Mutex::Locker locker(m_modules_mutex);
420 collection::const_iterator pos, end = m_modules.end();
421 for (pos = m_modules.begin(); pos != end; ++pos)
423 (*pos)->FindFunctionSymbols (lookup_name,
424 lookup_name_type_mask,
428 if (match_name_after_lookup)
432 while (i<sc_list.GetSize())
434 if (sc_list.GetContextAtIndex(i, sc))
436 const char *func_name = sc.GetFunctionName().GetCString();
437 if (func_name && strstr (func_name, name.GetCString()) == NULL)
439 // Remove the current context
440 sc_list.RemoveContextAtIndex(i);
441 // Don't increment i and continue in the loop
452 Mutex::Locker locker(m_modules_mutex);
453 collection::const_iterator pos, end = m_modules.end();
454 for (pos = m_modules.begin(); pos != end; ++pos)
456 (*pos)->FindFunctionSymbols (name, name_type_mask, sc_list);
460 return sc_list.GetSize() - old_size;
464 ModuleList::FindCompileUnits (const FileSpec &path,
466 SymbolContextList &sc_list) const
471 Mutex::Locker locker(m_modules_mutex);
472 collection::const_iterator pos, end = m_modules.end();
473 for (pos = m_modules.begin(); pos != end; ++pos)
475 (*pos)->FindCompileUnits (path, true, sc_list);
478 return sc_list.GetSize();
482 ModuleList::FindGlobalVariables (const ConstString &name,
485 VariableList& variable_list) const
487 size_t initial_size = variable_list.GetSize();
488 Mutex::Locker locker(m_modules_mutex);
489 collection::const_iterator pos, end = m_modules.end();
490 for (pos = m_modules.begin(); pos != end; ++pos)
492 (*pos)->FindGlobalVariables (name, NULL, append, max_matches, variable_list);
494 return variable_list.GetSize() - initial_size;
499 ModuleList::FindGlobalVariables (const RegularExpression& regex,
502 VariableList& variable_list) const
504 size_t initial_size = variable_list.GetSize();
505 Mutex::Locker locker(m_modules_mutex);
506 collection::const_iterator pos, end = m_modules.end();
507 for (pos = m_modules.begin(); pos != end; ++pos)
509 (*pos)->FindGlobalVariables (regex, append, max_matches, variable_list);
511 return variable_list.GetSize() - initial_size;
516 ModuleList::FindSymbolsWithNameAndType (const ConstString &name,
517 SymbolType symbol_type,
518 SymbolContextList &sc_list,
521 Mutex::Locker locker(m_modules_mutex);
524 size_t initial_size = sc_list.GetSize();
526 collection::const_iterator pos, end = m_modules.end();
527 for (pos = m_modules.begin(); pos != end; ++pos)
528 (*pos)->FindSymbolsWithNameAndType (name, symbol_type, sc_list);
529 return sc_list.GetSize() - initial_size;
533 ModuleList::FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
534 lldb::SymbolType symbol_type,
535 SymbolContextList &sc_list,
538 Mutex::Locker locker(m_modules_mutex);
541 size_t initial_size = sc_list.GetSize();
543 collection::const_iterator pos, end = m_modules.end();
544 for (pos = m_modules.begin(); pos != end; ++pos)
545 (*pos)->FindSymbolsMatchingRegExAndType (regex, symbol_type, sc_list);
546 return sc_list.GetSize() - initial_size;
550 ModuleList::FindModules (const ModuleSpec &module_spec, ModuleList& matching_module_list) const
552 size_t existing_matches = matching_module_list.GetSize();
554 Mutex::Locker locker(m_modules_mutex);
555 collection::const_iterator pos, end = m_modules.end();
556 for (pos = m_modules.begin(); pos != end; ++pos)
558 ModuleSP module_sp(*pos);
559 if (module_sp->MatchesModuleSpec (module_spec))
560 matching_module_list.Append(module_sp);
562 return matching_module_list.GetSize() - existing_matches;
566 ModuleList::FindModule (const Module *module_ptr) const
570 // Scope for "locker"
572 Mutex::Locker locker(m_modules_mutex);
573 collection::const_iterator pos, end = m_modules.end();
575 for (pos = m_modules.begin(); pos != end; ++pos)
577 if ((*pos).get() == module_ptr)
589 ModuleList::FindModule (const UUID &uuid) const
595 Mutex::Locker locker(m_modules_mutex);
596 collection::const_iterator pos, end = m_modules.end();
598 for (pos = m_modules.begin(); pos != end; ++pos)
600 if ((*pos)->GetUUID() == uuid)
612 ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, TypeList& types) const
614 Mutex::Locker locker(m_modules_mutex);
616 size_t total_matches = 0;
617 collection::const_iterator pos, end = m_modules.end();
620 // The symbol context "sc" contains a module so we want to search that
621 // one first if it is in our list...
622 for (pos = m_modules.begin(); pos != end; ++pos)
624 if (sc.module_sp.get() == (*pos).get())
626 total_matches += (*pos)->FindTypes (sc, name, name_is_fully_qualified, max_matches, types);
628 if (total_matches >= max_matches)
634 if (total_matches < max_matches)
636 SymbolContext world_sc;
637 for (pos = m_modules.begin(); pos != end; ++pos)
639 // Search the module if the module is not equal to the one in the symbol
640 // context "sc". If "sc" contains a empty module shared pointer, then
641 // the comparisong will always be true (valid_module_ptr != NULL).
642 if (sc.module_sp.get() != (*pos).get())
643 total_matches += (*pos)->FindTypes (world_sc, name, name_is_fully_qualified, max_matches, types);
645 if (total_matches >= max_matches)
650 return total_matches;
654 ModuleList::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const
656 Mutex::Locker locker(m_modules_mutex);
657 collection::const_iterator pos, end = m_modules.end();
658 for (pos = m_modules.begin(); pos != end; ++pos)
660 if ((*pos)->FindSourceFile (orig_spec, new_spec))
669 ModuleList::FindFirstModule (const ModuleSpec &module_spec) const
672 Mutex::Locker locker(m_modules_mutex);
673 collection::const_iterator pos, end = m_modules.end();
674 for (pos = m_modules.begin(); pos != end; ++pos)
676 ModuleSP module_sp(*pos);
677 if (module_sp->MatchesModuleSpec (module_spec))
685 ModuleList::GetSize() const
689 Mutex::Locker locker(m_modules_mutex);
690 size = m_modules.size();
697 ModuleList::Dump(Stream *s) const
699 // s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
701 // s << "ModuleList\n";
703 Mutex::Locker locker(m_modules_mutex);
704 collection::const_iterator pos, end = m_modules.end();
705 for (pos = m_modules.begin(); pos != end; ++pos)
712 ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr)
716 Mutex::Locker locker(m_modules_mutex);
717 collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end();
718 for (pos = begin; pos != end; ++pos)
720 Module *module = pos->get();
721 const FileSpec &module_file_spec = module->GetFileSpec();
722 log->Printf ("%s[%u] %s (%s) \"%s\"",
723 prefix_cstr ? prefix_cstr : "",
724 (uint32_t)std::distance (begin, pos),
725 module->GetUUID().GetAsString().c_str(),
726 module->GetArchitecture().GetArchitectureName(),
727 module_file_spec.GetPath().c_str());
733 ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) const
735 Mutex::Locker locker(m_modules_mutex);
736 collection::const_iterator pos, end = m_modules.end();
737 for (pos = m_modules.begin(); pos != end; ++pos)
739 if ((*pos)->ResolveFileAddress (vm_addr, so_addr))
747 ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) const
749 // The address is already section offset so it has a module
750 uint32_t resolved_flags = 0;
751 ModuleSP module_sp (so_addr.GetModule());
754 resolved_flags = module_sp->ResolveSymbolContextForAddress (so_addr,
760 Mutex::Locker locker(m_modules_mutex);
761 collection::const_iterator pos, end = m_modules.end();
762 for (pos = m_modules.begin(); pos != end; ++pos)
764 resolved_flags = (*pos)->ResolveSymbolContextForAddress (so_addr,
767 if (resolved_flags != 0)
772 return resolved_flags;
776 ModuleList::ResolveSymbolContextForFilePath
778 const char *file_path,
781 uint32_t resolve_scope,
782 SymbolContextList& sc_list
785 FileSpec file_spec(file_path, false);
786 return ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list);
790 ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) const
792 Mutex::Locker locker(m_modules_mutex);
793 collection::const_iterator pos, end = m_modules.end();
794 for (pos = m_modules.begin(); pos != end; ++pos)
796 (*pos)->ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list);
799 return sc_list.GetSize();
803 ModuleList::GetIndexForModule (const Module *module) const
807 Mutex::Locker locker(m_modules_mutex);
808 collection::const_iterator pos;
809 collection::const_iterator begin = m_modules.begin();
810 collection::const_iterator end = m_modules.end();
811 for (pos = begin; pos != end; ++pos)
813 if ((*pos).get() == module)
814 return std::distance (begin, pos);
817 return LLDB_INVALID_INDEX32;
821 GetSharedModuleList ()
823 // NOTE: Intentionally leak the module list so a program doesn't have to
824 // cleanup all modules and object files as it exits. This just wastes time
825 // doing a bunch of cleanup that isn't required.
826 static ModuleList *g_shared_module_list = NULL;
827 if (g_shared_module_list == NULL)
828 g_shared_module_list = new ModuleList(); // <--- Intentional leak!!!
830 return *g_shared_module_list;
834 ModuleList::ModuleIsInCache (const Module *module_ptr)
838 ModuleList &shared_module_list = GetSharedModuleList ();
839 return shared_module_list.FindModule (module_ptr).get() != NULL;
845 ModuleList::FindSharedModules (const ModuleSpec &module_spec, ModuleList &matching_module_list)
847 return GetSharedModuleList ().FindModules (module_spec, matching_module_list);
851 ModuleList::RemoveOrphanSharedModules (bool mandatory)
853 return GetSharedModuleList ().RemoveOrphans(mandatory);
857 ModuleList::GetSharedModule
859 const ModuleSpec &module_spec,
861 const FileSpecList *module_search_paths_ptr,
862 ModuleSP *old_module_sp_ptr,
863 bool *did_create_ptr,
867 ModuleList &shared_module_list = GetSharedModuleList ();
868 Mutex::Locker locker(shared_module_list.m_modules_mutex);
876 *did_create_ptr = false;
877 if (old_module_sp_ptr)
878 old_module_sp_ptr->reset();
880 const UUID *uuid_ptr = module_spec.GetUUIDPtr();
881 const FileSpec &module_file_spec = module_spec.GetFileSpec();
882 const ArchSpec &arch = module_spec.GetArchitecture();
884 // Make sure no one else can try and get or create a module while this
885 // function is actively working on it by doing an extra lock on the
886 // global mutex list.
887 if (always_create == false)
889 ModuleList matching_module_list;
890 const size_t num_matching_modules = shared_module_list.FindModules (module_spec, matching_module_list);
891 if (num_matching_modules > 0)
893 for (size_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
895 module_sp = matching_module_list.GetModuleAtIndex(module_idx);
897 // Make sure the file for the module hasn't been modified
898 if (module_sp->FileHasChanged())
900 if (old_module_sp_ptr && !old_module_sp_ptr->get())
901 *old_module_sp_ptr = module_sp;
903 Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_MODULES));
905 log->Printf("module changed: %p, removing from global module list", module_sp.get());
907 shared_module_list.Remove (module_sp);
912 // The module matches and the module was not modified from
913 // when it was last loaded.
924 module_sp.reset (new Module (module_spec));
925 // Make sure there are a module and an object file since we can specify
926 // a valid file path with an architecture that might not be in that file.
927 // By getting the object file we can guarantee that the architecture matches
930 if (module_sp->GetObjectFile())
932 // If we get in here we got the correct arch, now we just need
933 // to verify the UUID if one was given
934 if (uuid_ptr && *uuid_ptr != module_sp->GetUUID())
939 *did_create_ptr = true;
941 shared_module_list.ReplaceEquivalent(module_sp);
950 // Either the file didn't exist where at the path, or no path was given, so
951 // we now have to use more extreme measures to try and find the appropriate
954 // Fixup the incoming path in case the path points to a valid file, yet
955 // the arch or UUID (if one was passed in) don't match.
956 FileSpec file_spec = Symbols::LocateExecutableObjectFile (module_spec);
958 // Don't look for the file if it appears to be the same one we already
959 // checked for above...
960 if (file_spec != module_file_spec)
962 if (!file_spec.Exists())
964 file_spec.GetPath(path, sizeof(path));
966 module_file_spec.GetPath(path, sizeof(path));
967 if (file_spec.Exists())
969 std::string uuid_str;
970 if (uuid_ptr && uuid_ptr->IsValid())
971 uuid_str = uuid_ptr->GetAsString();
975 if (!uuid_str.empty())
976 error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_str.c_str());
978 error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.", path, arch.GetArchitectureName());
983 error.SetErrorStringWithFormat("'%s' does not exist", path);
991 // Make sure no one else can try and get or create a module while this
992 // function is actively working on it by doing an extra lock on the
993 // global mutex list.
994 ModuleSpec platform_module_spec(module_spec);
995 platform_module_spec.GetFileSpec() = file_spec;
996 platform_module_spec.GetPlatformFileSpec() = file_spec;
997 ModuleList matching_module_list;
998 if (shared_module_list.FindModules (platform_module_spec, matching_module_list) > 0)
1000 module_sp = matching_module_list.GetModuleAtIndex(0);
1002 // If we didn't have a UUID in mind when looking for the object file,
1003 // then we should make sure the modification time hasn't changed!
1004 if (platform_module_spec.GetUUIDPtr() == NULL)
1006 TimeValue file_spec_mod_time(file_spec.GetModificationTime());
1007 if (file_spec_mod_time.IsValid())
1009 if (file_spec_mod_time != module_sp->GetModificationTime())
1011 if (old_module_sp_ptr)
1012 *old_module_sp_ptr = module_sp;
1013 shared_module_list.Remove (module_sp);
1020 if (module_sp.get() == NULL)
1022 module_sp.reset (new Module (platform_module_spec));
1023 // Make sure there are a module and an object file since we can specify
1024 // a valid file path with an architecture that might not be in that file.
1025 // By getting the object file we can guarantee that the architecture matches
1026 if (module_sp && module_sp->GetObjectFile())
1029 *did_create_ptr = true;
1031 shared_module_list.ReplaceEquivalent(module_sp);
1035 file_spec.GetPath(path, sizeof(path));
1040 error.SetErrorStringWithFormat("unable to open %s architecture in '%s'", arch.GetArchitectureName(), path);
1042 error.SetErrorStringWithFormat("unable to open '%s'", path);
1046 std::string uuid_str;
1047 if (uuid_ptr && uuid_ptr->IsValid())
1048 uuid_str = uuid_ptr->GetAsString();
1050 if (!uuid_str.empty())
1051 error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_str.c_str());
1053 error.SetErrorStringWithFormat("cannot locate a module");
1063 ModuleList::RemoveSharedModule (lldb::ModuleSP &module_sp)
1065 return GetSharedModuleList ().Remove (module_sp);
1069 ModuleList::RemoveSharedModuleIfOrphaned (const Module *module_ptr)
1071 return GetSharedModuleList ().RemoveIfOrphaned (module_ptr);
1075 ModuleList::LoadScriptingResourcesInTarget (Target *target,
1076 std::list<Error>& errors,
1077 Stream *feedback_stream,
1078 bool continue_on_error)
1082 Mutex::Locker locker(m_modules_mutex);
1083 for (auto module : m_modules)
1088 if (!module->LoadScriptingResourceInTarget(target, error, feedback_stream))
1090 if (error.Fail() && error.AsCString())
1092 error.SetErrorStringWithFormat("unable to load scripting data for module %s - error reported was %s",
1093 module->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1095 errors.push_back(error);
1097 if (!continue_on_error)
1102 return errors.size() == 0;