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;
55 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
57 log_msg_descriptor.str().c_str(),
58 sc_directory.GetPath().c_str());
63 std::vector<FileSpec> subdirs;
65 sc_directory.GetPath().c_str(), find_directories, find_files,
67 for (
const FileSpec &subdir : subdirs) {
68 FileSpec subdir_directory_symbols = subdir;
74 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
76 log_msg_descriptor.str().c_str(), subdir.GetPath().c_str());
93 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded Got "
94 "DeviceSupport directory %s",
96 if (device_support_dir) {
102 std::string local_sdk_cache_str =
"~/Library/Developer/Xcode/";
103 local_sdk_cache_str += std::string(dirname);
104 FileSpec local_sdk_cache(local_sdk_cache_str.c_str());
108 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
109 "searching %s for additional SDKs",
110 local_sdk_cache.
GetPath().c_str());
112 "system developer dir directory");
117 const char *addtional_platform_dirs = getenv(
"PLATFORM_SDK_DIRECTORY");
118 if (addtional_platform_dirs)
120 "env var SDK directory");
131 std::vector<bool> check_sdk_info(num_sdk_infos,
true);
139 build.assign(*os_build_str);
144 if (!build.empty()) {
145 for (i = 0; i < num_sdk_infos; ++i)
147 llvm::StringRef(build);
153 if (!version.empty()) {
156 for (i = 0; i < num_sdk_infos; ++i) {
157 if (check_sdk_info[i]) {
163 for (i = 0; i < num_sdk_infos; ++i) {
164 if (check_sdk_info[i]) {
166 version.getMajor() &&
168 version.getMinor()) {
174 for (i = 0; i < num_sdk_infos; ++i) {
175 if (check_sdk_info[i]) {
177 version.getMajor()) {
183 }
else if (!build.empty()) {
185 for (i = 0; i < num_sdk_infos; ++i)
186 if (check_sdk_info[i])
197 auto max = std::max_element(
200 return a.version < b.version;
209 std::string platform_dir =
212 if (
FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
236 if (sdk_dir_info ==
nullptr)
263 return llvm::sys::fs::create_directory(module_cache_folder.
GetPath());
269 const FileSpec &module_cache_spec) {
282 "[{0}] Trying to find module {1}/{2} - platform path {3}/{4} symbol "
284 (
IsHost() ?
"host" :
"remote"),
314 "[%s] module %s was found in Device Support "
316 (
IsHost() ?
"host" :
"remote"),
331 if (!cache_path.empty()) {
333 cache_path.append(module_path);
334 FileSpec module_cache_spec(cache_path);
345 LLDB_LOG(log,
"[{0}] module {1}/{2} was rsynced and is now there",
346 (
IsHost() ?
"host" :
"remote"),
351 module_sp = std::make_shared<Module>(local_spec);
352 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
364 auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.
GetPath());
366 return Status(MD5.getError());
369 bool requires_transfer =
true;
370 llvm::ErrorOr<llvm::MD5::MD5Result> remote_md5 =
372 if (std::error_code ec = remote_md5.getError())
373 LLDB_LOG(log,
"couldn't get md5 sum from remote: {0}",
376 requires_transfer = *MD5 != *remote_md5;
377 if (requires_transfer) {
381 "[{0}] module {1}/{2} needs to be replaced from remote copy",
382 (
IsHost() ?
"host" :
"remote"),
393 module_sp = std::make_shared<Module>(local_spec);
394 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
396 LLDB_LOG(log,
"[{0}] module {1}/{2} was found in the cache",
397 (
IsHost() ?
"host" :
"remote"),
404 LLDB_LOG(log,
"[{0}] module {1}/{2} needs to come in remotely",
405 (
IsHost() ?
"host" :
"remote"),
413 LLDB_LOG(log,
"[{0}] module {1}/{2} is now cached and fine",
414 (
IsHost() ?
"host" :
"remote"),
418 module_sp = std::make_shared<Module>(local_spec);
419 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,...)
void AppendPathComponent(llvm::StringRef component)
llvm::StringRef GetFilename() const
Filename string const get accessor.
llvm::StringRef 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, bool invoke_symbol_locators=true)
FileSpec & GetPlatformFileSpec()
ArchSpec & GetArchitecture()
FileSpec & GetSymbolFileSpec()
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