27 void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
45 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded added "
46 "--sysroot SDK directory %s",
54 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded Got "
55 "DeviceSupport directory %s",
58 if (device_support_dir) {
59 const bool find_directories =
true;
60 const bool find_files =
false;
61 const bool find_other =
false;
67 &builtin_sdk_directory_infos);
73 for (
const auto &sdk_directory_info : builtin_sdk_directory_infos) {
74 sdk_symbols_symlink_fspec = sdk_directory_info.directory;
80 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
81 "added builtin SDK directory %s",
82 sdk_symbols_symlink_fspec.
GetPath().c_str());
89 std::string local_sdk_cache_str =
"~/Library/Developer/Xcode/";
90 local_sdk_cache_str += std::string(dirname);
91 FileSpec local_sdk_cache(local_sdk_cache_str.c_str());
96 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
97 "searching %s for additional SDKs",
98 local_sdk_cache.
GetPath().c_str());
101 if (local_sdk_cache.
GetPath(path,
sizeof(path))) {
103 path, find_directories, find_files, find_other,
108 for (uint32_t i = num_installed; i < num_sdk_infos; ++i) {
112 "PlatformDarwinDevice::"
113 "UpdateSDKDirectoryInfosIfNeeded "
114 "user SDK directory %s",
121 const char *addtional_platform_dirs = getenv(
"PLATFORM_SDK_DIRECTORY");
122 if (addtional_platform_dirs) {
125 addtional_platform_dirs, find_directories, find_files, find_other,
127 &env_var_sdk_directory_infos);
129 for (
const auto &sdk_directory_info : env_var_sdk_directory_infos) {
130 sdk_symbols_symlink_fspec = sdk_directory_info.directory;
136 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
137 "added env var SDK directory %s",
138 sdk_symbols_symlink_fspec.
GetPath().c_str());
153 std::vector<bool> check_sdk_info(num_sdk_infos,
true);
161 build.assign(*os_build_str);
166 if (!build.empty()) {
167 for (i = 0; i < num_sdk_infos; ++i)
169 llvm::StringRef(build);
175 if (!version.empty()) {
178 for (i = 0; i < num_sdk_infos; ++i) {
179 if (check_sdk_info[i]) {
185 for (i = 0; i < num_sdk_infos; ++i) {
186 if (check_sdk_info[i]) {
188 version.getMajor() &&
190 version.getMinor()) {
196 for (i = 0; i < num_sdk_infos; ++i) {
197 if (check_sdk_info[i]) {
199 version.getMajor()) {
205 }
else if (!build.empty()) {
207 for (i = 0; i < num_sdk_infos; ++i)
208 if (check_sdk_info[i])
219 auto max = std::max_element(
222 return a.version < b.version;
231 std::string platform_dir =
234 if (
FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
258 if (sdk_dir_info ==
nullptr)
285 return llvm::sys::fs::create_directory(module_cache_folder.
GetPath());
291 const FileSpec &module_cache_spec) {
304 "[%s] Trying to find module %s/%s - platform path %s/%s symbol "
306 (
IsHost() ?
"host" :
"remote"),
318 old_modules, did_create_ptr);
336 "[%s] module %s was found in Device Support "
338 (
IsHost() ?
"host" :
"remote"),
353 if (!cache_path.empty()) {
355 cache_path.append(module_path);
356 FileSpec module_cache_spec(cache_path);
367 LLDB_LOGF(log,
"[%s] module %s/%s was rsynced and is now there",
368 (
IsHost() ?
"host" :
"remote"),
373 module_sp = std::make_shared<Module>(local_spec);
374 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
386 auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.
GetPath());
388 return Status(MD5.getError());
391 bool requires_transfer =
true;
392 llvm::ErrorOr<llvm::MD5::MD5Result> remote_md5 =
394 if (std::error_code ec = remote_md5.getError())
395 LLDB_LOG(log,
"couldn't get md5 sum from remote: {0}",
398 requires_transfer = *MD5 != *remote_md5;
399 if (requires_transfer) {
402 "[%s] module %s/%s needs to be replaced from remote copy",
403 (
IsHost() ?
"host" :
"remote"),
414 module_sp = std::make_shared<Module>(local_spec);
415 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
417 LLDB_LOGF(log,
"[%s] module %s/%s was found in the cache",
418 (
IsHost() ?
"host" :
"remote"),
425 LLDB_LOGF(log,
"[%s] module %s/%s needs to come in remotely",
426 (
IsHost() ?
"host" :
"remote"),
434 LLDB_LOGF(log,
"[%s] module %s/%s is now cached and fine",
435 (
IsHost() ?
"host" :
"remote"),
439 module_sp = std::make_shared<Module>(local_spec);
440 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
#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 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()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static Status GetSharedModule(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr, bool invoke_locate_callback=true)
FileSpec & GetPlatformFileSpec()
ArchSpec & GetArchitecture()
FileSpec & GetSymbolFileSpec()
A plug-in interface definition class for debugging a process.
static Status FromErrorString(const char *str)
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