26 void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
44 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded added "
45 "--sysroot SDK directory %s",
53 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded Got "
54 "DeviceSupport directory %s",
57 if (device_support_dir) {
58 const bool find_directories =
true;
59 const bool find_files =
false;
60 const bool find_other =
false;
66 &builtin_sdk_directory_infos);
72 for (
const auto &sdk_directory_info : builtin_sdk_directory_infos) {
73 sdk_symbols_symlink_fspec = sdk_directory_info.directory;
79 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
80 "added builtin SDK directory %s",
81 sdk_symbols_symlink_fspec.
GetPath().c_str());
88 std::string local_sdk_cache_str =
"~/Library/Developer/Xcode/";
89 local_sdk_cache_str += std::string(dirname);
90 FileSpec local_sdk_cache(local_sdk_cache_str.c_str());
95 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
96 "searching %s for additional SDKs",
97 local_sdk_cache.
GetPath().c_str());
100 if (local_sdk_cache.
GetPath(path,
sizeof(path))) {
102 path, find_directories, find_files, find_other,
107 for (uint32_t i = num_installed; i < num_sdk_infos; ++i) {
111 "PlatformDarwinDevice::"
112 "UpdateSDKDirectoryInfosIfNeeded "
113 "user SDK directory %s",
120 const char *addtional_platform_dirs = getenv(
"PLATFORM_SDK_DIRECTORY");
121 if (addtional_platform_dirs) {
124 addtional_platform_dirs, find_directories, find_files, find_other,
126 &env_var_sdk_directory_infos);
128 for (
const auto &sdk_directory_info : env_var_sdk_directory_infos) {
129 sdk_symbols_symlink_fspec = sdk_directory_info.directory;
135 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
136 "added env var SDK directory %s",
137 sdk_symbols_symlink_fspec.
GetPath().c_str());
152 std::vector<bool> check_sdk_info(num_sdk_infos,
true);
160 build.assign(*os_build_str);
165 if (!build.empty()) {
166 for (i = 0; i < num_sdk_infos; ++i)
168 llvm::StringRef(build);
174 if (!version.empty()) {
177 for (i = 0; i < num_sdk_infos; ++i) {
178 if (check_sdk_info[i]) {
184 for (i = 0; i < num_sdk_infos; ++i) {
185 if (check_sdk_info[i]) {
187 version.getMajor() &&
189 version.getMinor()) {
195 for (i = 0; i < num_sdk_infos; ++i) {
196 if (check_sdk_info[i]) {
198 version.getMajor()) {
204 }
else if (!build.empty()) {
206 for (i = 0; i < num_sdk_infos; ++i)
207 if (check_sdk_info[i])
218 auto max = std::max_element(
221 return a.version < b.version;
230 std::string platform_dir =
233 if (
FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
257 if (sdk_dir_info ==
nullptr)
284 return llvm::sys::fs::create_directory(module_cache_folder.
GetPath());
290 const FileSpec &module_cache_spec) {
303 "[%s] Trying to find module %s/%s - platform path %s/%s symbol "
305 (
IsHost() ?
"host" :
"remote"),
327 if (image_info.
uuid &&
332 module_search_paths_ptr, old_modules,
335 LLDB_LOGF(log,
"[%s] module %s was found in the in-memory shared cache",
336 (
IsHost() ?
"host" :
"remote"),
352 module_search_paths_ptr, old_modules,
356 "[%s] module %s was found in Device Support "
358 (
IsHost() ?
"host" :
"remote"),
367 module_search_paths_ptr, old_modules,
375 if (!cache_path.empty()) {
377 cache_path.append(module_path);
378 FileSpec module_cache_spec(cache_path);
389 LLDB_LOGF(log,
"[%s] module %s/%s was rsynced and is now there",
390 (
IsHost() ?
"host" :
"remote"),
395 module_sp = std::make_shared<Module>(local_spec);
396 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
408 auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.
GetPath());
410 return Status(MD5.getError());
413 bool requires_transfer =
true;
414 llvm::ErrorOr<llvm::MD5::MD5Result> remote_md5 =
416 if (std::error_code ec = remote_md5.getError())
417 LLDB_LOG(log,
"couldn't get md5 sum from remote: {0}",
420 requires_transfer = *MD5 != *remote_md5;
421 if (requires_transfer) {
424 "[%s] module %s/%s needs to be replaced from remote copy",
425 (
IsHost() ?
"host" :
"remote"),
436 module_sp = std::make_shared<Module>(local_spec);
437 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
439 LLDB_LOGF(log,
"[%s] module %s/%s was found in the cache",
440 (
IsHost() ?
"host" :
"remote"),
447 LLDB_LOGF(log,
"[%s] module %s/%s needs to come in remotely",
448 (
IsHost() ?
"host" :
"remote"),
456 LLDB_LOGF(log,
"[%s] module %s/%s is now cached and fine",
457 (
IsHost() ?
"host" :
"remote"),
461 module_sp = std::make_shared<Module>(local_spec);
462 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
465 return Status(
"unable to obtain valid module file");
467 return Status(
"no cache path");
469 return Status(
"unable to resolve module");
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
void AppendPathComponent(llvm::StringRef component)
const ConstString & GetFilename() const
Filename string const get accessor.
const ConstString & GetDirectory() const
Directory string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
FileSpec CopyByRemovingLastPathComponent() const
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
void EnumerateDirectory(llvm::Twine path, bool find_directories, bool find_files, bool find_other, EnumerateDirectoryCallbackType callback, void *callback_baton)
@ eEnumerateDirectoryResultNext
Enumerate next entry in the current directory.
static FileSystem & Instance()
static Status GetSharedModule(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr, bool always_create=false)
FileSpec & GetPlatformFileSpec()
ArchSpec & GetArchitecture()
FileSpec & GetSymbolFileSpec()
bool Fail() const
Test for error condition.
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::Module > ModuleSP
lldb::DataBufferSP data_sp