diff options
author | Oleksiy Vyalov <ovyalov@google.com> | 2015-03-16 23:44:30 +0000 |
---|---|---|
committer | Oleksiy Vyalov <ovyalov@google.com> | 2015-03-16 23:44:30 +0000 |
commit | 933f853030ea34f2c718afea260572de2c4c9a31 (patch) | |
tree | b2a36c069f9b81d1ffec2724b382f507d90450f6 /lldb/source/Core/ModuleList.cpp | |
parent | 3c2e306a5c2083c09c7ad6b6963dcc14eae218fb (diff) | |
download | bcm5719-llvm-933f853030ea34f2c718afea260572de2c4c9a31.tar.gz bcm5719-llvm-933f853030ea34f2c718afea260572de2c4c9a31.zip |
Make ModuleList::GetSharedModule to use module_search_paths parameter.
http://reviews.llvm.org/D8365
llvm-svn: 232437
Diffstat (limited to 'lldb/source/Core/ModuleList.cpp')
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 5c8e0e0ca8e..669b3d9274c 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -978,14 +978,46 @@ ModuleList::GetSharedModule 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 (did_create_ptr) + *did_create_ptr = true; + + shared_module_list.ReplaceEquivalent(module_sp); + return error; + } + } else + module_sp.reset(); + + if (module_search_paths_ptr) { - 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) + 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 @@ -998,7 +1030,7 @@ ModuleList::GetSharedModule *did_create_ptr = true; shared_module_list.ReplaceEquivalent(module_sp); - return error; + return Error(); } } else |