本文整理汇总了C++中ModuleSpec::GetFileSpec方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleSpec::GetFileSpec方法的具体用法?C++ ModuleSpec::GetFileSpec怎么用?C++ ModuleSpec::GetFileSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleSpec
的用法示例。
在下文中一共展示了ModuleSpec::GetFileSpec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Get
Error ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname,
const ModuleSpec &module_spec,
ModuleSP &cached_module_sp, bool *did_create_ptr) {
const auto find_it =
m_loaded_modules.find(module_spec.GetUUID().GetAsString());
if (find_it != m_loaded_modules.end()) {
cached_module_sp = (*find_it).second.lock();
if (cached_module_sp)
return Error();
m_loaded_modules.erase(find_it);
}
const auto module_spec_dir =
GetModuleDirectory(root_dir_spec, module_spec.GetUUID());
const auto module_file_path = JoinPath(
module_spec_dir, module_spec.GetFileSpec().GetFilename().AsCString());
if (!module_file_path.Exists())
return Error("Module %s not found", module_file_path.GetPath().c_str());
if (module_file_path.GetByteSize() != module_spec.GetObjectSize())
return Error("Module %s has invalid file size",
module_file_path.GetPath().c_str());
// We may have already cached module but downloaded from an another host - in
// this case let's create a link to it.
auto error = CreateHostSysRootModuleLink(root_dir_spec, hostname,
module_spec.GetFileSpec(),
module_file_path, false);
if (error.Fail())
return Error("Failed to create link to %s: %s",
module_file_path.GetPath().c_str(), error.AsCString());
auto cached_module_spec(module_spec);
cached_module_spec.GetUUID().Clear(); // Clear UUID since it may contain md5
// content hash instead of real UUID.
cached_module_spec.GetFileSpec() = module_file_path;
cached_module_spec.GetPlatformFileSpec() = module_spec.GetFileSpec();
error = ModuleList::GetSharedModule(cached_module_spec, cached_module_sp,
nullptr, nullptr, did_create_ptr, false);
if (error.Fail())
return error;
FileSpec symfile_spec = GetSymbolFileSpec(cached_module_sp->GetFileSpec());
if (symfile_spec.Exists())
cached_module_sp->SetSymbolFileFileSpec(symfile_spec);
m_loaded_modules.insert(
std::make_pair(module_spec.GetUUID().GetAsString(), cached_module_sp));
return Error();
}
示例2: kext_bundle_cs
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);
}
示例3: GetSharedModule
Error PlatformFreeBSD::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();
if (IsRemote()) {
// If we have a remote platform always, let it try and locate
// the shared module first.
if (m_remote_platform_sp) {
error = m_remote_platform_sp->GetSharedModule(
module_spec, process, module_sp, module_search_paths_ptr,
old_module_sp_ptr, did_create_ptr);
}
}
if (!module_sp) {
// Fall back to the local platform and find the file locally
error = Platform::GetSharedModule(module_spec, process, module_sp,
module_search_paths_ptr,
old_module_sp_ptr, did_create_ptr);
}
if (module_sp)
module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
return error;
}
示例4: CreateHostSysRootModuleSymLink
Error
ModuleCache::Put (const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
const FileSpec &tmp_file)
{
const auto module_spec_dir = GetModuleDirectory (root_dir_spec, module_spec.GetUUID ());
auto error = MakeDirectory (module_spec_dir);
if (error.Fail ())
return error;
const auto module_file_path = JoinPath (module_spec_dir, module_spec.GetFileSpec ().GetFilename ().AsCString ());
const auto tmp_file_path = tmp_file.GetPath ();
const auto err_code = llvm::sys::fs::copy_file (tmp_file_path.c_str (), module_file_path.GetPath ().c_str ());
if (err_code)
{
error.SetErrorStringWithFormat ("failed to copy file %s to %s: %s",
tmp_file_path.c_str (),
module_file_path.GetPath ().c_str (),
err_code.message ().c_str ());
}
// Create sysroot link to a module.
const auto sysroot_module_path_spec = GetHostSysRootModulePath (root_dir_spec, hostname, module_spec.GetFileSpec ());
return CreateHostSysRootModuleSymLink (sysroot_module_path_spec, module_file_path);
}
示例5: GetSharedModule
Error PlatformiOSSimulator::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) {
// For iOS, the SDK files are all cached locally on the host
// system. So first we ask for the file in the cached SDK,
// then we attempt to get a shared module for the right architecture
// with the right UUID.
Error error;
ModuleSpec platform_module_spec(module_spec);
const FileSpec &platform_file = module_spec.GetFileSpec();
error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
platform_module_spec.GetFileSpec());
if (error.Success()) {
error = ResolveExecutable(platform_module_spec, module_sp,
module_search_paths_ptr);
} else {
const bool always_create = false;
error = ModuleList::GetSharedModule(
module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
did_create_ptr, always_create);
}
if (module_sp)
module_sp->SetPlatformFileSpec(platform_file);
return error;
}
示例6: kext_bundle_cs
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);
}
示例7: CFSTR
static bool
GetModuleSpecInfoFromUUIDDictionary (CFDictionaryRef uuid_dict, ModuleSpec &module_spec)
{
bool success = false;
if (uuid_dict != NULL && CFGetTypeID (uuid_dict) == CFDictionaryGetTypeID ())
{
std::string str;
CFStringRef cf_str;
cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGSymbolRichExecutable"));
if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
{
if (CFCString::FileSystemRepresentation(cf_str, str))
module_spec.GetFileSpec().SetFile (str.c_str(), true);
}
cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGDSYMPath"));
if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
{
if (CFCString::FileSystemRepresentation(cf_str, str))
{
module_spec.GetSymbolFileSpec().SetFile (str.c_str(), true);
success = true;
}
}
cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGArchitecture"));
if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
{
if (CFCString::FileSystemRepresentation(cf_str, str))
module_spec.GetArchitecture().SetTriple(str.c_str());
}
std::string DBGBuildSourcePath;
std::string DBGSourcePath;
cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGBuildSourcePath"));
if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
{
CFCString::FileSystemRepresentation(cf_str, DBGBuildSourcePath);
}
cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGSourcePath"));
if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
{
CFCString::FileSystemRepresentation(cf_str, DBGSourcePath);
}
if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty())
{
module_spec.GetSourceMappingList().Append (ConstString(DBGBuildSourcePath.c_str()), ConstString(DBGSourcePath.c_str()), true);
}
}
return success;
}
示例8:
Error
PlatformRemoteGDBServer::ResolveExecutable (const ModuleSpec &module_spec,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
//error.SetErrorString ("PlatformRemoteGDBServer::ResolveExecutable() is unimplemented");
if (m_gdb_client.GetFileExists(module_spec.GetFileSpec()))
return error;
// TODO: get the remote end to somehow resolve this file
error.SetErrorString("file not found on remote end");
return error;
}
示例9: locker
Module::Module (const ModuleSpec &module_spec) :
m_mutex (Mutex::eMutexTypeRecursive),
m_mod_time (module_spec.GetFileSpec().GetModificationTime()),
m_arch (module_spec.GetArchitecture()),
m_uuid (),
m_file (module_spec.GetFileSpec()),
m_platform_file(module_spec.GetPlatformFileSpec()),
m_symfile_spec (module_spec.GetSymbolFileSpec()),
m_object_name (module_spec.GetObjectName()),
m_object_offset (module_spec.GetObjectOffset()),
m_objfile_sp (),
m_symfile_ap (),
m_ast (),
m_source_mappings (),
m_did_load_objfile (false),
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
m_did_init_ast (false),
m_is_dynamic_loader_module (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{
// Scope for locker below...
{
Mutex::Locker locker (GetAllocationModuleCollectionMutex());
GetModuleCollection().push_back(this);
}
LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
if (log)
log->Printf ("%p Module::Module((%s) '%s/%s%s%s%s')",
this,
m_arch.GetArchitectureName(),
m_file.GetDirectory().AsCString(""),
m_file.GetFilename().AsCString(""),
m_object_name.IsEmpty() ? "" : "(",
m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
m_object_name.IsEmpty() ? "" : ")");
}
示例10: Error
Error
ModuleCache::Get (const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
ModuleSP &cached_module_sp,
bool *did_create_ptr)
{
const auto find_it = m_loaded_modules.find (module_spec.GetUUID ().GetAsString());
if (find_it != m_loaded_modules.end ())
{
cached_module_sp = (*find_it).second.lock ();
if (cached_module_sp)
return Error ();
m_loaded_modules.erase (find_it);
}
const auto module_spec_dir = GetModuleDirectory (root_dir_spec, module_spec.GetUUID ());
const auto module_file_path = JoinPath (module_spec_dir, module_spec.GetFileSpec ().GetFilename ().AsCString ());
if (!module_file_path.Exists ())
return Error ("module %s not found", module_file_path.GetPath ().c_str ());
// We may have already cached module but downloaded from an another host - in this case let's create a symlink to it.
const auto sysroot_module_path_spec = GetHostSysRootModulePath (root_dir_spec, hostname, module_spec.GetFileSpec ());
if (!sysroot_module_path_spec.Exists ())
CreateHostSysRootModuleSymLink (sysroot_module_path_spec, module_spec.GetFileSpec ());
auto cached_module_spec (module_spec);
cached_module_spec.GetUUID ().Clear (); // Clear UUID since it may contain md5 content hash instead of real UUID.
cached_module_spec.GetFileSpec () = module_file_path;
cached_module_spec.GetPlatformFileSpec () = module_spec.GetFileSpec ();
cached_module_sp.reset (new Module (cached_module_spec));
if (did_create_ptr)
*did_create_ptr = true;
m_loaded_modules.insert (std::make_pair (module_spec.GetUUID ().GetAsString (), cached_module_sp));
return Error ();
}
示例11:
bool
Module::MatchesModuleSpec (const ModuleSpec &module_ref)
{
const UUID &uuid = module_ref.GetUUID();
if (uuid.IsValid())
{
// If the UUID matches, then nothing more needs to match...
if (uuid == GetUUID())
return true;
else
return false;
}
const FileSpec &file_spec = module_ref.GetFileSpec();
if (file_spec)
{
if (!FileSpec::Equal (file_spec, m_file, file_spec.GetDirectory()))
return false;
}
const FileSpec &platform_file_spec = module_ref.GetPlatformFileSpec();
if (platform_file_spec)
{
if (!FileSpec::Equal (platform_file_spec, GetPlatformFileSpec (), platform_file_spec.GetDirectory()))
return false;
}
const ArchSpec &arch = module_ref.GetArchitecture();
if (arch.IsValid())
{
if (m_arch != arch)
return false;
}
const ConstString &object_name = module_ref.GetObjectName();
if (object_name)
{
if (object_name != GetObjectName())
return false;
}
return true;
}
示例12: LocateExecutableObjectFile
ModuleSpec Symbols::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
ModuleSpec result;
const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
Timer scoped_timer(
LLVM_PRETTY_FUNCTION,
"LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString("<NULL>") : "<NULL>",
arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid);
ModuleSpecList module_specs;
ModuleSpec matched_module_spec;
if (exec_fspec &&
ObjectFile::GetModuleSpecifications(*exec_fspec, 0, 0, module_specs) &&
module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec)) {
result.GetFileSpec() = exec_fspec;
} else {
LocateMacOSXFilesUsingDebugSymbols(module_spec, result);
}
return result;
}
示例13: lock_file
Error
ModuleCache::GetAndPut (const FileSpec &root_dir_spec,
const char *hostname,
const ModuleSpec &module_spec,
const ModuleDownloader &module_downloader,
const SymfileDownloader &symfile_downloader,
lldb::ModuleSP &cached_module_sp,
bool *did_create_ptr)
{
const auto module_spec_dir = GetModuleDirectory (root_dir_spec, module_spec.GetUUID ());
auto error = MakeDirectory (module_spec_dir);
if (error.Fail ())
return error;
// Open lock file.
const auto lock_file_spec = JoinPath (module_spec_dir, kLockFileName);
File lock_file (lock_file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate | File::eOpenOptionCloseOnExec);
if (!lock_file)
{
error.SetErrorToErrno ();
return Error("Failed to open lock file %s: %s", lock_file_spec.GetPath ().c_str (), error.AsCString ());
}
LockFile lock (lock_file.GetDescriptor ());
error = lock.WriteLock (0, 1);
if (error.Fail ())
return Error("Failed to lock file %s:%s", lock_file_spec.GetPath ().c_str (), error.AsCString ());
// Check local cache for a module.
error = Get (root_dir_spec, hostname, module_spec, cached_module_sp, did_create_ptr);
if (error.Success ())
return error;
const auto tmp_download_file_spec = JoinPath (module_spec_dir, kTempFileName);
error = module_downloader (module_spec, tmp_download_file_spec);
llvm::FileRemover tmp_file_remover (tmp_download_file_spec.GetPath ().c_str ());
if (error.Fail ())
return Error("Failed to download module: %s", error.AsCString ());
// Put downloaded file into local module cache.
error = Put (root_dir_spec, hostname, module_spec, tmp_download_file_spec, module_spec.GetFileSpec ());
if (error.Fail ())
return Error ("Failed to put module into cache: %s", error.AsCString ());
tmp_file_remover.releaseFile ();
error = Get (root_dir_spec, hostname, module_spec, cached_module_sp, did_create_ptr);
if (error.Fail ())
return error;
// Fetching a symbol file for the module
const auto tmp_download_sym_file_spec = JoinPath (module_spec_dir, kTempSymFileName);
error = symfile_downloader (cached_module_sp, tmp_download_sym_file_spec);
llvm::FileRemover tmp_symfile_remover (tmp_download_sym_file_spec.GetPath ().c_str ());
if (error.Fail ())
// Failed to download a symfile but fetching the module was successful. The module might
// contain the neccessary symbols and the debugging is also possible without a symfile.
return Error ();
FileSpec symfile_spec = GetSymbolFileSpec (cached_module_sp->GetFileSpec ());
error = Put (root_dir_spec, hostname, module_spec, tmp_download_sym_file_spec, symfile_spec);
if (error.Fail ())
return Error ("Failed to put symbol file into cache: %s", error.AsCString ());
tmp_symfile_remover.releaseFile();
cached_module_sp->SetSymbolFileFileSpec (symfile_spec);
return Error ();
}
示例14: ResolveExecutable
Error PlatformFreeBSD::ResolveExecutable(
const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr) {
Error error;
// Nothing special to do here, just use the actual file and architecture
char exe_path[PATH_MAX];
ModuleSpec resolved_module_spec(module_spec);
if (IsHost()) {
// If we have "ls" as the module_spec's file, resolve the executable
// location based on
// the current path variables
if (!resolved_module_spec.GetFileSpec().Exists()) {
module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
}
if (!resolved_module_spec.GetFileSpec().Exists())
resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else {
error.SetErrorStringWithFormat(
"unable to find executable for '%s'",
resolved_module_spec.GetFileSpec().GetPath().c_str());
}
} else {
if (m_remote_platform_sp) {
error =
GetCachedExecutable(resolved_module_spec, exe_module_sp,
module_search_paths_ptr, *m_remote_platform_sp);
} else {
// We may connect to a process and use the provided executable (Don't use
// local $PATH).
// Resolve any executable within a bundle on MacOSX
Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
if (resolved_module_spec.GetFileSpec().Exists()) {
error.Clear();
} else {
error.SetErrorStringWithFormat(
"the platform is not currently connected, and '%s' doesn't exist "
"in the system root.",
resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
if (error.Success()) {
if (resolved_module_spec.GetArchitecture().IsValid()) {
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
module_search_paths_ptr, NULL, NULL);
if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) {
exe_module_sp.reset();
error.SetErrorStringWithFormat(
"'%s' doesn't contain the architecture %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
resolved_module_spec.GetArchitecture().GetArchitectureName());
}
} else {
// No valid architecture was specified, ask the platform for
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
StreamString arch_names;
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
idx, resolved_module_spec.GetArchitecture());
++idx) {
error =
ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
module_search_paths_ptr, NULL, NULL);
// Did we find an executable using one of the
if (error.Success()) {
if (exe_module_sp && exe_module_sp->GetObjectFile())
break;
else
error.SetErrorToGenericError();
}
if (idx > 0)
arch_names.PutCString(", ");
arch_names.PutCString(
resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp) {
if (resolved_module_spec.GetFileSpec().Readable()) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(), arch_names.GetData());
} else {
error.SetErrorStringWithFormat(
"'%s' is not readable",
resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
//.........这里部分代码省略.........
示例15: error
Error
PlatformRemoteiOS::GetSharedModule (const ModuleSpec &module_spec,
ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
ModuleSP *old_module_sp_ptr,
bool *did_create_ptr)
{
// For iOS, the SDK files are all cached locally on the host
// system. So first we ask for the file in the cached SDK,
// then we attempt to get a shared module for the right architecture
// with the right UUID.
const FileSpec &platform_file = module_spec.GetFileSpec();
FileSpec local_file;
const UUID *module_uuid_ptr = module_spec.GetUUIDPtr();
Error error (GetSymbolFile (platform_file, module_uuid_ptr, local_file));
if (error.Success())
{
error = ResolveExecutable (local_file, module_spec.GetArchitecture(), module_sp, NULL);
if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
{
//printf ("found in user specified SDK\n");
error.Clear();
return error;
}
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
{
FileSpec local_file;
const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
// Try the last SDK index if it is set as most files from an SDK
// will tend to be valid in that same SDK.
if (m_last_module_sdk_idx < num_sdk_infos)
{
if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, local_file))
{
//printf ("sdk[%u] last: '%s'\n", m_last_module_sdk_idx, local_file.GetPath().c_str());
module_sp.reset();
error = ResolveExecutable (local_file,
module_spec.GetArchitecture(),
module_sp,
NULL);
if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
{
//printf ("sdk[%u] last found\n", m_last_module_sdk_idx);
error.Clear();
return error;
}
}
}
// First try for an exact match of major, minor and update
for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
{
if (m_last_module_sdk_idx == sdk_idx)
{
// Skip the last module SDK index if we already searched
// it above
continue;
}
if (GetFileInSDK (platform_file_path, sdk_idx, local_file))
{
//printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
error = ResolveExecutable (local_file,
module_spec.GetArchitecture(),
module_sp,
NULL);
if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
{
// Remember the index of the last SDK that we found a file
// in in case the wrong SDK was selected.
m_last_module_sdk_idx = sdk_idx;
//printf ("sdk[%u]: found (setting last to %u)\n", sdk_idx, m_last_module_sdk_idx);
error.Clear();
return error;
}
}
}
}
// Not the module we are looking for... Nothing to see here...
module_sp.reset();
}
else
{
// This may not be an SDK-related module. Try whether we can bring in the thing to our local cache.
error = GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
if (error.Success())
return error;
else
error.Clear(); // Clear the error and fall-through.
}
const bool always_create = false;
error = ModuleList::GetSharedModule (module_spec,
module_sp,
module_search_paths_ptr,
old_module_sp_ptr,
did_create_ptr,
//.........这里部分代码省略.........