27 void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
28 ((std::vector<FileSpec> *)baton)->push_back(
FileSpec(path));
33 llvm::StringRef dir, llvm::StringRef log_msg_descriptor) {
35 const bool find_directories =
true;
36 const bool find_files =
false;
37 const bool find_other =
false;
38 std::vector<FileSpec> shared_cache_expanded_directories;
40 dir, find_directories, find_files, find_other,
42 &shared_cache_expanded_directories);
48 for (
const FileSpec &sc_directory : shared_cache_expanded_directories) {
49 FileSpec sc_directory_symbols = sc_directory;
53 sc_directory.GetFilename().GetStringRef());
56 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
58 log_msg_descriptor.str().c_str(),
59 sc_directory.GetPath().c_str());
64 std::vector<FileSpec> subdirs;
66 sc_directory.GetPath().c_str(), find_directories, find_files,
68 for (
const FileSpec &subdir : subdirs) {
69 FileSpec subdir_directory_symbols = subdir;
73 sc_directory.GetFilename().GetStringRef());
76 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
78 log_msg_descriptor.str().c_str(), subdir.GetPath().c_str());
95 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded Got "
96 "DeviceSupport directory %s",
98 if (device_support_dir) {
103 std::string local_sdk_cache_str =
"~/Library/Developer/Xcode/";
104 local_sdk_cache_str += std::string(dirname);
105 FileSpec local_sdk_cache(local_sdk_cache_str.c_str());
109 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
110 "searching %s for additional SDKs",
111 local_sdk_cache.
GetPath().c_str());
113 "system developer dir directory");
116 const char *addtional_platform_dirs = getenv(
"PLATFORM_SDK_DIRECTORY");
117 if (addtional_platform_dirs)
119 "env var SDK directory");
130 std::vector<bool> check_sdk_info(num_sdk_infos,
true);
138 build.assign(*os_build_str);
143 if (!build.empty()) {
144 for (i = 0; i < num_sdk_infos; ++i)
146 llvm::StringRef(build);
152 if (!version.empty()) {
155 for (i = 0; i < num_sdk_infos; ++i) {
156 if (check_sdk_info[i]) {
162 for (i = 0; i < num_sdk_infos; ++i) {
163 if (check_sdk_info[i]) {
165 version.getMajor() &&
167 version.getMinor()) {
173 for (i = 0; i < num_sdk_infos; ++i) {
174 if (check_sdk_info[i]) {
176 version.getMajor()) {
182 }
else if (!build.empty()) {
184 for (i = 0; i < num_sdk_infos; ++i)
185 if (check_sdk_info[i])
196 auto max = std::max_element(
199 return a.version < b.version;
208 std::string platform_dir =
211 if (
FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
235 if (sdk_dir_info ==
nullptr)
262 return llvm::sys::fs::create_directory(module_cache_folder.
GetPath());
268 const FileSpec &module_cache_spec) {
281 "[%s] Trying to find module %s/%s - platform path %s/%s symbol "
283 (
IsHost() ?
"host" :
"remote"),
295 old_modules, did_create_ptr);
313 "[%s] module %s was found in Device Support "
315 (
IsHost() ?
"host" :
"remote"),
330 if (!cache_path.empty()) {
332 cache_path.append(module_path);
333 FileSpec module_cache_spec(cache_path);
344 LLDB_LOGF(log,
"[%s] module %s/%s was rsynced and is now there",
345 (
IsHost() ?
"host" :
"remote"),
350 module_sp = std::make_shared<Module>(local_spec);
351 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
363 auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.
GetPath());
365 return Status(MD5.getError());
368 bool requires_transfer =
true;
369 llvm::ErrorOr<llvm::MD5::MD5Result> remote_md5 =
371 if (std::error_code ec = remote_md5.getError())
372 LLDB_LOG(log,
"couldn't get md5 sum from remote: {0}",
375 requires_transfer = *MD5 != *remote_md5;
376 if (requires_transfer) {
379 "[%s] module %s/%s needs to be replaced from remote copy",
380 (
IsHost() ?
"host" :
"remote"),
391 module_sp = std::make_shared<Module>(local_spec);
392 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
394 LLDB_LOGF(log,
"[%s] module %s/%s was found in the cache",
395 (
IsHost() ?
"host" :
"remote"),
402 LLDB_LOGF(log,
"[%s] module %s/%s needs to come in remotely",
403 (
IsHost() ?
"host" :
"remote"),
411 LLDB_LOGF(log,
"[%s] module %s/%s is now cached and fine",
412 (
IsHost() ?
"host" :
"remote"),
416 module_sp = std::make_shared<Module>(local_spec);
417 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