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