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"
53#include <TargetConditionals.h>
59#define OPTTABLE_STR_TABLE_CODE
60#include "clang/Options/Options.inc"
61#undef OPTTABLE_STR_TABLE_CODE
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")) {
76 candidate.str().c_str());
91class SanitizedScriptingModuleName {
93 SanitizedScriptingModuleName(llvm::StringRef name,
94 ScriptInterpreter *script_interpreter)
95 : m_original_name(name), m_sanitized_name(name.str()) {
102 llvm::replace(m_sanitized_name,
'.',
'_');
103 llvm::replace(m_sanitized_name,
' ',
'_');
104 llvm::replace(m_sanitized_name,
'-',
'_');
106 if (script_interpreter &&
108 m_sanitized_name.insert(m_sanitized_name.begin(),
'_');
109 m_name_is_keyword =
true;
115 bool IsKeyword()
const {
return m_name_is_keyword; }
119 bool RequiredSanitization()
const {
120 return m_sanitized_name != m_original_name;
123 llvm::StringRef GetSanitizedName()
const {
return m_sanitized_name; }
124 llvm::StringRef GetOriginalName()
const {
return m_original_name; }
127 llvm::StringRef m_original_name;
128 std::string m_sanitized_name;
132 bool m_name_is_keyword =
false;
163 return "Darwin platform plug-in.";
171#define LLDB_PROPERTIES_platformdarwin
172#include "PlatformMacOSXProperties.inc"
174#define LLDB_PROPERTIES_platformdarwin
176#include "PlatformMacOSXPropertiesEnum.inc"
182 static constexpr llvm::StringLiteral g_setting_name(
"darwin");
183 return g_setting_name;
194 const uint32_t idx = ePropertyIgnoredExceptions;
197 assert(option_value);
202 const uint32_t idx = ePropertyIgnoredExceptions;
205 assert(option_value);
219 const bool is_global_setting =
false;
222 "Properties for the Darwin platform plug-in.", is_global_setting);
230 std::string ignored_exceptions
232 if (ignored_exceptions.empty())
235 std::string packet =
"QSetIgnoredExceptions:";
236 packet.append(ignored_exceptions);
257 SanitizedScriptingModuleName sanitized_name(
267 path_string.
Format(
"{0}/../Python/{1}.py",
269 sanitized_name.GetSanitizedName());
270 original_path_string.
Format(
"{0}/../Python/{1}.py",
272 sanitized_name.GetOriginalName());
282 if (sanitized_name.RequiredSanitization() &&
284 const char *reason_for_complaint = sanitized_name.IsKeyword()
285 ?
"conflicts with a keyword"
286 :
"contains reserved characters";
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",
296 reason_for_complaint, path_string.
GetString());
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,
309 file_list.
Append(script_fspec);
317 if (module_spec.
GetFilename() == filename_no_extension)
342 const FileSpec &module_spec =
module.GetFileSpec();
357 llvm::StringRef(symfile_spec.
GetPath())
358 .contains_insensitive(
".dSYM/Contents/Resources/DWARF") &&
361 feedback_stream, module_spec, *target, symfile_spec);
388 module_spec, process, module_sp, old_modules, did_create_ptr);
395 old_modules, did_create_ptr);
402 module_search_paths = target_sp->GetExecutableSearchPaths();
403 if (!module_sp && !module_search_paths.
IsEmpty() && platform_file) {
408 if (platform_file == bundle_directory) {
413 module_sp, old_modules,
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));
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 =
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);
440 new_module_spec, process, module_sp, old_modules,
444 module_sp->SetPlatformFileSpec(new_file_spec);
455 module_sp->SetPlatformFileSpec(module_spec.
GetFileSpec());
472 sc_base_addr, sc_uuid, using_sc, private_sc, sc_path)) {
474 image_info = HostInfo::GetSharedCacheImageInfo(module_spec.
GetUUID(),
477 image_info = HostInfo::GetSharedCacheImageInfo(
483 image_info = HostInfo::GetSharedCacheImageInfo(
497 LLDB_LOGF(log,
"module %s was found in a shared cache",
507 const uint8_t *trap_opcode =
nullptr;
508 uint32_t trap_opcode_size = 0;
509 bool bp_is_thumb =
false;
513 case llvm::Triple::aarch64_32:
514 case llvm::Triple::aarch64: {
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);
521 case llvm::Triple::thumb:
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};
532 bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass() ==
536 trap_opcode = g_thumb_breakpooint_opcode;
537 trap_opcode_size =
sizeof(g_thumb_breakpooint_opcode);
540 trap_opcode = g_arm_breakpoint_opcode;
541 trap_opcode_size =
sizeof(g_arm_breakpoint_opcode);
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);
555 if (trap_opcode && trap_opcode_size) {
557 return trap_opcode_size;
567 ObjectFile *obj_file = module_sp->GetObjectFile();
576 std::vector<ArchSpec> &archs) {
577 ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
578 archs.push_back(host_arch);
581 archs.push_back(
ArchSpec(
"x86_64-apple-macosx"));
582 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
584 ArchSpec host_arch64 = HostInfo::GetArchitecture(HostInfo::eArchKind64);
586 archs.push_back(HostInfo::GetArchitecture(HostInfo::eArchKind32));
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",
601 return {g_arm64e_compatible_archs};
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",
610 return {g_arm64_compatible_archs};
613 static const char *g_armv7_compatible_archs[] = {
614 "armv7",
"armv6m",
"armv6",
"armv5",
"armv4",
"arm",
615 "thumbv7",
"thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
617 return {g_armv7_compatible_archs};
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",
625 return {g_armv7f_compatible_archs};
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",
633 return {g_armv7k_compatible_archs};
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",
641 return {g_armv7s_compatible_archs};
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",
649 return {g_armv7m_compatible_archs};
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",
657 return {g_armv7em_compatible_archs};
660 static const char *g_armv6m_compatible_archs[] = {
661 "armv6m",
"armv6",
"armv5",
"armv4",
"arm",
662 "thumbv6m",
"thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
664 return {g_armv6m_compatible_archs};
667 static const char *g_armv6_compatible_archs[] = {
668 "armv6",
"armv5",
"armv4",
"arm",
669 "thumbv6",
"thumbv5",
"thumbv4t",
"thumb",
671 return {g_armv6_compatible_archs};
674 static const char *g_armv5_compatible_archs[] = {
675 "armv5",
"armv4",
"arm",
"thumbv5",
"thumbv4t",
"thumb",
677 return {g_armv5_compatible_archs};
680 static const char *g_armv4_compatible_archs[] = {
686 return {g_armv4_compatible_archs};
696 std::vector<ArchSpec> &archs, std::optional<llvm::Triple::OSType> os) {
701 triple.setArchName(arch);
702 triple.setVendor(llvm::Triple::VendorType::Apple);
710 static FileSpec g_xcode_select_filespec;
712 if (!g_xcode_select_filespec) {
713 FileSpec xcode_select_cmd(
"/usr/bin/xcode-select");
715 int exit_status = -1;
717 std::string command_output;
721 &exit_status, &signo, &command_output,
nullptr,
722 std::chrono::seconds(2),
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);
729 g_xcode_select_filespec =
FileSpec(command_output);
734 return g_xcode_select_filespec;
739 static const char *g_bp_names[] = {
740 "start_wqthread",
"_pthread_wqthread",
"_pthread_start",
743 static const char *g_bp_modules[] = {
"libsystem_c.dylib",
"libSystem.B.dylib",
744 "libsystem_pthread.dylib"};
747 for (
size_t i = 0; i < std::size(g_bp_modules); i++) {
748 const char *bp_module = g_bp_modules[i];
752 bool internal =
true;
753 bool hardware =
false;
756 std::size(g_bp_names), eFunctionNameTypeFull,
759 bp_sp->SetBreakpointKind(
"thread-creation");
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();
777 if (strcmp(shell_name,
"sh") == 0) {
781 if (launch_info.
GetEnvironment().lookup(
"COMMAND_MODE") ==
"legacy")
784 }
else if (strcmp(shell_name,
"csh") == 0 ||
785 strcmp(shell_name,
"tcsh") == 0 ||
786 strcmp(shell_name,
"zsh") == 0) {
822 static FileSpec g_command_line_tools_filespec;
824 if (!g_command_line_tools_filespec) {
828 g_command_line_tools_filespec = command_line_tools_path;
832 return g_command_line_tools_filespec;
836 void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) {
856 const bool find_directories =
true;
857 const bool find_files =
false;
858 const bool find_other =
true;
862 enumerator_info.
sdk_type = sdk_type;
865 sdks_spec.
GetPath(), find_directories, find_files, find_other,
875 FileSpec sdks_spec = HostInfo::GetXcodeContentsDirectory();
899 llvm_unreachable(
"unsupported sdk");
906 llvm::VersionTuple version = HostInfo::GetOSVersion();
908 if (!version.empty()) {
920 FileSpec native_sdk_spec = sdks_spec;
922 native_sdk_name.
Printf(
"MacOSX%u.%u.sdk", version.getMajor(),
923 version.getMinor().value_or(0));
927 return native_sdk_spec;
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) ||
945 if (build_str.consume_front(
"(")) {
946 size_t pos = build_str.find(
')');
947 build = build_str.slice(0, pos);
951 return std::make_tuple(version, build);
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");
965 if (!process_dict_sp->GetValueForKeyAsArray(crash_info_key, annotations)) {
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();
975 if (!process_dict_sp->GetValueForKeyAsDictionary(asi_info_key,
976 app_specific_info)) {
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();
986 return process_dict_sp->GetSize() ? process_dict_sp :
nullptr;
1000 std::string module_name =
module->GetSpecificationDescription();
1004 if (module_name ==
"/usr/lib/dyld")
1008 LLDB_LOG(log,
"Module {0} doesn't have any section!", module_name);
1014 LLDB_LOG(log,
"Module {0} doesn't have section {1}!", module_name,
1019 addr_t load_addr = crash_info->GetLoadBaseAddress(&target);
1022 LLDB_LOG(log,
"Module {0} has an invalid '{1}' section load address: {2}",
1023 module_name, section_name, load_addr);
1031 expected_size,
error);
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);
1040 if (annotations.
version < 5) {
1042 "Annotation version lower than 5 unsupported! Module {0} has "
1043 "version {1} instead.",
1044 module_name, annotations.
version);
1049 LLDB_LOG(log,
"No message available for module {0}.", module_name);
1053 std::string message;
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);
1064 if (message.back() ==
'\n')
1068 LLDB_LOG(log,
"No message2 available for module {0}.", module_name);
1070 std::string message2;
1074 if (!message2.empty() && bytes_read == message2.size() &&
error.Success())
1075 if (message2.back() ==
'\n')
1076 message2.pop_back();
1079 std::make_shared<StructuredData::Dictionary>();
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);
1087 array_sp->AddItem(entry_sp);
1097 if (!metadata_sp || !metadata_sp->GetSize() || !metadata_sp->HasKey(
"asi"))
1101 if (!metadata_sp->GetValueForKeyAsDictionary(
"asi", asi))
1105 std::make_shared<StructuredData::Dictionary>();
1107 auto flatten_asi_dict = [&dict_sp](llvm::StringRef key,
1120 asi->
ForEach(flatten_asi_dict);
1125static llvm::Expected<lldb_private::FileSpec>
1130 return llvm::createStringError(
"Failed to get module from target");
1132 SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
1134 return llvm::createStringError(
"Failed to get symbol file from executable");
1137 return llvm::createStringError(
1138 "Failed to resolve SDK for target: executable's symbol file has no "
1145 merged_sdk.
Merge(cu_sdk);
1155 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk});
1157 return llvm::createStringError(
1158 llvm::formatv(
"Failed to resolve SDK path: {0}",
1159 llvm::toString(path_or_err.takeError())));
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"};
1171 options.insert(options.end(), apple_arguments.begin(), apple_arguments.end());
1174 bool use_current_os_version =
false;
1176 auto get_host_os = []() {
return HostInfo::GetTargetTriple().getOS(); };
1179 use_current_os_version = get_host_os() == llvm::Triple::MacOSX;
1182 use_current_os_version = get_host_os() == llvm::Triple::IOS;
1185 use_current_os_version = get_host_os() == llvm::Triple::TvOS;
1188 use_current_os_version = get_host_os() == llvm::Triple::WatchOS;
1191 use_current_os_version = get_host_os() == llvm::Triple::XROS;
1197 llvm::VersionTuple version;
1198 if (use_current_os_version)
1204 if (exe_module_sp) {
1205 ObjectFile *object_file = exe_module_sp->GetObjectFile();
1214#define OPTION(PREFIX_OFFSET, NAME_OFFSET, VAR, ...) \
1215 llvm::StringRef opt_##VAR = OptionStrTable[NAME_OFFSET]; \
1217#include "clang/Options/Options.inc"
1219 minimum_version_option <<
'-';
1222 minimum_version_option << opt_mmacos_version_min_EQ;
1225 minimum_version_option << opt_mios_simulator_version_min_EQ;
1228 minimum_version_option << opt_mios_version_min_EQ;
1231 minimum_version_option << opt_mtvos_simulator_version_min_EQ;
1234 minimum_version_option << opt_mtvos_version_min_EQ;
1237 minimum_version_option << opt_mwatchos_simulator_version_min_EQ;
1240 minimum_version_option << opt_mwatchos_version_min_EQ;
1250 info.
type = sdk_type;
1251 LLDB_LOGF(log,
"Clang modules on %s are not supported",
1256 minimum_version_option << version.getAsString();
1257 options.emplace_back(std::string(minimum_version_option.
GetString()));
1264 if (!sysroot_spec_or_err) {
1266 sysroot_spec_or_err.takeError(),
1267 "Failed to resolve sysroot: {0}");
1269 sysroot_spec = *sysroot_spec_or_err;
1274 std::lock_guard<std::mutex> guard(
m_mutex);
1279 options.push_back(
"-isysroot");
1280 options.push_back(sysroot_spec.
GetPath());
1299 llvm::VersionTuple result;
1300 if (!result.tryParse(env.lookup(
"SIMULATOR_RUNTIME_VERSION")))
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";
1307 std::string product_version;
1310 if (!result.tryParse(product_version))
1318 return llvm::VersionTuple();
1327 static std::vector<FileSpec> g_executable_dirs;
1331 static llvm::once_flag g_once_flag;
1332 llvm::call_once(g_once_flag, []() {
1335 FileSpec xcode_contents_dir = HostInfo::GetXcodeContentsDirectory();
1336 if (xcode_contents_dir) {
1337 FileSpec xcode_lldb_resources = xcode_contents_dir;
1344 g_executable_dirs.push_back(dir);
1349 if (command_line_tools_dir) {
1350 FileSpec cmd_line_lldb_resources = command_line_tools_dir;
1357 g_executable_dirs.push_back(dir);
1364 for (
const auto &executable_dir : g_executable_dirs) {
1366 executable_file.
SetDirectory(executable_dir.GetDirectory());
1369 return executable_file;
1384 const char *disable_env_var =
"IDE_DISABLED_OS_ACTIVITY_DT_MODE";
1386 if (!env_vars.count(disable_env_var)) {
1389 env_vars.try_emplace(
"OS_ACTIVITY_DT_MODE",
"enable");
1403 module_search_paths = target_sp->GetExecutableSearchPaths();
1406 if (!module_sp && !module_search_paths.
IsEmpty() && platform_file) {
1415 std::vector<llvm::StringRef> path_parts = platform_file.
GetComponents();
1417 std::reverse(path_parts.begin(), path_parts.end());
1418 const size_t path_parts_size = path_parts.size();
1420 size_t num_module_search_paths = module_search_paths.
GetSize();
1421 for (
size_t i = 0; i < num_module_search_paths; ++i) {
1425 "PlatformRemoteDarwinDevice::GetSharedModule searching for binary in "
1433 for (
size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) {
1447 for (
int k = j; k >= 0; --k) {
1455 module_sp, old_modules,
1459 module_sp->SetPlatformFileSpec(path_to_try);
1470#if !defined(__APPLE__)
1471 return llvm::Triple::MacOSX;
1474 return llvm::Triple::MacOSX;
1476 return llvm::Triple::IOS;
1477#elif TARGET_OS_WATCH
1478 return llvm::Triple::WatchOS;
1480 return llvm::Triple::TvOS;
1481#elif TARGET_OS_BRIDGE
1482 return llvm::Triple::BridgeOS;
1484 return llvm::Triple::XROS;
1486#error "LLDB being compiled for an unrecognized Darwin OS"
1491llvm::Expected<std::pair<XcodeSDK, bool>>
1493 SymbolFile *sym_file =
module.GetSymbolFile();
1495 return llvm::createStringError(
1496 llvm::inconvertibleErrorCode(),
1497 llvm::formatv(
"No symbol file available for module '{0}'",
1501 return llvm::createStringError(
1502 llvm::formatv(
"Could not resolve SDK for module '{0}'. Symbol file has "
1503 "no compile units.",
1506 bool found_public_sdk =
false;
1507 bool found_internal_sdk =
false;
1513 found_public_sdk |= !is_internal_sdk;
1514 found_internal_sdk |= is_internal_sdk;
1516 merged_sdk.
Merge(cu_sdk);
1520 const bool found_mismatch = found_internal_sdk && found_public_sdk;
1522 return std::pair{std::move(merged_sdk), found_mismatch};
1525llvm::Expected<std::string>
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())));
1534 auto [sdk, _] = std::move(*sdk_or_err);
1537 return sdk.GetSysroot().GetPath();
1539 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1541 return llvm::createStringError(
1542 llvm::inconvertibleErrorCode(),
1543 llvm::formatv(
"Error while searching for SDK (XcodeSDK '{0}'): {1}",
1545 llvm::toString(path_or_err.takeError())));
1547 return path_or_err->str();
1550llvm::Expected<XcodeSDK>
1554 return llvm::createStringError(
"compile unit has no module");
1555 SymbolFile *sym_file = module_sp->GetSymbolFile();
1557 return llvm::createStringError(
1558 llvm::formatv(
"No symbol file available for module '{0}'",
1559 module_sp->GetFileSpec().GetFilename()));
1564llvm::Expected<std::string>
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())));
1573 auto sdk = std::move(*sdk_or_err);
1575 auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk});
1577 return llvm::createStringError(
1578 llvm::inconvertibleErrorCode(),
1579 llvm::formatv(
"Error while searching for SDK (XcodeSDK '{0}'): {1}",
1581 llvm::toString(path_or_err.takeError())));
1583 return path_or_err->str();
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.
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.
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.
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)
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 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.
lldb::OptionValuePropertiesSP m_collection_sp
virtual bool IsReservedWord(const char *word)
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)
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 std::string GetCanonicalName(Info info)
Return the canonical SDK name, such as "macosx" for the macOS SDK.
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.