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