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