LLDB  mainline
HostInfoMacOSX.mm
Go to the documentation of this file.
1 //===-- HostInfoMacOSX.mm ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Host/FileSystem.h"
10 #include "lldb/Host/Host.h"
11 #include "lldb/Host/HostInfo.h"
13 #include "lldb/Utility/Args.h"
14 #include "lldb/Utility/LLDBLog.h"
15 #include "lldb/Utility/Log.h"
16 #include "lldb/Utility/Timer.h"
18 
19 #include "llvm/ADT/SmallString.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/Support/FileSystem.h"
22 #include "llvm/Support/Path.h"
23 #include "llvm/Support/raw_ostream.h"
24 
25 // C++ Includes
26 #include <string>
27 
28 // C inclues
29 #include <cstdlib>
30 #include <sys/sysctl.h>
31 #include <sys/syslimits.h>
32 #include <sys/types.h>
33 
34 // Objective-C/C++ includes
35 #include <CoreFoundation/CoreFoundation.h>
36 #include <Foundation/Foundation.h>
37 #include <mach-o/dyld.h>
38 #if __has_include(<mach-o/dyld_introspection.h>)
39 #include <mach-o/dyld_introspection.h>
40 #define SDK_HAS_NEW_DYLD_INTROSPECTION_SPIS
41 #endif
42 #include <objc/objc-auto.h>
43 
44 // These are needed when compiling on systems
45 // that do not yet have these definitions
46 #include <AvailabilityMacros.h>
47 #ifndef CPU_SUBTYPE_X86_64_H
48 #define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t)8)
49 #endif
50 #ifndef CPU_TYPE_ARM64
51 #define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
52 #endif
53 
54 #ifndef CPU_TYPE_ARM64_32
55 #define CPU_ARCH_ABI64_32 0x02000000
56 #define CPU_TYPE_ARM64_32 (CPU_TYPE_ARM | CPU_ARCH_ABI64_32)
57 #endif
58 
59 #include <TargetConditionals.h> // for TARGET_OS_TV, TARGET_OS_WATCH
60 
61 using namespace lldb_private;
62 
63 llvm::Optional<std::string> HostInfoMacOSX::GetOSBuildString() {
64  int mib[2] = {CTL_KERN, KERN_OSVERSION};
65  char cstr[PATH_MAX];
66  size_t cstr_len = sizeof(cstr);
67  if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0)
68  return std::string(cstr, cstr_len - 1);
69 
70  return llvm::None;
71 }
72 
73 static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
74  @autoreleasepool {
75  NSDictionary *version_info =
76  [NSDictionary dictionaryWithContentsOfFile:
77  @"/System/Library/CoreServices/SystemVersion.plist"];
78  NSString *version_value = [version_info objectForKey: Key];
79  const char *version_str = [version_value UTF8String];
80  version.tryParse(version_str);
81  }
82 }
83 
84 llvm::VersionTuple HostInfoMacOSX::GetOSVersion() {
85  static llvm::VersionTuple g_version;
86  if (g_version.empty())
87  ParseOSVersion(g_version, @"ProductVersion");
88  return g_version;
89 }
90 
92  static llvm::VersionTuple g_version;
93  if (g_version.empty())
94  ParseOSVersion(g_version, @"iOSSupportVersion");
95  return g_version;
96 }
97 
98 
100  static FileSpec g_program_filespec;
101  if (!g_program_filespec) {
102  char program_fullpath[PATH_MAX];
103  // If DST is NULL, then return the number of bytes needed.
104  uint32_t len = sizeof(program_fullpath);
105  int err = _NSGetExecutablePath(program_fullpath, &len);
106  if (err == 0)
107  g_program_filespec.SetFile(program_fullpath, FileSpec::Style::native);
108  else if (err == -1) {
109  char *large_program_fullpath = (char *)::malloc(len + 1);
110 
111  err = _NSGetExecutablePath(large_program_fullpath, &len);
112  if (err == 0)
113  g_program_filespec.SetFile(large_program_fullpath,
114  FileSpec::Style::native);
115 
116  ::free(large_program_fullpath);
117  }
118  }
119  return g_program_filespec;
120 }
121 
123  FileSpec lldb_file_spec = GetShlibDir();
124  if (!lldb_file_spec)
125  return false;
126 
127  std::string raw_path = lldb_file_spec.GetPath();
128 
129  size_t framework_pos = raw_path.find("LLDB.framework");
130  if (framework_pos != std::string::npos) {
131  framework_pos += strlen("LLDB.framework");
132 #if TARGET_OS_IPHONE
133  // Shallow bundle
134  raw_path.resize(framework_pos);
135 #else
136  // Normal bundle
137  raw_path.resize(framework_pos);
138  raw_path.append("/Resources");
139 #endif
140  } else {
141  // Find the bin path relative to the lib path where the cmake-based
142  // OS X .dylib lives. This is not going to work if the bin and lib
143  // dir are not both in the same dir.
144  //
145  // It is not going to work to do it by the executable path either,
146  // as in the case of a python script, the executable is python, not
147  // the lldb driver.
148  raw_path.append("/../bin");
149  FileSpec support_dir_spec(raw_path);
150  FileSystem::Instance().Resolve(support_dir_spec);
151  if (!FileSystem::Instance().IsDirectory(support_dir_spec)) {
152  Log *log = GetLog(LLDBLog::Host);
153  LLDB_LOGF(log, "HostInfoMacOSX::%s(): failed to find support directory",
154  __FUNCTION__);
155  return false;
156  }
157 
158  // Get normalization from support_dir_spec. Note the FileSpec resolve
159  // does not remove '..' in the path.
160  char *const dir_realpath =
161  realpath(support_dir_spec.GetPath().c_str(), NULL);
162  if (dir_realpath) {
163  raw_path = dir_realpath;
164  free(dir_realpath);
165  } else {
166  raw_path = support_dir_spec.GetPath();
167  }
168  }
169 
170  file_spec.GetDirectory().SetString(
171  llvm::StringRef(raw_path.c_str(), raw_path.size()));
172  return (bool)file_spec.GetDirectory();
173 }
174 
176  FileSpec lldb_file_spec = GetShlibDir();
177  if (!lldb_file_spec)
178  return false;
179 
180  std::string raw_path = lldb_file_spec.GetPath();
181 
182  size_t framework_pos = raw_path.find("LLDB.framework");
183  if (framework_pos != std::string::npos) {
184  framework_pos += strlen("LLDB.framework");
185  raw_path.resize(framework_pos);
186  raw_path.append("/Headers");
187  }
188  file_spec.GetDirectory().SetString(
189  llvm::StringRef(raw_path.c_str(), raw_path.size()));
190  return true;
191 }
192 
194  FileSpec lldb_file_spec = GetShlibDir();
195  if (!lldb_file_spec)
196  return false;
197 
198  std::string raw_path = lldb_file_spec.GetPath();
199 
200  size_t framework_pos = raw_path.find("LLDB.framework");
201  if (framework_pos == std::string::npos)
202  return false;
203 
204  framework_pos += strlen("LLDB.framework");
205  raw_path.resize(framework_pos);
206  raw_path.append("/Resources/PlugIns");
207  file_spec.GetDirectory().SetString(
208  llvm::StringRef(raw_path.c_str(), raw_path.size()));
209  return true;
210 }
211 
213  FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns");
214  FileSystem::Instance().Resolve(temp_file);
215  file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
216  return true;
217 }
218 
220  ArchSpec &arch_64) {
221  // All apple systems support 32 bit execution.
222  uint32_t cputype, cpusubtype;
223  uint32_t is_64_bit_capable = false;
224  size_t len = sizeof(cputype);
225  ArchSpec host_arch;
226  // These will tell us about the kernel architecture, which even on a 64
227  // bit machine can be 32 bit...
228  if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0) {
229  len = sizeof(cpusubtype);
230  if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0)
231  cpusubtype = CPU_TYPE_ANY;
232 
233  len = sizeof(is_64_bit_capable);
234  ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0);
235 
236  if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) {
237  // The arm64e architecture is a preview. Pretend the host architecture
238  // is arm64.
239  cpusubtype = CPU_SUBTYPE_ARM64_ALL;
240  }
241 
242  if (is_64_bit_capable) {
243  if (cputype & CPU_ARCH_ABI64) {
244  // We have a 64 bit kernel on a 64 bit system
245  arch_64.SetArchitecture(eArchTypeMachO, cputype, cpusubtype);
246  } else {
247  // We have a 64 bit kernel that is returning a 32 bit cputype, the
248  // cpusubtype will be correct as if it were for a 64 bit architecture
249  arch_64.SetArchitecture(eArchTypeMachO, cputype | CPU_ARCH_ABI64,
250  cpusubtype);
251  }
252 
253  // Now we need modify the cpusubtype for the 32 bit slices.
254  uint32_t cpusubtype32 = cpusubtype;
255 #if defined(__i386__) || defined(__x86_64__)
256  if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == CPU_SUBTYPE_X86_64_H)
257  cpusubtype32 = CPU_SUBTYPE_I386_ALL;
258 #elif defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
259  if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64)
260  cpusubtype32 = CPU_SUBTYPE_ARM_V7S;
261 #endif
262  arch_32.SetArchitecture(eArchTypeMachO, cputype & ~(CPU_ARCH_MASK),
263  cpusubtype32);
264 
265  if (cputype == CPU_TYPE_ARM ||
266  cputype == CPU_TYPE_ARM64 ||
267  cputype == CPU_TYPE_ARM64_32) {
268 // When running on a watch or tv, report the host os correctly
269 #if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
270  arch_32.GetTriple().setOS(llvm::Triple::TvOS);
271  arch_64.GetTriple().setOS(llvm::Triple::TvOS);
272 #elif defined(TARGET_OS_BRIDGE) && TARGET_OS_BRIDGE == 1
273  arch_32.GetTriple().setOS(llvm::Triple::BridgeOS);
274  arch_64.GetTriple().setOS(llvm::Triple::BridgeOS);
275 #elif defined(TARGET_OS_WATCHOS) && TARGET_OS_WATCHOS == 1
276  arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
277  arch_64.GetTriple().setOS(llvm::Triple::WatchOS);
278 #elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
279  arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
280  arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
281 #else
282  arch_32.GetTriple().setOS(llvm::Triple::IOS);
283  arch_64.GetTriple().setOS(llvm::Triple::IOS);
284 #endif
285  } else {
286  arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
287  arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
288  }
289  } else {
290  // We have a 32 bit kernel on a 32 bit system
291  arch_32.SetArchitecture(eArchTypeMachO, cputype, cpusubtype);
292 #if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
293  arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
294 #else
295  arch_32.GetTriple().setOS(llvm::Triple::IOS);
296 #endif
297  arch_64.Clear();
298  }
299  }
300 }
301 
302 /// Return and cache $DEVELOPER_DIR if it is set and exists.
304  static std::string g_env_developer_dir;
305  static std::once_flag g_once_flag;
306  std::call_once(g_once_flag, [&]() {
307  if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
308  FileSpec fspec(developer_dir_env_var);
309  if (FileSystem::Instance().Exists(fspec))
310  g_env_developer_dir = fspec.GetPath();
311  }});
312  return g_env_developer_dir;
313 }
314 
316  static FileSpec g_xcode_contents_path;
317  static std::once_flag g_once_flag;
318  std::call_once(g_once_flag, [&]() {
319  // Try the shlib dir first.
320  if (FileSpec fspec = HostInfo::GetShlibDir()) {
321  if (FileSystem::Instance().Exists(fspec)) {
322  std::string xcode_contents_dir =
324  if (!xcode_contents_dir.empty()) {
325  g_xcode_contents_path = FileSpec(xcode_contents_dir);
326  return;
327  }
328  }
329  }
330 
331  llvm::SmallString<128> env_developer_dir(GetEnvDeveloperDir());
332  if (!env_developer_dir.empty()) {
333  llvm::sys::path::append(env_developer_dir, "Contents");
334  std::string xcode_contents_dir =
336  if (!xcode_contents_dir.empty()) {
337  g_xcode_contents_path = FileSpec(xcode_contents_dir);
338  return;
339  }
340  }
341 
342  FileSpec fspec(HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS()));
343  if (fspec) {
344  if (FileSystem::Instance().Exists(fspec)) {
345  std::string xcode_contents_dir =
347  if (!xcode_contents_dir.empty()) {
348  g_xcode_contents_path = FileSpec(xcode_contents_dir);
349  return;
350  }
351  }
352  }
353  });
354  return g_xcode_contents_path;
355 }
356 
358  static lldb_private::FileSpec g_developer_directory;
359  static llvm::once_flag g_once_flag;
360  llvm::call_once(g_once_flag, []() {
361  if (FileSpec fspec = GetXcodeContentsDirectory()) {
362  fspec.AppendPathComponent("Developer");
363  if (FileSystem::Instance().Exists(fspec))
364  g_developer_directory = fspec;
365  }
366  });
367  return g_developer_directory;
368 }
369 
371  XcodeSDK::Info info = sdk.Parse();
372  std::string sdk_name = XcodeSDK::GetCanonicalName(info);
373 
374  auto xcrun = [](const std::string &sdk,
375  llvm::StringRef developer_dir = "") -> std::string {
376  Args args;
377  if (!developer_dir.empty()) {
378  args.AppendArgument("/usr/bin/env");
379  args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
380  }
381  args.AppendArgument("/usr/bin/xcrun");
382  args.AppendArgument("--show-sdk-path");
383  args.AppendArgument("--sdk");
384  args.AppendArgument(sdk);
385 
386  Log *log = GetLog(LLDBLog::Host);
387  if (log) {
388  std::string cmdstr;
389  args.GetCommandString(cmdstr);
390  log->Printf("GetXcodeSDK() running shell cmd '%s'", cmdstr.c_str());
391  }
392 
393  int status = 0;
394  int signo = 0;
395  std::string output_str;
397  Host::RunShellCommand(args, FileSpec(), &status, &signo, &output_str,
398  std::chrono::seconds(15));
399 
400  // Check that xcrun return something useful.
401  if (status != 0 || output_str.empty())
402  return {};
403 
404  // Convert to a StringRef so we can manipulate the string without modifying
405  // the underlying data.
406  llvm::StringRef output(output_str);
407 
408  // Remove any trailing newline characters.
409  output = output.rtrim();
410 
411  // Strip any leading newline characters and everything before them.
412  const size_t last_newline = output.rfind('\n');
413  if (last_newline != llvm::StringRef::npos)
414  output = output.substr(last_newline + 1);
415 
416  return output.str();
417  };
418 
419  auto find_sdk = [&xcrun](const std::string &sdk_name) -> std::string {
420  // Invoke xcrun with the developer dir specified in the environment.
421  std::string developer_dir = GetEnvDeveloperDir();
422  if (!developer_dir.empty()) {
423  // Don't fallback if DEVELOPER_DIR was set.
424  return xcrun(sdk_name, developer_dir);
425  }
426 
427  // Invoke xcrun with the shlib dir.
428  if (FileSpec fspec = HostInfo::GetShlibDir()) {
429  if (FileSystem::Instance().Exists(fspec)) {
430  std::string contents_dir =
432  llvm::StringRef shlib_developer_dir =
433  llvm::sys::path::parent_path(contents_dir);
434  if (!shlib_developer_dir.empty()) {
435  std::string sdk = xcrun(sdk_name, std::move(shlib_developer_dir));
436  if (!sdk.empty())
437  return sdk;
438  }
439  }
440  }
441 
442  // Invoke xcrun without a developer dir as a last resort.
443  return xcrun(sdk_name);
444  };
445 
446  std::string path = find_sdk(sdk_name);
447  while (path.empty()) {
448  // Try an alternate spelling of the name ("macosx10.9internal").
449  if (info.type == XcodeSDK::Type::MacOSX && !info.version.empty() &&
450  info.internal) {
451  llvm::StringRef fixed(sdk_name);
452  if (fixed.consume_back(".internal"))
453  sdk_name = fixed.str() + "internal";
454  path = find_sdk(sdk_name);
455  if (!path.empty())
456  break;
457  }
458  Log *log = GetLog(LLDBLog::Host);
459  LLDB_LOGF(log, "Couldn't find SDK %s on host", sdk_name.c_str());
460 
461  // Try without the version.
462  if (!info.version.empty()) {
463  info.version = {};
464  sdk_name = XcodeSDK::GetCanonicalName(info);
465  path = find_sdk(sdk_name);
466  if (!path.empty())
467  break;
468  }
469 
470  LLDB_LOGF(log, "Couldn't find any matching SDK on host");
471  return {};
472  }
473 
474  // Whatever is left in output should be a valid path.
475  if (!FileSystem::Instance().Exists(path))
476  return {};
477  return path;
478 }
479 
481  static llvm::StringMap<std::string> g_sdk_path;
482  static std::mutex g_sdk_path_mutex;
483 
484  std::lock_guard<std::mutex> guard(g_sdk_path_mutex);
486 
487  auto it = g_sdk_path.find(sdk.GetString());
488  if (it != g_sdk_path.end())
489  return it->second;
490  auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)});
491  return it_new.first->second;
492 }
493 
494 namespace {
495 struct dyld_shared_cache_dylib_text_info {
496  uint64_t version; // current version 1
497  // following fields all exist in version 1
498  uint64_t loadAddressUnslid;
499  uint64_t textSegmentSize;
500  uuid_t dylibUuid;
501  const char *path; // pointer invalid at end of iterations
502  // following fields all exist in version 2
503  uint64_t textSegmentOffset; // offset from start of cache
504 };
505 typedef struct dyld_shared_cache_dylib_text_info
506  dyld_shared_cache_dylib_text_info;
507 }
508 
509 extern "C" int dyld_shared_cache_iterate_text(
510  const uuid_t cacheUuid,
511  void (^callback)(const dyld_shared_cache_dylib_text_info *info));
512 extern "C" uint8_t *_dyld_get_shared_cache_range(size_t *length);
513 extern "C" bool _dyld_get_shared_cache_uuid(uuid_t uuid);
514 
515 namespace {
516 class SharedCacheInfo {
517 public:
518  const UUID &GetUUID() const { return m_uuid; }
519  const llvm::StringMap<SharedCacheImageInfo> &GetImages() const {
520  return m_images;
521  }
522 
523  SharedCacheInfo();
524 
525 private:
526  llvm::StringMap<SharedCacheImageInfo> m_images;
527  UUID m_uuid;
528 };
529 }
530 
531 SharedCacheInfo::SharedCacheInfo() {
532 #if defined(SDK_HAS_NEW_DYLD_INTROSPECTION_SPIS)
533  if (__builtin_available(macOS 12, *)) {
534  if (dyld_process_create_for_current_task) {
535  auto dyld_process = dyld_process_create_for_current_task();
536  auto snapshot =
537  dyld_process_snapshot_create_for_process(dyld_process, nullptr);
538  auto shared_cache = dyld_process_snapshot_get_shared_cache(snapshot);
539  assert(dyld_process && snapshot && shared_cache);
540 
541  dyld_shared_cache_for_each_image(shared_cache, ^(dyld_image_t image) {
542  __block uint64_t minVmAddr = UINT64_MAX;
543  __block uint64_t maxVmAddr = 0;
544  uuid_t uuidStore;
545  __block uuid_t *uuid = &uuidStore;
546 
547  dyld_image_for_each_segment_info(image, ^(const char *segmentName,
548  uint64_t vmAddr,
549  uint64_t vmSize, int perm) {
550  minVmAddr = std::min(minVmAddr, vmAddr);
551  maxVmAddr = std::max(maxVmAddr, vmAddr + vmSize);
552  dyld_image_copy_uuid(image, uuid);
553  });
554  assert(minVmAddr != UINT_MAX);
555  assert(maxVmAddr != 0);
556  m_images[dyld_image_get_installname(image)] = SharedCacheImageInfo{
557  UUID::fromData(uuid, 16),
558  std::make_shared<DataBufferUnowned>((uint8_t *)minVmAddr,
559  maxVmAddr - minVmAddr)};
560  });
561  dyld_process_snapshot_dispose(snapshot);
562  return;
563  }
564  }
565 #endif
566 
567  size_t shared_cache_size;
568  uint8_t *shared_cache_start =
569  _dyld_get_shared_cache_range(&shared_cache_size);
570  uuid_t dsc_uuid;
571  _dyld_get_shared_cache_uuid(dsc_uuid);
572  m_uuid = UUID::fromData(dsc_uuid);
573 
575  dsc_uuid, ^(const dyld_shared_cache_dylib_text_info *info) {
576  m_images[info->path] = SharedCacheImageInfo{
577  UUID::fromData(info->dylibUuid, 16),
578  std::make_shared<DataBufferUnowned>(
579  shared_cache_start + info->textSegmentOffset,
580  shared_cache_size - info->textSegmentOffset)};
581  });
582 }
583 
585 HostInfoMacOSX::GetSharedCacheImageInfo(llvm::StringRef image_name) {
586  static SharedCacheInfo g_shared_cache_info;
587  return g_shared_cache_info.GetImages().lookup(image_name);
588 }
lldb_private::UUID::fromData
static UUID fromData(const void *bytes, uint32_t num_bytes)
Creates a UUID from the data pointed to by the bytes argument.
Definition: UUID.h:45
lldb_private::HostInfoMacOSX::ComputeHostArchitectureSupport
static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64)
Definition: HostInfoMacOSX.mm:219
lldb_private::UUID
Definition: UUID.h:23
ParseOSVersion
static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key)
Definition: HostInfoMacOSX.mm:73
UuidCompatibility.h
lldb_private::HostInfoMacOSX::GetXcodeSDKPath
static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk)
Query xcrun to find an Xcode SDK directory.
Definition: HostInfoMacOSX.mm:480
lldb_private::ArchSpec
Definition: ArchSpec.h:33
FileSystem.h
lldb_private::HostInfoMacOSX::GetSharedCacheImageInfo
static SharedCacheImageInfo GetSharedCacheImageInfo(llvm::StringRef image_name)
Shared cache utilities.
Definition: HostInfoMacOSX.mm:585
lldb_private::HostInfoMacOSX::GetXcodeDeveloperDirectory
static FileSpec GetXcodeDeveloperDirectory()
Definition: HostInfoMacOSX.mm:357
HostInfoMacOSX.h
lldb_private::HostInfoMacOSX::ComputeSupportExeDirectory
static bool ComputeSupportExeDirectory(FileSpec &file_spec)
Definition: HostInfoMacOSX.mm:122
Host.h
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:270
lldb_private::HostInfoMacOSX::ComputeUserPluginsDirectory
static bool ComputeUserPluginsDirectory(FileSpec &file_spec)
Definition: HostInfoMacOSX.mm:212
lldb_private::Args::AppendArgument
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
Definition: Args.cpp:318
lldb_private::XcodeSDK
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
lldb_private::LLDBLog::Host
@ Host
lldb_private::ConstString::SetCString
void SetCString(const char *cstr)
Set the C string value.
Definition: ConstString.cpp:301
lldb_private::XcodeSDK::Parse
Info Parse() const
Return parsed SDK type and version number.
Definition: XcodeSDK.cpp:108
lldb_private::XcodeSDK::GetString
llvm::StringRef GetString() const
Definition: XcodeSDK.cpp:135
lldb_private::Args
Definition: Args.h:33
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:455
lldb_private::XcodeSDK::Info
A parsed SDK directory name.
Definition: XcodeSDK.h:44
lldb_private::eArchTypeMachO
@ eArchTypeMachO
Definition: lldb-private-enumerations.h:63
lldb_private::XcodeSDK::GetAnyMacOS
static XcodeSDK GetAnyMacOS()
Definition: XcodeSDK.h:63
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::Log::Printf
void Printf(const char *format,...) __attribute__((format(printf
Prefer using LLDB_LOGF whenever possible.
Definition: Log.cpp:121
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ConstString::SetString
void SetString(const llvm::StringRef &s)
Definition: ConstString.cpp:305
_dyld_get_shared_cache_uuid
bool _dyld_get_shared_cache_uuid(uuid_t uuid)
Log.h
Args.h
lldb_private::Host::RunShellCommand
static Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout, bool run_in_shell=true, bool hide_stderr=false)
Run a shell command.
Definition: common/Host.cpp:400
lldb_private::HostInfoBase::GetShlibDir
static FileSpec GetShlibDir()
Returns the directory containing the lldb shared library.
Definition: HostInfoBase.cpp:119
lldb_private::XcodeSDK::FindXcodeContentsDirectoryInPath
static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path)
Definition: XcodeSDK.cpp:286
lldb_private::HostInfoMacOSX::GetOSVersion
static llvm::VersionTuple GetOSVersion()
Definition: HostInfoMacOSX.mm:84
Timer.h
lldb_private::HostInfoMacOSX::GetOSBuildString
static llvm::Optional< std::string > GetOSBuildString()
Definition: HostInfoMacOSX.mm:63
dyld_shared_cache_iterate_text
int dyld_shared_cache_iterate_text(const uuid_t cacheUuid, void(^callback)(const dyld_shared_cache_dylib_text_info *info))
LLDB_SCOPED_TIMER
#define LLDB_SCOPED_TIMER()
Definition: Timer.h:83
HostInfo.h
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::FileSystem::Resolve
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
Definition: common/FileSystem.cpp:235
CPU_TYPE_ARM64_32
#define CPU_TYPE_ARM64_32
Definition: HostInfoMacOSX.mm:56
GetEnvDeveloperDir
static std::string GetEnvDeveloperDir()
Return and cache $DEVELOPER_DIR if it is set and exists.
Definition: HostInfoMacOSX.mm:303
lldb_private::ArchSpec::SetArchitecture
bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub, uint32_t os=0)
Change the architecture object type, CPU type and OS type.
Definition: ArchSpec.cpp:844
lldb_private::SharedCacheImageInfo
Definition: HostInfoBase.h:28
lldb_private::Status
Definition: Status.h:44
lldb_private::XcodeSDK::Info::version
llvm::VersionTuple version
Definition: XcodeSDK.h:46
uint32_t
lldb_private::HostInfoMacOSX::ComputeSystemPluginsDirectory
static bool ComputeSystemPluginsDirectory(FileSpec &file_spec)
Definition: HostInfoMacOSX.mm:193
lldb_private::XcodeSDK::GetCanonicalName
static std::string GetCanonicalName(Info info)
Return the canonical SDK name, such as "macosx" for the macOS SDK.
Definition: XcodeSDK.cpp:162
_dyld_get_shared_cache_range
uint8_t * _dyld_get_shared_cache_range(size_t *length)
GetXcodeSDK
static std::string GetXcodeSDK(XcodeSDK sdk)
Definition: HostInfoMacOSX.mm:370
lldb_private::HostInfoMacOSX::GetProgramFileSpec
static FileSpec GetProgramFileSpec()
Definition: HostInfoMacOSX.mm:99
lldb_private::Args::GetCommandString
bool GetCommandString(std::string &command) const
Definition: Args.cpp:212
lldb_private::HostInfoMacOSX::GetMacCatalystVersion
static llvm::VersionTuple GetMacCatalystVersion()
Definition: HostInfoMacOSX.mm:91
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:46
lldb_private::HostInfoMacOSX::GetXcodeContentsDirectory
static FileSpec GetXcodeContentsDirectory()
Definition: HostInfoMacOSX.mm:315
CPU_SUBTYPE_X86_64_H
#define CPU_SUBTYPE_X86_64_H
Definition: HostInfoMacOSX.mm:48
lldb_private::XcodeSDK::Info::type
Type type
Definition: XcodeSDK.h:45
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::FileSpec::GetDirectory
ConstString & GetDirectory()
Directory string get accessor.
Definition: FileSpec.cpp:334
lldb_private::Log
Definition: Log.h:48
lldb_private::FileSpec::SetFile
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:172
lldb_private::HostInfoMacOSX::ComputeHeaderDirectory
static bool ComputeHeaderDirectory(FileSpec &file_spec)
Definition: HostInfoMacOSX.mm:175
lldb_private::ArchSpec::Clear
void Clear()
Clears the object state.
Definition: ArchSpec.cpp:528
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:235
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:347
uuid_t
unsigned char uuid_t[16]
Definition: UuidCompatibility.h:15
LLDBLog.h
CPU_TYPE_ARM64
#define CPU_TYPE_ARM64
Definition: HostInfoMacOSX.mm:51
UINT64_MAX
#define UINT64_MAX
Definition: lldb-defines.h:23
lldb_private::XcodeSDK::Info::internal
bool internal
Definition: XcodeSDK.h:47