LLDB  mainline
PlatformDarwin.cpp
Go to the documentation of this file.
1 //===-- PlatformDarwin.cpp ------------------------------------------------===//
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 "PlatformDarwin.h"
10 
11 #include <cstring>
12 
13 #include <algorithm>
14 #include <memory>
15 #include <mutex>
16 
19 #include "lldb/Core/Debugger.h"
20 #include "lldb/Core/Module.h"
21 #include "lldb/Core/ModuleSpec.h"
22 #include "lldb/Core/Section.h"
23 #include "lldb/Host/Host.h"
24 #include "lldb/Host/HostInfo.h"
25 #include "lldb/Host/XML.h"
28 #include "lldb/Symbol/ObjectFile.h"
29 #include "lldb/Symbol/SymbolFile.h"
31 #include "lldb/Target/Platform.h"
32 #include "lldb/Target/Process.h"
33 #include "lldb/Target/Target.h"
34 #include "lldb/Utility/Log.h"
36 #include "lldb/Utility/Status.h"
37 #include "lldb/Utility/Timer.h"
38 #include "llvm/ADT/STLExtras.h"
39 #include "llvm/Support/FileSystem.h"
40 #include "llvm/Support/Threading.h"
41 #include "llvm/Support/VersionTuple.h"
42 
43 #if defined(__APPLE__)
44 #include <TargetConditionals.h>
45 #endif
46 
47 using namespace lldb;
48 using namespace lldb_private;
49 
50 /// Default Constructor
51 PlatformDarwin::PlatformDarwin(bool is_host) : PlatformPOSIX(is_host) {}
52 
53 /// Destructor.
54 ///
55 /// The destructor is virtual since this class is designed to be
56 /// inherited from by the plug-in instance.
58 
61  const lldb_private::FileSpec &destination, uint32_t uid,
62  uint32_t gid) {
63  // Unconditionally unlink the destination. If it is an executable,
64  // simply opening it and truncating its contents would invalidate
65  // its cached code signature.
66  Unlink(destination);
67  return PlatformPOSIX::PutFile(source, destination, uid, gid);
68 }
69 
71  Target *target, Module &module, Stream *feedback_stream) {
72  FileSpecList file_list;
73  if (target &&
75  // NB some extensions might be meaningful and should not be stripped -
76  // "this.binary.file"
77  // should not lose ".file" but GetFileNameStrippingExtension() will do
78  // precisely that. Ideally, we should have a per-platform list of
79  // extensions (".exe", ".app", ".dSYM", ".framework") which should be
80  // stripped while leaving "this.binary.file" as-is.
81 
82  FileSpec module_spec = module.GetFileSpec();
83 
84  if (module_spec) {
85  if (SymbolFile *symfile = module.GetSymbolFile()) {
86  ObjectFile *objfile = symfile->GetObjectFile();
87  if (objfile) {
88  FileSpec symfile_spec(objfile->GetFileSpec());
89  if (symfile_spec &&
90  strcasestr(symfile_spec.GetPath().c_str(),
91  ".dSYM/Contents/Resources/DWARF") != nullptr &&
92  FileSystem::Instance().Exists(symfile_spec)) {
93  while (module_spec.GetFilename()) {
94  std::string module_basename(
95  module_spec.GetFilename().GetCString());
96  std::string original_module_basename(module_basename);
97 
98  bool was_keyword = false;
99 
100  // FIXME: for Python, we cannot allow certain characters in
101  // module
102  // filenames we import. Theoretically, different scripting
103  // languages may have different sets of forbidden tokens in
104  // filenames, and that should be dealt with by each
105  // ScriptInterpreter. For now, we just replace dots with
106  // underscores, but if we ever support anything other than
107  // Python we will need to rework this
108  std::replace(module_basename.begin(), module_basename.end(), '.',
109  '_');
110  std::replace(module_basename.begin(), module_basename.end(), ' ',
111  '_');
112  std::replace(module_basename.begin(), module_basename.end(), '-',
113  '_');
114  ScriptInterpreter *script_interpreter =
115  target->GetDebugger().GetScriptInterpreter();
116  if (script_interpreter &&
117  script_interpreter->IsReservedWord(module_basename.c_str())) {
118  module_basename.insert(module_basename.begin(), '_');
119  was_keyword = true;
120  }
121 
122  StreamString path_string;
123  StreamString original_path_string;
124  // for OSX we are going to be in
125  // .dSYM/Contents/Resources/DWARF/<basename> let us go to
126  // .dSYM/Contents/Resources/Python/<basename>.py and see if the
127  // file exists
128  path_string.Printf("%s/../Python/%s.py",
129  symfile_spec.GetDirectory().GetCString(),
130  module_basename.c_str());
131  original_path_string.Printf(
132  "%s/../Python/%s.py",
133  symfile_spec.GetDirectory().GetCString(),
134  original_module_basename.c_str());
135  FileSpec script_fspec(path_string.GetString());
136  FileSystem::Instance().Resolve(script_fspec);
137  FileSpec orig_script_fspec(original_path_string.GetString());
138  FileSystem::Instance().Resolve(orig_script_fspec);
139 
140  // if we did some replacements of reserved characters, and a
141  // file with the untampered name exists, then warn the user
142  // that the file as-is shall not be loaded
143  if (feedback_stream) {
144  if (module_basename != original_module_basename &&
145  FileSystem::Instance().Exists(orig_script_fspec)) {
146  const char *reason_for_complaint =
147  was_keyword ? "conflicts with a keyword"
148  : "contains reserved characters";
149  if (FileSystem::Instance().Exists(script_fspec))
150  feedback_stream->Printf(
151  "warning: the symbol file '%s' contains a debug "
152  "script. However, its name"
153  " '%s' %s and as such cannot be loaded. LLDB will"
154  " load '%s' instead. Consider removing the file with "
155  "the malformed name to"
156  " eliminate this warning.\n",
157  symfile_spec.GetPath().c_str(),
158  original_path_string.GetData(), reason_for_complaint,
159  path_string.GetData());
160  else
161  feedback_stream->Printf(
162  "warning: the symbol file '%s' contains a debug "
163  "script. However, its name"
164  " %s and as such cannot be loaded. If you intend"
165  " to have this script loaded, please rename '%s' to "
166  "'%s' and retry.\n",
167  symfile_spec.GetPath().c_str(), reason_for_complaint,
168  original_path_string.GetData(), path_string.GetData());
169  }
170  }
171 
172  if (FileSystem::Instance().Exists(script_fspec)) {
173  file_list.Append(script_fspec);
174  break;
175  }
176 
177  // If we didn't find the python file, then keep stripping the
178  // extensions and try again
179  ConstString filename_no_extension(
180  module_spec.GetFileNameStrippingExtension());
181  if (module_spec.GetFilename() == filename_no_extension)
182  break;
183 
184  module_spec.GetFilename() = filename_no_extension;
185  }
186  }
187  }
188  }
189  }
190  }
191  return file_list;
192 }
193 
195  const ModuleSpec &sym_spec,
196  FileSpec &sym_file) {
197  sym_file = sym_spec.GetSymbolFileSpec();
198  if (FileSystem::Instance().IsDirectory(sym_file)) {
199  sym_file = Symbols::FindSymbolFileInBundle(sym_file, sym_spec.GetUUIDPtr(),
200  sym_spec.GetArchitecturePtr());
201  }
202  return {};
203 }
204 
206 MakeCacheFolderForFile(const FileSpec &module_cache_spec) {
207  FileSpec module_cache_folder =
208  module_cache_spec.CopyByRemovingLastPathComponent();
209  return llvm::sys::fs::create_directory(module_cache_folder.GetPath());
210 }
211 
214  const lldb_private::ModuleSpec &module_spec,
215  const FileSpec &module_cache_spec) {
216  MakeCacheFolderForFile(module_cache_spec);
217  Status err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec);
218  return err;
219 }
220 
222  const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
223  const lldb_private::FileSpecList *module_search_paths_ptr,
224  llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {
225 
227  LLDB_LOGF(log,
228  "[%s] Trying to find module %s/%s - platform path %s/%s symbol "
229  "path %s/%s",
230  (IsHost() ? "host" : "remote"),
231  module_spec.GetFileSpec().GetDirectory().AsCString(),
232  module_spec.GetFileSpec().GetFilename().AsCString(),
233  module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
234  module_spec.GetPlatformFileSpec().GetFilename().AsCString(),
235  module_spec.GetSymbolFileSpec().GetDirectory().AsCString(),
236  module_spec.GetSymbolFileSpec().GetFilename().AsCString());
237 
238  Status err;
239 
240  if (CheckLocalSharedCache()) {
241  // When debugging on the host, we are most likely using the same shared
242  // cache as our inferior. The dylibs from the shared cache might not
243  // exist on the filesystem, so let's use the images in our own memory
244  // to create the modules.
245 
246  // Check if the requested image is in our shared cache.
247  SharedCacheImageInfo image_info =
248  HostInfo::GetSharedCacheImageInfo(module_spec.GetFileSpec().GetPath());
249 
250  // If we found it and it has the correct UUID, let's proceed with
251  // creating a module from the memory contents.
252  if (image_info.uuid &&
253  (!module_spec.GetUUID() || module_spec.GetUUID() == image_info.uuid)) {
254  ModuleSpec shared_cache_spec(module_spec.GetFileSpec(), image_info.uuid,
255  image_info.data_sp);
256  err = ModuleList::GetSharedModule(shared_cache_spec, module_sp,
257  module_search_paths_ptr, old_modules,
258  did_create_ptr);
259  if (module_sp)
260  return err;
261  }
262  }
263 
264  err = ModuleList::GetSharedModule(module_spec, module_sp,
265  module_search_paths_ptr, old_modules,
266  did_create_ptr);
267  if (module_sp)
268  return err;
269 
270  if (!IsHost()) {
271  std::string cache_path(GetLocalCacheDirectory());
272  // Only search for a locally cached file if we have a valid cache path
273  if (!cache_path.empty()) {
274  std::string module_path(module_spec.GetFileSpec().GetPath());
275  cache_path.append(module_path);
276  FileSpec module_cache_spec(cache_path);
277 
278  // if rsync is supported, always bring in the file - rsync will be very
279  // efficient when files are the same on the local and remote end of the
280  // connection
281  if (this->GetSupportsRSync()) {
282  err = BringInRemoteFile(this, module_spec, module_cache_spec);
283  if (err.Fail())
284  return err;
285  if (FileSystem::Instance().Exists(module_cache_spec)) {
287  LLDB_LOGF(log, "[%s] module %s/%s was rsynced and is now there",
288  (IsHost() ? "host" : "remote"),
289  module_spec.GetFileSpec().GetDirectory().AsCString(),
290  module_spec.GetFileSpec().GetFilename().AsCString());
291  ModuleSpec local_spec(module_cache_spec,
292  module_spec.GetArchitecture());
293  module_sp = std::make_shared<Module>(local_spec);
294  module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
295  return Status();
296  }
297  }
298 
299  // try to find the module in the cache
300  if (FileSystem::Instance().Exists(module_cache_spec)) {
301  // get the local and remote MD5 and compare
302  if (m_remote_platform_sp) {
303  // when going over the *slow* GDB remote transfer mechanism we first
304  // check the hashes of the files - and only do the actual transfer if
305  // they differ
306  uint64_t high_local, high_remote, low_local, low_remote;
307  auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.GetPath());
308  if (!MD5)
309  return Status(MD5.getError());
310  std::tie(high_local, low_local) = MD5->words();
311 
312  m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(),
313  low_remote, high_remote);
314  if (low_local != low_remote || high_local != high_remote) {
315  // bring in the remote file
317  LLDB_LOGF(log,
318  "[%s] module %s/%s needs to be replaced from remote copy",
319  (IsHost() ? "host" : "remote"),
320  module_spec.GetFileSpec().GetDirectory().AsCString(),
321  module_spec.GetFileSpec().GetFilename().AsCString());
322  Status err =
323  BringInRemoteFile(this, module_spec, module_cache_spec);
324  if (err.Fail())
325  return err;
326  }
327  }
328 
329  ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
330  module_sp = std::make_shared<Module>(local_spec);
331  module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
333  LLDB_LOGF(log, "[%s] module %s/%s was found in the cache",
334  (IsHost() ? "host" : "remote"),
335  module_spec.GetFileSpec().GetDirectory().AsCString(),
336  module_spec.GetFileSpec().GetFilename().AsCString());
337  return Status();
338  }
339 
340  // bring in the remote module file
341  LLDB_LOGF(log, "[%s] module %s/%s needs to come in remotely",
342  (IsHost() ? "host" : "remote"),
343  module_spec.GetFileSpec().GetDirectory().AsCString(),
344  module_spec.GetFileSpec().GetFilename().AsCString());
345  Status err = BringInRemoteFile(this, module_spec, module_cache_spec);
346  if (err.Fail())
347  return err;
348  if (FileSystem::Instance().Exists(module_cache_spec)) {
350  LLDB_LOGF(log, "[%s] module %s/%s is now cached and fine",
351  (IsHost() ? "host" : "remote"),
352  module_spec.GetFileSpec().GetDirectory().AsCString(),
353  module_spec.GetFileSpec().GetFilename().AsCString());
354  ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
355  module_sp = std::make_shared<Module>(local_spec);
356  module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
357  return Status();
358  } else
359  return Status("unable to obtain valid module file");
360  } else
361  return Status("no cache path");
362  } else
363  return Status("unable to resolve module");
364 }
365 
367  const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
368  const FileSpecList *module_search_paths_ptr,
369  llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
370  Status error;
371  module_sp.reset();
372 
373  if (IsRemote()) {
374  // If we have a remote platform always, let it try and locate the shared
375  // module first.
376  if (m_remote_platform_sp) {
377  error = m_remote_platform_sp->GetSharedModule(
378  module_spec, process, module_sp, module_search_paths_ptr, old_modules,
379  did_create_ptr);
380  }
381  }
382 
383  if (!module_sp) {
384  // Fall back to the local platform and find the file locally
385  error = Platform::GetSharedModule(module_spec, process, module_sp,
386  module_search_paths_ptr, old_modules,
387  did_create_ptr);
388 
389  const FileSpec &platform_file = module_spec.GetFileSpec();
390  if (!module_sp && module_search_paths_ptr && platform_file) {
391  // We can try to pull off part of the file path up to the bundle
392  // directory level and try any module search paths...
393  FileSpec bundle_directory;
394  if (Host::GetBundleDirectory(platform_file, bundle_directory)) {
395  if (platform_file == bundle_directory) {
396  ModuleSpec new_module_spec(module_spec);
397  new_module_spec.GetFileSpec() = bundle_directory;
398  if (Host::ResolveExecutableInBundle(new_module_spec.GetFileSpec())) {
399  Status new_error(Platform::GetSharedModule(
400  new_module_spec, process, module_sp, nullptr, old_modules,
401  did_create_ptr));
402 
403  if (module_sp)
404  return new_error;
405  }
406  } else {
407  char platform_path[PATH_MAX];
408  char bundle_dir[PATH_MAX];
409  platform_file.GetPath(platform_path, sizeof(platform_path));
410  const size_t bundle_directory_len =
411  bundle_directory.GetPath(bundle_dir, sizeof(bundle_dir));
412  char new_path[PATH_MAX];
413  size_t num_module_search_paths = module_search_paths_ptr->GetSize();
414  for (size_t i = 0; i < num_module_search_paths; ++i) {
415  const size_t search_path_len =
416  module_search_paths_ptr->GetFileSpecAtIndex(i).GetPath(
417  new_path, sizeof(new_path));
418  if (search_path_len < sizeof(new_path)) {
419  snprintf(new_path + search_path_len,
420  sizeof(new_path) - search_path_len, "/%s",
421  platform_path + bundle_directory_len);
422  FileSpec new_file_spec(new_path);
423  if (FileSystem::Instance().Exists(new_file_spec)) {
424  ModuleSpec new_module_spec(module_spec);
425  new_module_spec.GetFileSpec() = new_file_spec;
426  Status new_error(Platform::GetSharedModule(
427  new_module_spec, process, module_sp, nullptr, old_modules,
428  did_create_ptr));
429 
430  if (module_sp) {
431  module_sp->SetPlatformFileSpec(new_file_spec);
432  return new_error;
433  }
434  }
435  }
436  }
437  }
438  }
439  }
440  }
441  if (module_sp)
442  module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
443  return error;
444 }
445 
446 size_t
448  BreakpointSite *bp_site) {
449  const uint8_t *trap_opcode = nullptr;
450  uint32_t trap_opcode_size = 0;
451  bool bp_is_thumb = false;
452 
453  llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
454  switch (machine) {
455  case llvm::Triple::aarch64_32:
456  case llvm::Triple::aarch64: {
457  // 'brk #0' or 0xd4200000 in BE byte order
458  static const uint8_t g_arm64_breakpoint_opcode[] = {0x00, 0x00, 0x20, 0xD4};
459  trap_opcode = g_arm64_breakpoint_opcode;
460  trap_opcode_size = sizeof(g_arm64_breakpoint_opcode);
461  } break;
462 
463  case llvm::Triple::thumb:
464  bp_is_thumb = true;
465  LLVM_FALLTHROUGH;
466  case llvm::Triple::arm: {
467  static const uint8_t g_arm_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
468  static const uint8_t g_thumb_breakpooint_opcode[] = {0xFE, 0xDE};
469 
470  // Auto detect arm/thumb if it wasn't explicitly specified
471  if (!bp_is_thumb) {
472  lldb::BreakpointLocationSP bp_loc_sp(bp_site->GetOwnerAtIndex(0));
473  if (bp_loc_sp)
474  bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass() ==
475  AddressClass::eCodeAlternateISA;
476  }
477  if (bp_is_thumb) {
478  trap_opcode = g_thumb_breakpooint_opcode;
479  trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
480  break;
481  }
482  trap_opcode = g_arm_breakpoint_opcode;
483  trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
484  } break;
485 
486  case llvm::Triple::ppc:
487  case llvm::Triple::ppc64: {
488  static const uint8_t g_ppc_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
489  trap_opcode = g_ppc_breakpoint_opcode;
490  trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
491  } break;
492 
493  default:
494  return Platform::GetSoftwareBreakpointTrapOpcode(target, bp_site);
495  }
496 
497  if (trap_opcode && trap_opcode_size) {
498  if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
499  return trap_opcode_size;
500  }
501  return 0;
502 }
503 
505  lldb_private::Target &target, const lldb::ModuleSP &module_sp) {
506  if (!module_sp)
507  return false;
508 
509  ObjectFile *obj_file = module_sp->GetObjectFile();
510  if (!obj_file)
511  return false;
512 
513  ObjectFile::Type obj_type = obj_file->GetType();
514  return obj_type == ObjectFile::eTypeDynamicLinker;
515 }
516 
518  std::vector<ArchSpec> &archs) {
519  ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
520  archs.push_back(host_arch);
521 
522  if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h) {
523  archs.push_back(ArchSpec("x86_64-apple-macosx"));
524  archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
525  } else {
526  ArchSpec host_arch64 = HostInfo::GetArchitecture(HostInfo::eArchKind64);
527  if (host_arch.IsExactMatch(host_arch64))
528  archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
529  }
530 }
531 
532 static llvm::ArrayRef<const char *> GetCompatibleArchs(ArchSpec::Core core) {
533  switch (core) {
534  default:
535  LLVM_FALLTHROUGH;
536  case ArchSpec::eCore_arm_arm64e: {
537  static const char *g_arm64e_compatible_archs[] = {
538  "arm64e", "arm64", "armv7", "armv7f", "armv7k", "armv7s",
539  "armv7m", "armv7em", "armv6m", "armv6", "armv5", "armv4",
540  "arm", "thumbv7", "thumbv7f", "thumbv7k", "thumbv7s", "thumbv7m",
541  "thumbv7em", "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
542  };
543  return {g_arm64e_compatible_archs};
544  }
545  case ArchSpec::eCore_arm_arm64: {
546  static const char *g_arm64_compatible_archs[] = {
547  "arm64", "armv7", "armv7f", "armv7k", "armv7s", "armv7m",
548  "armv7em", "armv6m", "armv6", "armv5", "armv4", "arm",
549  "thumbv7", "thumbv7f", "thumbv7k", "thumbv7s", "thumbv7m", "thumbv7em",
550  "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
551  };
552  return {g_arm64_compatible_archs};
553  }
554  case ArchSpec::eCore_arm_armv7: {
555  static const char *g_armv7_compatible_archs[] = {
556  "armv7", "armv6m", "armv6", "armv5", "armv4", "arm",
557  "thumbv7", "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
558  };
559  return {g_armv7_compatible_archs};
560  }
561  case ArchSpec::eCore_arm_armv7f: {
562  static const char *g_armv7f_compatible_archs[] = {
563  "armv7f", "armv7", "armv6m", "armv6", "armv5",
564  "armv4", "arm", "thumbv7f", "thumbv7", "thumbv6m",
565  "thumbv6", "thumbv5", "thumbv4t", "thumb",
566  };
567  return {g_armv7f_compatible_archs};
568  }
569  case ArchSpec::eCore_arm_armv7k: {
570  static const char *g_armv7k_compatible_archs[] = {
571  "armv7k", "armv7", "armv6m", "armv6", "armv5",
572  "armv4", "arm", "thumbv7k", "thumbv7", "thumbv6m",
573  "thumbv6", "thumbv5", "thumbv4t", "thumb",
574  };
575  return {g_armv7k_compatible_archs};
576  }
577  case ArchSpec::eCore_arm_armv7s: {
578  static const char *g_armv7s_compatible_archs[] = {
579  "armv7s", "armv7", "armv6m", "armv6", "armv5",
580  "armv4", "arm", "thumbv7s", "thumbv7", "thumbv6m",
581  "thumbv6", "thumbv5", "thumbv4t", "thumb",
582  };
583  return {g_armv7s_compatible_archs};
584  }
585  case ArchSpec::eCore_arm_armv7m: {
586  static const char *g_armv7m_compatible_archs[] = {
587  "armv7m", "armv7", "armv6m", "armv6", "armv5",
588  "armv4", "arm", "thumbv7m", "thumbv7", "thumbv6m",
589  "thumbv6", "thumbv5", "thumbv4t", "thumb",
590  };
591  return {g_armv7m_compatible_archs};
592  }
593  case ArchSpec::eCore_arm_armv7em: {
594  static const char *g_armv7em_compatible_archs[] = {
595  "armv7em", "armv7", "armv6m", "armv6", "armv5",
596  "armv4", "arm", "thumbv7em", "thumbv7", "thumbv6m",
597  "thumbv6", "thumbv5", "thumbv4t", "thumb",
598  };
599  return {g_armv7em_compatible_archs};
600  }
601  case ArchSpec::eCore_arm_armv6m: {
602  static const char *g_armv6m_compatible_archs[] = {
603  "armv6m", "armv6", "armv5", "armv4", "arm",
604  "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
605  };
606  return {g_armv6m_compatible_archs};
607  }
608  case ArchSpec::eCore_arm_armv6: {
609  static const char *g_armv6_compatible_archs[] = {
610  "armv6", "armv5", "armv4", "arm",
611  "thumbv6", "thumbv5", "thumbv4t", "thumb",
612  };
613  return {g_armv6_compatible_archs};
614  }
615  case ArchSpec::eCore_arm_armv5: {
616  static const char *g_armv5_compatible_archs[] = {
617  "armv5", "armv4", "arm", "thumbv5", "thumbv4t", "thumb",
618  };
619  return {g_armv5_compatible_archs};
620  }
621  case ArchSpec::eCore_arm_armv4: {
622  static const char *g_armv4_compatible_archs[] = {
623  "armv4",
624  "arm",
625  "thumbv4t",
626  "thumb",
627  };
628  return {g_armv4_compatible_archs};
629  }
630  }
631  return {};
632 }
633 
634 /// The architecture selection rules for arm processors These cpu subtypes have
635 /// distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f
636 /// processor.
638  std::vector<ArchSpec> &archs, llvm::Optional<llvm::Triple::OSType> os) {
639  const ArchSpec system_arch = GetSystemArchitecture();
640  const ArchSpec::Core system_core = system_arch.GetCore();
641  for (const char *arch : GetCompatibleArchs(system_core)) {
642  llvm::Triple triple;
643  triple.setArchName(arch);
644  triple.setVendor(llvm::Triple::VendorType::Apple);
645  if (os)
646  triple.setOS(*os);
647  archs.push_back(ArchSpec(triple));
648  }
649 }
650 
652  static FileSpec g_xcode_select_filespec;
653 
654  if (!g_xcode_select_filespec) {
655  FileSpec xcode_select_cmd("/usr/bin/xcode-select");
656  if (FileSystem::Instance().Exists(xcode_select_cmd)) {
657  int exit_status = -1;
658  int signo = -1;
659  std::string command_output;
660  Status status =
661  Host::RunShellCommand("/usr/bin/xcode-select --print-path",
662  FileSpec(), // current working directory
663  &exit_status, &signo, &command_output,
664  std::chrono::seconds(2), // short timeout
665  false); // don't run in a shell
666  if (status.Success() && exit_status == 0 && !command_output.empty()) {
667  size_t first_non_newline = command_output.find_last_not_of("\r\n");
668  if (first_non_newline != std::string::npos) {
669  command_output.erase(first_non_newline + 1);
670  }
671  g_xcode_select_filespec = FileSpec(command_output);
672  }
673  }
674  }
675 
676  return g_xcode_select_filespec;
677 }
678 
680  BreakpointSP bp_sp;
681  static const char *g_bp_names[] = {
682  "start_wqthread", "_pthread_wqthread", "_pthread_start",
683  };
684 
685  static const char *g_bp_modules[] = {"libsystem_c.dylib",
686  "libSystem.B.dylib"};
687 
688  FileSpecList bp_modules;
689  for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++) {
690  const char *bp_module = g_bp_modules[i];
691  bp_modules.EmplaceBack(bp_module);
692  }
693 
694  bool internal = true;
695  bool hardware = false;
696  LazyBool skip_prologue = eLazyBoolNo;
697  bp_sp = target.CreateBreakpoint(&bp_modules, nullptr, g_bp_names,
698  llvm::array_lengthof(g_bp_names),
699  eFunctionNameTypeFull, eLanguageTypeUnknown,
700  0, skip_prologue, internal, hardware);
701  bp_sp->SetBreakpointKind("thread-creation");
702 
703  return bp_sp;
704 }
705 
706 uint32_t
708  const FileSpec &shell = launch_info.GetShell();
709  if (!shell)
710  return 1;
711 
712  std::string shell_string = shell.GetPath();
713  const char *shell_name = strrchr(shell_string.c_str(), '/');
714  if (shell_name == nullptr)
715  shell_name = shell_string.c_str();
716  else
717  shell_name++;
718 
719  if (strcmp(shell_name, "sh") == 0) {
720  // /bin/sh re-exec's itself as /bin/bash requiring another resume. But it
721  // only does this if the COMMAND_MODE environment variable is set to
722  // "legacy".
723  if (launch_info.GetEnvironment().lookup("COMMAND_MODE") == "legacy")
724  return 2;
725  return 1;
726  } else if (strcmp(shell_name, "csh") == 0 ||
727  strcmp(shell_name, "tcsh") == 0 ||
728  strcmp(shell_name, "zsh") == 0) {
729  // csh and tcsh always seem to re-exec themselves.
730  return 2;
731  } else
732  return 1;
733 }
734 
735 lldb::ProcessSP PlatformDarwin::DebugProcess(ProcessLaunchInfo &launch_info,
736  Debugger &debugger, Target &target,
737  Status &error) {
738  ProcessSP process_sp;
739 
740  if (IsHost()) {
741  // We are going to hand this process off to debugserver which will be in
742  // charge of setting the exit status. However, we still need to reap it
743  // from lldb. So, make sure we use a exit callback which does not set exit
744  // status.
745  const bool monitor_signals = false;
746  launch_info.SetMonitorProcessCallback(
747  &ProcessLaunchInfo::NoOpMonitorCallback, monitor_signals);
748  process_sp = Platform::DebugProcess(launch_info, debugger, target, error);
749  } else {
751  process_sp = m_remote_platform_sp->DebugProcess(launch_info, debugger,
752  target, error);
753  else
754  error.SetErrorString("the platform is not currently connected");
755  }
756  return process_sp;
757 }
758 
760  m_trap_handlers.push_back(ConstString("_sigtramp"));
761 }
762 
764  static FileSpec g_command_line_tools_filespec;
765 
766  if (!g_command_line_tools_filespec) {
767  FileSpec command_line_tools_path(GetXcodeSelectPath());
768  command_line_tools_path.AppendPathComponent("Library");
769  if (FileSystem::Instance().Exists(command_line_tools_path)) {
770  g_command_line_tools_filespec = command_line_tools_path;
771  }
772  }
773 
774  return g_command_line_tools_filespec;
775 }
776 
778  void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) {
779  SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo *>(baton);
780 
781  FileSpec spec(path);
782  if (XcodeSDK::SDKSupportsModules(enumerator_info->sdk_type, spec)) {
783  enumerator_info->found_path = spec;
784  return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
785  }
786 
787  return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext;
788 }
789 
791  const FileSpec &sdks_spec) {
792  // Look inside Xcode for the required installed iOS SDK version
793 
794  if (!FileSystem::Instance().IsDirectory(sdks_spec)) {
795  return FileSpec();
796  }
797 
798  const bool find_directories = true;
799  const bool find_files = false;
800  const bool find_other = true; // include symlinks
801 
802  SDKEnumeratorInfo enumerator_info;
803 
804  enumerator_info.sdk_type = sdk_type;
805 
806  FileSystem::Instance().EnumerateDirectory(
807  sdks_spec.GetPath(), find_directories, find_files, find_other,
808  DirectoryEnumerator, &enumerator_info);
809 
810  if (FileSystem::Instance().IsDirectory(enumerator_info.found_path))
811  return enumerator_info.found_path;
812  else
813  return FileSpec();
814 }
815 
817  FileSpec sdks_spec = HostInfo::GetXcodeContentsDirectory();
818  sdks_spec.AppendPathComponent("Developer");
819  sdks_spec.AppendPathComponent("Platforms");
820 
821  switch (sdk_type) {
822  case XcodeSDK::Type::MacOSX:
823  sdks_spec.AppendPathComponent("MacOSX.platform");
824  break;
825  case XcodeSDK::Type::iPhoneSimulator:
826  sdks_spec.AppendPathComponent("iPhoneSimulator.platform");
827  break;
828  case XcodeSDK::Type::iPhoneOS:
829  sdks_spec.AppendPathComponent("iPhoneOS.platform");
830  break;
831  case XcodeSDK::Type::WatchSimulator:
832  sdks_spec.AppendPathComponent("WatchSimulator.platform");
833  break;
834  case XcodeSDK::Type::AppleTVSimulator:
835  sdks_spec.AppendPathComponent("AppleTVSimulator.platform");
836  break;
837  default:
838  llvm_unreachable("unsupported sdk");
839  }
840 
841  sdks_spec.AppendPathComponent("Developer");
842  sdks_spec.AppendPathComponent("SDKs");
843 
844  if (sdk_type == XcodeSDK::Type::MacOSX) {
845  llvm::VersionTuple version = HostInfo::GetOSVersion();
846 
847  if (!version.empty()) {
848  if (XcodeSDK::SDKSupportsModules(XcodeSDK::Type::MacOSX, version)) {
849  // If the Xcode SDKs are not available then try to use the
850  // Command Line Tools one which is only for MacOSX.
851  if (!FileSystem::Instance().Exists(sdks_spec)) {
852  sdks_spec = GetCommandLineToolsLibraryPath();
853  sdks_spec.AppendPathComponent("SDKs");
854  }
855 
856  // We slightly prefer the exact SDK for this machine. See if it is
857  // there.
858 
859  FileSpec native_sdk_spec = sdks_spec;
860  StreamString native_sdk_name;
861  native_sdk_name.Printf("MacOSX%u.%u.sdk", version.getMajor(),
862  version.getMinor().getValueOr(0));
863  native_sdk_spec.AppendPathComponent(native_sdk_name.GetString());
864 
865  if (FileSystem::Instance().Exists(native_sdk_spec)) {
866  return native_sdk_spec;
867  }
868  }
869  }
870  }
871 
872  return FindSDKInXcodeForModules(sdk_type, sdks_spec);
873 }
874 
875 std::tuple<llvm::VersionTuple, llvm::StringRef>
877  llvm::StringRef build;
878  llvm::StringRef version_str;
879  llvm::StringRef build_str;
880  std::tie(version_str, build_str) = dir.split(' ');
881  llvm::VersionTuple version;
882  if (!version.tryParse(version_str) ||
883  build_str.empty()) {
884  if (build_str.consume_front("(")) {
885  size_t pos = build_str.find(')');
886  build = build_str.slice(0, pos);
887  }
888  }
889 
890  return std::make_tuple(version, build);
891 }
892 
893 llvm::Expected<StructuredData::DictionarySP>
896 
898 
899  if (!annotations || !annotations->GetSize()) {
900  LLDB_LOG(log, "Couldn't extract crash information annotations");
901  return nullptr;
902  }
903 
904  StructuredData::DictionarySP extended_crash_info =
905  std::make_shared<StructuredData::Dictionary>();
906 
907  extended_crash_info->AddItem("crash-info annotations", annotations);
908 
909  return extended_crash_info;
910 }
911 
915 
916  ConstString section_name("__crash_info");
917  Target &target = process.GetTarget();
918  StructuredData::ArraySP array_sp = std::make_shared<StructuredData::Array>();
919 
920  for (ModuleSP module : target.GetImages().Modules()) {
921  SectionList *sections = module->GetSectionList();
922 
923  std::string module_name = module->GetSpecificationDescription();
924 
925  // The DYDL module is skipped since it's always loaded when running the
926  // binary.
927  if (module_name == "/usr/lib/dyld")
928  continue;
929 
930  if (!sections) {
931  LLDB_LOG(log, "Module {0} doesn't have any section!", module_name);
932  continue;
933  }
934 
935  SectionSP crash_info = sections->FindSectionByName(section_name);
936  if (!crash_info) {
937  LLDB_LOG(log, "Module {0} doesn't have section {1}!", module_name,
938  section_name);
939  continue;
940  }
941 
942  addr_t load_addr = crash_info->GetLoadBaseAddress(&target);
943 
944  if (load_addr == LLDB_INVALID_ADDRESS) {
945  LLDB_LOG(log, "Module {0} has an invalid '{1}' section load address: {2}",
946  module_name, section_name, load_addr);
947  continue;
948  }
949 
950  Status error;
951  CrashInfoAnnotations annotations;
952  size_t expected_size = sizeof(CrashInfoAnnotations);
953  size_t bytes_read = process.ReadMemoryFromInferior(load_addr, &annotations,
954  expected_size, error);
955 
956  if (expected_size != bytes_read || error.Fail()) {
957  LLDB_LOG(log, "Failed to read {0} section from memory in module {1}: {2}",
958  section_name, module_name, error);
959  continue;
960  }
961 
962  // initial support added for version 5
963  if (annotations.version < 5) {
964  LLDB_LOG(log,
965  "Annotation version lower than 5 unsupported! Module {0} has "
966  "version {1} instead.",
967  module_name, annotations.version);
968  continue;
969  }
970 
971  if (!annotations.message) {
972  LLDB_LOG(log, "No message available for module {0}.", module_name);
973  continue;
974  }
975 
977  bytes_read =
978  process.ReadCStringFromMemory(annotations.message, message, error);
979 
980  if (message.empty() || bytes_read != message.size() || error.Fail()) {
981  LLDB_LOG(log, "Failed to read the message from memory in module {0}: {1}",
982  module_name, error);
983  continue;
984  }
985 
986  // Remove trailing newline from message
987  if (message.back() == '\n')
988  message.pop_back();
989 
990  if (!annotations.message2)
991  LLDB_LOG(log, "No message2 available for module {0}.", module_name);
992 
993  std::string message2;
994  bytes_read =
995  process.ReadCStringFromMemory(annotations.message2, message2, error);
996 
997  if (!message2.empty() && bytes_read == message2.size() && error.Success())
998  if (message2.back() == '\n')
999  message2.pop_back();
1000 
1001  StructuredData::DictionarySP entry_sp =
1002  std::make_shared<StructuredData::Dictionary>();
1003 
1004  entry_sp->AddStringItem("image", module->GetFileSpec().GetPath(false));
1005  entry_sp->AddStringItem("uuid", module->GetUUID().GetAsString());
1006  entry_sp->AddStringItem("message", message);
1007  entry_sp->AddStringItem("message2", message2);
1008  entry_sp->AddIntegerItem("abort-cause", annotations.abort_cause);
1009 
1010  array_sp->AddItem(entry_sp);
1011  }
1012 
1013  return array_sp;
1014 }
1015 
1017  Target *target, std::vector<std::string> &options, XcodeSDK::Type sdk_type) {
1018  const std::vector<std::string> apple_arguments = {
1019  "-x", "objective-c++", "-fobjc-arc",
1020  "-fblocks", "-D_ISO646_H", "-D__ISO646_H",
1021  "-fgnuc-version=4.2.1"};
1022 
1023  options.insert(options.end(), apple_arguments.begin(), apple_arguments.end());
1024 
1025  StreamString minimum_version_option;
1026  bool use_current_os_version = false;
1027  // If the SDK type is for the host OS, use its version number.
1028  auto get_host_os = []() { return HostInfo::GetTargetTriple().getOS(); };
1029  switch (sdk_type) {
1030  case XcodeSDK::Type::MacOSX:
1031  use_current_os_version = get_host_os() == llvm::Triple::MacOSX;
1032  break;
1033  case XcodeSDK::Type::iPhoneOS:
1034  use_current_os_version = get_host_os() == llvm::Triple::IOS;
1035  break;
1036  case XcodeSDK::Type::AppleTVOS:
1037  use_current_os_version = get_host_os() == llvm::Triple::TvOS;
1038  break;
1039  case XcodeSDK::Type::watchOS:
1040  use_current_os_version = get_host_os() == llvm::Triple::WatchOS;
1041  break;
1042  default:
1043  break;
1044  }
1045 
1046  llvm::VersionTuple version;
1047  if (use_current_os_version)
1048  version = GetOSVersion();
1049  else if (target) {
1050  // Our OS doesn't match our executable so we need to get the min OS version
1051  // from the object file
1052  ModuleSP exe_module_sp = target->GetExecutableModule();
1053  if (exe_module_sp) {
1054  ObjectFile *object_file = exe_module_sp->GetObjectFile();
1055  if (object_file)
1056  version = object_file->GetMinimumOSVersion();
1057  }
1058  }
1059  // Only add the version-min options if we got a version from somewhere
1060  if (!version.empty() && sdk_type != XcodeSDK::Type::Linux) {
1061 #define OPTION(PREFIX, NAME, VAR, ...) \
1062  const char *opt_##VAR = NAME; \
1063  (void)opt_##VAR;
1064 #include "clang/Driver/Options.inc"
1065 #undef OPTION
1066  minimum_version_option << '-';
1067  switch (sdk_type) {
1068  case XcodeSDK::Type::MacOSX:
1069  minimum_version_option << opt_mmacosx_version_min_EQ;
1070  break;
1071  case XcodeSDK::Type::iPhoneSimulator:
1072  minimum_version_option << opt_mios_simulator_version_min_EQ;
1073  break;
1074  case XcodeSDK::Type::iPhoneOS:
1075  minimum_version_option << opt_mios_version_min_EQ;
1076  break;
1077  case XcodeSDK::Type::AppleTVSimulator:
1078  minimum_version_option << opt_mtvos_simulator_version_min_EQ;
1079  break;
1080  case XcodeSDK::Type::AppleTVOS:
1081  minimum_version_option << opt_mtvos_version_min_EQ;
1082  break;
1083  case XcodeSDK::Type::WatchSimulator:
1084  minimum_version_option << opt_mwatchos_simulator_version_min_EQ;
1085  break;
1086  case XcodeSDK::Type::watchOS:
1087  minimum_version_option << opt_mwatchos_version_min_EQ;
1088  break;
1089  case XcodeSDK::Type::bridgeOS:
1090  case XcodeSDK::Type::Linux:
1091  case XcodeSDK::Type::unknown:
1093  XcodeSDK::Info info;
1094  info.type = sdk_type;
1096  "Clang modules on %s are not supported",
1097  XcodeSDK::GetCanonicalName(info).c_str());
1098  }
1099  return;
1100  }
1101  minimum_version_option << version.getAsString();
1102  options.emplace_back(std::string(minimum_version_option.GetString()));
1103  }
1104 
1105  FileSpec sysroot_spec;
1106  // Scope for mutex locker below
1107  {
1108  std::lock_guard<std::mutex> guard(m_mutex);
1109  sysroot_spec = GetSDKDirectoryForModules(sdk_type);
1110  }
1111 
1112  if (FileSystem::Instance().IsDirectory(sysroot_spec.GetPath())) {
1113  options.push_back("-isysroot");
1114  options.push_back(sysroot_spec.GetPath());
1115  }
1116 }
1117 
1119  if (basename.IsEmpty())
1120  return basename;
1121 
1122  StreamString stream;
1123  stream.Printf("lib%s.dylib", basename.GetCString());
1124  return ConstString(stream.GetString());
1125 }
1126 
1127 llvm::VersionTuple PlatformDarwin::GetOSVersion(Process *process) {
1128  if (process && GetPluginName().contains("-simulator")) {
1130  if (Host::GetProcessInfo(process->GetID(), proc_info)) {
1131  const Environment &env = proc_info.GetEnvironment();
1132 
1133  llvm::VersionTuple result;
1134  if (!result.tryParse(env.lookup("SIMULATOR_RUNTIME_VERSION")))
1135  return result;
1136 
1137  std::string dyld_root_path = env.lookup("DYLD_ROOT_PATH");
1138  if (!dyld_root_path.empty()) {
1139  dyld_root_path += "/System/Library/CoreServices/SystemVersion.plist";
1140  ApplePropertyList system_version_plist(dyld_root_path.c_str());
1141  std::string product_version;
1142  if (system_version_plist.GetValueAsString("ProductVersion",
1143  product_version)) {
1144  if (!result.tryParse(product_version))
1145  return result;
1146  }
1147  }
1148  }
1149  // For simulator platforms, do NOT call back through
1150  // Platform::GetOSVersion() as it might call Process::GetHostOSVersion()
1151  // which we don't want as it will be incorrect
1152  return llvm::VersionTuple();
1153  }
1154 
1155  return Platform::GetOSVersion(process);
1156 }
1157 
1159  // A collection of SBFileSpec whose SBFileSpec.m_directory members are filled
1160  // in with any executable directories that should be searched.
1161  static std::vector<FileSpec> g_executable_dirs;
1162 
1163  // Find the global list of directories that we will search for executables
1164  // once so we don't keep doing the work over and over.
1165  static llvm::once_flag g_once_flag;
1166  llvm::call_once(g_once_flag, []() {
1167 
1168  // When locating executables, trust the DEVELOPER_DIR first if it is set
1169  FileSpec xcode_contents_dir = HostInfo::GetXcodeContentsDirectory();
1170  if (xcode_contents_dir) {
1171  FileSpec xcode_lldb_resources = xcode_contents_dir;
1172  xcode_lldb_resources.AppendPathComponent("SharedFrameworks");
1173  xcode_lldb_resources.AppendPathComponent("LLDB.framework");
1174  xcode_lldb_resources.AppendPathComponent("Resources");
1175  if (FileSystem::Instance().Exists(xcode_lldb_resources)) {
1176  FileSpec dir;
1177  dir.GetDirectory().SetCString(xcode_lldb_resources.GetPath().c_str());
1178  g_executable_dirs.push_back(dir);
1179  }
1180  }
1181  // Xcode might not be installed so we also check for the Command Line Tools.
1182  FileSpec command_line_tools_dir = GetCommandLineToolsLibraryPath();
1183  if (command_line_tools_dir) {
1184  FileSpec cmd_line_lldb_resources = command_line_tools_dir;
1185  cmd_line_lldb_resources.AppendPathComponent("PrivateFrameworks");
1186  cmd_line_lldb_resources.AppendPathComponent("LLDB.framework");
1187  cmd_line_lldb_resources.AppendPathComponent("Resources");
1188  if (FileSystem::Instance().Exists(cmd_line_lldb_resources)) {
1189  FileSpec dir;
1190  dir.GetDirectory().SetCString(
1191  cmd_line_lldb_resources.GetPath().c_str());
1192  g_executable_dirs.push_back(dir);
1193  }
1194  }
1195  });
1196 
1197  // Now search the global list of executable directories for the executable we
1198  // are looking for
1199  for (const auto &executable_dir : g_executable_dirs) {
1200  FileSpec executable_file;
1201  executable_file.GetDirectory() = executable_dir.GetDirectory();
1202  executable_file.GetFilename().SetCString(basename);
1203  if (FileSystem::Instance().Exists(executable_file))
1204  return executable_file;
1205  }
1206 
1207  return FileSpec();
1208 }
1209 
1212  // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr if
1213  // the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't require
1214  // any specific value; rather, it just needs to exist). We will set it here
1215  // as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag is not set. Xcode
1216  // makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
1217  // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
1218  // specifically want it unset.
1219  const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
1220  auto &env_vars = launch_info.GetEnvironment();
1221  if (!env_vars.count(disable_env_var)) {
1222  // We want to make sure that OS_ACTIVITY_DT_MODE is set so that we get
1223  // os_log and NSLog messages mirrored to the target process stderr.
1224  env_vars.try_emplace("OS_ACTIVITY_DT_MODE", "enable");
1225  }
1226 
1227  // Let our parent class do the real launching.
1228  return PlatformPOSIX::LaunchProcess(launch_info);
1229 }
1230 
1232  const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
1233  const FileSpecList *module_search_paths_ptr,
1234  llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
1235  const FileSpec &platform_file = module_spec.GetFileSpec();
1236  // See if the file is present in any of the module_search_paths_ptr
1237  // directories.
1238  if (!module_sp && module_search_paths_ptr && platform_file) {
1239  // create a vector of all the file / directory names in platform_file e.g.
1240  // this might be
1241  // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
1242  //
1243  // We'll need to look in the module_search_paths_ptr directories for both
1244  // "UIFoundation" and "UIFoundation.framework" -- most likely the latter
1245  // will be the one we find there.
1246 
1247  FileSpec platform_pull_upart(platform_file);
1248  std::vector<std::string> path_parts;
1249  path_parts.push_back(
1250  platform_pull_upart.GetLastPathComponent().AsCString());
1251  while (platform_pull_upart.RemoveLastPathComponent()) {
1252  ConstString part = platform_pull_upart.GetLastPathComponent();
1253  path_parts.push_back(part.AsCString());
1254  }
1255  const size_t path_parts_size = path_parts.size();
1256 
1257  size_t num_module_search_paths = module_search_paths_ptr->GetSize();
1258  for (size_t i = 0; i < num_module_search_paths; ++i) {
1260  LLDB_LOGF(
1261  log_verbose,
1262  "PlatformRemoteDarwinDevice::GetSharedModule searching for binary in "
1263  "search-path %s",
1264  module_search_paths_ptr->GetFileSpecAtIndex(i).GetPath().c_str());
1265  // Create a new FileSpec with this module_search_paths_ptr plus just the
1266  // filename ("UIFoundation"), then the parent dir plus filename
1267  // ("UIFoundation.framework/UIFoundation") etc - up to four names (to
1268  // handle "Foo.framework/Contents/MacOS/Foo")
1269 
1270  for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
1271  FileSpec path_to_try(module_search_paths_ptr->GetFileSpecAtIndex(i));
1272 
1273  // Add the components backwards. For
1274  // .../PrivateFrameworks/UIFoundation.framework/UIFoundation path_parts
1275  // is
1276  // [0] UIFoundation
1277  // [1] UIFoundation.framework
1278  // [2] PrivateFrameworks
1279  //
1280  // and if 'j' is 2, we want to append path_parts[1] and then
1281  // path_parts[0], aka 'UIFoundation.framework/UIFoundation', to the
1282  // module_search_paths_ptr path.
1283 
1284  for (int k = j; k >= 0; --k) {
1285  path_to_try.AppendPathComponent(path_parts[k]);
1286  }
1287 
1288  if (FileSystem::Instance().Exists(path_to_try)) {
1289  ModuleSpec new_module_spec(module_spec);
1290  new_module_spec.GetFileSpec() = path_to_try;
1291  Status new_error(
1292  Platform::GetSharedModule(new_module_spec, process, module_sp,
1293  nullptr, old_modules, did_create_ptr));
1294 
1295  if (module_sp) {
1296  module_sp->SetPlatformFileSpec(path_to_try);
1297  return new_error;
1298  }
1299  }
1300  }
1301  }
1302  }
1303  return Status();
1304 }
1305 
1307  llvm::StringRef component) {
1308  auto begin = llvm::sys::path::begin(path);
1309  auto end = llvm::sys::path::end(path);
1310  for (auto it = begin; it != end; ++it) {
1311  if (it->contains(component)) {
1312  llvm::SmallString<128> buffer;
1313  llvm::sys::path::append(buffer, begin, ++it,
1314  llvm::sys::path::Style::posix);
1315  return buffer.str().str();
1316  }
1317  }
1318  return {};
1319 }
1320 
1322  if (FileSpec fspec = HostInfo::GetShlibDir())
1323  return FileSpec(FindComponentInPath(fspec.GetPath(), ".xctoolchain"));
1324  return {};
1325 }
1326 
1328  if (FileSpec fspec = HostInfo::GetShlibDir())
1329  return FileSpec(FindComponentInPath(fspec.GetPath(), "CommandLineTools"));
1330  return {};
1331 }
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb_private::SymbolFile
Definition: SymbolFile.h:38
PlatformDarwin::DirectoryEnumerator
static lldb_private::FileSystem::EnumerateDirectoryResult DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path)
Definition: PlatformDarwin.cpp:777
PlatformDarwin::FindSDKInXcodeForModules
static lldb_private::FileSpec FindSDKInXcodeForModules(lldb_private::XcodeSDK::Type sdk_type, const lldb_private::FileSpec &sdks_spec)
Definition: PlatformDarwin.cpp:790
lldb_private::FileSpec::GetLastPathComponent
ConstString GetLastPathComponent() const
Definition: FileSpec.cpp:413
lldb_private::SectionList::FindSectionByName
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
Definition: Section.cpp:554
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::ObjectFile::GetFileSpec
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:292
PlatformDarwin::x86GetSupportedArchitectures
void x86GetSupportedArchitectures(std::vector< lldb_private::ArchSpec > &archs)
Definition: PlatformDarwin.cpp:517
lldb_private::ModuleSpec::GetPlatformFileSpec
FileSpec & GetPlatformFileSpec()
Definition: ModuleSpec.h:64
lldb_private::ModuleSpec::GetUUIDPtr
UUID * GetUUIDPtr()
Definition: ModuleSpec.h:92
lldb_private::ModuleList::Modules
ModuleIterable Modules() const
Definition: ModuleList.h:489
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:667
ModuleSpec.h
PlatformDarwin::CheckLocalSharedCache
virtual bool CheckLocalSharedCache() const
Definition: PlatformDarwin.h:146
Host.h
PlatformDarwin::~PlatformDarwin
~PlatformDarwin() override
Destructor.
lldb_private::ArchSpec::GetCore
Core GetCore() const
Definition: ArchSpec.h:423
GetCommandLineToolsLibraryPath
static FileSpec GetCommandLineToolsLibraryPath()
Definition: PlatformDarwin.cpp:763
PlatformDarwin::CrashInfoAnnotations
Definition: PlatformDarwin.h:109
PlatformDarwin::SetThreadCreationBreakpoint
lldb::BreakpointSP SetThreadCreationBreakpoint(lldb_private::Target &target) override
Definition: PlatformDarwin.cpp:679
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:283
lldb_private::Process
Definition: Process.h:338
lldb_private::Target::GetExecutableModule
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1344
lldb_private::Platform::GetLocalCacheDirectory
virtual const char * GetLocalCacheDirectory()
Definition: Platform.cpp:1395
Module.h
lldb_private::BreakpointSite::GetOwnerAtIndex
lldb::BreakpointLocationSP GetOwnerAtIndex(size_t idx)
This method returns the breakpoint location at index index located at this breakpoint site.
Definition: BreakpointSite.cpp:142
BreakpointLocation.h
PlatformDarwin::LocateExecutable
lldb_private::FileSpec LocateExecutable(const char *basename) override
Find a support executable that may not live within in the standard locations related to LLDB.
Definition: PlatformDarwin.cpp:1158
PlatformDarwin::GetSDKDirectoryForModules
static lldb_private::FileSpec GetSDKDirectoryForModules(lldb_private::XcodeSDK::Type sdk_type)
Definition: PlatformDarwin.cpp:816
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1206
lldb_private::RemoteAwarePlatform::LaunchProcess
Status LaunchProcess(ProcessLaunchInfo &launch_info) override
Launch a new process on a platform, not necessarily for debugging, it could be just for running the p...
Definition: RemoteAwarePlatform.cpp:413
LIBLLDB_LOG_PLATFORM
#define LIBLLDB_LOG_PLATFORM
Definition: Logging.h:80
GetCompatibleArchs
static llvm::ArrayRef< const char * > GetCompatibleArchs(ArchSpec::Core core)
Definition: PlatformDarwin.cpp:532
lldb_private::Module::GetSymbolFile
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
Definition: Module.cpp:1036
lldb_private::ConstString::SetCString
void SetCString(const char *cstr)
Set the C string value.
Definition: ConstString.cpp:313
lldb_private::Module
Definition: Module.h:85
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:193
LocateSymbolFile.h
lldb_private::SectionList
Definition: Section.h:34
lldb_private::Platform::m_trap_handlers
std::vector< ConstString > m_trap_handlers
Definition: Platform.h:910
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Process::ReadCStringFromMemory
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
Definition: Process.cpp:1988
PlatformDarwin::GetCurrentCommandLineToolsDirectory
static lldb_private::FileSpec GetCurrentCommandLineToolsDirectory()
Return the command line tools directory the current LLDB instance is located in.
Definition: PlatformDarwin.cpp:1327
lldb_private::Target::CreateBreakpoint
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition: Target.cpp:331
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::XcodeSDK::Info
A parsed SDK directory name.
Definition: XcodeSDK.h:44
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
lldb_private::Debugger::GetScriptLanguage
lldb::ScriptLanguage GetScriptLanguage() const
Definition: Debugger.cpp:316
lldb_private::ObjectFile::Type
Type
Definition: ObjectFile.h:66
lldb_private::Target::GetDebugger
Debugger & GetDebugger()
Definition: Target.h:1001
lldb_private::FileSpec::CopyByRemovingLastPathComponent
FileSpec CopyByRemovingLastPathComponent() const
Definition: FileSpec.cpp:404
Debugger.h
lldb_private::Target
Definition: Target.h:452
PlatformDarwin::SDKEnumeratorInfo::found_path
lldb_private::FileSpec found_path
Definition: PlatformDarwin.h:149
lldb_private::Debugger::GetScriptInterpreter
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, llvm::Optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1379
Section.h
lldb_private::PluginInterface::GetPluginName
virtual llvm::StringRef GetPluginName()=0
PlatformDarwin::SDKEnumeratorInfo
Definition: PlatformDarwin.h:148
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:926
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::Platform::m_mutex
std::mutex m_mutex
Definition: Platform.h:900
lldb_private::ModuleSpec::GetSymbolFileSpec
FileSpec & GetSymbolFileSpec()
Definition: ModuleSpec.h:76
lldb_private::ApplePropertyList::GetValueAsString
bool GetValueAsString(const char *key, std::string &value) const
Definition: XML.cpp:402
lldb_private::Process::ReadMemoryFromInferior
size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition: Process.cpp:2034
Process.h
lldb_private::ArchSpec::Core
Core
Definition: ArchSpec.h:101
PlatformDarwin::GetSharedModule
lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr) override
Definition: PlatformDarwin.cpp:366
Target.h
lldb_private::ModuleSpec::GetUUID
UUID & GetUUID()
Definition: ModuleSpec.h:98
PlatformDarwin::PlatformDarwin
PlatformDarwin(bool is_host)
Default Constructor.
Definition: PlatformDarwin.cpp:51
LIBLLDB_LOG_HOST
#define LIBLLDB_LOG_HOST
Definition: Logging.h:69
lldb_private::Module::GetFileSpec
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:477
PlatformPOSIX::PutFile
lldb_private::Status PutFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
Definition: PlatformPOSIX.cpp:89
lldb_private::Platform::GetSystemArchitecture
const ArchSpec & GetSystemArchitecture()
Definition: Platform.cpp:949
Platform.h
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:288
PlatformPOSIX
Definition: PlatformPOSIX.h:18
ProcessInfo.h
lldb_private::BreakpointSite
Definition: BreakpointSite.h:35
PlatformDarwin::PutFile
lldb_private::Status PutFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
Definition: PlatformDarwin.cpp:60
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
strcasestr
char * strcasestr(const char *s, const char *find)
Definition: Windows.cpp:47
Log.h
lldb_private::ConstString::IsEmpty
bool IsEmpty() const
Test for empty string.
Definition: ConstString.h:304
PlatformDarwin::CrashInfoAnnotations::abort_cause
uint64_t abort_cause
Definition: PlatformDarwin.h:117
MakeCacheFolderForFile
static lldb_private::Status MakeCacheFolderForFile(const FileSpec &module_cache_spec)
Definition: PlatformDarwin.cpp:206
PlatformDarwin::ARMGetSupportedArchitectures
void ARMGetSupportedArchitectures(std::vector< lldb_private::ArchSpec > &archs, llvm::Optional< llvm::Triple::OSType > os={})
The architecture selection rules for arm processors These cpu subtypes have distinct names (e....
Definition: PlatformDarwin.cpp:637
GetXcodeSelectPath
static FileSpec GetXcodeSelectPath()
Definition: PlatformDarwin.cpp:651
PlatformDarwin::AddClangModuleCompilationOptionsForSDKType
void AddClangModuleCompilationOptionsForSDKType(lldb_private::Target *target, std::vector< std::string > &options, lldb_private::XcodeSDK::Type sdk_type)
Definition: PlatformDarwin.cpp:1016
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:182
PlatformDarwin::CalculateTrapHandlerSymbolNames
void CalculateTrapHandlerSymbolNames() override
Ask the Platform subclass to fill in the list of trap handler names.
Definition: PlatformDarwin.cpp:759
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::RemoteAwarePlatform::m_remote_platform_sp
lldb::PlatformSP m_remote_platform_sp
Definition: RemoteAwarePlatform.h:104
lldb_private::FileSystem::EnumerateDirectoryResult
EnumerateDirectoryResult
Definition: FileSystem.h:167
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::Platform::GetSupportsRSync
virtual bool GetSupportsRSync()
Definition: Platform.h:570
lldb::eScriptLanguagePython
@ eScriptLanguagePython
Definition: lldb-enumerations.h:218
Timer.h
lldb_private::StructuredData::DictionarySP
std::shared_ptr< Dictionary > DictionarySP
Definition: StructuredData.h:67
PlatformDarwin::ResolveSymbolFile
lldb_private::Status ResolveSymbolFile(lldb_private::Target &target, const lldb_private::ModuleSpec &sym_spec, lldb_private::FileSpec &sym_file) override
Find a symbol file given a symbol file module specification.
Definition: PlatformDarwin.cpp:194
lldb_private::Debugger
Definition: Debugger.h:70
lldb_private::RemoteAwarePlatform::Unlink
Status Unlink(const FileSpec &file_spec) override
Definition: RemoteAwarePlatform.cpp:281
HostInfo.h
PlatformDarwin::LocateExecutableScriptingResources
lldb_private::FileSpecList LocateExecutableScriptingResources(lldb_private::Target *target, lldb_private::Module &module, lldb_private::Stream *feedback_stream) override
Definition: PlatformDarwin.cpp:70
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
PlatformDarwin::ExtractCrashInfoAnnotations
lldb_private::StructuredData::ArraySP ExtractCrashInfoAnnotations(lldb_private::Process &process)
Extract the __crash_info annotations from each of of the target's modules.
Definition: PlatformDarwin.cpp:913
ObjectFile.h
PlatformDarwin::FindBundleBinaryInExecSearchPaths
lldb_private::Status FindBundleBinaryInExecSearchPaths(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr)
Definition: PlatformDarwin.cpp:1231
lldb_private::Platform::IsRemote
bool IsRemote() const
Definition: Platform.h:427
lldb_private::ScriptInterpreter::IsReservedWord
virtual bool IsReservedWord(const char *word)
Definition: ScriptInterpreter.h:543
lldb_private::ProcessLaunchInfo::SetMonitorProcessCallback
void SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, bool monitor_signals)
Definition: ProcessLaunchInfo.cpp:179
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:52
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:968
lldb_private::SharedCacheImageInfo
Definition: HostInfoBase.h:28
lldb_private::Status
Definition: Status.h:44
PlatformDarwin::GetFullNameForDylib
lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override
Definition: PlatformDarwin.cpp:1118
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
message
message(FATAL_ERROR "invalid libipt include path provided") endif() include_directories($
Definition: Plugins/Trace/intel-pt/CMakeLists.txt:6
uint32_t
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
lldb_private::FileSpec::RemoveLastPathComponent
bool RemoveLastPathComponent()
Removes the last path component by replacing the current path with its parent.
Definition: FileSpec.cpp:444
lldb_private::ObjectFile::GetMinimumOSVersion
virtual llvm::VersionTuple GetMinimumOSVersion()
Get the minimum OS version this object file can run on.
Definition: ObjectFile.h:615
lldb_private::ModuleSpec::GetArchitecturePtr
ArchSpec * GetArchitecturePtr()
Definition: ModuleSpec.h:80
lldb_private::ProcessInfo::GetEnvironment
Environment & GetEnvironment()
Definition: ProcessInfo.h:87
lldb_private::XcodeSDK::Type
Type
Different types of Xcode SDKs.
Definition: XcodeSDK.h:29
lldb_private::ApplePropertyList
Definition: XML.h:145
PlatformDarwin::GetSharedModuleWithLocalCache
virtual lldb_private::Status GetSharedModuleWithLocalCache(const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr)
Definition: PlatformDarwin.cpp:221
PlatformDarwin::GetCurrentToolchainDirectory
static lldb_private::FileSpec GetCurrentToolchainDirectory()
Return the toolchain directory the current LLDB instance is located in.
Definition: PlatformDarwin.cpp:1321
lldb_private::SharedCacheImageInfo::uuid
UUID uuid
Definition: HostInfoBase.h:29
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(LLDBLog mask)
Definition: Logging.cpp:83
lldb_private::SharedCacheImageInfo::data_sp
lldb::DataBufferSP data_sp
Definition: HostInfoBase.h:30
lldb_private::ProcessLaunchInfo::GetShell
const FileSpec & GetShell() const
Definition: ProcessLaunchInfo.cpp:140
XML.h
lldb_private::Environment
Definition: Environment.h:18
lldb_private::GetLogIfAnyCategoriesSet
Log * GetLogIfAnyCategoriesSet(LLDBLog mask)
Definition: Logging.cpp:87
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:88
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:276
lldb_private::Platform
Definition: Platform.h:71
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::Process::GetID
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition: Process.h:538
PlatformDarwin::CrashInfoAnnotations::version
uint64_t version
Definition: PlatformDarwin.h:110
PlatformDarwin::ModuleIsExcludedForUnconstrainedSearches
bool ModuleIsExcludedForUnconstrainedSearches(lldb_private::Target &target, const lldb::ModuleSP &module_sp) override
Definition: PlatformDarwin.cpp:504
PlatformDarwin::CrashInfoAnnotations::message
uint64_t message
Definition: PlatformDarwin.h:111
Status.h
lldb_private::FileSpec::AppendPathComponent
void AppendPathComponent(llvm::StringRef component)
Definition: FileSpec.cpp:433
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
PlatformDarwin::CrashInfoAnnotations::message2
uint64_t message2
Definition: PlatformDarwin.h:114
lldb_private::BreakpointSite::SetTrapOpcode
bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size)
Sets the trap opcode.
Definition: BreakpointSite.cpp:104
CommandInterpreter.h
lldb_private::FileSpec::GetDirectory
ConstString & GetDirectory()
Directory string get accessor.
Definition: FileSpec.cpp:333
PlatformDarwin::FetchExtendedCrashInformation
llvm::Expected< lldb_private::StructuredData::DictionarySP > FetchExtendedCrashInformation(lldb_private::Process &process) override
Gather all of crash informations into a structured data dictionary.
Definition: PlatformDarwin.cpp:894
BreakpointSite.h
lldb_private::Log
Definition: Log.h:48
lldb_private::StructuredData::ArraySP
std::shared_ptr< Array > ArraySP
Definition: StructuredData.h:62
PlatformDarwin::ParseVersionBuildDir
static std::tuple< llvm::VersionTuple, llvm::StringRef > ParseVersionBuildDir(llvm::StringRef str)
Definition: PlatformDarwin.cpp:876
PlatformDarwin::GetResumeCountForLaunchInfo
uint32_t GetResumeCountForLaunchInfo(lldb_private::ProcessLaunchInfo &launch_info) override
Definition: PlatformDarwin.cpp:707
PlatformDarwin::GetSoftwareBreakpointTrapOpcode
size_t GetSoftwareBreakpointTrapOpcode(lldb_private::Target &target, lldb_private::BreakpointSite *bp_site) override
Definition: PlatformDarwin.cpp:447
llvm::SmallVectorImpl
Definition: Disassembler.h:42
PlatformDarwin::GetOSVersion
llvm::VersionTuple GetOSVersion(lldb_private::Process *process=nullptr) override
Get the OS version from a connected platform.
Definition: PlatformDarwin.cpp:1127
lldb_private::Platform::IsHost
bool IsHost() const
Definition: Platform.h:423
SymbolVendor.h
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
PlatformDarwin::LaunchProcess
lldb_private::Status LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override
Launch a new process on a platform, not necessarily for debugging, it could be just for running the p...
Definition: PlatformDarwin.cpp:1211
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:346
PlatformDarwin::DebugProcess
lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target &target, lldb_private::Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
Definition: PlatformDarwin.cpp:735
PlatformDarwin::SDKEnumeratorInfo::sdk_type
lldb_private::XcodeSDK::Type sdk_type
Definition: PlatformDarwin.h:150
PlatformDarwin::FindComponentInPath
static std::string FindComponentInPath(llvm::StringRef path, llvm::StringRef component)
Definition: PlatformDarwin.cpp:1306
lldb
Definition: SBAddress.h:15
LIBLLDB_LOG_PROCESS
#define LIBLLDB_LOG_PROCESS
Definition: Logging.h:56
BringInRemoteFile
static lldb_private::Status BringInRemoteFile(Platform *platform, const lldb_private::ModuleSpec &module_spec, const FileSpec &module_cache_spec)
Definition: PlatformDarwin.cpp:213
lldb_private::FileSpec::GetFilename
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:339
SymbolFile.h
lldb_private::ObjectFile
Definition: ObjectFile.h:60
lldb_private::Platform::GetFile
virtual Status GetFile(const FileSpec &source, const FileSpec &destination)
Definition: Platform.cpp:1311
PlatformDarwin.h
lldb_private::ArchSpec::IsExactMatch
bool IsExactMatch(const ArchSpec &rhs) const
Compare an ArchSpec to another ArchSpec, requiring an exact cpu type match between them.
Definition: ArchSpec.cpp:930
lldb_private::ObjectFile::GetType
Type GetType()
Definition: ObjectFile.h:637
lldb_private::FileSpec::GetFileNameStrippingExtension
ConstString GetFileNameStrippingExtension() const
Return the filename without the extension part.
Definition: FileSpec.cpp:387