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#include <optional>
17
20#include "lldb/Core/Debugger.h"
21#include "lldb/Core/Module.h"
24#include "lldb/Core/Section.h"
25#include "lldb/Host/Host.h"
26#include "lldb/Host/HostInfo.h"
27#include "lldb/Host/XML.h"
38#include "lldb/Target/Process.h"
39#include "lldb/Target/Target.h"
41#include "lldb/Utility/Log.h"
43#include "lldb/Utility/Status.h"
44#include "lldb/Utility/Timer.h"
45#include "llvm/ADT/STLExtras.h"
46#include "llvm/ADT/StringTable.h"
47#include "llvm/Support/Error.h"
48#include "llvm/Support/FileSystem.h"
49#include "llvm/Support/Threading.h"
50#include "llvm/Support/VersionTuple.h"
51
52#if defined(__APPLE__)
54#include <TargetConditionals.h>
55#endif
56
57using namespace lldb;
58using namespace lldb_private;
59
60#define OPTTABLE_STR_TABLE_CODE
61#include "clang/Options/Options.inc"
62#undef OPTTABLE_STR_TABLE_CODE
63
64static Status ExceptionMaskValidator(const char *string, void *unused) {
66 llvm::StringRef str_ref(string);
67 llvm::SmallVector<llvm::StringRef> candidates;
68 str_ref.split(candidates, '|');
69 for (auto candidate : candidates) {
70 if (!(candidate == "EXC_BAD_ACCESS"
71 || candidate == "EXC_BAD_INSTRUCTION"
72 || candidate == "EXC_ARITHMETIC"
73 || candidate == "EXC_RESOURCE"
74 || candidate == "EXC_GUARD"
75 || candidate == "EXC_SYSCALL")) {
76 error = Status::FromErrorStringWithFormat("invalid exception type: '%s'",
77 candidate.str().c_str());
78 return error;
79 }
80 }
81 return {};
82}
83
84/// Destructor.
85///
86/// The destructor is virtual since this class is designed to be
87/// inherited from by the plug-in instance.
89
90// Static Variables
91static uint32_t g_initialize_count = 0;
92
101
109
111 return "Darwin platform plug-in.";
112}
113
115 // We only create subclasses of the PlatformDarwin plugin.
116 return PlatformSP();
117}
118
119#define LLDB_PROPERTIES_platformdarwin
120#include "PlatformMacOSXProperties.inc"
121
122#define LLDB_PROPERTIES_platformdarwin
123enum {
124#include "PlatformMacOSXPropertiesEnum.inc"
125};
126
128public:
129 static llvm::StringRef GetSettingName() {
130 static constexpr llvm::StringLiteral g_setting_name("darwin");
131 return g_setting_name;
132 }
133
135 m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
136 m_collection_sp->Initialize(g_platformdarwin_properties_def);
137 }
138
139 ~PlatformDarwinProperties() override = default;
140
141 const char *GetIgnoredExceptions() const {
142 const uint32_t idx = ePropertyIgnoredExceptions;
143 const OptionValueString *option_value =
144 m_collection_sp->GetPropertyAtIndexAsOptionValueString(idx);
145 assert(option_value);
146 return option_value->GetCurrentValue();
147 }
148
150 const uint32_t idx = ePropertyIgnoredExceptions;
151 OptionValueString *option_value =
152 m_collection_sp->GetPropertyAtIndexAsOptionValueString(idx);
153 assert(option_value);
154 return option_value;
155 }
156};
157
159 static PlatformDarwinProperties g_settings;
160 return g_settings;
161}
162
164 lldb_private::Debugger &debugger) {
167 const bool is_global_setting = false;
169 debugger, GetGlobalProperties().GetValueProperties(),
170 "Properties for the Darwin platform plug-in.", is_global_setting);
171 OptionValueString *value = GetGlobalProperties().GetIgnoredExceptionValue();
173 }
174}
175
176Args
178 std::string ignored_exceptions
179 = GetGlobalProperties().GetIgnoredExceptions();
180 if (ignored_exceptions.empty())
181 return {};
182 Args ret_args;
183 std::string packet = "QSetIgnoredExceptions:";
184 packet.append(ignored_exceptions);
185 ret_args.AppendArgument(packet);
186 return ret_args;
187}
188
191 const lldb_private::FileSpec &destination, uint32_t uid,
192 uint32_t gid) {
193 // Unconditionally unlink the destination. If it is an executable,
194 // simply opening it and truncating its contents would invalidate
195 // its cached code signature.
196 Unlink(destination);
197 return PlatformPOSIX::PutFile(source, destination, uid, gid);
198}
199
200llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile>
202 Stream &feedback_stream, FileSpec module_spec, const Target &target,
203 const FileSpec &symfile_spec) {
204
205 assert(target.GetDebugger().GetScriptInterpreter() &&
206 "Trying to locate scripting resources but no ScriptInterpreter is "
207 "available.");
208
209 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> file_specs;
210 const FileSpec original_module_spec = module_spec;
211 while (module_spec.GetFilename()) {
213 target.GetDebugger()
216 module_spec.GetFilename().GetStringRef());
217
218 StreamString path_string;
219 StreamString original_path_string;
220 // for OSX we are going to be in
221 // .dSYM/Contents/Resources/DWARF/<basename> let us go to
222 // .dSYM/Contents/Resources/Python/<basename>.py and see if the
223 // file exists
224 path_string.Format("{0}/../Python/{1}.py",
225 symfile_spec.GetDirectory().GetStringRef(),
226 sanitized_name.GetSanitizedName());
227 original_path_string.Format("{0}/../Python/{1}.py",
228 symfile_spec.GetDirectory().GetStringRef(),
229 sanitized_name.GetOriginalName());
230
231 FileSpec script_fspec(path_string.GetString());
232 FileSystem::Instance().Resolve(script_fspec);
233 FileSpec orig_script_fspec(original_path_string.GetString());
234 FileSystem::Instance().Resolve(orig_script_fspec);
235
236 WarnIfInvalidUnsanitizedScriptExists(feedback_stream, sanitized_name,
237 orig_script_fspec, script_fspec);
238
239 if (FileSystem::Instance().Exists(script_fspec)) {
240 LoadScriptFromSymFile load_style =
241 Platform::GetScriptLoadStyleForModule(original_module_spec, target);
242 file_specs.try_emplace(std::move(script_fspec), load_style);
243 break;
244 }
245
246 // If we didn't find the python file, then keep stripping the
247 // extensions and try again
248 ConstString filename_no_extension(
249 module_spec.GetFileNameStrippingExtension());
250 if (module_spec.GetFilename() == filename_no_extension)
251 break;
252
253 module_spec.SetFilename(filename_no_extension);
254 }
255
256 return file_specs;
257}
258
259llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile>
261 Target *target, Module &module, Stream &feedback_stream) {
262 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> empty;
263 if (!target)
264 return empty;
265
266 // For now only Python scripts supported for auto-loading.
268 return empty;
269
270 // NB some extensions might be meaningful and should not be stripped -
271 // "this.binary.file"
272 // should not lose ".file" but GetFileNameStrippingExtension() will do
273 // precisely that. Ideally, we should have a per-platform list of
274 // extensions (".exe", ".app", ".dSYM", ".framework") which should be
275 // stripped while leaving "this.binary.file" as-is.
276
277 const FileSpec &module_spec = module.GetFileSpec();
278
279 if (!module_spec)
280 return empty;
281
282 SymbolFile *symfile = module.GetSymbolFile();
283 if (!symfile)
284 return empty;
285
286 ObjectFile *objfile = symfile->GetObjectFile();
287 if (!objfile)
288 return empty;
289
290 const FileSpec &symfile_spec = objfile->GetFileSpec();
291 if (symfile_spec &&
292 llvm::StringRef(symfile_spec.GetPath())
293 .contains_insensitive(".dSYM/Contents/Resources/DWARF") &&
294 FileSystem::Instance().Exists(symfile_spec))
296 feedback_stream, module_spec, *target, symfile_spec);
297
298 return empty;
299}
300
302#if defined(__APPLE__)
303 SymbolFile *symfile = module.GetSymbolFile();
304 if (!symfile)
305 return false;
306
307 ObjectFile *objfile = symfile->GetObjectFile();
308 if (!objfile)
309 return false;
310
311 std::string symfile_path = objfile->GetFileSpec().GetPath();
312 llvm::StringRef path_ref(symfile_path);
313
314 // Find the .dSYM bundle root from the symfile path, which is typically
315 // .dSYM/Contents/Resources/DWARF/<name>.
316 auto pos = path_ref.find(".dSYM/");
317 if (pos == llvm::StringRef::npos)
318 return false;
319
320 FileSpec bundle_spec(path_ref.substr(0, pos + 5));
321
324 "dSYM bundle '{0}' has valid trusted code signature",
325 bundle_spec.GetPath());
326 return true;
327 }
328
329 return false;
330#else
331 return false;
332#endif
333}
334
336 const ModuleSpec &sym_spec,
337 FileSpec &sym_file) {
338 sym_file = sym_spec.GetSymbolFileSpec();
339 if (FileSystem::Instance().IsDirectory(sym_file)) {
341 sym_file, sym_spec.GetUUIDPtr(), sym_spec.GetArchitecturePtr());
342 }
343 return {};
344}
345
347 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
348 llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
350 module_sp.reset();
351
352 if (IsRemote()) {
353 // If we have a remote platform always, let it try and locate the shared
354 // module first.
356 error = m_remote_platform_sp->GetSharedModule(
357 module_spec, process, module_sp, old_modules, did_create_ptr);
358 }
359 }
360
361 if (!module_sp) {
362 // Fall back to the local platform and find the file locally
363 error = Platform::GetSharedModule(module_spec, process, module_sp,
364 old_modules, did_create_ptr);
365
366 const FileSpec &platform_file = module_spec.GetFileSpec();
367 // Get module search paths from the target if available.
368 TargetSP target_sp = module_spec.GetTargetSP();
369 FileSpecList module_search_paths;
370 if (target_sp)
371 module_search_paths = target_sp->GetExecutableSearchPaths();
372 if (!module_sp && !module_search_paths.IsEmpty() && platform_file) {
373 // We can try to pull off part of the file path up to the bundle
374 // directory level and try any module search paths...
375 FileSpec bundle_directory;
376 if (Host::GetBundleDirectory(platform_file, bundle_directory)) {
377 if (platform_file == bundle_directory) {
378 ModuleSpec new_module_spec(module_spec);
379 new_module_spec.GetFileSpec() = bundle_directory;
380 if (Host::ResolveExecutableInBundle(new_module_spec.GetFileSpec())) {
381 Status new_error(Platform::GetSharedModule(new_module_spec, process,
382 module_sp, old_modules,
383 did_create_ptr));
384
385 if (module_sp)
386 return new_error;
387 }
388 } else {
389 char platform_path[PATH_MAX];
390 char bundle_dir[PATH_MAX];
391 platform_file.GetPath(platform_path, sizeof(platform_path));
392 const size_t bundle_directory_len =
393 bundle_directory.GetPath(bundle_dir, sizeof(bundle_dir));
394 char new_path[PATH_MAX];
395 size_t num_module_search_paths = module_search_paths.GetSize();
396 for (size_t i = 0; i < num_module_search_paths; ++i) {
397 const size_t search_path_len =
398 module_search_paths.GetFileSpecAtIndex(i).GetPath(
399 new_path, sizeof(new_path));
400 if (search_path_len < sizeof(new_path)) {
401 snprintf(new_path + search_path_len,
402 sizeof(new_path) - search_path_len, "/%s",
403 platform_path + bundle_directory_len);
404 FileSpec new_file_spec(new_path);
405 if (FileSystem::Instance().Exists(new_file_spec)) {
406 ModuleSpec new_module_spec(module_spec);
407 new_module_spec.GetFileSpec() = new_file_spec;
409 new_module_spec, process, module_sp, old_modules,
410 did_create_ptr));
411
412 if (module_sp) {
413 module_sp->SetPlatformFileSpec(new_file_spec);
414 return new_error;
415 }
416 }
417 }
418 }
419 }
420 }
421 }
422 }
423 if (module_sp)
424 module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
425 return error;
426}
428 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
429 llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
430 Status err;
431
432 SymbolSharedCacheUse sc_mode =
434 SharedCacheImageInfo image_info;
435 if (process && process->GetDynamicLoader()) {
436 addr_t sc_base_addr;
437 UUID sc_uuid;
438 LazyBool using_sc, private_sc;
439 FileSpec sc_path;
440 std::optional<uint64_t> size;
442 sc_base_addr, sc_uuid, using_sc, private_sc, sc_path, size)) {
443 if (module_spec.GetUUID())
444 image_info = HostInfo::GetSharedCacheImageInfo(module_spec.GetUUID(),
445 sc_uuid, sc_mode);
446 else
447 image_info = HostInfo::GetSharedCacheImageInfo(
448 module_spec.GetFileSpec().GetPathAsConstString(), sc_uuid, sc_mode);
449 }
450 }
451 // Fall back to looking for the file in lldb's own shared cache.
452 if (!image_info.GetUUID())
453 image_info = HostInfo::GetSharedCacheImageInfo(
454 module_spec.GetFileSpec().GetPathAsConstString(), sc_mode);
455
456 // If we found it and it has the correct UUID, let's proceed with
457 // creating a module from the memory contents.
458 if (image_info.GetUUID() && (!module_spec.GetUUID() ||
459 module_spec.GetUUID() == image_info.GetUUID())) {
460 ModuleSpec shared_cache_spec(module_spec.GetFileSpec(),
461 image_info.GetUUID(),
462 image_info.GetExtractor());
463 err = ModuleList::GetSharedModule(shared_cache_spec, module_sp, old_modules,
464 did_create_ptr);
465 if (module_sp) {
467 LLDB_LOGF(log, "module %s was found in a shared cache",
468 module_spec.GetFileSpec().GetPath().c_str());
469 }
470 }
471 return err;
472}
473
474size_t
476 BreakpointSite *bp_site) {
477 const uint8_t *trap_opcode = nullptr;
478 uint32_t trap_opcode_size = 0;
479 bool bp_is_thumb = false;
480
481 llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
482 switch (machine) {
483 case llvm::Triple::aarch64_32:
484 case llvm::Triple::aarch64: {
485 // 'brk #0' or 0xd4200000 in BE byte order
486 static const uint8_t g_arm64_breakpoint_opcode[] = {0x00, 0x00, 0x20, 0xD4};
487 trap_opcode = g_arm64_breakpoint_opcode;
488 trap_opcode_size = sizeof(g_arm64_breakpoint_opcode);
489 } break;
490
491 case llvm::Triple::thumb:
492 bp_is_thumb = true;
493 [[fallthrough]];
494 case llvm::Triple::arm: {
495 static const uint8_t g_arm_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
496 static const uint8_t g_thumb_breakpooint_opcode[] = {0xFE, 0xDE};
497
498 // Auto detect arm/thumb if it wasn't explicitly specified
499 if (!bp_is_thumb) {
501 if (bp_loc_sp)
502 bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass() ==
504 }
505 if (bp_is_thumb) {
506 trap_opcode = g_thumb_breakpooint_opcode;
507 trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
508 break;
509 }
510 trap_opcode = g_arm_breakpoint_opcode;
511 trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
512 } break;
513
514 case llvm::Triple::ppc:
515 case llvm::Triple::ppc64: {
516 static const uint8_t g_ppc_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
517 trap_opcode = g_ppc_breakpoint_opcode;
518 trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
519 } break;
520
521 default:
522 return Platform::GetSoftwareBreakpointTrapOpcode(target, bp_site);
523 }
524
525 if (trap_opcode && trap_opcode_size) {
526 if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
527 return trap_opcode_size;
528 }
529 return 0;
530}
531
533 lldb_private::Target &target, const lldb::ModuleSP &module_sp) {
534 if (!module_sp)
535 return false;
536
537 ObjectFile *obj_file = module_sp->GetObjectFile();
538 if (!obj_file)
539 return false;
540
541 ObjectFile::Type obj_type = obj_file->GetType();
542 return obj_type == ObjectFile::eTypeDynamicLinker;
543}
544
546 std::vector<ArchSpec> &archs) {
547 ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
548 archs.push_back(host_arch);
549
550 if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h) {
551 archs.push_back(ArchSpec("x86_64-apple-macosx"));
552 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
553 } else {
554 ArchSpec host_arch64 = HostInfo::GetArchitecture(HostInfo::eArchKind64);
555 if (host_arch.IsExactMatch(host_arch64))
556 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
557 }
558}
559
560static llvm::ArrayRef<const char *> GetCompatibleArchs(ArchSpec::Core core) {
561 switch (core) {
562 default:
563 [[fallthrough]];
565 static const char *g_arm64e_compatible_archs[] = {
566 "arm64e", "arm64", "armv7", "armv7f", "armv7k", "armv7s",
567 "armv7m", "armv7em", "armv6m", "armv6", "armv5", "armv4",
568 "arm", "thumbv7", "thumbv7f", "thumbv7k", "thumbv7s", "thumbv7m",
569 "thumbv7em", "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
570 };
571 return {g_arm64e_compatible_archs};
572 }
574 static const char *g_arm64_compatible_archs[] = {
575 "arm64", "armv7", "armv7f", "armv7k", "armv7s", "armv7m",
576 "armv7em", "armv6m", "armv6", "armv5", "armv4", "arm",
577 "thumbv7", "thumbv7f", "thumbv7k", "thumbv7s", "thumbv7m", "thumbv7em",
578 "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
579 };
580 return {g_arm64_compatible_archs};
581 }
583 static const char *g_armv7_compatible_archs[] = {
584 "armv7", "armv6m", "armv6", "armv5", "armv4", "arm",
585 "thumbv7", "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
586 };
587 return {g_armv7_compatible_archs};
588 }
590 static const char *g_armv7f_compatible_archs[] = {
591 "armv7f", "armv7", "armv6m", "armv6", "armv5",
592 "armv4", "arm", "thumbv7f", "thumbv7", "thumbv6m",
593 "thumbv6", "thumbv5", "thumbv4t", "thumb",
594 };
595 return {g_armv7f_compatible_archs};
596 }
598 static const char *g_armv7k_compatible_archs[] = {
599 "armv7k", "armv7", "armv6m", "armv6", "armv5",
600 "armv4", "arm", "thumbv7k", "thumbv7", "thumbv6m",
601 "thumbv6", "thumbv5", "thumbv4t", "thumb",
602 };
603 return {g_armv7k_compatible_archs};
604 }
606 static const char *g_armv7s_compatible_archs[] = {
607 "armv7s", "armv7", "armv6m", "armv6", "armv5",
608 "armv4", "arm", "thumbv7s", "thumbv7", "thumbv6m",
609 "thumbv6", "thumbv5", "thumbv4t", "thumb",
610 };
611 return {g_armv7s_compatible_archs};
612 }
614 static const char *g_armv7m_compatible_archs[] = {
615 "armv7m", "armv7", "armv6m", "armv6", "armv5",
616 "armv4", "arm", "thumbv7m", "thumbv7", "thumbv6m",
617 "thumbv6", "thumbv5", "thumbv4t", "thumb",
618 };
619 return {g_armv7m_compatible_archs};
620 }
622 static const char *g_armv7em_compatible_archs[] = {
623 "armv7em", "armv7", "armv6m", "armv6", "armv5",
624 "armv4", "arm", "thumbv7em", "thumbv7", "thumbv6m",
625 "thumbv6", "thumbv5", "thumbv4t", "thumb",
626 };
627 return {g_armv7em_compatible_archs};
628 }
630 static const char *g_armv6m_compatible_archs[] = {
631 "armv6m", "armv6", "armv5", "armv4", "arm",
632 "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
633 };
634 return {g_armv6m_compatible_archs};
635 }
637 static const char *g_armv6_compatible_archs[] = {
638 "armv6", "armv5", "armv4", "arm",
639 "thumbv6", "thumbv5", "thumbv4t", "thumb",
640 };
641 return {g_armv6_compatible_archs};
642 }
644 static const char *g_armv5_compatible_archs[] = {
645 "armv5", "armv4", "arm", "thumbv5", "thumbv4t", "thumb",
646 };
647 return {g_armv5_compatible_archs};
648 }
650 static const char *g_armv4_compatible_archs[] = {
651 "armv4",
652 "arm",
653 "thumbv4t",
654 "thumb",
655 };
656 return {g_armv4_compatible_archs};
657 }
658 }
659 return {};
660}
661
662/// The architecture selection rules for arm processors These cpu subtypes have
663/// distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f
664/// processor.
666 std::vector<ArchSpec> &archs, std::optional<llvm::Triple::OSType> os) {
667 const ArchSpec system_arch = GetSystemArchitecture();
668 const ArchSpec::Core system_core = system_arch.GetCore();
669 for (const char *arch : GetCompatibleArchs(system_core)) {
670 llvm::Triple triple;
671 triple.setArchName(arch);
672 triple.setVendor(llvm::Triple::VendorType::Apple);
673 if (os)
674 triple.setOS(*os);
675 archs.push_back(ArchSpec(triple));
676 }
677}
678
680 static FileSpec g_xcode_select_filespec;
681
682 if (!g_xcode_select_filespec) {
683 FileSpec xcode_select_cmd("/usr/bin/xcode-select");
684 if (FileSystem::Instance().Exists(xcode_select_cmd)) {
685 int exit_status = -1;
686 int signo = -1;
687 std::string command_output;
688 Status status =
689 Host::RunShellCommand("/usr/bin/xcode-select --print-path",
690 FileSpec(), // current working directory
691 &exit_status, &signo, &command_output, nullptr,
692 std::chrono::seconds(2), // short timeout
693 false); // don't run in a shell
694 if (status.Success() && exit_status == 0 && !command_output.empty()) {
695 size_t first_non_newline = command_output.find_last_not_of("\r\n");
696 if (first_non_newline != std::string::npos) {
697 command_output.erase(first_non_newline + 1);
698 }
699 g_xcode_select_filespec = FileSpec(command_output);
700 }
701 }
702 }
703
704 return g_xcode_select_filespec;
705}
706
708 BreakpointSP bp_sp;
709 static const char *g_bp_names[] = {
710 "start_wqthread", "_pthread_wqthread", "_pthread_start",
711 };
712
713 static const char *g_bp_modules[] = {"libsystem_c.dylib", "libSystem.B.dylib",
714 "libsystem_pthread.dylib"};
715
716 FileSpecList bp_modules;
717 for (size_t i = 0; i < std::size(g_bp_modules); i++) {
718 const char *bp_module = g_bp_modules[i];
719 bp_modules.EmplaceBack(bp_module);
720 }
721
722 bool internal = true;
723 bool hardware = false;
724 LazyBool skip_prologue = eLazyBoolNo;
725 bp_sp = target.CreateBreakpoint(&bp_modules, nullptr, g_bp_names,
726 std::size(g_bp_names), eFunctionNameTypeFull,
727 eLanguageTypeUnknown, 0, skip_prologue,
728 internal, hardware);
729 bp_sp->SetBreakpointKind("thread-creation");
730
731 return bp_sp;
732}
733
734uint32_t
736 const FileSpec &shell = launch_info.GetShell();
737 if (!shell)
738 return 1;
739
740 std::string shell_string = shell.GetPath();
741 const char *shell_name = strrchr(shell_string.c_str(), '/');
742 if (shell_name == nullptr)
743 shell_name = shell_string.c_str();
744 else
745 shell_name++;
746
747 if (strcmp(shell_name, "sh") == 0) {
748 // /bin/sh re-exec's itself as /bin/bash requiring another resume. But it
749 // only does this if the COMMAND_MODE environment variable is set to
750 // "legacy".
751 if (launch_info.GetEnvironment().lookup("COMMAND_MODE") == "legacy")
752 return 2;
753 return 1;
754 } else if (strcmp(shell_name, "csh") == 0 ||
755 strcmp(shell_name, "tcsh") == 0 ||
756 strcmp(shell_name, "zsh") == 0) {
757 // csh and tcsh always seem to re-exec themselves.
758 return 2;
759 } else
760 return 1;
761}
762
764 Debugger &debugger, Target &target,
765 Status &error) {
766 ProcessSP process_sp;
767
768 if (IsHost()) {
769 // We are going to hand this process off to debugserver which will be in
770 // charge of setting the exit status. However, we still need to reap it
771 // from lldb. So, make sure we use a exit callback which does not set exit
772 // status.
773 launch_info.SetMonitorProcessCallback(
775 process_sp = Platform::DebugProcess(launch_info, debugger, target, error);
776 } else {
778 process_sp = m_remote_platform_sp->DebugProcess(launch_info, debugger,
779 target, error);
780 else
781 error =
782 Status::FromErrorString("the platform is not currently connected");
783 }
784 return process_sp;
785}
786
790
792 static FileSpec g_command_line_tools_filespec;
793
794 if (!g_command_line_tools_filespec) {
795 FileSpec command_line_tools_path(GetXcodeSelectPath());
796 command_line_tools_path.AppendPathComponent("Library");
797 if (FileSystem::Instance().Exists(command_line_tools_path)) {
798 g_command_line_tools_filespec = command_line_tools_path;
799 }
800 }
801
802 return g_command_line_tools_filespec;
803}
804
806 void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) {
807 SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo *>(baton);
808
809 FileSpec spec(path);
810 if (XcodeSDK::SDKSupportsModules(enumerator_info->sdk_type, spec)) {
811 enumerator_info->found_path = spec;
813 }
814
816}
817
819 const FileSpec &sdks_spec) {
820 // Look inside Xcode for the required installed iOS SDK version
821
822 if (!FileSystem::Instance().IsDirectory(sdks_spec)) {
823 return FileSpec();
824 }
825
826 const bool find_directories = true;
827 const bool find_files = false;
828 const bool find_other = true; // include symlinks
829
830 SDKEnumeratorInfo enumerator_info;
831
832 enumerator_info.sdk_type = sdk_type;
833
835 sdks_spec.GetPath(), find_directories, find_files, find_other,
836 DirectoryEnumerator, &enumerator_info);
837
838 if (FileSystem::Instance().IsDirectory(enumerator_info.found_path))
839 return enumerator_info.found_path;
840 else
841 return FileSpec();
842}
843
845 FileSpec sdks_spec = HostInfo::GetXcodeContentsDirectory();
846 sdks_spec.AppendPathComponent("Developer");
847 sdks_spec.AppendPathComponent("Platforms");
848
849 switch (sdk_type) {
851 sdks_spec.AppendPathComponent("MacOSX.platform");
852 break;
854 sdks_spec.AppendPathComponent("iPhoneSimulator.platform");
855 break;
857 sdks_spec.AppendPathComponent("iPhoneOS.platform");
858 break;
860 sdks_spec.AppendPathComponent("WatchSimulator.platform");
861 break;
863 sdks_spec.AppendPathComponent("AppleTVSimulator.platform");
864 break;
866 sdks_spec.AppendPathComponent("XRSimulator.platform");
867 break;
868 default:
869 llvm_unreachable("unsupported sdk");
870 }
871
872 sdks_spec.AppendPathComponent("Developer");
873 sdks_spec.AppendPathComponent("SDKs");
874
875 if (sdk_type == XcodeSDK::Type::MacOSX) {
876 llvm::VersionTuple version = HostInfo::GetOSVersion();
877
878 if (!version.empty()) {
880 // If the Xcode SDKs are not available then try to use the
881 // Command Line Tools one which is only for MacOSX.
882 if (!FileSystem::Instance().Exists(sdks_spec)) {
883 sdks_spec = GetCommandLineToolsLibraryPath();
884 sdks_spec.AppendPathComponent("SDKs");
885 }
886
887 // We slightly prefer the exact SDK for this machine. See if it is
888 // there.
889
890 FileSpec native_sdk_spec = sdks_spec;
891 StreamString native_sdk_name;
892 native_sdk_name.Printf("MacOSX%u.%u.sdk", version.getMajor(),
893 version.getMinor().value_or(0));
894 native_sdk_spec.AppendPathComponent(native_sdk_name.GetString());
895
896 if (FileSystem::Instance().Exists(native_sdk_spec)) {
897 return native_sdk_spec;
898 }
899 }
900 }
901 }
902
903 return FindSDKInXcodeForModules(sdk_type, sdks_spec);
904}
905
906// Discovering the correct version and build can help us
907// identify the most likely SDK directory when looking for
908// files.
909//
910// The directory name can be one of many formats, such as
911// 10.0 (21R329) universal
912// 17.0 (23A200) arm64e
913// 17.0 (20A352)
914// Watch4,2 10.0 (21R329)
915std::tuple<llvm::VersionTuple, llvm::StringRef>
917 llvm::StringRef build;
918 llvm::VersionTuple version;
919
920 llvm::SmallVector<llvm::StringRef> parts;
921 dir.split(parts, ' ');
922 for (llvm::StringRef part : parts) {
923 // Look for an OS version number, eg "17.0"
924 if (isdigit(part[0]))
925 version.tryParse(part);
926 // Look for a build number, eg "(20A352)"
927 if (part.consume_front("(")) {
928 size_t pos = part.find(')');
929 build = part.slice(0, pos);
930 }
931 }
932
933 return std::make_tuple(version, build);
934}
935
936llvm::Expected<StructuredData::DictionarySP>
938 static constexpr llvm::StringLiteral crash_info_key("Crash-Info Annotations");
939 static constexpr llvm::StringLiteral asi_info_key(
940 "Application Specific Information");
941
942 // We cache the information we find in the process extended info dict:
943 StructuredData::DictionarySP process_dict_sp =
944 process.GetExtendedCrashInfoDict();
945 StructuredData::Array *annotations = nullptr;
946 StructuredData::ArraySP new_annotations_sp;
947 if (!process_dict_sp->GetValueForKeyAsArray(crash_info_key, annotations)) {
948 new_annotations_sp = ExtractCrashInfoAnnotations(process);
949 if (new_annotations_sp && new_annotations_sp->GetSize()) {
950 process_dict_sp->AddItem(crash_info_key, new_annotations_sp);
951 annotations = new_annotations_sp.get();
952 }
953 }
954
955 StructuredData::Dictionary *app_specific_info;
956 StructuredData::DictionarySP new_app_specific_info_sp;
957 if (!process_dict_sp->GetValueForKeyAsDictionary(asi_info_key,
958 app_specific_info)) {
959 new_app_specific_info_sp = ExtractAppSpecificInfo(process);
960 if (new_app_specific_info_sp && new_app_specific_info_sp->GetSize()) {
961 process_dict_sp->AddItem(asi_info_key, new_app_specific_info_sp);
962 app_specific_info = new_app_specific_info_sp.get();
963 }
964 }
965
966 // Now get anything else that was in the process info dict, and add it to the
967 // return here:
968 return process_dict_sp->GetSize() ? process_dict_sp : nullptr;
969}
970
974
975 ConstString section_name("__crash_info");
976 Target &target = process.GetTarget();
977 StructuredData::ArraySP array_sp = std::make_shared<StructuredData::Array>();
978
979 for (ModuleSP module : target.GetImages().Modules()) {
980 SectionList *sections = module->GetSectionList();
981
982 std::string module_name = module->GetSpecificationDescription();
983
984 // The DYDL module is skipped since it's always loaded when running the
985 // binary.
986 if (module_name == "/usr/lib/dyld")
987 continue;
988
989 if (!sections) {
990 LLDB_LOG(log, "Module {0} doesn't have any section!", module_name);
991 continue;
992 }
993
994 SectionSP crash_info = sections->FindSectionByName(section_name);
995 if (!crash_info) {
996 LLDB_LOG(log, "Module {0} doesn't have section {1}!", module_name,
997 section_name);
998 continue;
999 }
1000
1001 addr_t load_addr = crash_info->GetLoadBaseAddress(&target);
1002
1003 if (load_addr == LLDB_INVALID_ADDRESS) {
1004 LLDB_LOG(log, "Module {0} has an invalid '{1}' section load address: {2}",
1005 module_name, section_name, load_addr);
1006 continue;
1007 }
1008
1009 Status error;
1010 CrashInfoAnnotations annotations;
1011 size_t expected_size = sizeof(CrashInfoAnnotations);
1012 size_t bytes_read = process.ReadMemoryFromInferior(load_addr, &annotations,
1013 expected_size, error);
1014
1015 if (expected_size != bytes_read || error.Fail()) {
1016 LLDB_LOG(log, "Failed to read {0} section from memory in module {1}: {2}",
1017 section_name, module_name, error);
1018 continue;
1019 }
1020
1021 // initial support added for version 5
1022 if (annotations.version < 5) {
1023 LLDB_LOG(log,
1024 "Annotation version lower than 5 unsupported! Module {0} has "
1025 "version {1} instead.",
1026 module_name, annotations.version);
1027 continue;
1028 }
1029
1030 if (!annotations.message) {
1031 LLDB_LOG(log, "No message available for module {0}.", module_name);
1032 continue;
1033 }
1034
1035 std::string message;
1036 bytes_read =
1037 process.ReadCStringFromMemory(annotations.message, message, error);
1038
1039 if (message.empty() || bytes_read != message.size() || error.Fail()) {
1040 LLDB_LOG(log, "Failed to read the message from memory in module {0}: {1}",
1041 module_name, error);
1042 continue;
1043 }
1044
1045 // Remove trailing newline from message
1046 if (message.back() == '\n')
1047 message.pop_back();
1048
1049 if (!annotations.message2)
1050 LLDB_LOG(log, "No message2 available for module {0}.", module_name);
1051
1052 std::string message2;
1053 bytes_read =
1054 process.ReadCStringFromMemory(annotations.message2, message2, error);
1055
1056 if (!message2.empty() && bytes_read == message2.size() && error.Success())
1057 if (message2.back() == '\n')
1058 message2.pop_back();
1059
1061 std::make_shared<StructuredData::Dictionary>();
1062
1063 entry_sp->AddStringItem("image", module->GetFileSpec().GetPath(false));
1064 entry_sp->AddStringItem("uuid", module->GetUUID().GetAsString());
1065 entry_sp->AddStringItem("message", message);
1066 entry_sp->AddStringItem("message2", message2);
1067 entry_sp->AddIntegerItem("abort-cause", annotations.abort_cause);
1068
1069 array_sp->AddItem(entry_sp);
1070 }
1071
1072 return array_sp;
1073}
1074
1077 StructuredData::DictionarySP metadata_sp = process.GetMetadata();
1078
1079 if (!metadata_sp || !metadata_sp->GetSize() || !metadata_sp->HasKey("asi"))
1080 return {};
1081
1083 if (!metadata_sp->GetValueForKeyAsDictionary("asi", asi))
1084 return {};
1085
1087 std::make_shared<StructuredData::Dictionary>();
1088
1089 auto flatten_asi_dict = [&dict_sp](llvm::StringRef key,
1090 StructuredData::Object *val) -> bool {
1091 if (!val)
1092 return false;
1093
1094 StructuredData::Array *arr = val->GetAsArray();
1095 if (!arr || !arr->GetSize())
1096 return false;
1097
1098 dict_sp->AddItem(key, arr->GetItemAtIndex(0));
1099 return true;
1100 };
1101
1102 asi->ForEach(flatten_asi_dict);
1103
1104 return dict_sp;
1105}
1106
1107static llvm::Expected<lldb_private::FileSpec>
1109
1110 ModuleSP exe_module_sp = target->GetExecutableModule();
1111 if (!exe_module_sp)
1112 return llvm::createStringError("failed to get module from target");
1113
1114 SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
1115 if (!sym_file)
1116 return llvm::createStringError("failed to get symbol file from executable");
1117
1118 if (sym_file->GetNumCompileUnits() == 0)
1119 return llvm::createStringError(
1120 "Failed to resolve SDK for target: executable's symbol file has no "
1121 "compile units");
1122
1123 XcodeSDK merged_sdk;
1124 for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
1125 if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
1126 auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
1127 merged_sdk.Merge(cu_sdk);
1128 }
1129 }
1130
1131 // TODO: The result of this loop is almost equivalent to deriving the SDK
1132 // from the target triple, which would be a lot cheaper.
1133 FileSpec sdk_path = merged_sdk.GetSysroot();
1134 if (FileSystem::Instance().Exists(sdk_path)) {
1135 return sdk_path;
1136 }
1137 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk});
1138 if (!path_or_err)
1139 return llvm::createStringError(
1140 llvm::formatv("Failed to resolve SDK path: {0}",
1141 llvm::toString(path_or_err.takeError())));
1142
1143 return FileSpec(*path_or_err);
1144}
1145
1147 Target *target, std::vector<std::string> &options, XcodeSDK::Type sdk_type) {
1148 const std::vector<std::string> apple_arguments = {
1149 "-x", "objective-c++", "-fobjc-arc",
1150 "-fblocks", "-D_ISO646_H", "-D__ISO646_H",
1151 "-fgnuc-version=4.2.1"};
1152
1153 options.insert(options.end(), apple_arguments.begin(), apple_arguments.end());
1154
1155 StreamString minimum_version_option;
1156 bool use_current_os_version = false;
1157 // If the SDK type is for the host OS, use its version number.
1158 auto get_host_os = []() { return HostInfo::GetTargetTriple().getOS(); };
1159 switch (sdk_type) {
1161 use_current_os_version = get_host_os() == llvm::Triple::MacOSX;
1162 break;
1164 use_current_os_version = get_host_os() == llvm::Triple::IOS;
1165 break;
1167 use_current_os_version = get_host_os() == llvm::Triple::TvOS;
1168 break;
1170 use_current_os_version = get_host_os() == llvm::Triple::WatchOS;
1171 break;
1173 use_current_os_version = get_host_os() == llvm::Triple::XROS;
1174 break;
1175 default:
1176 break;
1177 }
1178
1179 llvm::VersionTuple version;
1180 if (use_current_os_version)
1181 version = GetOSVersion();
1182 else if (target) {
1183 // Our OS doesn't match our executable so we need to get the min OS version
1184 // from the object file
1185 ModuleSP exe_module_sp = target->GetExecutableModule();
1186 if (exe_module_sp) {
1187 ObjectFile *object_file = exe_module_sp->GetObjectFile();
1188 if (object_file)
1189 version = object_file->GetMinimumOSVersion();
1190 }
1191 }
1192 // Only add the version-min options if we got a version from somewhere.
1193 // clang has no version-min clang flag for XROS.
1194 if (!version.empty() && sdk_type != XcodeSDK::Type::Linux &&
1195 sdk_type != XcodeSDK::Type::XROS) {
1196#define OPTION(PREFIX_OFFSET, NAME_OFFSET, VAR, ...) \
1197 llvm::StringRef opt_##VAR = OptionStrTable[NAME_OFFSET]; \
1198 (void)opt_##VAR;
1199#include "clang/Options/Options.inc"
1200#undef OPTION
1201 minimum_version_option << '-';
1202 switch (sdk_type) {
1204 minimum_version_option << opt_mmacos_version_min_EQ;
1205 break;
1207 minimum_version_option << opt_mios_simulator_version_min_EQ;
1208 break;
1210 minimum_version_option << opt_mios_version_min_EQ;
1211 break;
1213 minimum_version_option << opt_mtvos_simulator_version_min_EQ;
1214 break;
1216 minimum_version_option << opt_mtvos_version_min_EQ;
1217 break;
1219 minimum_version_option << opt_mwatchos_simulator_version_min_EQ;
1220 break;
1222 minimum_version_option << opt_mwatchos_version_min_EQ;
1223 break;
1226 // FIXME: Pass the right argument once it exists.
1230 if (Log *log = GetLog(LLDBLog::Host)) {
1231 XcodeSDK::Info info;
1232 info.type = sdk_type;
1233 LLDB_LOGF(log, "Clang modules on %s are not supported",
1234 XcodeSDK::GetCanonicalName(info).c_str());
1235 }
1236 return;
1237 }
1238 minimum_version_option << version.getAsString();
1239 options.emplace_back(std::string(minimum_version_option.GetString()));
1240 }
1241
1242 FileSpec sysroot_spec;
1243
1244 if (target) {
1245 auto sysroot_spec_or_err = ::ResolveSDKPathFromDebugInfo(target);
1246 if (!sysroot_spec_or_err) {
1248 sysroot_spec_or_err.takeError(),
1249 "Failed to resolve sysroot: {0}");
1250 } else {
1251 sysroot_spec = *sysroot_spec_or_err;
1252 }
1253 }
1254
1255 if (!FileSystem::Instance().IsDirectory(sysroot_spec.GetPath())) {
1256 std::lock_guard<std::mutex> guard(m_mutex);
1257 sysroot_spec = GetSDKDirectoryForModules(sdk_type);
1258 }
1259
1260 if (FileSystem::Instance().IsDirectory(sysroot_spec.GetPath())) {
1261 options.push_back("-isysroot");
1262 options.push_back(sysroot_spec.GetPath());
1263 }
1264}
1265
1267 if (basename.IsEmpty())
1268 return basename;
1269
1270 StreamString stream;
1271 stream.Printf("lib%s.dylib", basename.GetCString());
1272 return ConstString(stream.GetString());
1273}
1274
1275llvm::VersionTuple PlatformDarwin::GetOSVersion(Process *process) {
1276 if (process && GetPluginName().contains("-simulator")) {
1278 if (Host::GetProcessInfo(process->GetID(), proc_info)) {
1279 const Environment &env = proc_info.GetEnvironment();
1280
1281 llvm::VersionTuple result;
1282 if (!result.tryParse(env.lookup("SIMULATOR_RUNTIME_VERSION")))
1283 return result;
1284
1285 std::string dyld_root_path = env.lookup("DYLD_ROOT_PATH");
1286 if (!dyld_root_path.empty()) {
1287 dyld_root_path += "/System/Library/CoreServices/SystemVersion.plist";
1288 ApplePropertyList system_version_plist(dyld_root_path.c_str());
1289 std::string product_version;
1290 if (system_version_plist.GetValueAsString("ProductVersion",
1291 product_version)) {
1292 if (!result.tryParse(product_version))
1293 return result;
1294 }
1295 }
1296 }
1297 // For simulator platforms, do NOT call back through
1298 // Platform::GetOSVersion() as it might call Process::GetHostOSVersion()
1299 // which we don't want as it will be incorrect
1300 return llvm::VersionTuple();
1301 }
1302
1303 return Platform::GetOSVersion(process);
1304}
1305
1307 // A collection of SBFileSpec whose SBFileSpec.m_directory members are filled
1308 // in with any executable directories that should be searched.
1309 static std::vector<FileSpec> g_executable_dirs;
1310
1311 // Find the global list of directories that we will search for executables
1312 // once so we don't keep doing the work over and over.
1313 static llvm::once_flag g_once_flag;
1314 llvm::call_once(g_once_flag, []() {
1315
1316 // When locating executables, trust the DEVELOPER_DIR first if it is set
1317 FileSpec xcode_contents_dir = HostInfo::GetXcodeContentsDirectory();
1318 if (xcode_contents_dir) {
1319 FileSpec xcode_lldb_resources = xcode_contents_dir;
1320 xcode_lldb_resources.AppendPathComponent("SharedFrameworks");
1321 xcode_lldb_resources.AppendPathComponent("LLDB.framework");
1322 xcode_lldb_resources.AppendPathComponent("Resources");
1323 if (FileSystem::Instance().Exists(xcode_lldb_resources)) {
1324 FileSpec dir;
1325 dir.SetDirectory(xcode_lldb_resources.GetPathAsConstString());
1326 g_executable_dirs.push_back(dir);
1327 }
1328 }
1329 // Xcode might not be installed so we also check for the Command Line Tools.
1330 FileSpec command_line_tools_dir = GetCommandLineToolsLibraryPath();
1331 if (command_line_tools_dir) {
1332 FileSpec cmd_line_lldb_resources = command_line_tools_dir;
1333 cmd_line_lldb_resources.AppendPathComponent("PrivateFrameworks");
1334 cmd_line_lldb_resources.AppendPathComponent("LLDB.framework");
1335 cmd_line_lldb_resources.AppendPathComponent("Resources");
1336 if (FileSystem::Instance().Exists(cmd_line_lldb_resources)) {
1337 FileSpec dir;
1338 dir.SetDirectory(cmd_line_lldb_resources.GetPathAsConstString());
1339 g_executable_dirs.push_back(dir);
1340 }
1341 }
1342 });
1343
1344 // Now search the global list of executable directories for the executable we
1345 // are looking for
1346 for (const auto &executable_dir : g_executable_dirs) {
1347 FileSpec executable_file;
1348 executable_file.SetDirectory(executable_dir.GetDirectory());
1349 executable_file.SetFilename(basename);
1350 if (FileSystem::Instance().Exists(executable_file))
1351 return executable_file;
1352 }
1353
1354 return FileSpec();
1355}
1356
1359 // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr if
1360 // the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't require
1361 // any specific value; rather, it just needs to exist). We will set it here
1362 // as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag is not set. Xcode
1363 // makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
1364 // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
1365 // specifically want it unset.
1366 const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
1367 auto &env_vars = launch_info.GetEnvironment();
1368 if (!env_vars.count(disable_env_var)) {
1369 // We want to make sure that OS_ACTIVITY_DT_MODE is set so that we get
1370 // os_log and NSLog messages mirrored to the target process stderr.
1371 env_vars.try_emplace("OS_ACTIVITY_DT_MODE", "enable");
1372 }
1373
1374 // Let our parent class do the real launching.
1375 return PlatformPOSIX::LaunchProcess(launch_info);
1376}
1377
1379 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
1380 llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
1381 const FileSpec &platform_file = module_spec.GetFileSpec();
1382 TargetSP target_sp = module_spec.GetTargetSP();
1383 FileSpecList module_search_paths;
1384 if (target_sp)
1385 module_search_paths = target_sp->GetExecutableSearchPaths();
1386 // See if the file is present in any of the module_search_paths
1387 // directories.
1388 if (!module_sp && !module_search_paths.IsEmpty() && platform_file) {
1389 // create a vector of all the file / directory names in platform_file e.g.
1390 // this might be
1391 // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
1392 //
1393 // We'll need to look in the module_search_paths_ptr directories for both
1394 // "UIFoundation" and "UIFoundation.framework" -- most likely the latter
1395 // will be the one we find there.
1396
1397 std::vector<llvm::StringRef> path_parts = platform_file.GetComponents();
1398 // We want the components in reverse order.
1399 std::reverse(path_parts.begin(), path_parts.end());
1400 const size_t path_parts_size = path_parts.size();
1401
1402 size_t num_module_search_paths = module_search_paths.GetSize();
1403 for (size_t i = 0; i < num_module_search_paths; ++i) {
1404 Log *log_verbose = GetLog(LLDBLog::Host);
1405 LLDB_LOGF(
1406 log_verbose,
1407 "PlatformRemoteDarwinDevice::GetSharedModule searching for binary in "
1408 "search-path %s",
1409 module_search_paths.GetFileSpecAtIndex(i).GetPath().c_str());
1410 // Create a new FileSpec with this module_search_paths_ptr plus just the
1411 // filename ("UIFoundation"), then the parent dir plus filename
1412 // ("UIFoundation.framework/UIFoundation") etc - up to four names (to
1413 // handle "Foo.framework/Contents/MacOS/Foo")
1414
1415 for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
1416 FileSpec path_to_try(module_search_paths.GetFileSpecAtIndex(i));
1417
1418 // Add the components backwards. For
1419 // .../PrivateFrameworks/UIFoundation.framework/UIFoundation path_parts
1420 // is
1421 // [0] UIFoundation
1422 // [1] UIFoundation.framework
1423 // [2] PrivateFrameworks
1424 //
1425 // and if 'j' is 2, we want to append path_parts[1] and then
1426 // path_parts[0], aka 'UIFoundation.framework/UIFoundation', to the
1427 // module_search_paths_ptr path.
1428
1429 for (int k = j; k >= 0; --k) {
1430 path_to_try.AppendPathComponent(path_parts[k]);
1431 }
1432
1433 if (FileSystem::Instance().Exists(path_to_try)) {
1434 ModuleSpec new_module_spec(module_spec);
1435 new_module_spec.GetFileSpec() = path_to_try;
1436 Status new_error(Platform::GetSharedModule(new_module_spec, process,
1437 module_sp, old_modules,
1438 did_create_ptr));
1439
1440 if (module_sp) {
1441 module_sp->SetPlatformFileSpec(path_to_try);
1442 return new_error;
1443 }
1444 }
1445 }
1446 }
1447 }
1448 return Status();
1449}
1450
1451llvm::Triple::OSType PlatformDarwin::GetHostOSType() {
1452#if !defined(__APPLE__)
1453 return llvm::Triple::MacOSX;
1454#else
1455#if TARGET_OS_OSX
1456 return llvm::Triple::MacOSX;
1457#elif TARGET_OS_IOS
1458 return llvm::Triple::IOS;
1459#elif TARGET_OS_WATCH
1460 return llvm::Triple::WatchOS;
1461#elif TARGET_OS_TV
1462 return llvm::Triple::TvOS;
1463#elif TARGET_OS_BRIDGE
1464 return llvm::Triple::BridgeOS;
1465#elif TARGET_OS_XR
1466 return llvm::Triple::XROS;
1467#else
1468#error "LLDB being compiled for an unrecognized Darwin OS"
1469#endif
1470#endif // __APPLE__
1471}
1472
1473llvm::Expected<std::pair<XcodeSDK, bool>>
1475 SymbolFile *sym_file = module.GetSymbolFile();
1476 if (!sym_file)
1477 return llvm::createStringError(
1478 llvm::inconvertibleErrorCode(),
1479 llvm::formatv("No symbol file available for module '{0}'",
1480 module.GetFileSpec().GetFilename().AsCString("")));
1481
1482 if (sym_file->GetNumCompileUnits() == 0)
1483 return llvm::createStringError(
1484 llvm::formatv("Could not resolve SDK for module '{0}'. Symbol file has "
1485 "no compile units.",
1486 module.GetFileSpec()));
1487
1488 bool found_public_sdk = false;
1489 bool found_internal_sdk = false;
1490 XcodeSDK merged_sdk;
1491 for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
1492 if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
1493 auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
1494 bool is_internal_sdk = cu_sdk.IsAppleInternalSDK();
1495 found_public_sdk |= !is_internal_sdk;
1496 found_internal_sdk |= is_internal_sdk;
1497
1498 merged_sdk.Merge(cu_sdk);
1499 }
1500 }
1501
1502 const bool found_mismatch = found_internal_sdk && found_public_sdk;
1503
1504 return std::pair{std::move(merged_sdk), found_mismatch};
1505}
1506
1507llvm::Expected<std::string>
1509 auto sdk_or_err = GetSDKPathFromDebugInfo(module);
1510 if (!sdk_or_err)
1511 return llvm::createStringError(
1512 llvm::inconvertibleErrorCode(),
1513 llvm::formatv("Failed to parse SDK path from debug-info: {0}",
1514 llvm::toString(sdk_or_err.takeError())));
1515
1516 auto [sdk, _] = std::move(*sdk_or_err);
1517
1518 if (FileSystem::Instance().Exists(sdk.GetSysroot()))
1519 return sdk.GetSysroot().GetPath();
1520
1521 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1522 if (!path_or_err)
1523 return llvm::createStringError(
1524 llvm::inconvertibleErrorCode(),
1525 llvm::formatv("Error while searching for SDK (XcodeSDK '{0}'): {1}",
1526 sdk.GetString(),
1527 llvm::toString(path_or_err.takeError())));
1528
1529 return path_or_err->str();
1530}
1531
1532llvm::Expected<XcodeSDK>
1534 ModuleSP module_sp = unit.CalculateSymbolContextModule();
1535 if (!module_sp)
1536 return llvm::createStringError("compile unit has no module");
1537 SymbolFile *sym_file = module_sp->GetSymbolFile();
1538 if (!sym_file)
1539 return llvm::createStringError(
1540 llvm::formatv("No symbol file available for module '{0}'",
1541 module_sp->GetFileSpec().GetFilename()));
1542
1543 return sym_file->ParseXcodeSDK(unit);
1544}
1545
1546llvm::Expected<std::string>
1548 auto sdk_or_err = GetSDKPathFromDebugInfo(unit);
1549 if (!sdk_or_err)
1550 return llvm::createStringError(
1551 llvm::inconvertibleErrorCode(),
1552 llvm::formatv("Failed to parse SDK path from debug-info: {0}",
1553 llvm::toString(sdk_or_err.takeError())));
1554
1555 auto sdk = std::move(*sdk_or_err);
1556
1557 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1558 if (!path_or_err)
1559 return llvm::createStringError(
1560 llvm::inconvertibleErrorCode(),
1561 llvm::formatv("Error while searching for SDK (XcodeSDK '{0}'): {1}",
1562 sdk.GetString(),
1563 llvm::toString(path_or_err.takeError())));
1564
1565 return path_or_err->str();
1566}
1567
1568llvm::Expected<FileSpecList>
1571
1572 XcodeSDK::Type sdk_type =
1574 XcodeSDK::Info info;
1575 info.type = sdk_type;
1576 XcodeSDK sdk(info);
1577
1578 auto sdk_root_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1579 if (!sdk_root_or_err) {
1580 LLDB_LOG_ERROR(log, sdk_root_or_err.takeError(),
1581 "Failed to resolve SDK root for triple '{1}': {0}",
1582 target.GetArchitecture().GetTriple().str());
1583
1584 // Fall back to any macOS SDK.
1585 sdk = XcodeSDK::GetAnyMacOS();
1586 LLDB_LOG(log, "Falling back to SDK '{0}'", sdk.GetString());
1587 sdk_root_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1588 }
1589
1590 if (!sdk_root_or_err)
1591 return sdk_root_or_err.takeError();
1592
1593 // $SDKROOT/usr/share/lldb is an auto-loadable path.
1594 llvm::SmallString<256> resolved(*sdk_root_or_err);
1595 llvm::sys::path::append(resolved, "usr", "share", "lldb");
1596
1597 FileSpecList fspecs;
1598 fspecs.Append(FileSpec(resolved));
1599
1600 return fspecs;
1601}
static llvm::raw_ostream & error(Stream &strm)
static DynamicLoaderDarwinKernelProperties & GetGlobalProperties()
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:364
#define LLDB_LOGF(log,...)
Definition Log.h:378
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:394
static uint32_t g_initialize_count
static llvm::Expected< lldb_private::FileSpec > ResolveSDKPathFromDebugInfo(lldb_private::Target *target)
static Status ExceptionMaskValidator(const char *string, void *unused)
static llvm::ArrayRef< const char * > GetCompatibleArchs(ArchSpec::Core core)
static FileSpec GetXcodeSelectPath()
static FileSpec GetCommandLineToolsLibraryPath()
static llvm::StringRef GetSettingName()
OptionValueString * GetIgnoredExceptionValue()
const char * GetIgnoredExceptions() const
~PlatformDarwinProperties() override=default
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
bool GetValueAsString(const char *key, std::string &value) const
Definition XML.cpp:404
An architecture specification class.
Definition ArchSpec.h:32
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:457
bool IsExactMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, ExactMatch).
Definition ArchSpec.h:504
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:673
Core GetCore() const
Definition ArchSpec.h:448
A command line argument class.
Definition Args.h:33
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:332
Class that manages the actual breakpoint that will be inserted into the running program.
bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size)
Sets the trap opcode.
lldb::BreakpointLocationSP GetConstituentAtIndex(size_t idx)
This method returns the breakpoint location at index index located at this breakpoint site.
A class that describes a compilation unit.
Definition CompileUnit.h:43
lldb::ModuleSP CalculateSymbolContextModule() override
A uniqued constant string class.
Definition ConstString.h:40
bool IsEmpty() const
Test for empty string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
A class to manage flag bits.
Definition Debugger.h:100
lldb::ScriptLanguage GetScriptLanguage() const
Definition Debugger.cpp:437
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
virtual bool GetSharedCacheInformation(lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache, lldb_private::FileSpec &shared_cache_path, std::optional< uint64_t > &size)
Get information about the shared cache for a process, if possible.
A file collection class.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
void EmplaceBack(Args &&...args)
Inserts a new FileSpec into the FileSpecList constructed in-place with the given arguments.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
size_t GetSize() const
Get the number of files in the file list.
A file utility class.
Definition FileSpec.h:57
void AppendPathComponent(llvm::StringRef component)
Definition FileSpec.cpp:454
void SetDirectory(ConstString directory)
Directory string set accessor.
Definition FileSpec.cpp:342
const ConstString & GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:250
std::vector< llvm::StringRef > GetComponents() const
Gets the components of the FileSpec's path.
Definition FileSpec.cpp:475
const ConstString & GetDirectory() const
Directory string const get accessor.
Definition FileSpec.h:234
ConstString GetFileNameStrippingExtension() const
Return the filename without the extension part.
Definition FileSpec.cpp:414
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
ConstString GetPathAsConstString(bool denormalize=true) const
Get the full path as a ConstString.
Definition FileSpec.cpp:390
void SetFilename(ConstString filename)
Filename string set accessor.
Definition FileSpec.cpp:352
void EnumerateDirectory(llvm::Twine path, bool find_directories, bool find_files, bool find_other, EnumerateDirectoryCallbackType callback, void *callback_baton)
@ eEnumerateDirectoryResultNext
Enumerate next entry in the current directory.
Definition FileSystem.h:182
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static bool IsBundleCodeSignTrusted(const FileSpec &bundle_path)
Check whether a bundle at the given path has a valid code signature that chains to a trusted anchor i...
static bool ResolveExecutableInBundle(FileSpec &file)
When executable files may live within a directory, where the directory represents an executable bundl...
static Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, std::string *error_output, const Timeout< std::micro > &timeout, bool run_in_shell=true)
Run a shell command.
static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info)
Definition aix/Host.cpp:211
static bool GetBundleDirectory(const FileSpec &file, FileSpec &bundle_directory)
If you have an executable that is in a bundle and want to get back to the bundle directory from the p...
lldb::SymbolSharedCacheUse GetSharedCacheBinaryLoading() const
static Status GetSharedModule(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr, bool invoke_locate_callback=true)
static ModuleListProperties & GetGlobalModuleListProperties()
ModuleIterable Modules() const
Definition ModuleList.h:570
FileSpec & GetFileSpec()
Definition ModuleSpec.h:57
FileSpec & GetSymbolFileSpec()
Definition ModuleSpec.h:81
ArchSpec * GetArchitecturePtr()
Definition ModuleSpec.h:85
lldb::TargetSP GetTargetSP() const
Definition ModuleSpec.h:133
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:90
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition Module.h:446
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
@ eTypeDynamicLinker
The platform's dynamic linker executable.
Definition ObjectFile.h:59
virtual llvm::VersionTuple GetMinimumOSVersion()
Get the minimum OS version this object file can run on.
Definition ObjectFile.h:616
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition ObjectFile.h:280
void SetValidator(ValidatorCallback validator, void *baton=nullptr)
const char * GetCurrentValue() const
StructuredData::ArraySP ExtractCrashInfoAnnotations(Process &process)
Extract the __crash_info annotations from each of the target's modules.
bool IsSymbolFileTrusted(Module &module) override
Returns true if the module's symbol file (e.g.
llvm::Expected< StructuredData::DictionarySP > FetchExtendedCrashInformation(Process &process) override
Gather all of crash informations into a structured data dictionary.
~PlatformDarwin() override
Destructor.
static FileSpec GetSDKDirectoryForModules(XcodeSDK::Type sdk_type)
Status GetModuleFromSharedCaches(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr)
Status ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec, FileSpec &sym_file) override
Find a symbol file given a symbol file module specification.
void CalculateTrapHandlerSymbolNames() override
Ask the Platform subclass to fill in the list of trap handler names.
static std::tuple< llvm::VersionTuple, llvm::StringRef > ParseVersionBuildDir(llvm::StringRef str)
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
llvm::VersionTuple GetOSVersion(Process *process=nullptr) override
Get the OS version from a connected platform.
Status GetSharedModule(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr) override
static FileSystem::EnumerateDirectoryResult DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path)
static FileSpec FindSDKInXcodeForModules(XcodeSDK::Type sdk_type, const FileSpec &sdks_spec)
ConstString GetFullNameForDylib(ConstString basename) override
static void DebuggerInitialize(lldb_private::Debugger &debugger)
static llvm::StringRef GetPluginNameStatic()
static llvm::Triple::OSType GetHostOSType()
StructuredData::DictionarySP ExtractAppSpecificInfo(Process &process)
Extract the Application Specific Information messages from a crash report.
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target &target, Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target) override
static llvm::StringRef GetDescriptionStatic()
Status FindBundleBinaryInExecSearchPaths(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr)
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...
uint32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override
llvm::Expected< std::string > ResolveSDKPathFromDebugInfo(Module &module) override
Returns the full path of the most appropriate SDK for the specified 'module'.
size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site) override
void AddClangModuleCompilationOptionsForSDKType(Target *target, std::vector< std::string > &options, XcodeSDK::Type sdk_type)
Args GetExtraStartupCommands() override
Status PutFile(const FileSpec &source, const FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
static llvm::SmallDenseMap< FileSpec, LoadScriptFromSymFile > LocateExecutableScriptingResourcesFromDSYM(Stream &feedback_stream, FileSpec module_spec, const Target &target, const FileSpec &symfile_spec)
Helper function for LocateExecutableScriptingResources which gathers FileSpecs for executable scripts...
FileSpec LocateExecutable(const char *basename) override
Find a support executable that may not live within in the standard locations related to LLDB.
void x86GetSupportedArchitectures(std::vector< ArchSpec > &archs)
llvm::Expected< std::pair< XcodeSDK, bool > > GetSDKPathFromDebugInfo(Module &module) override
Search each CU associated with the specified 'module' for the SDK paths the CUs were compiled against...
llvm::SmallDenseMap< FileSpec, LoadScriptFromSymFile > LocateExecutableScriptingResourcesForPlatform(Target *target, Module &module_spec, Stream &feedback_stream) override
Locate the platform-specific scripting resource given a module specification.
llvm::Expected< FileSpecList > GetSafeAutoLoadPaths(const Target &target) const override
Returns a FileSpecList of safe paths to auto-load scripting resources from for a particular platform.
bool ModuleIsExcludedForUnconstrainedSearches(Target &target, const lldb::ModuleSP &module_sp) override
void ARMGetSupportedArchitectures(std::vector< ArchSpec > &archs, std::optional< llvm::Triple::OSType > os={})
The architecture selection rules for arm processors These cpu subtypes have distinct names (e....
std::vector< ConstString > m_trap_handlers
Definition Platform.h:1062
virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site)
virtual lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target &target, Status &error)
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
virtual Status GetSharedModule(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr)
Definition Platform.cpp:258
const ArchSpec & GetSystemArchitecture()
Definition Platform.cpp:906
static void WarnIfInvalidUnsanitizedScriptExists(Stream &os, const ScriptInterpreter::SanitizedScriptingModuleName &sanitized_name, const FileSpec &original_fspec, const FileSpec &fspec)
If we did some replacements of reserved characters, and a file with the untampered name exists,...
virtual llvm::VersionTuple GetOSVersion(Process *process=nullptr)
Get the OS version from a connected platform.
Definition Platform.cpp:390
virtual Status LaunchProcess(ProcessLaunchInfo &launch_info)
Launch a new process on a platform, not necessarily for debugging, it could be just for running the p...
bool IsRemote() const
Definition Platform.h:532
bool IsHost() const
Definition Platform.h:528
static LoadScriptFromSymFile GetScriptLoadStyleForModule(const FileSpec &module_fspec, const Target &target)
Returns the LoadScriptFromSymFile of scripting resource associated with the specified module FileSpec...
Definition Platform.cpp:165
virtual llvm::StringRef GetPluginName()=0
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForPlatformPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool UnregisterPlugin(ABICreateInstance create_callback)
static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, const UUID *uuid, const ArchSpec *arch)
Environment & GetEnvironment()
Definition ProcessInfo.h:88
const FileSpec & GetShell() const
static void NoOpMonitorCallback(lldb::pid_t pid, int signal, int status)
A Monitor callback which does not take any action on process events.
void SetMonitorProcessCallback(Host::MonitorChildProcessCallback callback)
A plug-in interface definition class for debugging a process.
Definition Process.h:355
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
size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition Process.cpp:2243
virtual StructuredData::DictionarySP GetMetadata()
Fetch process defined metadata.
Definition Process.h:2711
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:2197
StructuredData::DictionarySP GetExtendedCrashInfoDict()
Fetch extended crash information held by the process.
Definition Process.h:2716
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
Definition Process.cpp:2962
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1251
lldb::OptionValuePropertiesSP m_collection_sp
Status Unlink(const FileSpec &file_spec) override
Holds an lldb_private::Module name and a "sanitized" version of it for the purposes of loading a scri...
virtual SanitizedScriptingModuleName GetSanitizedScriptingModuleName(llvm::StringRef name)
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
Definition Section.cpp:556
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
bool Success() const
Test for success condition.
Definition Status.cpp:303
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
Definition Stream.h:367
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:132
ObjectSP GetItemAtIndex(size_t idx) const
void ForEach(std::function< bool(llvm::StringRef key, Object *object)> const &callback) const
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Array > ArraySP
Provides public interface for all SymbolFiles.
Definition SymbolFile.h:51
virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit)
Return the Xcode SDK comp_unit was compiled against.
Definition SymbolFile.h:152
virtual uint32_t GetNumCompileUnits()=0
virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx)=0
virtual ObjectFile * GetObjectFile()=0
Debugger & GetDebugger() const
Definition Target.h:1240
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1525
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:490
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1157
const ArchSpec & GetArchitecture() const
Definition Target.h:1199
Represents UUID's of various sizes.
Definition UUID.h:27
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition XcodeSDK.h:25
Type
Different types of Xcode SDKs.
Definition XcodeSDK.h:31
const FileSpec & GetSysroot() const
Definition XcodeSDK.cpp:145
void Merge(const XcodeSDK &other)
The merge function follows a strict order to maintain monotonicity:
Definition XcodeSDK.cpp:157
static XcodeSDK GetAnyMacOS()
Definition XcodeSDK.h:71
llvm::StringRef GetString() const
Definition XcodeSDK.cpp:143
static std::string GetCanonicalName(Info info)
Return the canonical SDK name, such as "macosx" for the macOS SDK.
Definition XcodeSDK.cpp:177
static XcodeSDK::Type GetSDKTypeForTriple(const llvm::Triple &triple)
Return the best-matching SDK type for a specific triple.
Definition XcodeSDK.cpp:259
bool IsAppleInternalSDK() const
Definition XcodeSDK.cpp:125
static bool SDKSupportsModules(Type type, llvm::VersionTuple version)
Whether LLDB feels confident importing Clang modules from this SDK.
Definition XcodeSDK.cpp:223
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:327
LoadScriptFromSymFile
Definition Target.h:57
@ eScriptLanguagePython
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
std::shared_ptr< lldb_private::Platform > PlatformSP
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Section > SectionSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
lldb::DataExtractorSP GetExtractor()
A parsed SDK directory name.
Definition XcodeSDK.h:48
#define PATH_MAX