37#include "llvm/Support/FileSystem.h"
39#include <CoreFoundation/CoreFoundation.h>
54void PlatformDarwinKernel::Initialize() {
55 PlatformDarwin::Initialize();
58 PluginManager::RegisterPlugin(PlatformDarwinKernel::GetPluginNameStatic(),
59 PlatformDarwinKernel::GetDescriptionStatic(),
60 PlatformDarwinKernel::CreateInstance,
61 PlatformDarwinKernel::DebuggerInitialize);
65void PlatformDarwinKernel::Terminate() {
68 PluginManager::UnregisterPlugin(PlatformDarwinKernel::CreateInstance);
72 PlatformDarwin::Terminate();
75PlatformSP PlatformDarwinKernel::CreateInstance(
bool force,
79 const char *arch_name;
85 const char *triple_cstr =
86 arch ? arch->
GetTriple().getTriple().c_str() :
"<null>";
88 LLDB_LOGF(log,
"PlatformDarwinKernel::%s(force=%s, arch={%s,%s})",
89 __FUNCTION__, force ?
"true" :
"false", arch_name, triple_cstr);
98 "PlatformDarwinKernel::%s() aborting creation of platform "
99 "because force == false",
107 if (!create && arch && arch->
IsValid()) {
108 const llvm::Triple &triple = arch->
GetTriple();
109 switch (triple.getVendor()) {
110 case llvm::Triple::Apple:
116 case llvm::Triple::UnknownVendor:
124 switch (triple.getOS()) {
125 case llvm::Triple::Darwin:
126 case llvm::Triple::MacOSX:
127 case llvm::Triple::IOS:
128 case llvm::Triple::WatchOS:
129 case llvm::Triple::TvOS:
134 case llvm::Triple::UnknownOS:
145 case llvm::Triple::x86:
146 case llvm::Triple::x86_64:
147 case llvm::Triple::ppc:
148 case llvm::Triple::ppc64:
151 case llvm::Triple::arm:
152 case llvm::Triple::aarch64:
153 case llvm::Triple::thumb:
162 LLDB_LOGF(log,
"PlatformDarwinKernel::%s() creating platform",
168 LLDB_LOGF(log,
"PlatformDarwinKernel::%s() aborting creation of platform",
174llvm::StringRef PlatformDarwinKernel::GetDescriptionStatic() {
175 return "Darwin Kernel platform plug-in.";
180#define LLDB_PROPERTIES_platformdarwinkernel
181#include "PlatformMacOSXProperties.inc"
184#define LLDB_PROPERTIES_platformdarwinkernel
185#include "PlatformMacOSXPropertiesEnum.inc"
188class PlatformDarwinKernelProperties :
public Properties {
191 static ConstString g_setting_name(
"darwin-kernel");
192 return g_setting_name;
195 PlatformDarwinKernelProperties() :
Properties() {
196 m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
197 m_collection_sp->Initialize(g_platformdarwinkernel_properties);
200 ~PlatformDarwinKernelProperties()
override =
default;
202 FileSpecList GetKextDirectories()
const {
203 const uint32_t idx = ePropertyKextDirectories;
205 m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(
207 assert(option_value);
213 static PlatformDarwinKernelProperties g_settings;
217void PlatformDarwinKernel::DebuggerInitialize(
219 if (!PluginManager::GetSettingForPlatformPlugin(
220 debugger, PlatformDarwinKernelProperties::GetSettingName())) {
221 const bool is_global_setting =
true;
222 PluginManager::CreateSettingForPlatformPlugin(
224 ConstString(
"Properties for the PlatformDarwinKernel plug-in."),
230PlatformDarwinKernel::PlatformDarwinKernel(
233 m_name_to_kext_path_map_with_dsyms(),
234 m_name_to_kext_path_map_without_dsyms(), m_search_directories(),
235 m_search_directories_no_recursing(), m_kernel_binaries_with_dsyms(),
236 m_kernel_binaries_without_dsyms(), m_kernel_dsyms_no_binaries(),
237 m_kernel_dsyms_yaas(), m_ios_debug_session(is_ios_debug_session)
240 CollectKextAndKernelDirectories();
241 SearchForKextsAndKernelsRecursively();
248PlatformDarwinKernel::~PlatformDarwinKernel() =
default;
250void PlatformDarwinKernel::GetStatus(
Stream &strm) {
251 Platform::GetStatus(strm);
252 strm.
Printf(
" Debug session type: ");
253 if (m_ios_debug_session == eLazyBoolYes)
254 strm.
Printf(
"iOS kernel debugging\n");
255 else if (m_ios_debug_session == eLazyBoolNo)
256 strm.
Printf(
"Mac OS X kernel debugging\n");
258 strm.
Printf(
"unknown kernel debugging\n");
260 strm.
Printf(
"Directories searched recursively:\n");
261 const uint32_t num_kext_dirs = m_search_directories.size();
262 for (
uint32_t i = 0; i < num_kext_dirs; ++i) {
263 strm.
Printf(
"[%d] %s\n", i, m_search_directories[i].GetPath().c_str());
266 strm.
Printf(
"Directories not searched recursively:\n");
267 const uint32_t num_kext_dirs_no_recursion =
268 m_search_directories_no_recursing.size();
269 for (
uint32_t i = 0; i < num_kext_dirs_no_recursion; i++) {
270 strm.
Printf(
"[%d] %s\n", i,
271 m_search_directories_no_recursing[i].GetPath().c_str());
274 strm.
Printf(
" Number of kexts with dSYMs indexed: %d\n",
275 (
int)m_name_to_kext_path_map_with_dsyms.size());
276 strm.
Printf(
" Number of kexts without dSYMs indexed: %d\n",
277 (
int)m_name_to_kext_path_map_without_dsyms.size());
278 strm.
Printf(
" Number of Kernel binaries with dSYMs indexed: %d\n",
279 (
int)m_kernel_binaries_with_dsyms.size());
280 strm.
Printf(
" Number of Kernel binaries without dSYMs indexed: %d\n",
281 (
int)m_kernel_binaries_without_dsyms.size());
282 strm.
Printf(
" Number of Kernel dSYMs with no binaries indexed: %d\n",
283 (
int)m_kernel_dsyms_no_binaries.size());
284 strm.
Printf(
" Number of Kernel dSYM.yaa's indexed: %d\n",
285 (
int)m_kernel_dsyms_yaas.size());
290 for (
auto pos : m_name_to_kext_path_map_with_dsyms) {
291 LLDB_LOGF(log,
"%s", pos.second.GetPath().c_str());
295 for (
auto pos : m_name_to_kext_path_map_without_dsyms) {
296 LLDB_LOGF(log,
"%s", pos.second.GetPath().c_str());
298 LLDB_LOGF(log,
"\nkernel binaries with dSYMS");
299 for (
auto fs : m_kernel_binaries_with_dsyms) {
300 LLDB_LOGF(log,
"%s", fs.GetPath().c_str());
302 LLDB_LOGF(log,
"\nkernel binaries without dSYMS");
303 for (
auto fs : m_kernel_binaries_without_dsyms) {
304 LLDB_LOGF(log,
"%s", fs.GetPath().c_str());
306 LLDB_LOGF(log,
"\nkernel dSYMS with no binaries");
307 for (
auto fs : m_kernel_dsyms_no_binaries) {
308 LLDB_LOGF(log,
"%s", fs.GetPath().c_str());
311 for (
auto fs : m_kernel_dsyms_yaas) {
312 LLDB_LOGF(log,
"%s", fs.GetPath().c_str());
321void PlatformDarwinKernel::CollectKextAndKernelDirectories() {
329 std::string developer_dir = HostInfo::GetXcodeDeveloperDirectory().GetPath();
330 if (developer_dir.empty())
331 developer_dir =
"/Applications/Xcode.app/Contents/Developer";
333 if (m_ios_debug_session != eLazyBoolNo) {
334 AddSDKSubdirsToSearchPaths(developer_dir +
335 "/Platforms/iPhoneOS.platform/Developer/SDKs");
336 AddSDKSubdirsToSearchPaths(developer_dir +
337 "/Platforms/AppleTVOS.platform/Developer/SDKs");
338 AddSDKSubdirsToSearchPaths(developer_dir +
339 "/Platforms/WatchOS.platform/Developer/SDKs");
340 AddSDKSubdirsToSearchPaths(developer_dir +
341 "/Platforms/BridgeOS.platform/Developer/SDKs");
343 if (m_ios_debug_session != eLazyBoolYes) {
344 AddSDKSubdirsToSearchPaths(developer_dir +
345 "/Platforms/MacOSX.platform/Developer/SDKs");
348 AddSDKSubdirsToSearchPaths(
"/Volumes/KernelDebugKit");
349 AddSDKSubdirsToSearchPaths(
"/AppleInternal/Developer/KDKs");
352 AddSDKSubdirsToSearchPaths(
"/Library/Developer/KDKs");
354 if (m_ios_debug_session != eLazyBoolNo) {
356 if (m_ios_debug_session != eLazyBoolYes) {
357 AddRootSubdirsToSearchPaths(
this,
"/");
360 GetUserSpecifiedDirectoriesToSearch();
363 FileSpec possible_dir(developer_dir +
"/../Symbols");
364 FileSystem::Instance().Resolve(possible_dir);
365 if (FileSystem::Instance().IsDirectory(possible_dir))
366 m_search_directories.push_back(possible_dir);
370 FileSystem::Instance().Resolve(cwd);
371 m_search_directories_no_recursing.push_back(cwd);
374void PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch() {
376 std::vector<FileSpec> possible_sdk_dirs;
378 const uint32_t user_dirs_count = user_dirs.GetSize();
379 for (
uint32_t i = 0; i < user_dirs_count; i++) {
380 FileSpec dir = user_dirs.GetFileSpecAtIndex(i);
381 FileSystem::Instance().Resolve(dir);
382 if (FileSystem::Instance().IsDirectory(dir)) {
383 m_search_directories.push_back(dir);
388void PlatformDarwinKernel::AddRootSubdirsToSearchPaths(
390 const char *subdirs[] = {
391 "/System/Library/Extensions",
"/Library/Extensions",
392 "/System/Library/Kernels",
393 "/System/Library/Extensions/KDK",
396 for (
int i = 0; subdirs[i] !=
nullptr; i++) {
398 FileSystem::Instance().Resolve(testdir);
399 if (FileSystem::Instance().IsDirectory(testdir))
400 thisp->m_search_directories.push_back(testdir);
404 thisp->m_search_directories_no_recursing.push_back(
FileSpec(dir +
"/"));
408void PlatformDarwinKernel::AddSDKSubdirsToSearchPaths(
const std::string &dir) {
410 const bool find_directories =
true;
411 const bool find_files =
false;
412 const bool find_other =
false;
413 FileSystem::Instance().EnumerateDirectory(
414 dir.c_str(), find_directories, find_files, find_other,
415 FindKDKandSDKDirectoriesInDirectory,
this);
420PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory(
421 void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
427 if (ft == llvm::sys::fs::file_type::directory_file &&
428 (file_spec.GetFileNameExtension() == g_sdk_suffix ||
429 file_spec.GetFileNameExtension() == g_kdk_suffix)) {
430 AddRootSubdirsToSearchPaths(thisp, file_spec.GetPath());
432 return FileSystem::eEnumerateDirectoryResultNext;
437void PlatformDarwinKernel::SearchForKextsAndKernelsRecursively() {
438 const uint32_t num_dirs = m_search_directories.size();
439 for (
uint32_t i = 0; i < num_dirs; i++) {
440 const FileSpec &dir = m_search_directories[i];
441 const bool find_directories =
true;
442 const bool find_files =
true;
443 const bool find_other =
true;
444 FileSystem::Instance().EnumerateDirectory(
445 dir.
GetPath().c_str(), find_directories, find_files, find_other,
446 GetKernelsAndKextsInDirectoryWithRecursion,
this);
448 const uint32_t num_dirs_no_recurse = m_search_directories_no_recursing.size();
449 for (
uint32_t i = 0; i < num_dirs_no_recurse; i++) {
450 const FileSpec &dir = m_search_directories_no_recursing[i];
451 const bool find_directories =
true;
452 const bool find_files =
true;
453 const bool find_other =
true;
454 FileSystem::Instance().EnumerateDirectory(
455 dir.
GetPath().c_str(), find_directories, find_files, find_other,
456 GetKernelsAndKextsInDirectoryNoRecursion,
this);
469PlatformDarwinKernel::GetKernelsAndKextsInDirectoryWithRecursion(
470 void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
471 return GetKernelsAndKextsInDirectoryHelper(baton, ft, path,
true);
475PlatformDarwinKernel::GetKernelsAndKextsInDirectoryNoRecursion(
476 void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
477 return GetKernelsAndKextsInDirectoryHelper(baton, ft, path,
false);
481PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
482 void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path,
489 ConstString file_spec_extension = file_spec.GetFileNameExtension();
493 LLDB_LOGV(log,
"PlatformDarwinKernel examining '{0}'", file_spec);
497 llvm::StringRef filename = file_spec.GetFilename().GetStringRef();
498 bool is_kernel_filename =
499 filename.startswith(
"kernel") || filename.startswith(
"mach");
500 bool is_dsym_yaa = filename.endswith(
".dSYM.yaa");
502 if (ft == llvm::sys::fs::file_type::regular_file ||
503 ft == llvm::sys::fs::file_type::symlink_file) {
504 if (is_kernel_filename) {
505 if (file_spec_extension != g_dsym_suffix && !is_dsym_yaa) {
506 if (KernelHasdSYMSibling(file_spec)) {
508 "PlatformDarwinKernel registering kernel binary '%s' with "
510 file_spec.GetPath().c_str());
511 thisp->m_kernel_binaries_with_dsyms.push_back(file_spec);
515 "PlatformDarwinKernel registering kernel binary '%s', no dSYM",
516 file_spec.GetPath().c_str());
517 thisp->m_kernel_binaries_without_dsyms.push_back(file_spec);
521 LLDB_LOGF(log,
"PlatformDarwinKernel registering kernel .dSYM.yaa '%s'",
522 file_spec.GetPath().c_str());
523 thisp->m_kernel_dsyms_yaas.push_back(file_spec);
525 return FileSystem::eEnumerateDirectoryResultNext;
528 if (ft == llvm::sys::fs::file_type::directory_file) {
529 if (file_spec_extension == g_kext_suffix) {
530 AddKextToMap(thisp, file_spec);
532 FileSpec contents_plugins(file_spec.GetPath() +
"/Contents/PlugIns");
533 std::string search_here_too;
534 if (FileSystem::Instance().IsDirectory(contents_plugins)) {
535 search_here_too = contents_plugins.GetPath();
537 FileSpec plugins(file_spec.GetPath() +
"/PlugIns");
538 if (FileSystem::Instance().IsDirectory(plugins)) {
539 search_here_too = plugins.GetPath();
543 if (!search_here_too.empty()) {
544 const bool find_directories =
true;
545 const bool find_files =
false;
546 const bool find_other =
false;
547 FileSystem::Instance().EnumerateDirectory(
548 search_here_too.c_str(), find_directories, find_files, find_other,
549 recurse ? GetKernelsAndKextsInDirectoryWithRecursion
550 : GetKernelsAndKextsInDirectoryNoRecursion,
553 return FileSystem::eEnumerateDirectoryResultNext;
556 if (is_kernel_filename && file_spec_extension == g_dsym_suffix) {
557 if (KerneldSYMHasNoSiblingBinary(file_spec)) {
559 "PlatformDarwinKernel registering kernel dSYM '%s' with "
561 file_spec.GetPath().c_str());
562 thisp->m_kernel_dsyms_no_binaries.push_back(file_spec);
563 return FileSystem::eEnumerateDirectoryResultNext;
570 if (recurse && file_spec_extension != g_dsym_suffix &&
571 file_spec_extension != g_kext_suffix &&
572 file_spec_extension != g_bundle_suffix) {
573 LLDB_LOGV(log,
"PlatformDarwinKernel descending into directory '{0}'",
575 return FileSystem::eEnumerateDirectoryResultEnter;
577 return FileSystem::eEnumerateDirectoryResultNext;
585 CFStringRef bundle_id(bundle.GetIdentifier());
586 if (bundle_id && CFGetTypeID(bundle_id) == CFStringGetTypeID()) {
588 if (CFStringGetCString(bundle_id, bundle_id_buf,
sizeof(bundle_id_buf),
589 kCFStringEncodingUTF8)) {
591 if (KextHasdSYMSibling(file_spec))
594 "PlatformDarwinKernel registering kext binary '%s' with dSYM "
597 thisp->m_name_to_kext_path_map_with_dsyms.insert(
598 std::pair<ConstString, FileSpec>(bundle_conststr, file_spec));
603 "PlatformDarwinKernel registering kext binary '%s', no dSYM",
605 thisp->m_name_to_kext_path_map_without_dsyms.insert(
606 std::pair<ConstString, FileSpec>(bundle_conststr, file_spec));
617bool PlatformDarwinKernel::KextHasdSYMSibling(
618 const FileSpec &kext_bundle_filepath) {
619 FileSpec dsym_fspec = kext_bundle_filepath;
623 if (FileSystem::Instance().IsDirectory(dsym_fspec)) {
632 std::string deep_bundle_str =
633 kext_bundle_filepath.
GetPath() +
"/Contents/MacOS/";
634 deep_bundle_str += executable_name.
AsCString();
635 deep_bundle_str +=
".dSYM";
636 dsym_fspec.
SetFile(deep_bundle_str, FileSpec::Style::native);
637 FileSystem::Instance().Resolve(dsym_fspec);
638 if (FileSystem::Instance().IsDirectory(dsym_fspec)) {
644 std::string shallow_bundle_str = kext_bundle_filepath.
GetPath() +
"/";
645 shallow_bundle_str += executable_name.
AsCString();
646 shallow_bundle_str +=
".dSYM";
647 dsym_fspec.
SetFile(shallow_bundle_str, FileSpec::Style::native);
648 FileSystem::Instance().Resolve(dsym_fspec);
649 return FileSystem::Instance().IsDirectory(dsym_fspec);
655bool PlatformDarwinKernel::KernelHasdSYMSibling(
const FileSpec &kernel_binary) {
656 FileSpec kernel_dsym = kernel_binary;
660 return FileSystem::Instance().IsDirectory(kernel_dsym);
668bool PlatformDarwinKernel::KerneldSYMHasNoSiblingBinary(
671 std::string possible_path = kernel_dsym.
GetPath();
675 FileSpec binary_filespec = kernel_dsym;
680 if (FileSystem::Instance().Exists(binary_filespec))
686 if (GetDWARFBinaryInDSYMBundle(kernel_dsym).size() > 0)
698PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(
FileSpec dsym_bundle) {
699 std::vector<FileSpec> results;
705 std::string filename =
709 std::string binary_filepath = dsym_bundle.
GetPath();
710 binary_filepath +=
"/Contents/Resources/DWARF/";
711 binary_filepath += filename;
713 FileSpec binary_fspec(binary_filepath);
714 if (FileSystem::Instance().Exists(binary_fspec))
715 results.push_back(binary_fspec);
719Status PlatformDarwinKernel::GetSharedModule(
721 const FileSpecList *module_search_paths_ptr,
729 std::string kext_bundle_id = platform_file.
GetPath();
734 if (kext_bundle_id ==
"mach_kernel" || kext_bundle_id.empty()) {
735 error = GetSharedModuleKernel(module_spec, process, module_sp,
736 module_search_paths_ptr, old_modules,
738 if (
error.Success() && module_sp) {
742 return GetSharedModuleKext(module_spec, process, module_sp,
743 module_search_paths_ptr, old_modules,
750 return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
751 module_search_paths_ptr, old_modules,
755Status PlatformDarwinKernel::GetSharedModuleKext(
757 const FileSpecList *module_search_paths_ptr,
767 if (m_name_to_kext_path_map_with_dsyms.count(kext_bundle) > 0) {
768 for (BundleIDToKextIterator it = m_name_to_kext_path_map_with_dsyms.begin();
769 it != m_name_to_kext_path_map_with_dsyms.end(); ++it) {
770 if (it->first == kext_bundle) {
771 error = ExamineKextForMatchingUUID(it->second, module_spec.
GetUUID(),
774 if (module_sp.get()) {
783 error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
784 module_search_paths_ptr, old_modules,
786 if (
error.Success() && module_sp.get()) {
793Status PlatformDarwinKernel::GetSharedModuleKernel(
795 const FileSpecList *module_search_paths_ptr,
801 for (
auto possible_kernel : m_kernel_binaries_with_dsyms) {
802 if (FileSystem::Instance().Exists(possible_kernel)) {
804 kern_spec.GetUUID() = module_spec.
GetUUID();
805 module_sp.reset(
new Module(kern_spec));
806 if (module_sp && module_sp->GetObjectFile() &&
807 module_sp->MatchesModuleSpec(kern_spec)) {
810 const bool notify =
false;
815 error = ModuleList::GetSharedModule(kern_spec, module_sp,
nullptr,
817 if (module_sp && module_sp->GetObjectFile() &&
818 module_sp->GetObjectFile()->GetType() !=
819 ObjectFile::Type::eTypeCoreFile) {
830 for (
auto possible_kernel_dsym : m_kernel_dsyms_no_binaries) {
831 std::vector<FileSpec> objfile_names =
832 GetDWARFBinaryInDSYMBundle(possible_kernel_dsym);
833 for (
FileSpec objfile : objfile_names) {
835 kern_spec.GetUUID() = module_spec.
GetUUID();
836 kern_spec.GetSymbolFileSpec() = possible_kernel_dsym;
838 module_sp.reset(
new Module(kern_spec));
839 if (module_sp && module_sp->GetObjectFile() &&
840 module_sp->MatchesModuleSpec(kern_spec)) {
843 const bool notify =
false;
848 error = ModuleList::GetSharedModule(kern_spec, module_sp,
nullptr,
850 if (module_sp && module_sp->GetObjectFile() &&
851 module_sp->GetObjectFile()->GetType() !=
852 ObjectFile::Type::eTypeCoreFile) {
863 error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
864 module_search_paths_ptr, old_modules,
866 if (
error.Success() && module_sp.get()) {
873std::vector<lldb_private::FileSpec>
874PlatformDarwinKernel::SearchForExecutablesRecursively(
const std::string &dir) {
875 std::vector<FileSpec> executables;
877 for (llvm::sys::fs::recursive_directory_iterator it(dir.c_str(), EC),
879 it != end && !EC; it.increment(EC)) {
880 auto status = it->status();
883 if (llvm::sys::fs::is_regular_file(*status) &&
884 llvm::sys::fs::can_execute(it->path()))
885 executables.emplace_back(it->path());
890Status PlatformDarwinKernel::ExamineKextForMatchingUUID(
892 const ArchSpec &arch, ModuleSP &exe_module_sp) {
893 for (
const auto &exe_file :
894 SearchForExecutablesRecursively(kext_bundle_path.
GetPath())) {
895 if (FileSystem::Instance().Exists(exe_file)) {
897 exe_spec.GetUUID() = uuid;
899 exe_spec.GetArchitecture() = arch;
906 ModuleSP module_sp(
new Module(exe_spec));
907 if (module_sp && module_sp->GetObjectFile() &&
908 module_sp->MatchesModuleSpec(exe_spec)) {
909 Status error = ModuleList::GetSharedModule(exe_spec, exe_module_sp,
911 if (exe_module_sp && exe_module_sp->GetObjectFile()) {
915 exe_module_sp.reset();
926 if (!process->
ReadMemory(input_addr, header_data->GetBytes(),
927 header_data->GetByteSize(),
error) ||
931 ObjectContainerSP container_sp(
932 ObjectContainerMachOFileset::CreateMemoryInstance(
933 module_sp, header_data, process->shared_from_this(), input_addr));
940 fileset_container->
FindEntry(
"com.apple.kernel");
946bool PlatformDarwinKernel::LoadPlatformBinaryAndSetup(
Process *process,
950 GetLog(LLDBLog::Platform | LLDBLog::DynamicLoader | LLDBLog::Process);
955 addr_t actual_address = find_kernel_in_macho_fileset(process, input_addr);
958 "PlatformDarwinKernel::%s check address 0x%" PRIx64
" for "
959 "a macho fileset, got back kernel address 0x%" PRIx64,
960 __FUNCTION__, input_addr, actual_address);
969 PlatformSP platform_sp =
971 PlatformDarwinKernel::GetPluginNameStatic());
975 DynamicLoaderUP dyld_up =
976 std::make_unique<DynamicLoaderDarwinKernel>(process, actual_address);
986std::vector<ArchSpec> PlatformDarwinKernel::GetSupportedArchitectures(
987 const ArchSpec &process_host_arch) {
988 std::vector<ArchSpec> result;
989 ARMGetSupportedArchitectures(result);
990 x86GetSupportedArchitectures(result);
994void PlatformDarwinKernel::CalculateTrapHandlerSymbolNames() {
995 m_trap_handlers.push_back(
ConstString(
"trap_from_kernel"));
996 m_trap_handlers.push_back(
ConstString(
"hndl_machine_check"));
997 m_trap_handlers.push_back(
ConstString(
"hndl_double_fault"));
998 m_trap_handlers.push_back(
ConstString(
"hndl_allintrs"));
999 m_trap_handlers.push_back(
ConstString(
"hndl_alltraps"));
1000 m_trap_handlers.push_back(
ConstString(
"interrupt"));
1001 m_trap_handlers.push_back(
ConstString(
"fleh_prefabt"));
1002 m_trap_handlers.push_back(
ConstString(
"ExceptionVectorsBase"));
1003 m_trap_handlers.push_back(
ConstString(
"ExceptionVectorsTable"));
1004 m_trap_handlers.push_back(
ConstString(
"fleh_undef"));
1005 m_trap_handlers.push_back(
ConstString(
"fleh_dataabt"));
1006 m_trap_handlers.push_back(
ConstString(
"fleh_irq"));
1007 m_trap_handlers.push_back(
ConstString(
"fleh_decirq"));
1008 m_trap_handlers.push_back(
ConstString(
"fleh_fiq_generic"));
1009 m_trap_handlers.push_back(
ConstString(
"fleh_dec"));
static llvm::raw_ostream & error(Stream &strm)
static DynamicLoaderDarwinKernelProperties & GetGlobalProperties()
#define LLDB_LOGF(log,...)
#define LLDB_LOGV(log,...)
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
bool TripleVendorWasSpecified() const
bool TripleOSWasSpecified() const
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
A subclass of DataBuffer that stores a data buffer on the heap.
A class to manage flag bits.
PlatformList & GetPlatformList()
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
const ConstString & GetFilename() const
Filename string const get accessor.
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 GetFileNameExtension() const
Extract the extension of the file.
void SetFilename(ConstString filename)
Filename string set accessor.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
ArchSpec & GetArchitecture()
A class that describes an executable image and its associated object and symbol files.
Entry * FindEntry(llvm::StringRef id)
FileSpecList GetCurrentValue() const
A plug-in interface definition class for debugging a process.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
void SetDynamicLoader(lldb::DynamicLoaderUP dyld)
Target & GetTarget()
Get the target object pointer for this module.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
const ModuleList & GetImages() const
Get accessor for the images for this process.
void SetPlatform(const lldb::PlatformSP &platform_sp)
#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.