[Go to site: main page, start]

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, Target &target, 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, target, 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, target, module_sp,
363 old_modules, did_create_ptr);
364
365 const FileSpec &platform_file = module_spec.GetFileSpec();
366 FileSpecList module_search_paths = target.GetExecutableSearchPaths();
367 if (!module_sp && !module_search_paths.IsEmpty() && platform_file) {
368 // We can try to pull off part of the file path up to the bundle
369 // directory level and try any module search paths...
370 FileSpec bundle_directory;
371 if (Host::GetBundleDirectory(platform_file, bundle_directory)) {
372 if (platform_file == bundle_directory) {
373 ModuleSpec new_module_spec(module_spec);
374 new_module_spec.GetFileSpec() = bundle_directory;
375 if (Host::ResolveExecutableInBundle(new_module_spec.GetFileSpec())) {
376 Status new_error(Platform::GetSharedModule(new_module_spec, target,
377 module_sp, old_modules,
378 did_create_ptr));
379
380 if (module_sp)
381 return new_error;
382 }
383 } else {
384 char platform_path[PATH_MAX];
385 char bundle_dir[PATH_MAX];
386 platform_file.GetPath(platform_path, sizeof(platform_path));
387 const size_t bundle_directory_len =
388 bundle_directory.GetPath(bundle_dir, sizeof(bundle_dir));
389 char new_path[PATH_MAX];
390 size_t num_module_search_paths = module_search_paths.GetSize();
391 for (size_t i = 0; i < num_module_search_paths; ++i) {
392 const size_t search_path_len =
393 module_search_paths.GetFileSpecAtIndex(i).GetPath(
394 new_path, sizeof(new_path));
395 if (search_path_len < sizeof(new_path)) {
396 snprintf(new_path + search_path_len,
397 sizeof(new_path) - search_path_len, "/%s",
398 platform_path + bundle_directory_len);
399 FileSpec new_file_spec(new_path);
400 if (FileSystem::Instance().Exists(new_file_spec)) {
401 ModuleSpec new_module_spec(module_spec);
402 new_module_spec.GetFileSpec() = new_file_spec;
404 new_module_spec, target, module_sp, old_modules,
405 did_create_ptr));
406
407 if (module_sp) {
408 module_sp->SetPlatformFileSpec(new_file_spec);
409 return new_error;
410 }
411 }
412 }
413 }
414 }
415 }
416 }
417 }
418 if (module_sp)
419 module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
420 return error;
421}
423 const ModuleSpec &module_spec, Target &target, ModuleSP &module_sp,
424 llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
425 Status err;
426
427 SymbolSharedCacheUse sc_mode =
429 SharedCacheImageInfo image_info;
430 Process *process = target.GetProcessSP().get();
431 if (process && process->GetDynamicLoader()) {
432 addr_t sc_base_addr;
433 UUID sc_uuid;
434 LazyBool using_sc, private_sc;
435 FileSpec sc_path;
436 std::optional<uint64_t> size;
438 sc_base_addr, sc_uuid, using_sc, private_sc, sc_path, size)) {
439 if (module_spec.GetUUID())
440 image_info = HostInfo::GetSharedCacheImageInfo(module_spec.GetUUID(),
441 sc_uuid, sc_mode);
442 else
443 image_info = HostInfo::GetSharedCacheImageInfo(
444 ConstString(module_spec.GetFileSpec().GetPath()), sc_uuid, sc_mode);
445 }
446 }
447 // Fall back to looking for the file in lldb's own shared cache.
448 if (!image_info.GetUUID())
449 image_info = HostInfo::GetSharedCacheImageInfo(
450 ConstString(module_spec.GetFileSpec().GetPath()), sc_mode);
451
452 // If we found it and it has the correct UUID, let's proceed with
453 // creating a module from the memory contents.
454 if (image_info.GetUUID() && (!module_spec.GetUUID() ||
455 module_spec.GetUUID() == image_info.GetUUID())) {
456 ModuleSpec shared_cache_spec(module_spec.GetFileSpec(),
457 image_info.GetUUID(),
458 image_info.GetExtractor());
459 err = ModuleList::GetSharedModule(shared_cache_spec, module_sp, old_modules,
460 did_create_ptr);
461 if (module_sp) {
463 LLDB_LOGF(log, "module %s was found in a shared cache",
464 module_spec.GetFileSpec().GetPath().c_str());
465 }
466 }
467 return err;
468}
469
470size_t
472 BreakpointSite *bp_site) {
473 const uint8_t *trap_opcode = nullptr;
474 uint32_t trap_opcode_size = 0;
475 bool bp_is_thumb = false;
476
477 llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
478 switch (machine) {
479 case llvm::Triple::aarch64_32:
480 case llvm::Triple::aarch64: {
481 // 'brk #0' or 0xd4200000 in BE byte order
482 static const uint8_t g_arm64_breakpoint_opcode[] = {0x00, 0x00, 0x20, 0xD4};
483 trap_opcode = g_arm64_breakpoint_opcode;
484 trap_opcode_size = sizeof(g_arm64_breakpoint_opcode);
485 } break;
486
487 case llvm::Triple::thumb:
488 bp_is_thumb = true;
489 [[fallthrough]];
490 case llvm::Triple::arm: {
491 static const uint8_t g_arm_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
492 static const uint8_t g_thumb_breakpooint_opcode[] = {0xFE, 0xDE};
493
494 // Auto detect arm/thumb if it wasn't explicitly specified
495 if (!bp_is_thumb) {
497 if (bp_loc_sp)
498 bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass() ==
500 }
501 if (bp_is_thumb) {
502 trap_opcode = g_thumb_breakpooint_opcode;
503 trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
504 break;
505 }
506 trap_opcode = g_arm_breakpoint_opcode;
507 trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
508 } break;
509
510 case llvm::Triple::ppc:
511 case llvm::Triple::ppc64: {
512 static const uint8_t g_ppc_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
513 trap_opcode = g_ppc_breakpoint_opcode;
514 trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
515 } break;
516
517 default:
518 return Platform::GetSoftwareBreakpointTrapOpcode(target, bp_site);
519 }
520
521 if (trap_opcode && trap_opcode_size) {
522 if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
523 return trap_opcode_size;
524 }
525 return 0;
526}
527
529 lldb_private::Target &target, const lldb::ModuleSP &module_sp) {
530 if (!module_sp)
531 return false;
532
533 ObjectFile *obj_file = module_sp->GetObjectFile();
534 if (!obj_file)
535 return false;
536
537 ObjectFile::Type obj_type = obj_file->GetType();
538 return obj_type == ObjectFile::eTypeDynamicLinker;
539}
540
542 std::vector<ArchSpec> &archs) {
543 ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
544 archs.push_back(host_arch);
545
546 if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h) {
547 archs.push_back(ArchSpec("x86_64-apple-macosx"));
548 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
549 } else {
550 ArchSpec host_arch64 = HostInfo::GetArchitecture(HostInfo::eArchKind64);
551 if (host_arch.IsExactMatch(host_arch64))
552 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
553 }
554}
555
556static llvm::ArrayRef<const char *> GetCompatibleArchs(ArchSpec::Core core) {
557 switch (core) {
558 default:
559 [[fallthrough]];
561 static const char *g_arm64e_compatible_archs[] = {
562 "arm64e", "arm64", "armv7", "armv7f", "armv7k", "armv7s",
563 "armv7m", "armv7em", "armv6m", "armv6", "armv5", "armv4",
564 "arm", "thumbv7", "thumbv7f", "thumbv7k", "thumbv7s", "thumbv7m",
565 "thumbv7em", "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
566 };
567 return {g_arm64e_compatible_archs};
568 }
570 static const char *g_arm64_compatible_archs[] = {
571 "arm64", "armv7", "armv7f", "armv7k", "armv7s", "armv7m",
572 "armv7em", "armv6m", "armv6", "armv5", "armv4", "arm",
573 "thumbv7", "thumbv7f", "thumbv7k", "thumbv7s", "thumbv7m", "thumbv7em",
574 "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
575 };
576 return {g_arm64_compatible_archs};
577 }
579 static const char *g_armv7_compatible_archs[] = {
580 "armv7", "armv6m", "armv6", "armv5", "armv4", "arm",
581 "thumbv7", "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
582 };
583 return {g_armv7_compatible_archs};
584 }
586 static const char *g_armv7f_compatible_archs[] = {
587 "armv7f", "armv7", "armv6m", "armv6", "armv5",
588 "armv4", "arm", "thumbv7f", "thumbv7", "thumbv6m",
589 "thumbv6", "thumbv5", "thumbv4t", "thumb",
590 };
591 return {g_armv7f_compatible_archs};
592 }
594 static const char *g_armv7k_compatible_archs[] = {
595 "armv7k", "armv7", "armv6m", "armv6", "armv5",
596 "armv4", "arm", "thumbv7k", "thumbv7", "thumbv6m",
597 "thumbv6", "thumbv5", "thumbv4t", "thumb",
598 };
599 return {g_armv7k_compatible_archs};
600 }
602 static const char *g_armv7s_compatible_archs[] = {
603 "armv7s", "armv7", "armv6m", "armv6", "armv5",
604 "armv4", "arm", "thumbv7s", "thumbv7", "thumbv6m",
605 "thumbv6", "thumbv5", "thumbv4t", "thumb",
606 };
607 return {g_armv7s_compatible_archs};
608 }
610 static const char *g_armv7m_compatible_archs[] = {
611 "armv7m", "armv7", "armv6m", "armv6", "armv5",
612 "armv4", "arm", "thumbv7m", "thumbv7", "thumbv6m",
613 "thumbv6", "thumbv5", "thumbv4t", "thumb",
614 };
615 return {g_armv7m_compatible_archs};
616 }
618 static const char *g_armv7em_compatible_archs[] = {
619 "armv7em", "armv7", "armv6m", "armv6", "armv5",
620 "armv4", "arm", "thumbv7em", "thumbv7", "thumbv6m",
621 "thumbv6", "thumbv5", "thumbv4t", "thumb",
622 };
623 return {g_armv7em_compatible_archs};
624 }
626 static const char *g_armv6m_compatible_archs[] = {
627 "armv6m", "armv6", "armv5", "armv4", "arm",
628 "thumbv6m", "thumbv6", "thumbv5", "thumbv4t", "thumb",
629 };
630 return {g_armv6m_compatible_archs};
631 }
633 static const char *g_armv6_compatible_archs[] = {
634 "armv6", "armv5", "armv4", "arm",
635 "thumbv6", "thumbv5", "thumbv4t", "thumb",
636 };
637 return {g_armv6_compatible_archs};
638 }
640 static const char *g_armv5_compatible_archs[] = {
641 "armv5", "armv4", "arm", "thumbv5", "thumbv4t", "thumb",
642 };
643 return {g_armv5_compatible_archs};
644 }
646 static const char *g_armv4_compatible_archs[] = {
647 "armv4",
648 "arm",
649 "thumbv4t",
650 "thumb",
651 };
652 return {g_armv4_compatible_archs};
653 }
654 }
655 return {};
656}
657
658/// The architecture selection rules for arm processors These cpu subtypes have
659/// distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f
660/// processor.
662 std::vector<ArchSpec> &archs, std::optional<llvm::Triple::OSType> os) {
663 const ArchSpec system_arch = GetSystemArchitecture();
664 const ArchSpec::Core system_core = system_arch.GetCore();
665 for (const char *arch : GetCompatibleArchs(system_core)) {
666 llvm::Triple triple;
667 triple.setArchName(arch);
668 triple.setVendor(llvm::Triple::VendorType::Apple);
669 if (os)
670 triple.setOS(*os);
671 archs.push_back(ArchSpec(triple));
672 }
673}
674
676 static FileSpec g_xcode_select_filespec;
677
678 if (!g_xcode_select_filespec) {
679 FileSpec xcode_select_cmd("/usr/bin/xcode-select");
680 if (FileSystem::Instance().Exists(xcode_select_cmd)) {
681 int exit_status = -1;
682 int signo = -1;
683 std::string command_output;
684 Status status =
685 Host::RunShellCommand("/usr/bin/xcode-select --print-path",
686 FileSpec(), // current working directory
687 &exit_status, &signo, &command_output, nullptr,
688 std::chrono::seconds(2), // short timeout
689 false); // don't run in a shell
690 if (status.Success() && exit_status == 0 && !command_output.empty()) {
691 size_t first_non_newline = command_output.find_last_not_of("\r\n");
692 if (first_non_newline != std::string::npos) {
693 command_output.erase(first_non_newline + 1);
694 }
695 g_xcode_select_filespec = FileSpec(command_output);
696 }
697 }
698 }
699
700 return g_xcode_select_filespec;
701}
702
704 BreakpointSP bp_sp;
705 static const char *g_bp_names[] = {
706 "start_wqthread", "_pthread_wqthread", "_pthread_start",
707 };
708
709 static const char *g_bp_modules[] = {"libsystem_c.dylib", "libSystem.B.dylib",
710 "libsystem_pthread.dylib"};
711
712 FileSpecList bp_modules;
713 for (size_t i = 0; i < std::size(g_bp_modules); i++) {
714 const char *bp_module = g_bp_modules[i];
715 bp_modules.EmplaceBack(bp_module);
716 }
717
718 bool internal = true;
719 bool hardware = false;
720 LazyBool skip_prologue = eLazyBoolNo;
721 bp_sp = target.CreateBreakpoint(&bp_modules, nullptr, g_bp_names,
722 std::size(g_bp_names), eFunctionNameTypeFull,
723 eLanguageTypeUnknown, 0, skip_prologue,
724 internal, hardware);
725 bp_sp->SetBreakpointKind("thread-creation");
726
727 return bp_sp;
728}
729
730uint32_t
732 const FileSpec &shell = launch_info.GetShell();
733 if (!shell)
734 return 1;
735
736 std::string shell_string = shell.GetPath();
737 const char *shell_name = strrchr(shell_string.c_str(), '/');
738 if (shell_name == nullptr)
739 shell_name = shell_string.c_str();
740 else
741 shell_name++;
742
743 if (strcmp(shell_name, "sh") == 0) {
744 // /bin/sh re-exec's itself as /bin/bash requiring another resume. But it
745 // only does this if the COMMAND_MODE environment variable is set to
746 // "legacy".
747 if (launch_info.GetEnvironment().lookup("COMMAND_MODE") == "legacy")
748 return 2;
749 return 1;
750 } else if (strcmp(shell_name, "csh") == 0 ||
751 strcmp(shell_name, "tcsh") == 0 ||
752 strcmp(shell_name, "zsh") == 0) {
753 // csh and tcsh always seem to re-exec themselves.
754 return 2;
755 } else
756 return 1;
757}
758
760 Debugger &debugger, Target &target,
761 Status &error) {
762 ProcessSP process_sp;
763
764 if (IsHost()) {
765 // We are going to hand this process off to debugserver which will be in
766 // charge of setting the exit status. However, we still need to reap it
767 // from lldb. So, make sure we use a exit callback which does not set exit
768 // status.
769 launch_info.SetMonitorProcessCallback(
771 process_sp = Platform::DebugProcess(launch_info, debugger, target, error);
772 } else {
774 process_sp = m_remote_platform_sp->DebugProcess(launch_info, debugger,
775 target, error);
776 else
777 error =
778 Status::FromErrorString("the platform is not currently connected");
779 }
780 return process_sp;
781}
782
786
788 static FileSpec g_command_line_tools_filespec;
789
790 if (!g_command_line_tools_filespec) {
791 FileSpec command_line_tools_path(GetXcodeSelectPath());
792 command_line_tools_path.AppendPathComponent("Library");
793 if (FileSystem::Instance().Exists(command_line_tools_path)) {
794 g_command_line_tools_filespec = command_line_tools_path;
795 }
796 }
797
798 return g_command_line_tools_filespec;
799}
800
802 void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) {
803 SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo *>(baton);
804
805 FileSpec spec(path);
806 if (XcodeSDK::SDKSupportsModules(enumerator_info->sdk_type, spec)) {
807 enumerator_info->found_path = spec;
809 }
810
812}
813
815 const FileSpec &sdks_spec) {
816 // Look inside Xcode for the required installed iOS SDK version
817
818 if (!FileSystem::Instance().IsDirectory(sdks_spec)) {
819 return FileSpec();
820 }
821
822 const bool find_directories = true;
823 const bool find_files = false;
824 const bool find_other = true; // include symlinks
825
826 SDKEnumeratorInfo enumerator_info;
827
828 enumerator_info.sdk_type = sdk_type;
829
831 sdks_spec.GetPath(), find_directories, find_files, find_other,
832 DirectoryEnumerator, &enumerator_info);
833
834 if (FileSystem::Instance().IsDirectory(enumerator_info.found_path))
835 return enumerator_info.found_path;
836 else
837 return FileSpec();
838}
839
841 FileSpec sdks_spec = HostInfo::GetXcodeContentsDirectory();
842 sdks_spec.AppendPathComponent("Developer");
843 sdks_spec.AppendPathComponent("Platforms");
844
845 switch (sdk_type) {
847 sdks_spec.AppendPathComponent("MacOSX.platform");
848 break;
850 sdks_spec.AppendPathComponent("iPhoneSimulator.platform");
851 break;
853 sdks_spec.AppendPathComponent("iPhoneOS.platform");
854 break;
856 sdks_spec.AppendPathComponent("WatchSimulator.platform");
857 break;
859 sdks_spec.AppendPathComponent("AppleTVSimulator.platform");
860 break;
862 sdks_spec.AppendPathComponent("XRSimulator.platform");
863 break;
864 default:
865 llvm_unreachable("unsupported sdk");
866 }
867
868 sdks_spec.AppendPathComponent("Developer");
869 sdks_spec.AppendPathComponent("SDKs");
870
871 if (sdk_type == XcodeSDK::Type::MacOSX) {
872 llvm::VersionTuple version = HostInfo::GetOSVersion();
873
874 if (!version.empty()) {
876 // If the Xcode SDKs are not available then try to use the
877 // Command Line Tools one which is only for MacOSX.
878 if (!FileSystem::Instance().Exists(sdks_spec)) {
879 sdks_spec = GetCommandLineToolsLibraryPath();
880 sdks_spec.AppendPathComponent("SDKs");
881 }
882
883 // We slightly prefer the exact SDK for this machine. See if it is
884 // there.
885
886 FileSpec native_sdk_spec = sdks_spec;
887 StreamString native_sdk_name;
888 native_sdk_name.Printf("MacOSX%u.%u.sdk", version.getMajor(),
889 version.getMinor().value_or(0));
890 native_sdk_spec.AppendPathComponent(native_sdk_name.GetString());
891
892 if (FileSystem::Instance().Exists(native_sdk_spec)) {
893 return native_sdk_spec;
894 }
895 }
896 }
897 }
898
899 return FindSDKInXcodeForModules(sdk_type, sdks_spec);
900}
901
902// Discovering the correct version and build can help us
903// identify the most likely SDK directory when looking for
904// files.
905//
906// The directory name can be one of many formats, such as
907// 10.0 (21R329) universal
908// 17.0 (23A200) arm64e
909// 17.0 (20A352)
910// Watch4,2 10.0 (21R329)
911std::tuple<llvm::VersionTuple, llvm::StringRef>
913 llvm::StringRef build;
914 llvm::VersionTuple version;
915
916 llvm::SmallVector<llvm::StringRef> parts;
917 dir.split(parts, ' ');
918 for (llvm::StringRef part : parts) {
919 // Look for an OS version number, eg "17.0"
920 if (isdigit(part[0]))
921 version.tryParse(part);
922 // Look for a build number, eg "(20A352)"
923 if (part.consume_front("(")) {
924 size_t pos = part.find(')');
925 build = part.slice(0, pos);
926 }
927 }
928
929 return std::make_tuple(version, build);
930}
931
932llvm::Expected<StructuredData::DictionarySP>
934 static constexpr llvm::StringLiteral crash_info_key("Crash-Info Annotations");
935 static constexpr llvm::StringLiteral asi_info_key(
936 "Application Specific Information");
937
938 // We cache the information we find in the process extended info dict:
939 StructuredData::DictionarySP process_dict_sp =
940 process.GetExtendedCrashInfoDict();
941 StructuredData::Array *annotations = nullptr;
942 StructuredData::ArraySP new_annotations_sp;
943 if (!process_dict_sp->GetValueForKeyAsArray(crash_info_key, annotations)) {
944 new_annotations_sp = ExtractCrashInfoAnnotations(process);
945 if (new_annotations_sp && new_annotations_sp->GetSize()) {
946 process_dict_sp->AddItem(crash_info_key, new_annotations_sp);
947 annotations = new_annotations_sp.get();
948 }
949 }
950
951 StructuredData::Dictionary *app_specific_info;
952 StructuredData::DictionarySP new_app_specific_info_sp;
953 if (!process_dict_sp->GetValueForKeyAsDictionary(asi_info_key,
954 app_specific_info)) {
955 new_app_specific_info_sp = ExtractAppSpecificInfo(process);
956 if (new_app_specific_info_sp && new_app_specific_info_sp->GetSize()) {
957 process_dict_sp->AddItem(asi_info_key, new_app_specific_info_sp);
958 app_specific_info = new_app_specific_info_sp.get();
959 }
960 }
961
962 // Now get anything else that was in the process info dict, and add it to the
963 // return here:
964 return process_dict_sp->GetSize() ? process_dict_sp : nullptr;
965}
966
970
971 llvm::StringRef section_name("__crash_info");
972 Target &target = process.GetTarget();
973 StructuredData::ArraySP array_sp = std::make_shared<StructuredData::Array>();
974
975 for (ModuleSP module : target.GetImages().Modules()) {
976 SectionList *sections = module->GetSectionList();
977
978 std::string module_name = module->GetSpecificationDescription();
979
980 // The DYDL module is skipped since it's always loaded when running the
981 // binary.
982 if (module_name == "/usr/lib/dyld")
983 continue;
984
985 if (!sections) {
986 LLDB_LOG(log, "Module {0} doesn't have any section!", module_name);
987 continue;
988 }
989
990 SectionSP crash_info = sections->FindSectionByName(section_name);
991 if (!crash_info) {
992 LLDB_LOG(log, "Module {0} doesn't have section {1}!", module_name,
993 section_name);
994 continue;
995 }
996
997 addr_t load_addr = crash_info->GetLoadBaseAddress(&target);
998
999 if (load_addr == LLDB_INVALID_ADDRESS) {
1000 LLDB_LOG(log, "Module {0} has an invalid '{1}' section load address: {2}",
1001 module_name, section_name, load_addr);
1002 continue;
1003 }
1004
1005 Status error;
1006 CrashInfoAnnotations annotations;
1007 size_t expected_size = sizeof(CrashInfoAnnotations);
1008 size_t bytes_read = process.ReadMemoryFromInferior(load_addr, &annotations,
1009 expected_size, error);
1010
1011 if (expected_size != bytes_read || error.Fail()) {
1012 LLDB_LOG(log, "Failed to read {0} section from memory in module {1}: {2}",
1013 section_name, module_name, error);
1014 continue;
1015 }
1016
1017 // initial support added for version 5
1018 if (annotations.version < 5) {
1019 LLDB_LOG(log,
1020 "Annotation version lower than 5 unsupported! Module {0} has "
1021 "version {1} instead.",
1022 module_name, annotations.version);
1023 continue;
1024 }
1025
1026 if (!annotations.message) {
1027 LLDB_LOG(log, "No message available for module {0}.", module_name);
1028 continue;
1029 }
1030
1031 std::string message;
1032 bytes_read =
1033 process.ReadCStringFromMemory(annotations.message, message, error);
1034
1035 if (message.empty() || bytes_read != message.size() || error.Fail()) {
1036 LLDB_LOG(log, "Failed to read the message from memory in module {0}: {1}",
1037 module_name, error);
1038 continue;
1039 }
1040
1041 // Remove trailing newline from message
1042 if (message.back() == '\n')
1043 message.pop_back();
1044
1045 if (!annotations.message2)
1046 LLDB_LOG(log, "No message2 available for module {0}.", module_name);
1047
1048 std::string message2;
1049 bytes_read =
1050 process.ReadCStringFromMemory(annotations.message2, message2, error);
1051
1052 if (!message2.empty() && bytes_read == message2.size() && error.Success())
1053 if (message2.back() == '\n')
1054 message2.pop_back();
1055
1057 std::make_shared<StructuredData::Dictionary>();
1058
1059 entry_sp->AddStringItem("image", module->GetFileSpec().GetPath(false));
1060 entry_sp->AddStringItem("uuid", module->GetUUID().GetAsString());
1061 entry_sp->AddStringItem("message", message);
1062 entry_sp->AddStringItem("message2", message2);
1063 entry_sp->AddIntegerItem("abort-cause", annotations.abort_cause);
1064
1065 array_sp->AddItem(entry_sp);
1066 }
1067
1068 return array_sp;
1069}
1070
1073 StructuredData::DictionarySP metadata_sp = process.GetMetadata();
1074
1075 if (!metadata_sp || !metadata_sp->GetSize() || !metadata_sp->HasKey("asi"))
1076 return {};
1077
1079 if (!metadata_sp->GetValueForKeyAsDictionary("asi", asi))
1080 return {};
1081
1083 std::make_shared<StructuredData::Dictionary>();
1084
1085 auto flatten_asi_dict = [&dict_sp](llvm::StringRef key,
1086 StructuredData::Object *val) -> bool {
1087 if (!val)
1088 return false;
1089
1090 StructuredData::Array *arr = val->GetAsArray();
1091 if (!arr || !arr->GetSize())
1092 return false;
1093
1094 dict_sp->AddItem(key, arr->GetItemAtIndex(0));
1095 return true;
1096 };
1097
1098 asi->ForEach(flatten_asi_dict);
1099
1100 return dict_sp;
1101}
1102
1103static llvm::Expected<lldb_private::FileSpec>
1105
1106 ModuleSP exe_module_sp = target->GetExecutableModule();
1107 if (!exe_module_sp)
1108 return llvm::createStringError("could not get module from target");
1109
1110 SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
1111 if (!sym_file)
1112 return llvm::createStringError("could not get symbol file from executable");
1113
1114 if (sym_file->GetNumCompileUnits() == 0)
1115 return llvm::createStringError(
1116 "could not resolve SDK for target: executable's symbol file has no "
1117 "compile units");
1118
1119 XcodeSDK merged_sdk;
1120 for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i)
1121 if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i))
1122 merged_sdk.Merge(sym_file->ParseXcodeSDK(*cu_sp));
1123
1124 // TODO: The result of this loop is almost equivalent to deriving the SDK
1125 // from the target triple, which would be a lot cheaper.
1126 return PlatformDarwin::ResolveXcodeSDK(std::move(merged_sdk));
1127}
1128
1130 Target *target, std::vector<std::string> &options, XcodeSDK::Type sdk_type) {
1131 const std::vector<std::string> apple_arguments = {
1132 "-x", "objective-c++", "-fobjc-arc",
1133 "-fblocks", "-D_ISO646_H", "-D__ISO646_H",
1134 "-fgnuc-version=4.2.1"};
1135
1136 options.insert(options.end(), apple_arguments.begin(), apple_arguments.end());
1137
1138 StreamString minimum_version_option;
1139 bool use_current_os_version = false;
1140 // If the SDK type is for the host OS, use its version number.
1141 auto get_host_os = []() { return HostInfo::GetTargetTriple().getOS(); };
1142 switch (sdk_type) {
1144 use_current_os_version = get_host_os() == llvm::Triple::MacOSX;
1145 break;
1147 use_current_os_version = get_host_os() == llvm::Triple::IOS;
1148 break;
1150 use_current_os_version = get_host_os() == llvm::Triple::TvOS;
1151 break;
1153 use_current_os_version = get_host_os() == llvm::Triple::WatchOS;
1154 break;
1156 use_current_os_version = get_host_os() == llvm::Triple::XROS;
1157 break;
1158 default:
1159 break;
1160 }
1161
1162 llvm::VersionTuple version;
1163 if (use_current_os_version)
1164 version = GetOSVersion();
1165 else if (target) {
1166 // Our OS doesn't match our executable so we need to get the min OS version
1167 // from the object file
1168 ModuleSP exe_module_sp = target->GetExecutableModule();
1169 if (exe_module_sp) {
1170 ObjectFile *object_file = exe_module_sp->GetObjectFile();
1171 if (object_file)
1172 version = object_file->GetMinimumOSVersion();
1173 }
1174 }
1175 // Only add the version-min options if we got a version from somewhere.
1176 // clang has no version-min clang flag for XROS.
1177 if (!version.empty() && sdk_type != XcodeSDK::Type::Linux &&
1178 sdk_type != XcodeSDK::Type::XROS) {
1179#define OPTION(PREFIX_OFFSET, NAME_OFFSET, VAR, ...) \
1180 llvm::StringRef opt_##VAR = OptionStrTable[NAME_OFFSET]; \
1181 (void)opt_##VAR;
1182#include "clang/Options/Options.inc"
1183#undef OPTION
1184 minimum_version_option << '-';
1185 switch (sdk_type) {
1187 minimum_version_option << opt_mmacos_version_min_EQ;
1188 break;
1190 minimum_version_option << opt_mios_simulator_version_min_EQ;
1191 break;
1193 minimum_version_option << opt_mios_version_min_EQ;
1194 break;
1196 minimum_version_option << opt_mtvos_simulator_version_min_EQ;
1197 break;
1199 minimum_version_option << opt_mtvos_version_min_EQ;
1200 break;
1202 minimum_version_option << opt_mwatchos_simulator_version_min_EQ;
1203 break;
1205 minimum_version_option << opt_mwatchos_version_min_EQ;
1206 break;
1209 // FIXME: Pass the right argument once it exists.
1213 if (Log *log = GetLog(LLDBLog::Host)) {
1214 XcodeSDK::Info info;
1215 info.type = sdk_type;
1216 LLDB_LOGF(log, "Clang modules on %s are not supported",
1217 XcodeSDK::GetCanonicalName(info).c_str());
1218 }
1219 return;
1220 }
1221 minimum_version_option << version.getAsString();
1222 options.emplace_back(std::string(minimum_version_option.GetString()));
1223 }
1224
1225 FileSpec sysroot_spec;
1226
1227 if (target) {
1228 auto sysroot_spec_or_err = ::ResolveSDKPathFromDebugInfo(target);
1229 if (!sysroot_spec_or_err) {
1231 sysroot_spec_or_err.takeError(),
1232 "Failed to resolve sysroot: {0}");
1233 } else {
1234 sysroot_spec = *sysroot_spec_or_err;
1235 }
1236 }
1237
1238 if (!FileSystem::Instance().IsDirectory(sysroot_spec.GetPath())) {
1239 std::lock_guard<std::mutex> guard(m_mutex);
1240 sysroot_spec = GetSDKDirectoryForModules(sdk_type);
1241 }
1242
1243 if (FileSystem::Instance().IsDirectory(sysroot_spec.GetPath())) {
1244 options.push_back("-isysroot");
1245 options.push_back(sysroot_spec.GetPath());
1246 }
1247}
1248
1249std::string PlatformDarwin::GetFullNameForDylib(llvm::StringRef basename) {
1250 if (basename.empty())
1251 return basename.str();
1252
1253 return llvm::formatv("lib{0}.dylib", basename).str();
1254}
1255
1256llvm::VersionTuple PlatformDarwin::GetOSVersion(Process *process) {
1257 if (process && GetPluginName().contains("-simulator")) {
1259 if (Host::GetProcessInfo(process->GetID(), proc_info)) {
1260 const Environment &env = proc_info.GetEnvironment();
1261
1262 llvm::VersionTuple result;
1263 if (!result.tryParse(env.lookup("SIMULATOR_RUNTIME_VERSION")))
1264 return result;
1265
1266 std::string dyld_root_path = env.lookup("DYLD_ROOT_PATH");
1267 if (!dyld_root_path.empty()) {
1268 dyld_root_path += "/System/Library/CoreServices/SystemVersion.plist";
1269 ApplePropertyList system_version_plist(dyld_root_path.c_str());
1270 std::string product_version;
1271 if (system_version_plist.GetValueAsString("ProductVersion",
1272 product_version)) {
1273 if (!result.tryParse(product_version))
1274 return result;
1275 }
1276 }
1277 }
1278 // For simulator platforms, do NOT call back through
1279 // Platform::GetOSVersion() as it might call Process::GetHostOSVersion()
1280 // which we don't want as it will be incorrect
1281 return llvm::VersionTuple();
1282 }
1283
1284 return Platform::GetOSVersion(process);
1285}
1286
1288 // A collection of SBFileSpec whose SBFileSpec.m_directory members are filled
1289 // in with any executable directories that should be searched.
1290 static std::vector<FileSpec> g_executable_dirs;
1291
1292 // Find the global list of directories that we will search for executables
1293 // once so we don't keep doing the work over and over.
1294 static llvm::once_flag g_once_flag;
1295 llvm::call_once(g_once_flag, []() {
1296
1297 // When locating executables, trust the DEVELOPER_DIR first if it is set
1298 FileSpec xcode_contents_dir = HostInfo::GetXcodeContentsDirectory();
1299 if (xcode_contents_dir) {
1300 FileSpec xcode_lldb_resources = xcode_contents_dir;
1301 xcode_lldb_resources.AppendPathComponent("SharedFrameworks");
1302 xcode_lldb_resources.AppendPathComponent("LLDB.framework");
1303 xcode_lldb_resources.AppendPathComponent("Resources");
1304 if (FileSystem::Instance().Exists(xcode_lldb_resources)) {
1305 FileSpec dir;
1306 dir.SetDirectory(xcode_lldb_resources.GetPath());
1307 g_executable_dirs.push_back(dir);
1308 }
1309 }
1310 // Xcode might not be installed so we also check for the Command Line Tools.
1311 FileSpec command_line_tools_dir = GetCommandLineToolsLibraryPath();
1312 if (command_line_tools_dir) {
1313 FileSpec cmd_line_lldb_resources = command_line_tools_dir;
1314 cmd_line_lldb_resources.AppendPathComponent("PrivateFrameworks");
1315 cmd_line_lldb_resources.AppendPathComponent("LLDB.framework");
1316 cmd_line_lldb_resources.AppendPathComponent("Resources");
1317 if (FileSystem::Instance().Exists(cmd_line_lldb_resources)) {
1318 FileSpec dir;
1319 dir.SetDirectory(cmd_line_lldb_resources.GetPath());
1320 g_executable_dirs.push_back(dir);
1321 }
1322 }
1323 });
1324
1325 // Now search the global list of executable directories for the executable we
1326 // are looking for
1327 for (const auto &executable_dir : g_executable_dirs) {
1328 FileSpec executable_file;
1329 executable_file.SetDirectory(executable_dir.GetDirectory());
1330 executable_file.SetFilename(basename);
1331 if (FileSystem::Instance().Exists(executable_file))
1332 return executable_file;
1333 }
1334
1335 return FileSpec();
1336}
1337
1340 // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr if
1341 // the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't require
1342 // any specific value; rather, it just needs to exist). We will set it here
1343 // as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag is not set. Xcode
1344 // makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
1345 // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
1346 // specifically want it unset.
1347 const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
1348 auto &env_vars = launch_info.GetEnvironment();
1349 if (!env_vars.count(disable_env_var)) {
1350 // We want to make sure that OS_ACTIVITY_DT_MODE is set so that we get
1351 // os_log and NSLog messages mirrored to the target process stderr.
1352 env_vars.try_emplace("OS_ACTIVITY_DT_MODE", "enable");
1353 }
1354
1355 // Let our parent class do the real launching.
1356 return PlatformPOSIX::LaunchProcess(launch_info);
1357}
1358
1360 const ModuleSpec &module_spec, Target &target, ModuleSP &module_sp,
1361 llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
1362 const FileSpec &platform_file = module_spec.GetFileSpec();
1363 FileSpecList module_search_paths = target.GetExecutableSearchPaths();
1364 // See if the file is present in any of the module_search_paths
1365 // directories.
1366 if (!module_sp && !module_search_paths.IsEmpty() && platform_file) {
1367 // create a vector of all the file / directory names in platform_file e.g.
1368 // this might be
1369 // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
1370 //
1371 // We'll need to look in the module_search_paths_ptr directories for both
1372 // "UIFoundation" and "UIFoundation.framework" -- most likely the latter
1373 // will be the one we find there.
1374
1375 std::vector<llvm::StringRef> path_parts = platform_file.GetComponents();
1376 // We want the components in reverse order.
1377 std::reverse(path_parts.begin(), path_parts.end());
1378 const size_t path_parts_size = path_parts.size();
1379
1380 size_t num_module_search_paths = module_search_paths.GetSize();
1381 for (size_t i = 0; i < num_module_search_paths; ++i) {
1382 Log *log_verbose = GetLog(LLDBLog::Host);
1383 LLDB_LOGF(
1384 log_verbose,
1385 "PlatformRemoteDarwinDevice::GetSharedModule searching for binary in "
1386 "search-path %s",
1387 module_search_paths.GetFileSpecAtIndex(i).GetPath().c_str());
1388 // Create a new FileSpec with this module_search_paths_ptr plus just the
1389 // filename ("UIFoundation"), then the parent dir plus filename
1390 // ("UIFoundation.framework/UIFoundation") etc - up to four names (to
1391 // handle "Foo.framework/Contents/MacOS/Foo")
1392
1393 for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
1394 FileSpec path_to_try(module_search_paths.GetFileSpecAtIndex(i));
1395
1396 // Add the components backwards. For
1397 // .../PrivateFrameworks/UIFoundation.framework/UIFoundation path_parts
1398 // is
1399 // [0] UIFoundation
1400 // [1] UIFoundation.framework
1401 // [2] PrivateFrameworks
1402 //
1403 // and if 'j' is 2, we want to append path_parts[1] and then
1404 // path_parts[0], aka 'UIFoundation.framework/UIFoundation', to the
1405 // module_search_paths_ptr path.
1406
1407 for (int k = j; k >= 0; --k) {
1408 path_to_try.AppendPathComponent(path_parts[k]);
1409 }
1410
1411 if (FileSystem::Instance().Exists(path_to_try)) {
1412 ModuleSpec new_module_spec(module_spec);
1413 new_module_spec.GetFileSpec() = path_to_try;
1415 new_module_spec, target, module_sp, old_modules, did_create_ptr));
1416
1417 if (module_sp) {
1418 module_sp->SetPlatformFileSpec(path_to_try);
1419 return new_error;
1420 }
1421 }
1422 }
1423 }
1424 }
1425 return Status();
1426}
1427
1428llvm::Triple::OSType PlatformDarwin::GetHostOSType() {
1429#if !defined(__APPLE__)
1430 return llvm::Triple::MacOSX;
1431#else
1432#if TARGET_OS_OSX
1433 return llvm::Triple::MacOSX;
1434#elif TARGET_OS_IOS
1435 return llvm::Triple::IOS;
1436#elif TARGET_OS_WATCH
1437 return llvm::Triple::WatchOS;
1438#elif TARGET_OS_TV
1439 return llvm::Triple::TvOS;
1440#elif TARGET_OS_BRIDGE
1441 return llvm::Triple::BridgeOS;
1442#elif TARGET_OS_XR
1443 return llvm::Triple::XROS;
1444#else
1445#error "LLDB being compiled for an unrecognized Darwin OS"
1446#endif
1447#endif // __APPLE__
1448}
1449
1450llvm::Expected<std::pair<XcodeSDK, bool>>
1452 SymbolFile *sym_file = module.GetSymbolFile();
1453 if (!sym_file)
1454 return llvm::createStringError(
1455 llvm::inconvertibleErrorCode(),
1456 llvm::formatv("No symbol file available for module '{0}'",
1457 module.GetFileSpec().GetFilename()));
1458
1459 if (sym_file->GetNumCompileUnits() == 0)
1460 return llvm::createStringError(
1461 llvm::formatv("Could not resolve SDK for module '{0}'. Symbol file has "
1462 "no compile units.",
1463 module.GetFileSpec()));
1464
1465 bool found_public_sdk = false;
1466 bool found_internal_sdk = false;
1467 XcodeSDK merged_sdk;
1468 for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
1469 if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
1470 auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
1471 bool is_internal_sdk = cu_sdk.IsAppleInternalSDK();
1472 found_public_sdk |= !is_internal_sdk;
1473 found_internal_sdk |= is_internal_sdk;
1474
1475 merged_sdk.Merge(cu_sdk);
1476 }
1477 }
1478
1479 const bool found_mismatch = found_internal_sdk && found_public_sdk;
1480
1481 return std::pair{std::move(merged_sdk), found_mismatch};
1482}
1483
1484llvm::Expected<FileSpec> PlatformDarwin::ResolveXcodeSDK(XcodeSDK sdk) {
1485 if (FileSpec sysroot = sdk.GetSysroot();
1486 FileSystem::Instance().Exists(sysroot))
1487 return sysroot;
1488
1489 Progress progress("Looking for Xcode SDK", sdk.GetString().str());
1490 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1491 if (!path_or_err)
1492 return llvm::joinErrors(llvm::createStringError(llvm::formatv(
1493 "could not find SDK '{0}'", sdk.GetString())),
1494 path_or_err.takeError());
1495 return FileSpec(*path_or_err);
1496}
1497
1498llvm::Expected<std::string>
1500 auto sdk_or_err = GetSDKPathFromDebugInfo(module);
1501 if (!sdk_or_err)
1502 return llvm::joinErrors(
1503 llvm::createStringError("could not parse SDK path from debug-info"),
1504 sdk_or_err.takeError());
1505
1506 auto path_or_err = ResolveXcodeSDK(std::move(sdk_or_err->first));
1507 if (!path_or_err)
1508 return path_or_err.takeError();
1509 return path_or_err->GetPath();
1510}
1511
1512llvm::Expected<XcodeSDK>
1514 ModuleSP module_sp = unit.CalculateSymbolContextModule();
1515 if (!module_sp)
1516 return llvm::createStringError("compile unit has no module");
1517 SymbolFile *sym_file = module_sp->GetSymbolFile();
1518 if (!sym_file)
1519 return llvm::createStringError(
1520 llvm::formatv("No symbol file available for module '{0}'",
1521 module_sp->GetFileSpec().GetFilename()));
1522
1523 return sym_file->ParseXcodeSDK(unit);
1524}
1525
1526llvm::Expected<std::string>
1528 auto sdk_or_err = GetSDKPathFromDebugInfo(unit);
1529 if (!sdk_or_err)
1530 return llvm::joinErrors(
1531 llvm::createStringError("could not parse SDK path from debug-info"),
1532 sdk_or_err.takeError());
1533
1534 auto path_or_err = ResolveXcodeSDK(std::move(*sdk_or_err));
1535 if (!path_or_err)
1536 return path_or_err.takeError();
1537 return path_or_err->GetPath();
1538}
1539
1540llvm::Expected<FileSpecList>
1543
1544 XcodeSDK::Type sdk_type =
1546 XcodeSDK::Info info;
1547 info.type = sdk_type;
1548 XcodeSDK sdk(info);
1549
1550 auto sdk_root_or_err = ResolveXcodeSDK(sdk);
1551 if (!sdk_root_or_err) {
1552 LLDB_LOG_ERROR(log, sdk_root_or_err.takeError(),
1553 "Failed to resolve SDK root for triple '{1}': {0}",
1554 target.GetArchitecture().GetTriple().str());
1555
1556 // Fall back to any macOS SDK.
1557 sdk = XcodeSDK::GetAnyMacOS();
1558 LLDB_LOG(log, "Falling back to SDK '{0}'", sdk.GetString());
1559 sdk_root_or_err = ResolveXcodeSDK(sdk);
1560 }
1561
1562 if (!sdk_root_or_err)
1563 return sdk_root_or_err.takeError();
1564
1565 // $SDKROOT/usr/share/lldb is an auto-loadable path.
1566 llvm::SmallString<256> resolved(sdk_root_or_err->GetPath());
1567 llvm::sys::path::append(resolved, "usr", "share", "lldb");
1568
1569 FileSpecList fspecs;
1570 fspecs.Append(FileSpec(resolved));
1571
1572 return fspecs;
1573}
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: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
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: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 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.
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.
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::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:1087
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: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...
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:259
bool IsRemote() const
Definition Platform.h:557
bool IsHost() const
Definition Platform.h:553
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: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 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
FileSpecList GetExecutableSearchPaths()
Definition Target.cpp:5497
Debugger & GetDebugger() const
Definition Target.h:1330
const lldb::ProcessSP & GetProcessSP() const
Definition Target.cpp:328
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:1247
const ArchSpec & GetArchitecture() const
Definition Target.h:1289
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:338
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::Module > ModuleSP
lldb::DataExtractorSP GetExtractor()
A parsed SDK directory name.
Definition XcodeSDK.h:48
#define PATH_MAX