46#include "clang/Options/Options.h"
47#include "llvm/ADT/STLExtras.h"
48#include "llvm/Support/Error.h"
49#include "llvm/Support/FileSystem.h"
50#include "llvm/Support/Threading.h"
51#include "llvm/Support/VersionTuple.h"
55#include <TargetConditionals.h>
63 llvm::StringRef str_ref(
string);
64 llvm::SmallVector<llvm::StringRef> candidates;
65 str_ref.split(candidates,
'|');
66 for (
auto candidate : candidates) {
67 if (!(candidate ==
"EXC_BAD_ACCESS"
68 || candidate ==
"EXC_BAD_INSTRUCTION"
69 || candidate ==
"EXC_ARITHMETIC"
70 || candidate ==
"EXC_RESOURCE"
71 || candidate ==
"EXC_GUARD"
72 || candidate ==
"EXC_SYSCALL")) {
74 candidate.str().c_str());
108 return "Darwin platform plug-in.";
116#define LLDB_PROPERTIES_platformdarwin
117#include "PlatformMacOSXProperties.inc"
119#define LLDB_PROPERTIES_platformdarwin
121#include "PlatformMacOSXPropertiesEnum.inc"
127 static constexpr llvm::StringLiteral g_setting_name(
"darwin");
128 return g_setting_name;
139 const uint32_t idx = ePropertyIgnoredExceptions;
142 assert(option_value);
147 const uint32_t idx = ePropertyIgnoredExceptions;
150 assert(option_value);
164 const bool is_global_setting =
false;
167 "Properties for the Darwin platform plug-in.", is_global_setting);
175 std::string ignored_exceptions
177 if (ignored_exceptions.empty())
180 std::string packet =
"QSetIgnoredExceptions:";
181 packet.append(ignored_exceptions);
197llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile>
203 "Trying to locate scripting resources but no ScriptInterpreter is "
206 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> file_specs;
207 const FileSpec original_module_spec = module_spec;
222 original_path_string.
Format(
"{0}/../Python/{1}.py",
232 orig_script_fspec, script_fspec);
237 file_specs.try_emplace(std::move(script_fspec), load_style);
245 if (module_spec.
GetFilename() == filename_no_extension)
254llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile>
257 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> empty;
272 const FileSpec &module_spec =
module.GetFileSpec();
287 llvm::StringRef(symfile_spec.
GetPath())
288 .contains_insensitive(
".dSYM/Contents/Resources/DWARF") &&
291 feedback_stream, module_spec, *target, symfile_spec);
297#if defined(__APPLE__)
307 llvm::StringRef path_ref(symfile_path);
311 auto pos = path_ref.find(
".dSYM/");
312 if (pos == llvm::StringRef::npos)
315 FileSpec bundle_spec(path_ref.substr(0, pos + 5));
319 "dSYM bundle '{0}' has valid trusted code signature",
352 module_spec, target, module_sp, old_modules, did_create_ptr);
359 old_modules, did_create_ptr);
363 if (!module_sp && !module_search_paths.
IsEmpty() && platform_file) {
368 if (platform_file == bundle_directory) {
373 module_sp, old_modules,
382 platform_file.
GetPath(platform_path,
sizeof(platform_path));
383 const size_t bundle_directory_len =
384 bundle_directory.
GetPath(bundle_dir,
sizeof(bundle_dir));
386 size_t num_module_search_paths = module_search_paths.
GetSize();
387 for (
size_t i = 0; i < num_module_search_paths; ++i) {
388 const size_t search_path_len =
390 new_path,
sizeof(new_path));
391 if (search_path_len <
sizeof(new_path)) {
392 snprintf(new_path + search_path_len,
393 sizeof(new_path) - search_path_len,
"/%s",
394 platform_path + bundle_directory_len);
400 new_module_spec, target, module_sp, old_modules,
404 module_sp->SetPlatformFileSpec(new_file_spec);
415 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
432 std::optional<uint64_t> size;
434 sc_base_addr, sc_uuid, using_sc, private_sc, sc_path, size)) {
436 image_info = HostInfo::GetSharedCacheImageInfo(module_spec.
GetUUID(),
441 HostInfo::GetSharedCacheImageInfo(filepath, sc_uuid, sc_mode);
448 image_info = HostInfo::GetSharedCacheImageInfo(filepath, sc_mode);
462 LLDB_LOGF(log,
"module %s was found in a shared cache",
472 const uint8_t *trap_opcode =
nullptr;
473 uint32_t trap_opcode_size = 0;
474 bool bp_is_thumb =
false;
478 case llvm::Triple::aarch64_32:
479 case llvm::Triple::aarch64: {
481 static const uint8_t g_arm64_breakpoint_opcode[] = {0x00, 0x00, 0x20, 0xD4};
482 trap_opcode = g_arm64_breakpoint_opcode;
483 trap_opcode_size =
sizeof(g_arm64_breakpoint_opcode);
486 case llvm::Triple::thumb:
489 case llvm::Triple::arm: {
490 static const uint8_t g_arm_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
491 static const uint8_t g_thumb_breakpooint_opcode[] = {0xFE, 0xDE};
497 bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass() ==
501 trap_opcode = g_thumb_breakpooint_opcode;
502 trap_opcode_size =
sizeof(g_thumb_breakpooint_opcode);
505 trap_opcode = g_arm_breakpoint_opcode;
506 trap_opcode_size =
sizeof(g_arm_breakpoint_opcode);
509 case llvm::Triple::ppc:
510 case llvm::Triple::ppc64: {
511 static const uint8_t g_ppc_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
512 trap_opcode = g_ppc_breakpoint_opcode;
513 trap_opcode_size =
sizeof(g_ppc_breakpoint_opcode);
520 if (trap_opcode && trap_opcode_size) {
522 return trap_opcode_size;
532 ObjectFile *obj_file = module_sp->GetObjectFile();
541 std::vector<ArchSpec> &archs) {
542 ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
543 archs.push_back(host_arch);
546 archs.push_back(
ArchSpec(
"x86_64-apple-macosx"));
547 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
549 ArchSpec host_arch64 = HostInfo::GetArchitecture(HostInfo::eArchKind64);
551 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
560 static const char *g_arm64e_compatible_archs[] = {
561 "arm64e",
"arm64",
"armv7",
"armv7f",
"armv7k",
"armv7s",
562 "armv7m",
"armv7em",
"armv6m",
"armv6",
"armv5",
"armv4",
563 "arm",
"thumbv7",
"thumbv7f",
"thumbv7k",
"thumbv7s",
"thumbv7m",
564 "thumbv7em",
"thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
566 return {g_arm64e_compatible_archs};
569 static const char *g_arm64_compatible_archs[] = {
570 "arm64",
"armv7",
"armv7f",
"armv7k",
"armv7s",
"armv7m",
571 "armv7em",
"armv6m",
"armv6",
"armv5",
"armv4",
"arm",
572 "thumbv7",
"thumbv7f",
"thumbv7k",
"thumbv7s",
"thumbv7m",
"thumbv7em",
573 "thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
575 return {g_arm64_compatible_archs};
578 static const char *g_armv7_compatible_archs[] = {
579 "armv7",
"armv6m",
"armv6",
"armv5",
"armv4",
"arm",
580 "thumbv7",
"thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
582 return {g_armv7_compatible_archs};
585 static const char *g_armv7f_compatible_archs[] = {
586 "armv7f",
"armv7",
"armv6m",
"armv6",
"armv5",
587 "armv4",
"arm",
"thumbv7f",
"thumbv7",
"thumbv6m",
588 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
590 return {g_armv7f_compatible_archs};
593 static const char *g_armv7k_compatible_archs[] = {
594 "armv7k",
"armv7",
"armv6m",
"armv6",
"armv5",
595 "armv4",
"arm",
"thumbv7k",
"thumbv7",
"thumbv6m",
596 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
598 return {g_armv7k_compatible_archs};
601 static const char *g_armv7s_compatible_archs[] = {
602 "armv7s",
"armv7",
"armv6m",
"armv6",
"armv5",
603 "armv4",
"arm",
"thumbv7s",
"thumbv7",
"thumbv6m",
604 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
606 return {g_armv7s_compatible_archs};
609 static const char *g_armv7m_compatible_archs[] = {
610 "armv7m",
"armv7",
"armv6m",
"armv6",
"armv5",
611 "armv4",
"arm",
"thumbv7m",
"thumbv7",
"thumbv6m",
612 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
614 return {g_armv7m_compatible_archs};
617 static const char *g_armv7em_compatible_archs[] = {
618 "armv7em",
"armv7",
"armv6m",
"armv6",
"armv5",
619 "armv4",
"arm",
"thumbv7em",
"thumbv7",
"thumbv6m",
620 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
622 return {g_armv7em_compatible_archs};
625 static const char *g_armv6m_compatible_archs[] = {
626 "armv6m",
"armv6",
"armv5",
"armv4",
"arm",
627 "thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
629 return {g_armv6m_compatible_archs};
632 static const char *g_armv6_compatible_archs[] = {
633 "armv6",
"armv5",
"armv4",
"arm",
634 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
636 return {g_armv6_compatible_archs};
639 static const char *g_armv5_compatible_archs[] = {
640 "armv5",
"armv4",
"arm",
"thumbv5",
"thumbv4t",
"thumb",
642 return {g_armv5_compatible_archs};
645 static const char *g_armv4_compatible_archs[] = {
651 return {g_armv4_compatible_archs};
661 std::vector<ArchSpec> &archs, std::optional<llvm::Triple::OSType> os) {
666 triple.setArchName(arch);
667 triple.setVendor(llvm::Triple::VendorType::Apple);
675 static FileSpec g_xcode_select_filespec;
677 if (!g_xcode_select_filespec) {
678 FileSpec xcode_select_cmd(
"/usr/bin/xcode-select");
680 int exit_status = -1;
682 std::string command_output;
686 &exit_status, &signo, &command_output,
nullptr,
687 std::chrono::seconds(2),
689 if (status.
Success() && exit_status == 0 && !command_output.empty()) {
690 size_t first_non_newline = command_output.find_last_not_of(
"\r\n");
691 if (first_non_newline != std::string::npos) {
692 command_output.erase(first_non_newline + 1);
694 g_xcode_select_filespec =
FileSpec(command_output);
699 return g_xcode_select_filespec;
704 static const char *g_bp_names[] = {
705 "start_wqthread",
"_pthread_wqthread",
"_pthread_start",
708 static const char *g_bp_modules[] = {
"libsystem_c.dylib",
"libSystem.B.dylib",
709 "libsystem_pthread.dylib"};
712 for (
size_t i = 0; i < std::size(g_bp_modules); i++) {
713 const char *bp_module = g_bp_modules[i];
717 bool internal =
true;
718 bool hardware =
false;
721 std::size(g_bp_names), eFunctionNameTypeFull,
724 bp_sp->SetBreakpointKind(
"thread-creation");
735 std::string shell_string = shell.
GetPath();
736 const char *shell_name = strrchr(shell_string.c_str(),
'/');
737 if (shell_name ==
nullptr)
738 shell_name = shell_string.c_str();
742 if (strcmp(shell_name,
"sh") == 0) {
746 if (launch_info.
GetEnvironment().lookup(
"COMMAND_MODE") ==
"legacy")
749 }
else if (strcmp(shell_name,
"csh") == 0 ||
750 strcmp(shell_name,
"tcsh") == 0 ||
751 strcmp(shell_name,
"zsh") == 0) {
787 static FileSpec g_command_line_tools_filespec;
789 if (!g_command_line_tools_filespec) {
793 g_command_line_tools_filespec = command_line_tools_path;
797 return g_command_line_tools_filespec;
801 void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) {
821 const bool find_directories =
true;
822 const bool find_files =
false;
823 const bool find_other =
true;
827 enumerator_info.
sdk_type = sdk_type;
830 sdks_spec.
GetPath(), find_directories, find_files, find_other,
840 FileSpec sdks_spec = HostInfo::GetXcodeContentsDirectory();
864 llvm_unreachable(
"unsupported sdk");
871 llvm::VersionTuple version = HostInfo::GetOSVersion();
873 if (!version.empty()) {
885 FileSpec native_sdk_spec = sdks_spec;
887 native_sdk_name.
Printf(
"MacOSX%u.%u.sdk", version.getMajor(),
888 version.getMinor().value_or(0));
892 return native_sdk_spec;
910std::tuple<llvm::VersionTuple, llvm::StringRef>
912 llvm::StringRef build;
913 llvm::VersionTuple version;
915 llvm::SmallVector<llvm::StringRef> parts;
916 dir.split(parts,
' ');
917 for (llvm::StringRef part : parts) {
919 if (isdigit(part[0]))
920 version.tryParse(part);
922 if (part.consume_front(
"(")) {
923 size_t pos = part.find(
')');
924 build = part.slice(0, pos);
928 return std::make_tuple(version, build);
931llvm::Expected<StructuredData::DictionarySP>
933 static constexpr llvm::StringLiteral crash_info_key(
"Crash-Info Annotations");
934 static constexpr llvm::StringLiteral asi_info_key(
935 "Application Specific Information");
942 if (!process_dict_sp->GetValueForKeyAsArray(crash_info_key, annotations)) {
944 if (new_annotations_sp && new_annotations_sp->GetSize()) {
945 process_dict_sp->AddItem(crash_info_key, new_annotations_sp);
946 annotations = new_annotations_sp.get();
952 if (!process_dict_sp->GetValueForKeyAsDictionary(asi_info_key,
953 app_specific_info)) {
955 if (new_app_specific_info_sp && new_app_specific_info_sp->GetSize()) {
956 process_dict_sp->AddItem(asi_info_key, new_app_specific_info_sp);
957 app_specific_info = new_app_specific_info_sp.get();
963 return process_dict_sp->GetSize() ? process_dict_sp :
nullptr;
970 llvm::StringRef section_name(
"__crash_info");
977 std::string module_name =
module->GetSpecificationDescription();
981 if (module_name ==
"/usr/lib/dyld")
985 LLDB_LOG(log,
"Module {0} doesn't have any section!", module_name);
991 LLDB_LOG(log,
"Module {0} doesn't have section {1}!", module_name,
996 addr_t load_addr = crash_info->GetLoadBaseAddress(&target);
999 LLDB_LOG(log,
"Module {0} has an invalid '{1}' section load address: {2}",
1000 module_name, section_name, load_addr);
1008 expected_size,
error);
1010 if (expected_size != bytes_read ||
error.Fail()) {
1011 LLDB_LOG(log,
"Failed to read {0} section from memory in module {1}: {2}",
1012 section_name, module_name,
error);
1017 if (annotations.
version < 5) {
1019 "Annotation version lower than 5 unsupported! Module {0} has "
1020 "version {1} instead.",
1021 module_name, annotations.
version);
1026 LLDB_LOG(log,
"No message available for module {0}.", module_name);
1030 std::string message;
1034 if (message.empty() || bytes_read != message.size() ||
error.Fail()) {
1035 LLDB_LOG(log,
"Failed to read the message from memory in module {0}: {1}",
1036 module_name,
error);
1041 if (message.back() ==
'\n')
1045 LLDB_LOG(log,
"No message2 available for module {0}.", module_name);
1047 std::string message2;
1051 if (!message2.empty() && bytes_read == message2.size() &&
error.Success())
1052 if (message2.back() ==
'\n')
1053 message2.pop_back();
1056 std::make_shared<StructuredData::Dictionary>();
1058 entry_sp->AddStringItem(
"image", module->GetFileSpec().GetPath(
false));
1059 entry_sp->AddStringItem(
"uuid", module->GetUUID().GetAsString());
1060 entry_sp->AddStringItem(
"message", message);
1061 entry_sp->AddStringItem(
"message2", message2);
1062 entry_sp->AddIntegerItem(
"abort-cause", annotations.
abort_cause);
1064 array_sp->AddItem(entry_sp);
1074 if (!metadata_sp || !metadata_sp->GetSize() || !metadata_sp->HasKey(
"asi"))
1078 if (!metadata_sp->GetValueForKeyAsDictionary(
"asi", asi))
1082 std::make_shared<StructuredData::Dictionary>();
1084 auto flatten_asi_dict = [&dict_sp](llvm::StringRef key,
1097 asi->
ForEach(flatten_asi_dict);
1102static llvm::Expected<lldb_private::FileSpec>
1107 return llvm::createStringError(
"could not get module from target");
1109 SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
1111 return llvm::createStringError(
"could not get symbol file from executable");
1114 return llvm::createStringError(
1115 "could not resolve SDK for target: executable's symbol file has no "
1130 const std::vector<std::string> apple_arguments = {
1131 "-x",
"objective-c++",
"-fobjc-arc",
1132 "-fblocks",
"-D_ISO646_H",
"-D__ISO646_H",
1133 "-fgnuc-version=4.2.1"};
1135 options.insert(options.end(), apple_arguments.begin(), apple_arguments.end());
1138 bool use_current_os_version =
false;
1140 auto get_host_os = []() {
return HostInfo::GetTargetTriple().getOS(); };
1143 use_current_os_version = get_host_os() == llvm::Triple::MacOSX;
1146 use_current_os_version = get_host_os() == llvm::Triple::IOS;
1149 use_current_os_version = get_host_os() == llvm::Triple::TvOS;
1152 use_current_os_version = get_host_os() == llvm::Triple::WatchOS;
1155 use_current_os_version = get_host_os() == llvm::Triple::XROS;
1161 llvm::VersionTuple version;
1162 if (use_current_os_version)
1168 if (exe_module_sp) {
1169 ObjectFile *object_file = exe_module_sp->GetObjectFile();
1178 clang::options::ID version_min_option = clang::options::OPT_INVALID;
1181 version_min_option = clang::options::OPT_mmacos_version_min_EQ;
1184 version_min_option = clang::options::OPT_mios_simulator_version_min_EQ;
1187 version_min_option = clang::options::OPT_mios_version_min_EQ;
1190 version_min_option = clang::options::OPT_mtvos_simulator_version_min_EQ;
1193 version_min_option = clang::options::OPT_mtvos_version_min_EQ;
1196 version_min_option =
1197 clang::options::OPT_mwatchos_simulator_version_min_EQ;
1200 version_min_option = clang::options::OPT_mwatchos_version_min_EQ;
1210 info.
type = sdk_type;
1211 LLDB_LOGF(log,
"Clang modules on %s are not supported",
1216 minimum_version_option << clang::getDriverOptTable()
1217 .getOption(version_min_option)
1219 << version.getAsString();
1220 options.emplace_back(std::string(minimum_version_option.
GetString()));
1227 if (!sysroot_spec_or_err) {
1229 sysroot_spec_or_err.takeError(),
1230 "Failed to resolve sysroot: {0}");
1232 sysroot_spec = *sysroot_spec_or_err;
1237 std::lock_guard<std::mutex> guard(
m_mutex);
1242 options.push_back(
"-isysroot");
1243 options.push_back(sysroot_spec.
GetPath());
1248 if (basename.empty())
1249 return basename.str();
1251 return llvm::formatv(
"lib{0}.dylib", basename).str();
1260 llvm::VersionTuple result;
1261 if (!result.tryParse(env.lookup(
"SIMULATOR_RUNTIME_VERSION")))
1264 std::string dyld_root_path = env.lookup(
"DYLD_ROOT_PATH");
1265 if (!dyld_root_path.empty()) {
1266 dyld_root_path +=
"/System/Library/CoreServices/SystemVersion.plist";
1268 std::string product_version;
1271 if (!result.tryParse(product_version))
1279 return llvm::VersionTuple();
1288 static std::vector<FileSpec> g_executable_dirs;
1292 static llvm::once_flag g_once_flag;
1293 llvm::call_once(g_once_flag, []() {
1296 FileSpec xcode_contents_dir = HostInfo::GetXcodeContentsDirectory();
1297 if (xcode_contents_dir) {
1298 FileSpec xcode_lldb_resources = xcode_contents_dir;
1305 g_executable_dirs.push_back(dir);
1310 if (command_line_tools_dir) {
1311 FileSpec cmd_line_lldb_resources = command_line_tools_dir;
1318 g_executable_dirs.push_back(dir);
1325 for (
const auto &executable_dir : g_executable_dirs) {
1327 executable_file.
SetDirectory(executable_dir.GetDirectory());
1330 return executable_file;
1345 const char *disable_env_var =
"IDE_DISABLED_OS_ACTIVITY_DT_MODE";
1347 if (!env_vars.count(disable_env_var)) {
1350 env_vars.try_emplace(
"OS_ACTIVITY_DT_MODE",
"enable");
1364 if (!module_sp && !module_search_paths.
IsEmpty() && platform_file) {
1373 std::vector<llvm::StringRef> path_parts = platform_file.
GetComponents();
1375 std::reverse(path_parts.begin(), path_parts.end());
1376 const size_t path_parts_size = path_parts.size();
1378 size_t num_module_search_paths = module_search_paths.
GetSize();
1379 for (
size_t i = 0; i < num_module_search_paths; ++i) {
1383 "PlatformRemoteDarwinDevice::GetSharedModule searching for binary in "
1391 for (
size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
1405 for (
int k = j; k >= 0; --k) {
1413 new_module_spec, target, module_sp, old_modules, did_create_ptr));
1416 module_sp->SetPlatformFileSpec(path_to_try);
1427#if !defined(__APPLE__)
1428 return llvm::Triple::MacOSX;
1431 return llvm::Triple::MacOSX;
1433 return llvm::Triple::IOS;
1434#elif TARGET_OS_WATCH
1435 return llvm::Triple::WatchOS;
1437 return llvm::Triple::TvOS;
1438#elif TARGET_OS_BRIDGE
1439 return llvm::Triple::BridgeOS;
1441 return llvm::Triple::XROS;
1443#error "LLDB being compiled for an unrecognized Darwin OS"
1448llvm::Expected<std::pair<XcodeSDKAndSysroot, bool>>
1450 SymbolFile *sym_file =
module.GetSymbolFile();
1452 return llvm::createStringError(
1453 llvm::inconvertibleErrorCode(),
1454 llvm::formatv(
"No symbol file available for module '{0}'",
1458 return llvm::createStringError(
1459 llvm::formatv(
"Could not resolve SDK for module '{0}'. Symbol file has "
1460 "no compile units.",
1463 bool found_public_sdk =
false;
1464 bool found_internal_sdk =
false;
1470 found_public_sdk |= !is_internal_sdk;
1471 found_internal_sdk |= is_internal_sdk;
1473 merged_sdk.
Merge(cu_sdk);
1477 const bool found_mismatch = found_internal_sdk && found_public_sdk;
1479 return std::pair{std::move(merged_sdk), found_mismatch};
1484 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1486 return llvm::joinErrors(llvm::createStringError(llvm::formatv(
1487 "could not find SDK '{0}'", sdk.
GetString())),
1488 path_or_err.takeError());
1492llvm::Expected<FileSpec>
1505llvm::Expected<std::string>
1509 return llvm::joinErrors(
1510 llvm::createStringError(
"could not parse SDK path from debug-info"),
1511 sdk_or_err.takeError());
1515 return path_or_err.takeError();
1516 return path_or_err->GetPath();
1519llvm::Expected<std::string>
1523 return llvm::joinErrors(
1524 llvm::createStringError(
"could not parse SDK path from debug-info"),
1525 sdk_or_err.takeError());
1529 return path_or_err.takeError();
1530 return path_or_err->GetPath();
1533llvm::Expected<FileSpecList>
1540 info.
type = sdk_type;
1544 if (!sdk_root_or_err) {
1546 "Failed to resolve SDK root for triple '{1}': {0}",
1555 if (!sdk_root_or_err)
1556 return sdk_root_or_err.takeError();
1559 llvm::SmallString<256> resolved(sdk_root_or_err->GetPath());
1560 llvm::sys::path::append(resolved,
"usr",
"share",
"lldb");
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.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
bool GetValueAsString(const char *key, std::string &value) const
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsExactMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, ExactMatch).
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
A command line argument class.
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
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.
A uniqued constant string class.
A class to manage flag bits.
lldb::ScriptLanguage GetScriptLanguage() const
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.
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.
void AppendPathComponent(llvm::StringRef component)
llvm::StringRef GetFileNameStrippingExtension() const
Return the filename without the extension part.
void SetFilename(llvm::StringRef filename)
Filename string set accessor.
std::vector< llvm::StringRef > GetComponents() const
Gets the components of the FileSpec's path.
llvm::StringRef GetFilename() const
Filename string const get accessor.
llvm::StringRef GetDirectory() const
Directory string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void SetDirectory(llvm::StringRef directory)
Directory string set accessor.
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.
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)
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
FileSpec & GetSymbolFileSpec()
ArchSpec * GetArchitecturePtr()
A class that describes an executable image and its associated object and symbol files.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
A plug-in interface definition class for object file parsers.
@ eTypeDynamicLinker
The platform's dynamic linker executable.
virtual llvm::VersionTuple GetMinimumOSVersion()
Get the minimum OS version this object file can run on.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
void SetValidator(ValidatorCallback validator, void *baton=nullptr)
const char * GetCurrentValue() const
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()
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.
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
virtual StructuredData::DictionarySP GetMetadata()
Fetch process defined metadata.
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.
StructuredData::DictionarySP GetExtendedCrashInfoDict()
Fetch extended crash information held by the process.
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
Target & GetTarget()
Get the target object pointer for this module.
A Progress indicator helper class.
lldb::OptionValuePropertiesSP m_collection_sp
Holds an lldb_private::Module name and a "sanitized" version of it for the purposes of loading a scri...
llvm::StringRef GetSanitizedName() const
llvm::StringRef GetOriginalName() const
virtual SanitizedScriptingModuleName GetSanitizedScriptingModuleName(llvm::StringRef name)
lldb::SectionSP FindSectionByName(llvm::StringRef section_name) const
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Success() const
Test for success condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
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.
virtual uint32_t GetNumCompileUnits()=0
virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx)=0
virtual XcodeSDKAndSysroot ParseXcodeSDK(CompileUnit &comp_unit)
Return the Xcode SDK comp_unit was compiled against.
virtual ObjectFile * GetObjectFile()=0
FileSpecList GetExecutableSearchPaths()
Debugger & GetDebugger() const
const lldb::ProcessSP & GetProcessSP() const
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
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)
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
Represents UUID's of various sizes.
An abstraction which groups an XcodeSDK with the sysroot it was used from.
bool IsAppleInternalSDK() const
const FileSpec & GetSysroot() const
const XcodeSDK & GetSDK() const
void Merge(const XcodeSDKAndSysroot &other)
An abstraction for Xcode-style SDKs that works like ArchSpec.
Type
Different types of Xcode SDKs.
static XcodeSDK GetAnyMacOS()
llvm::StringRef GetString() const
static std::string GetCanonicalName(Info info)
Return the canonical SDK name, such as "macosx" for the macOS SDK.
static XcodeSDK::Type GetSDKTypeForTriple(const llvm::Triple &triple)
Return the best-matching SDK type for a specific triple.
static bool SDKSupportsModules(Type type, llvm::VersionTuple version)
Whether LLDB feels confident importing Clang modules from this SDK.
#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.
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
std::shared_ptr< lldb_private::Module > ModuleSP
const UUID & GetUUID() const
lldb::DataExtractorSP GetExtractor()
A parsed SDK directory name.