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