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) {
101 std::string local_sdk_cache_str =
"~/Library/Developer/Xcode/";
102 local_sdk_cache_str += std::string(dirname);
103 FileSpec local_sdk_cache(local_sdk_cache_str.c_str());
107 "PlatformDarwinDevice::UpdateSDKDirectoryInfosIfNeeded "
108 "searching %s for additional SDKs",
109 local_sdk_cache.
GetPath().c_str());
111 "system developer dir directory");
114 const char *addtional_platform_dirs = getenv(
"PLATFORM_SDK_DIRECTORY");
115 if (addtional_platform_dirs)
117 "env var SDK directory");
128 std::vector<bool> check_sdk_info(num_sdk_infos,
true);
136 build.assign(*os_build_str);
141 if (!build.empty()) {
142 for (i = 0; i < num_sdk_infos; ++i)
144 llvm::StringRef(build);
150 if (!version.empty()) {
153 for (i = 0; i < num_sdk_infos; ++i) {
154 if (check_sdk_info[i]) {
160 for (i = 0; i < num_sdk_infos; ++i) {
161 if (check_sdk_info[i]) {
163 version.getMajor() &&
165 version.getMinor()) {
171 for (i = 0; i < num_sdk_infos; ++i) {
172 if (check_sdk_info[i]) {
174 version.getMajor()) {
180 }
else if (!build.empty()) {
182 for (i = 0; i < num_sdk_infos; ++i)
183 if (check_sdk_info[i])
194 auto max = std::max_element(
197 return a.version < b.version;
206 std::string platform_dir =
209 if (
FileSpec fspec = HostInfo::GetXcodeDeveloperDirectory()) {
233 if (sdk_dir_info ==
nullptr)
260 return llvm::sys::fs::create_directory(module_cache_folder.
GetPath());
266 const FileSpec &module_cache_spec) {
279 "[{0}] Trying to find module {1}/{2} - platform path {3}/{4} symbol "
281 (
IsHost() ?
"host" :
"remote"),
293 old_modules, did_create_ptr);
311 "[%s] module %s was found in Device Support "
313 (
IsHost() ?
"host" :
"remote"),
328 if (!cache_path.empty()) {
330 cache_path.append(module_path);
331 FileSpec module_cache_spec(cache_path);
342 LLDB_LOG(log,
"[{0}] module {1}/{2} was rsynced and is now there",
343 (
IsHost() ?
"host" :
"remote"),
348 module_sp = std::make_shared<Module>(local_spec);
349 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
361 auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.
GetPath());
363 return Status(MD5.getError());
366 bool requires_transfer =
true;
367 llvm::ErrorOr<llvm::MD5::MD5Result> remote_md5 =
369 if (std::error_code ec = remote_md5.getError())
370 LLDB_LOG(log,
"couldn't get md5 sum from remote: {0}",
373 requires_transfer = *MD5 != *remote_md5;
374 if (requires_transfer) {
378 "[{0}] module {1}/{2} needs to be replaced from remote copy",
379 (
IsHost() ?
"host" :
"remote"),
390 module_sp = std::make_shared<Module>(local_spec);
391 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
393 LLDB_LOG(log,
"[{0}] module {1}/{2} was found in the cache",
394 (
IsHost() ?
"host" :
"remote"),
401 LLDB_LOG(log,
"[{0}] module {1}/{2} needs to come in remotely",
402 (
IsHost() ?
"host" :
"remote"),
410 LLDB_LOG(log,
"[{0}] module {1}/{2} is now cached and fine",
411 (
IsHost() ?
"host" :
"remote"),
415 module_sp = std::make_shared<Module>(local_spec);
416 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)
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