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