39 if (g_initialize_count++ == 0) {
40 #if defined(__APPLE__) 42 default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
43 Platform::SetHostPlatform(default_platform_sp);
52 if (g_initialize_count > 0) {
53 if (--g_initialize_count == 0) {
64 const char *arch_name;
70 const char *triple_cstr =
71 arch ? arch->
GetTriple().getTriple().c_str() :
"<null>";
73 log->
Printf(
"PlatformMacOSX::%s(force=%s, arch={%s,%s})", __FUNCTION__,
74 force ?
"true" :
"false", arch_name, triple_cstr);
79 const bool is_host =
false;
82 if (!create && arch && arch->
IsValid()) {
83 const llvm::Triple &triple = arch->
GetTriple();
84 switch (triple.getVendor()) {
85 case llvm::Triple::Apple:
89 #if defined(__APPLE__) 92 case llvm::Triple::UnknownVendor:
101 switch (triple.getOS()) {
102 case llvm::Triple::Darwin:
104 case llvm::Triple::MacOSX:
106 #if defined(__APPLE__) 109 case llvm::Triple::UnknownOS:
121 log->
Printf(
"PlatformMacOSX::%s() creating platform", __FUNCTION__);
126 log->
Printf(
"PlatformMacOSX::%s() aborting creation of platform",
134 static ConstString g_host_name(Platform::GetHostPlatformName());
138 return g_remote_name;
144 return "Local Mac OS X user platform plug-in.";
146 return "Remote Mac OS X user platform plug-in.";
161 ObjectFile *objfile = exe_module_sp->GetObjectFile();
163 std::string xcode_contents_path;
164 std::string default_xcode_sdk;
168 fspec = HostInfo::GetShlibDir();
171 xcode_contents_path = fspec.
GetPath();
172 size_t pos = xcode_contents_path.find(
"/Xcode.app/Contents/");
173 if (pos != std::string::npos) {
176 xcode_contents_path.erase(pos + strlen(
"/Xcode.app/Contents/"));
178 xcode_contents_path.clear();
183 const char *command =
"xcrun -sdk macosx --show-sdk-path";
192 std::chrono::seconds(3));
193 if (status == 0 && !output.empty()) {
194 size_t first_non_newline = output.find_last_not_of(
"\r\n");
195 if (first_non_newline != std::string::npos)
196 output.erase(first_non_newline + 1);
197 default_xcode_sdk = output;
199 pos = default_xcode_sdk.find(
"/Xcode.app/Contents/");
200 if (pos != std::string::npos)
201 xcode_contents_path = default_xcode_sdk.substr(
202 0, pos + strlen(
"/Xcode.app/Contents/"));
207 if (!xcode_contents_path.empty()) {
209 sdk_path.
Printf(
"%sDeveloper/Platforms/MacOSX.platform/Developer/" 210 "SDKs/MacOSX%u.%u.sdk",
211 xcode_contents_path.c_str(), versions[0],
214 if (FileSystem::Instance().Exists(fspec))
218 if (!default_xcode_sdk.empty()) {
219 fspec.
SetFile(default_xcode_sdk, FileSpec::Style::native);
220 if (FileSystem::Instance().Exists(fspec))
230 const UUID *uuid_ptr,
239 local_file = platform_file;
248 std::string local_os_build;
249 #if !defined(__linux__) 250 HostInfo::GetOSBuildString(local_os_build);
252 std::string remote_os_build;
254 if (local_os_build == remote_os_build) {
256 local_file = platform_file;
261 std::string module_path(platform_file.
GetPath());
262 cache_path.append(module_path);
263 FileSpec module_cache_spec(cache_path);
264 if (FileSystem::Instance().Exists(module_cache_spec)) {
265 local_file = module_cache_spec;
273 llvm::sys::fs::create_directory(module_cache_folder.
GetPath()));
276 err =
GetFile(platform_file, module_cache_spec);
279 if (FileSystem::Instance().Exists(module_cache_spec)) {
280 local_file = module_cache_spec;
283 return Status(
"unable to obtain valid module file");
286 local_file = platform_file;
292 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) 301 lldb::ModuleSP &module_sp,
302 const lldb_private::FileSpecList *module_search_paths_ptr,
303 lldb::ModuleSP *old_module_sp_ptr,
bool *did_create_ptr) {
305 module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
310 ArchSpec::eCore_x86_64_x86_64h) {
311 ObjectFile *objfile = module_sp->GetObjectFile();
312 if (objfile == NULL) {
316 lldb::ModuleSP x86_64_module_sp;
317 lldb::ModuleSP old_x86_64_module_sp;
318 bool did_create =
false;
320 module_spec_x86_64, x86_64_module_sp, module_search_paths_ptr,
321 &old_x86_64_module_sp, &did_create);
322 if (x86_64_module_sp && x86_64_module_sp->GetObjectFile()) {
323 module_sp = x86_64_module_sp;
324 if (old_module_sp_ptr)
325 *old_module_sp_ptr = old_x86_64_module_sp;
327 *did_create_ptr = did_create;
Enumerations for broadcasting.
An architecture specification class.
A plug-in interface definition class for object file parsers.
#define LIBLLDB_LOG_PLATFORM
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool TripleVendorWasSpecified() const
FileSpec CopyByRemovingLastPathComponent() const
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Log * GetLogIfAllCategoriesSet(uint32_t mask)
llvm::StringRef GetString() const
A plug-in interface definition class for debugging a process.
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions)
Get the SDK OS version this object file was built with.
ArchSpec & GetArchitecture()
A uniqued constant string class.
bool Fail() const
Test for error condition.
bool TripleOSWasSpecified() const
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Printf(const char *format,...) __attribute__((format(printf