ConstString PlatformWindows::GetFullNameForDylib(ConstString basename) { if (basename.IsEmpty()) return basename; StreamString stream; stream.Printf("%s.dll", basename.GetCString()); return ConstString(stream.GetData()); }
ConstString PlatformLinux::GetFullNameForDylib (ConstString basename) { if (basename.IsEmpty()) return basename; StreamString stream; stream.Printf("lib%s.so", basename.GetCString()); return ConstString(stream.GetData()); }
void SwiftPersistentExpressionState::SwiftDeclMap::AddDecl (swift::ValueDecl *value_decl, bool check_existing, const ConstString &alias) { std::string name_str; if (alias.IsEmpty()) { name_str = (value_decl->getName().str()); } else { name_str.assign(alias.GetCString()); } if (!check_existing) { m_swift_decls.insert(std::make_pair(name_str, value_decl)); return; } SwiftDeclMapTy::iterator map_end = m_swift_decls.end(); std::pair<SwiftDeclMapTy::iterator, SwiftDeclMapTy::iterator> found_range = m_swift_decls.equal_range(name_str); if (found_range.first == map_end) { m_swift_decls.insert(std::make_pair(name_str, value_decl)); return; } else { SwiftDeclMapTy::iterator cur_item; bool done = false; for (cur_item = found_range.first; !done && cur_item != found_range.second; cur_item++) { swift::ValueDecl *cur_decl = (*cur_item).second; if (DeclsAreEquivalent(cur_decl, value_decl)) { m_swift_decls.erase (cur_item); break; } } m_swift_decls.insert(std::make_pair(name_str, value_decl)); } }
Error PlatformRemoteAppleWatch::GetSharedModule( const ModuleSpec &module_spec, lldb_private::Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { // For Apple Watch, 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(); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE); Error error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) { ModuleSpec platform_module_spec(module_spec); UpdateSDKDirectoryInfosIfNeeded(); const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); // If we are connected we migth be able to correctly deduce the SDK // directory // using the OS build. const uint32_t connected_sdk_idx = GetConnectedSDKIndex(); if (connected_sdk_idx < num_sdk_infos) { if (log) { log->Printf("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx] .directory.GetPath() .c_str()); } if (GetFileInSDK(platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); error = ResolveExecutable(platform_module_spec, module_sp, nullptr); if (module_sp) { m_last_module_sdk_idx = connected_sdk_idx; error.Clear(); return error; } } } // 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 (log) { log->Printf("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx] .directory.GetPath() .c_str()); } if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); error = ResolveExecutable(platform_module_spec, module_sp, nullptr); if (module_sp) { 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 (log) { log->Printf("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); } if (GetFileInSDK(platform_file_path, sdk_idx, platform_module_spec.GetFileSpec())) { // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str()); error = ResolveExecutable(platform_module_spec, module_sp, nullptr); if (module_sp) { // 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; error.Clear(); return error; } } } } // Not the module we are looking for... Nothing to see here... module_sp.reset(); // 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; // See if the file is present in any of the module_search_paths_ptr // directories. if (!module_sp && module_search_paths_ptr && platform_file) { // create a vector of all the file / directory names in platform_file // e.g. this might be // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation // // We'll need to look in the module_search_paths_ptr directories for // both "UIFoundation" and "UIFoundation.framework" -- most likely the // latter will be the one we find there. FileSpec platform_pull_apart(platform_file); std::vector<std::string> path_parts; ConstString unix_root_dir("/"); while (true) { ConstString part = platform_pull_apart.GetLastPathComponent(); platform_pull_apart.RemoveLastPathComponent(); if (part.IsEmpty() || part == unix_root_dir) break; path_parts.push_back(part.AsCString()); } const size_t path_parts_size = path_parts.size(); size_t num_module_search_paths = module_search_paths_ptr->GetSize(); for (size_t i = 0; i < num_module_search_paths; ++i) { // Create a new FileSpec with this module_search_paths_ptr // plus just the filename ("UIFoundation"), then the parent // dir plus filename ("UIFoundation.framework/UIFoundation") // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo") for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) { FileSpec path_to_try(module_search_paths_ptr->GetFileSpecAtIndex(i)); // Add the components backwards. For // .../PrivateFrameworks/UIFoundation.framework/UIFoundation // path_parts is // [0] UIFoundation // [1] UIFoundation.framework // [2] PrivateFrameworks // // and if 'j' is 2, we want to append path_parts[1] and then // path_parts[0], aka // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr // path. for (int k = j; k >= 0; --k) { path_to_try.AppendPathComponent(path_parts[k]); } if (path_to_try.Exists()) { ModuleSpec new_module_spec(module_spec); new_module_spec.GetFileSpec() = path_to_try; Error new_error(Platform::GetSharedModule( new_module_spec, process, module_sp, NULL, old_module_sp_ptr, did_create_ptr)); if (module_sp) { module_sp->SetPlatformFileSpec(path_to_try); return new_error; } } } } } 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; }
bool ObjCLanguage::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint, std::string& prefix, std::string& suffix) { static ConstString g_CFBag("CFBag"); static ConstString g_CFBinaryHeap("CFBinaryHeap"); static ConstString g_NSNumberChar("NSNumber:char"); static ConstString g_NSNumberShort("NSNumber:short"); static ConstString g_NSNumberInt("NSNumber:int"); static ConstString g_NSNumberLong("NSNumber:long"); static ConstString g_NSNumberFloat("NSNumber:float"); static ConstString g_NSNumberDouble("NSNumber:double"); static ConstString g_NSData("NSData"); static ConstString g_NSArray("NSArray"); static ConstString g_NSString("NSString"); static ConstString g_NSStringStar("NSString*"); if (type_hint.IsEmpty()) return false; prefix.clear(); suffix.clear(); if (type_hint == g_CFBag || type_hint == g_CFBinaryHeap) { prefix = "@"; return true; } if (type_hint == g_NSNumberChar) { prefix = "(char)"; return true; } if (type_hint == g_NSNumberShort) { prefix = "(short)"; return true; } if (type_hint == g_NSNumberInt) { prefix = "(int)"; return true; } if (type_hint == g_NSNumberLong) { prefix = "(long)"; return true; } if (type_hint == g_NSNumberFloat) { prefix = "(float)"; return true; } if (type_hint == g_NSNumberDouble) { prefix = "(double)"; return true; } if (type_hint == g_NSData || type_hint == g_NSArray) { prefix = "@\""; suffix = "\""; return true; } if (type_hint == g_NSString || type_hint == g_NSStringStar) { prefix = "@"; return true; } return false; }