46#include "llvm/ADT/STLExtras.h"
47#include "llvm/ADT/StringTable.h"
48#include "llvm/Support/Error.h"
49#include "llvm/Support/FileSystem.h"
50#include "llvm/Support/Threading.h"
51#include "llvm/Support/VersionTuple.h"
55#include <TargetConditionals.h>
61#define OPTTABLE_STR_TABLE_CODE
62#include "clang/Options/Options.inc"
63#undef OPTTABLE_STR_TABLE_CODE
67 llvm::StringRef str_ref(
string);
68 llvm::SmallVector<llvm::StringRef> candidates;
69 str_ref.split(candidates,
'|');
70 for (
auto candidate : candidates) {
71 if (!(candidate ==
"EXC_BAD_ACCESS"
72 || candidate ==
"EXC_BAD_INSTRUCTION"
73 || candidate ==
"EXC_ARITHMETIC"
74 || candidate ==
"EXC_RESOURCE"
75 || candidate ==
"EXC_GUARD"
76 || candidate ==
"EXC_SYSCALL")) {
78 candidate.str().c_str());
112 return "Darwin platform plug-in.";
120#define LLDB_PROPERTIES_platformdarwin
121#include "PlatformMacOSXProperties.inc"
123#define LLDB_PROPERTIES_platformdarwin
125#include "PlatformMacOSXPropertiesEnum.inc"
131 static constexpr llvm::StringLiteral g_setting_name(
"darwin");
132 return g_setting_name;
143 const uint32_t idx = ePropertyIgnoredExceptions;
146 assert(option_value);
151 const uint32_t idx = ePropertyIgnoredExceptions;
154 assert(option_value);
168 const bool is_global_setting =
false;
171 "Properties for the Darwin platform plug-in.", is_global_setting);
179 std::string ignored_exceptions
181 if (ignored_exceptions.empty())
184 std::string packet =
"QSetIgnoredExceptions:";
185 packet.append(ignored_exceptions);
201llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile>
207 "Trying to locate scripting resources but no ScriptInterpreter is "
210 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> file_specs;
211 const FileSpec original_module_spec = module_spec;
225 path_string.
Format(
"{0}/../Python/{1}.py",
228 original_path_string.
Format(
"{0}/../Python/{1}.py",
238 orig_script_fspec, script_fspec);
243 file_specs.try_emplace(std::move(script_fspec), load_style);
251 if (module_spec.
GetFilename() == filename_no_extension)
260llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile>
263 llvm::SmallDenseMap<FileSpec, LoadScriptFromSymFile> empty;
278 const FileSpec &module_spec =
module.GetFileSpec();
293 llvm::StringRef(symfile_spec.
GetPath())
294 .contains_insensitive(
".dSYM/Contents/Resources/DWARF") &&
297 feedback_stream, module_spec, *target, symfile_spec);
303#if defined(__APPLE__)
313 llvm::StringRef path_ref(symfile_path);
317 auto pos = path_ref.find(
".dSYM/");
318 if (pos == llvm::StringRef::npos)
321 FileSpec bundle_spec(path_ref.substr(0, pos + 5));
325 "dSYM bundle '{0}' has valid trusted code signature",
358 module_spec, process, module_sp, old_modules, did_create_ptr);
365 old_modules, did_create_ptr);
372 module_search_paths = target_sp->GetExecutableSearchPaths();
373 if (!module_sp && !module_search_paths.
IsEmpty() && platform_file) {
378 if (platform_file == bundle_directory) {
383 module_sp, old_modules,
392 platform_file.
GetPath(platform_path,
sizeof(platform_path));
393 const size_t bundle_directory_len =
394 bundle_directory.
GetPath(bundle_dir,
sizeof(bundle_dir));
396 size_t num_module_search_paths = module_search_paths.
GetSize();
397 for (
size_t i = 0; i < num_module_search_paths; ++i) {
398 const size_t search_path_len =
400 new_path,
sizeof(new_path));
401 if (search_path_len <
sizeof(new_path)) {
402 snprintf(new_path + search_path_len,
403 sizeof(new_path) - search_path_len,
"/%s",
404 platform_path + bundle_directory_len);
410 new_module_spec, process, module_sp, old_modules,
414 module_sp->SetPlatformFileSpec(new_file_spec);
425 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
441 std::optional<uint64_t> size;
443 sc_base_addr, sc_uuid, using_sc, private_sc, sc_path, size)) {
445 image_info = HostInfo::GetSharedCacheImageInfo(module_spec.
GetUUID(),
448 image_info = HostInfo::GetSharedCacheImageInfo(
454 image_info = HostInfo::GetSharedCacheImageInfo(
468 LLDB_LOGF(log,
"module %s was found in a shared cache",
478 const uint8_t *trap_opcode =
nullptr;
479 uint32_t trap_opcode_size = 0;
480 bool bp_is_thumb =
false;
484 case llvm::Triple::aarch64_32:
485 case llvm::Triple::aarch64: {
487 static const uint8_t g_arm64_breakpoint_opcode[] = {0x00, 0x00, 0x20, 0xD4};
488 trap_opcode = g_arm64_breakpoint_opcode;
489 trap_opcode_size =
sizeof(g_arm64_breakpoint_opcode);
492 case llvm::Triple::thumb:
495 case llvm::Triple::arm: {
496 static const uint8_t g_arm_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
497 static const uint8_t g_thumb_breakpooint_opcode[] = {0xFE, 0xDE};
503 bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass() ==
507 trap_opcode = g_thumb_breakpooint_opcode;
508 trap_opcode_size =
sizeof(g_thumb_breakpooint_opcode);
511 trap_opcode = g_arm_breakpoint_opcode;
512 trap_opcode_size =
sizeof(g_arm_breakpoint_opcode);
515 case llvm::Triple::ppc:
516 case llvm::Triple::ppc64: {
517 static const uint8_t g_ppc_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
518 trap_opcode = g_ppc_breakpoint_opcode;
519 trap_opcode_size =
sizeof(g_ppc_breakpoint_opcode);
526 if (trap_opcode && trap_opcode_size) {
528 return trap_opcode_size;
538 ObjectFile *obj_file = module_sp->GetObjectFile();
547 std::vector<ArchSpec> &archs) {
548 ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
549 archs.push_back(host_arch);
552 archs.push_back(
ArchSpec(
"x86_64-apple-macosx"));
553 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
555 ArchSpec host_arch64 = HostInfo::GetArchitecture(HostInfo::eArchKind64);
557 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
566 static const char *g_arm64e_compatible_archs[] = {
567 "arm64e",
"arm64",
"armv7",
"armv7f",
"armv7k",
"armv7s",
568 "armv7m",
"armv7em",
"armv6m",
"armv6",
"armv5",
"armv4",
569 "arm",
"thumbv7",
"thumbv7f",
"thumbv7k",
"thumbv7s",
"thumbv7m",
570 "thumbv7em",
"thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
572 return {g_arm64e_compatible_archs};
575 static const char *g_arm64_compatible_archs[] = {
576 "arm64",
"armv7",
"armv7f",
"armv7k",
"armv7s",
"armv7m",
577 "armv7em",
"armv6m",
"armv6",
"armv5",
"armv4",
"arm",
578 "thumbv7",
"thumbv7f",
"thumbv7k",
"thumbv7s",
"thumbv7m",
"thumbv7em",
579 "thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
581 return {g_arm64_compatible_archs};
584 static const char *g_armv7_compatible_archs[] = {
585 "armv7",
"armv6m",
"armv6",
"armv5",
"armv4",
"arm",
586 "thumbv7",
"thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
588 return {g_armv7_compatible_archs};
591 static const char *g_armv7f_compatible_archs[] = {
592 "armv7f",
"armv7",
"armv6m",
"armv6",
"armv5",
593 "armv4",
"arm",
"thumbv7f",
"thumbv7",
"thumbv6m",
594 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
596 return {g_armv7f_compatible_archs};
599 static const char *g_armv7k_compatible_archs[] = {
600 "armv7k",
"armv7",
"armv6m",
"armv6",
"armv5",
601 "armv4",
"arm",
"thumbv7k",
"thumbv7",
"thumbv6m",
602 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
604 return {g_armv7k_compatible_archs};
607 static const char *g_armv7s_compatible_archs[] = {
608 "armv7s",
"armv7",
"armv6m",
"armv6",
"armv5",
609 "armv4",
"arm",
"thumbv7s",
"thumbv7",
"thumbv6m",
610 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
612 return {g_armv7s_compatible_archs};
615 static const char *g_armv7m_compatible_archs[] = {
616 "armv7m",
"armv7",
"armv6m",
"armv6",
"armv5",
617 "armv4",
"arm",
"thumbv7m",
"thumbv7",
"thumbv6m",
618 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
620 return {g_armv7m_compatible_archs};
623 static const char *g_armv7em_compatible_archs[] = {
624 "armv7em",
"armv7",
"armv6m",
"armv6",
"armv5",
625 "armv4",
"arm",
"thumbv7em",
"thumbv7",
"thumbv6m",
626 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
628 return {g_armv7em_compatible_archs};
631 static const char *g_armv6m_compatible_archs[] = {
632 "armv6m",
"armv6",
"armv5",
"armv4",
"arm",
633 "thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
635 return {g_armv6m_compatible_archs};
638 static const char *g_armv6_compatible_archs[] = {
639 "armv6",
"armv5",
"armv4",
"arm",
640 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
642 return {g_armv6_compatible_archs};
645 static const char *g_armv5_compatible_archs[] = {
646 "armv5",
"armv4",
"arm",
"thumbv5",
"thumbv4t",
"thumb",
648 return {g_armv5_compatible_archs};
651 static const char *g_armv4_compatible_archs[] = {
657 return {g_armv4_compatible_archs};
667 std::vector<ArchSpec> &archs, std::optional<llvm::Triple::OSType> os) {
672 triple.setArchName(arch);
673 triple.setVendor(llvm::Triple::VendorType::Apple);
681 static FileSpec g_xcode_select_filespec;
683 if (!g_xcode_select_filespec) {
684 FileSpec xcode_select_cmd(
"/usr/bin/xcode-select");
686 int exit_status = -1;
688 std::string command_output;
692 &exit_status, &signo, &command_output,
nullptr,
693 std::chrono::seconds(2),
695 if (status.
Success() && exit_status == 0 && !command_output.empty()) {
696 size_t first_non_newline = command_output.find_last_not_of(
"\r\n");
697 if (first_non_newline != std::string::npos) {
698 command_output.erase(first_non_newline + 1);
700 g_xcode_select_filespec =
FileSpec(command_output);
705 return g_xcode_select_filespec;
710 static const char *g_bp_names[] = {
711 "start_wqthread",
"_pthread_wqthread",
"_pthread_start",
714 static const char *g_bp_modules[] = {
"libsystem_c.dylib",
"libSystem.B.dylib",
715 "libsystem_pthread.dylib"};
718 for (
size_t i = 0; i < std::size(g_bp_modules); i++) {
719 const char *bp_module = g_bp_modules[i];
723 bool internal =
true;
724 bool hardware =
false;
727 std::size(g_bp_names), eFunctionNameTypeFull,
730 bp_sp->SetBreakpointKind(
"thread-creation");
741 std::string shell_string = shell.
GetPath();
742 const char *shell_name = strrchr(shell_string.c_str(),
'/');
743 if (shell_name ==
nullptr)
744 shell_name = shell_string.c_str();
748 if (strcmp(shell_name,
"sh") == 0) {
752 if (launch_info.
GetEnvironment().lookup(
"COMMAND_MODE") ==
"legacy")
755 }
else if (strcmp(shell_name,
"csh") == 0 ||
756 strcmp(shell_name,
"tcsh") == 0 ||
757 strcmp(shell_name,
"zsh") == 0) {
793 static FileSpec g_command_line_tools_filespec;
795 if (!g_command_line_tools_filespec) {
799 g_command_line_tools_filespec = command_line_tools_path;
803 return g_command_line_tools_filespec;
807 void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) {
827 const bool find_directories =
true;
828 const bool find_files =
false;
829 const bool find_other =
true;
833 enumerator_info.
sdk_type = sdk_type;
836 sdks_spec.
GetPath(), find_directories, find_files, find_other,
846 FileSpec sdks_spec = HostInfo::GetXcodeContentsDirectory();
870 llvm_unreachable(
"unsupported sdk");
877 llvm::VersionTuple version = HostInfo::GetOSVersion();
879 if (!version.empty()) {
891 FileSpec native_sdk_spec = sdks_spec;
893 native_sdk_name.
Printf(
"MacOSX%u.%u.sdk", version.getMajor(),
894 version.getMinor().value_or(0));
898 return native_sdk_spec;
916std::tuple<llvm::VersionTuple, llvm::StringRef>
918 llvm::StringRef build;
919 llvm::VersionTuple version;
921 llvm::SmallVector<llvm::StringRef> parts;
922 dir.split(parts,
' ');
923 for (llvm::StringRef part : parts) {
925 if (isdigit(part[0]))
926 version.tryParse(part);
928 if (part.consume_front(
"(")) {
929 size_t pos = part.find(
')');
930 build = part.slice(0, pos);
934 return std::make_tuple(version, build);
937llvm::Expected<StructuredData::DictionarySP>
939 static constexpr llvm::StringLiteral crash_info_key(
"Crash-Info Annotations");
940 static constexpr llvm::StringLiteral asi_info_key(
941 "Application Specific Information");
948 if (!process_dict_sp->GetValueForKeyAsArray(crash_info_key, annotations)) {
950 if (new_annotations_sp && new_annotations_sp->GetSize()) {
951 process_dict_sp->AddItem(crash_info_key, new_annotations_sp);
952 annotations = new_annotations_sp.get();
958 if (!process_dict_sp->GetValueForKeyAsDictionary(asi_info_key,
959 app_specific_info)) {
961 if (new_app_specific_info_sp && new_app_specific_info_sp->GetSize()) {
962 process_dict_sp->AddItem(asi_info_key, new_app_specific_info_sp);
963 app_specific_info = new_app_specific_info_sp.get();
969 return process_dict_sp->GetSize() ? process_dict_sp :
nullptr;
983 std::string module_name =
module->GetSpecificationDescription();
987 if (module_name ==
"/usr/lib/dyld")
991 LLDB_LOG(log,
"Module {0} doesn't have any section!", module_name);
997 LLDB_LOG(log,
"Module {0} doesn't have section {1}!", module_name,
1002 addr_t load_addr = crash_info->GetLoadBaseAddress(&target);
1005 LLDB_LOG(log,
"Module {0} has an invalid '{1}' section load address: {2}",
1006 module_name, section_name, load_addr);
1014 expected_size,
error);
1016 if (expected_size != bytes_read ||
error.Fail()) {
1017 LLDB_LOG(log,
"Failed to read {0} section from memory in module {1}: {2}",
1018 section_name, module_name,
error);
1023 if (annotations.
version < 5) {
1025 "Annotation version lower than 5 unsupported! Module {0} has "
1026 "version {1} instead.",
1027 module_name, annotations.
version);
1032 LLDB_LOG(log,
"No message available for module {0}.", module_name);
1036 std::string message;
1040 if (message.empty() || bytes_read != message.size() ||
error.Fail()) {
1041 LLDB_LOG(log,
"Failed to read the message from memory in module {0}: {1}",
1042 module_name,
error);
1047 if (message.back() ==
'\n')
1051 LLDB_LOG(log,
"No message2 available for module {0}.", module_name);
1053 std::string message2;
1057 if (!message2.empty() && bytes_read == message2.size() &&
error.Success())
1058 if (message2.back() ==
'\n')
1059 message2.pop_back();
1062 std::make_shared<StructuredData::Dictionary>();
1064 entry_sp->AddStringItem(
"image", module->GetFileSpec().GetPath(
false));
1065 entry_sp->AddStringItem(
"uuid", module->GetUUID().GetAsString());
1066 entry_sp->AddStringItem(
"message", message);
1067 entry_sp->AddStringItem(
"message2", message2);
1068 entry_sp->AddIntegerItem(
"abort-cause", annotations.
abort_cause);
1070 array_sp->AddItem(entry_sp);
1080 if (!metadata_sp || !metadata_sp->GetSize() || !metadata_sp->HasKey(
"asi"))
1084 if (!metadata_sp->GetValueForKeyAsDictionary(
"asi", asi))
1088 std::make_shared<StructuredData::Dictionary>();
1090 auto flatten_asi_dict = [&dict_sp](llvm::StringRef key,
1103 asi->
ForEach(flatten_asi_dict);
1108static llvm::Expected<lldb_private::FileSpec>
1113 return llvm::createStringError(
"could not get module from target");
1115 SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
1117 return llvm::createStringError(
"could not get symbol file from executable");
1120 return llvm::createStringError(
1121 "could not resolve SDK for target: executable's symbol file has no "
1136 const std::vector<std::string> apple_arguments = {
1137 "-x",
"objective-c++",
"-fobjc-arc",
1138 "-fblocks",
"-D_ISO646_H",
"-D__ISO646_H",
1139 "-fgnuc-version=4.2.1"};
1141 options.insert(options.end(), apple_arguments.begin(), apple_arguments.end());
1144 bool use_current_os_version =
false;
1146 auto get_host_os = []() {
return HostInfo::GetTargetTriple().getOS(); };
1149 use_current_os_version = get_host_os() == llvm::Triple::MacOSX;
1152 use_current_os_version = get_host_os() == llvm::Triple::IOS;
1155 use_current_os_version = get_host_os() == llvm::Triple::TvOS;
1158 use_current_os_version = get_host_os() == llvm::Triple::WatchOS;
1161 use_current_os_version = get_host_os() == llvm::Triple::XROS;
1167 llvm::VersionTuple version;
1168 if (use_current_os_version)
1174 if (exe_module_sp) {
1175 ObjectFile *object_file = exe_module_sp->GetObjectFile();
1184#define OPTION(PREFIX_OFFSET, NAME_OFFSET, VAR, ...) \
1185 llvm::StringRef opt_##VAR = OptionStrTable[NAME_OFFSET]; \
1187#include "clang/Options/Options.inc"
1189 minimum_version_option <<
'-';
1192 minimum_version_option << opt_mmacos_version_min_EQ;
1195 minimum_version_option << opt_mios_simulator_version_min_EQ;
1198 minimum_version_option << opt_mios_version_min_EQ;
1201 minimum_version_option << opt_mtvos_simulator_version_min_EQ;
1204 minimum_version_option << opt_mtvos_version_min_EQ;
1207 minimum_version_option << opt_mwatchos_simulator_version_min_EQ;
1210 minimum_version_option << opt_mwatchos_version_min_EQ;
1220 info.
type = sdk_type;
1221 LLDB_LOGF(log,
"Clang modules on %s are not supported",
1226 minimum_version_option << version.getAsString();
1227 options.emplace_back(std::string(minimum_version_option.
GetString()));
1234 if (!sysroot_spec_or_err) {
1236 sysroot_spec_or_err.takeError(),
1237 "Failed to resolve sysroot: {0}");
1239 sysroot_spec = *sysroot_spec_or_err;
1244 std::lock_guard<std::mutex> guard(
m_mutex);
1249 options.push_back(
"-isysroot");
1250 options.push_back(sysroot_spec.
GetPath());
1269 llvm::VersionTuple result;
1270 if (!result.tryParse(env.lookup(
"SIMULATOR_RUNTIME_VERSION")))
1273 std::string dyld_root_path = env.lookup(
"DYLD_ROOT_PATH");
1274 if (!dyld_root_path.empty()) {
1275 dyld_root_path +=
"/System/Library/CoreServices/SystemVersion.plist";
1277 std::string product_version;
1280 if (!result.tryParse(product_version))
1288 return llvm::VersionTuple();
1297 static std::vector<FileSpec> g_executable_dirs;
1301 static llvm::once_flag g_once_flag;
1302 llvm::call_once(g_once_flag, []() {
1305 FileSpec xcode_contents_dir = HostInfo::GetXcodeContentsDirectory();
1306 if (xcode_contents_dir) {
1307 FileSpec xcode_lldb_resources = xcode_contents_dir;
1314 g_executable_dirs.push_back(dir);
1319 if (command_line_tools_dir) {
1320 FileSpec cmd_line_lldb_resources = command_line_tools_dir;
1327 g_executable_dirs.push_back(dir);
1334 for (
const auto &executable_dir : g_executable_dirs) {
1336 executable_file.
SetDirectory(executable_dir.GetDirectory());
1339 return executable_file;
1354 const char *disable_env_var =
"IDE_DISABLED_OS_ACTIVITY_DT_MODE";
1356 if (!env_vars.count(disable_env_var)) {
1359 env_vars.try_emplace(
"OS_ACTIVITY_DT_MODE",
"enable");
1373 module_search_paths = target_sp->GetExecutableSearchPaths();
1376 if (!module_sp && !module_search_paths.
IsEmpty() && platform_file) {
1385 std::vector<llvm::StringRef> path_parts = platform_file.
GetComponents();
1387 std::reverse(path_parts.begin(), path_parts.end());
1388 const size_t path_parts_size = path_parts.size();
1390 size_t num_module_search_paths = module_search_paths.
GetSize();
1391 for (
size_t i = 0; i < num_module_search_paths; ++i) {
1395 "PlatformRemoteDarwinDevice::GetSharedModule searching for binary in "
1403 for (
size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
1417 for (
int k = j; k >= 0; --k) {
1425 module_sp, old_modules,
1429 module_sp->SetPlatformFileSpec(path_to_try);
1440#if !defined(__APPLE__)
1441 return llvm::Triple::MacOSX;
1444 return llvm::Triple::MacOSX;
1446 return llvm::Triple::IOS;
1447#elif TARGET_OS_WATCH
1448 return llvm::Triple::WatchOS;
1450 return llvm::Triple::TvOS;
1451#elif TARGET_OS_BRIDGE
1452 return llvm::Triple::BridgeOS;
1454 return llvm::Triple::XROS;
1456#error "LLDB being compiled for an unrecognized Darwin OS"
1461llvm::Expected<std::pair<XcodeSDK, bool>>
1463 SymbolFile *sym_file =
module.GetSymbolFile();
1465 return llvm::createStringError(
1466 llvm::inconvertibleErrorCode(),
1467 llvm::formatv(
"No symbol file available for module '{0}'",
1471 return llvm::createStringError(
1472 llvm::formatv(
"Could not resolve SDK for module '{0}'. Symbol file has "
1473 "no compile units.",
1476 bool found_public_sdk =
false;
1477 bool found_internal_sdk =
false;
1483 found_public_sdk |= !is_internal_sdk;
1484 found_internal_sdk |= is_internal_sdk;
1486 merged_sdk.
Merge(cu_sdk);
1490 const bool found_mismatch = found_internal_sdk && found_public_sdk;
1492 return std::pair{std::move(merged_sdk), found_mismatch};
1501 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1503 return llvm::joinErrors(llvm::createStringError(llvm::formatv(
1504 "could not find SDK '{0}'", sdk.
GetString())),
1505 path_or_err.takeError());
1509llvm::Expected<std::string>
1513 return llvm::joinErrors(
1514 llvm::createStringError(
"could not parse SDK path from debug-info"),
1515 sdk_or_err.takeError());
1519 return path_or_err.takeError();
1520 return path_or_err->GetPath();
1523llvm::Expected<XcodeSDK>
1527 return llvm::createStringError(
"compile unit has no module");
1528 SymbolFile *sym_file = module_sp->GetSymbolFile();
1530 return llvm::createStringError(
1531 llvm::formatv(
"No symbol file available for module '{0}'",
1532 module_sp->GetFileSpec().GetFilename()));
1537llvm::Expected<std::string>
1541 return llvm::joinErrors(
1542 llvm::createStringError(
"could not parse SDK path from debug-info"),
1543 sdk_or_err.takeError());
1547 return path_or_err.takeError();
1548 return path_or_err->GetPath();
1551llvm::Expected<FileSpecList>
1558 info.
type = sdk_type;
1562 if (!sdk_root_or_err) {
1564 "Failed to resolve SDK root for triple '{1}': {0}",
1573 if (!sdk_root_or_err)
1574 return sdk_root_or_err.takeError();
1577 llvm::SmallString<256> resolved(sdk_root_or_err->GetPath());
1578 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.
lldb::ModuleSP CalculateSymbolContextModule() override
A uniqued constant string class.
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.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
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)
void SetDirectory(ConstString directory)
Directory string set accessor.
const ConstString & GetFilename() const
Filename string const get accessor.
std::vector< llvm::StringRef > GetComponents() const
Gets the components of the FileSpec's path.
const ConstString & GetDirectory() const
Directory string const get accessor.
ConstString GetFileNameStrippingExtension() const
Return the filename without the extension part.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
ConstString GetPathAsConstString(bool denormalize=true) const
Get the full path as a ConstString.
void SetFilename(ConstString filename)
Filename 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)
static ModuleListProperties & GetGlobalModuleListProperties()
ModuleIterable Modules() const
FileSpec & GetSymbolFileSpec()
ArchSpec * GetArchitecturePtr()
lldb::TargetSP GetTargetSP() const
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(ConstString section_dstr) 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 XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit)
Return the Xcode SDK comp_unit was compiled against.
virtual uint32_t GetNumCompileUnits()=0
virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx)=0
virtual ObjectFile * GetObjectFile()=0
Debugger & GetDebugger() 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 for Xcode-style SDKs that works like ArchSpec.
Type
Different types of Xcode SDKs.
const FileSpec & GetSysroot() const
void Merge(const XcodeSDK &other)
The merge function follows a strict order to maintain monotonicity:
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.
bool IsAppleInternalSDK() const
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::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
const UUID & GetUUID() const
lldb::DataExtractorSP GetExtractor()
A parsed SDK directory name.