39#ifdef ENABLE_DEBUG_PRINTF
41#define DEBUG_PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__)
43#define DEBUG_PRINTF(fmt, ...)
70 "Do not read memory looking for a Darwin kernel when attaching.",
75 "Check for the Darwin kernel's load addr in the lowglo page "
76 "(boot-args=debug) only.",
81 "Scan near the pc value on attach to find the Darwin kernel's load "
87 "Scan through the entire potential address range of Darwin kernel "
88 "(only on 32-bit targets).",
92#define LLDB_PROPERTIES_dynamicloaderdarwinkernel
93#include "DynamicLoaderDarwinKernelProperties.inc"
96#define LLDB_PROPERTIES_dynamicloaderdarwinkernel
97#include "DynamicLoaderDarwinKernelPropertiesEnum.inc"
103 static constexpr llvm::StringLiteral g_setting_name(
"darwin-kernel");
104 return g_setting_name;
115 const uint32_t idx = ePropertyLoadKexts;
116 return GetPropertyAtIndexAs<bool>(
118 g_dynamicloaderdarwinkernel_properties[idx].default_uint_value != 0);
122 const uint32_t idx = ePropertyScanType;
123 return GetPropertyAtIndexAs<KASLRScanType>(
126 g_dynamicloaderdarwinkernel_properties[idx].default_uint_value));
163 const llvm::Triple &triple_ref =
165 switch (triple_ref.getOS()) {
166 case llvm::Triple::Darwin:
167 case llvm::Triple::MacOSX:
168 case llvm::Triple::IOS:
169 case llvm::Triple::TvOS:
170 case llvm::Triple::WatchOS:
171 case llvm::Triple::XROS:
172 case llvm::Triple::BridgeOS:
173 if (triple_ref.getVendor() != llvm::Triple::Apple) {
179 case llvm::Triple::UnknownOS:
209 return kernel_load_address;
244 addr_t kernel_addresses_64[] = {
245 0xfffffff000002010ULL,
246 0xfffffff000004010ULL,
247 0xffffff8000004010ULL,
248 0xffffff8000002010ULL,
250 addr_t kernel_addresses_32[] = {0xffff0110,
260 uint64_t addr = data.
GetU64 (&offset);
274 uint32_t addr = data.
GetU32 (&offset);
298 if (thread.get() ==
nullptr)
307 if ((
pc & (1ULL << 63)) == 0) {
311 if ((
pc & (1ULL << 31)) == 0) {
319 int pagesize = 0x4000;
325 addr_t addr =
pc & ~(pagesize - 1ULL);
328 while (
pc - addr < 128 * 0x100000) {
335 if (read_error ==
true)
354 addr_t kernel_range_low, kernel_range_high;
356 kernel_range_low = 1ULL << 63;
359 kernel_range_low = 1ULL << 31;
370 addr_t addr = kernel_range_low;
372 while (addr >= kernel_range_low && addr < kernel_range_high) {
378 return addr + 0x1000;
381 return addr + 0x4000;
407 const uint32_t magicks[] = { llvm::MachO::MH_MAGIC_64, llvm::MachO::MH_MAGIC, llvm::MachO::MH_CIGAM, llvm::MachO::MH_CIGAM_64};
409 bool found_matching_pattern =
false;
410 for (
size_t i = 0; i < std::size(magicks); i++)
411 if (::memcmp (&header.magic, &magicks[i], sizeof (uint32_t)) == 0)
412 found_matching_pattern =
true;
414 if (!found_matching_pattern)
417 if (header.magic == llvm::MachO::MH_CIGAM ||
418 header.magic == llvm::MachO::MH_CIGAM_64) {
419 header.magic = llvm::byteswap<uint32_t>(header.magic);
420 header.cputype = llvm::byteswap<uint32_t>(header.cputype);
421 header.cpusubtype = llvm::byteswap<uint32_t>(header.cpusubtype);
422 header.filetype = llvm::byteswap<uint32_t>(header.filetype);
423 header.ncmds = llvm::byteswap<uint32_t>(header.ncmds);
424 header.sizeofcmds = llvm::byteswap<uint32_t>(header.sizeofcmds);
425 header.flags = llvm::byteswap<uint32_t>(header.flags);
439 Log *log =
GetLog(LLDBLog::DynamicLoader);
447 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
448 "looking for kernel binary at 0x%" PRIx64,
451 llvm::MachO::mach_header header;
461 if (header.filetype == llvm::MachO::MH_EXECUTE &&
462 (header.flags & llvm::MachO::MH_DYLDLINK) == 0) {
466 if (!memory_module_sp.get())
469 ObjectFile *exe_objfile = memory_module_sp->GetObjectFile();
470 if (exe_objfile ==
nullptr) {
472 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress "
473 "found a binary at 0x%" PRIx64
474 " but could not create an object file from memory",
486 std::string uuid_str;
487 if (memory_module_sp->GetUUID().IsValid()) {
488 uuid_str =
"with UUID ";
489 uuid_str += memory_module_sp->GetUUID().GetAsString();
491 uuid_str =
"and no LC_UUID found in load commands ";
495 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
496 "kernel binary image found at 0x%" PRIx64
" with arch '%s' %s",
497 addr, kernel_arch.
GetTriple().str().c_str(), uuid_str.c_str());
499 return memory_module_sp->GetUUID();
509 :
DynamicLoader(process), m_kernel_load_address(kernel_addr), m_kernel(),
510 m_kext_summary_header_ptr_addr(), m_kext_summary_header_addr(),
511 m_kext_summary_header(), m_known_kexts(), m_mutex(),
518 if (platform_sp.get())
549 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
569 bool changed =
false;
577 m_module_sp = module_sp;
578 m_kernel_image =
is_kernel(module_sp.get());
587 m_load_address = load_addr;
591 return m_load_address;
603 return m_load_process_stop_id;
608 m_load_process_stop_id = stop_id;
614 return m_uuid == rhs.
GetUUID();
645 if (m_memory_module_sp.get() !=
nullptr)
652 llvm::MachO::mach_header mh;
653 size_t size_to_read = 512;
655 if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC)
656 size_to_read =
sizeof(llvm::MachO::mach_header) + mh.sizeofcmds;
657 if (mh.magic == llvm::MachO::MH_CIGAM_64 ||
658 mh.magic == llvm::MachO::MH_MAGIC_64)
659 size_to_read =
sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
665 if (memory_module_sp.get() ==
nullptr)
668 bool this_is_kernel =
is_kernel(memory_module_sp.get());
673 if (m_uuid.IsValid()) {
674 if (m_uuid != memory_module_sp->GetUUID()) {
677 "KextImageInfo::ReadMemoryModule the kernel said to find "
678 "uuid %s at 0x%" PRIx64
679 " but instead we found uuid %s, throwing it away",
680 m_uuid.GetAsString().c_str(), m_load_address,
681 memory_module_sp->GetUUID().GetAsString().c_str());
688 if (!m_uuid.IsValid() && memory_module_sp->GetUUID().IsValid()) {
689 m_uuid = memory_module_sp->GetUUID();
692 m_memory_module_sp = memory_module_sp;
693 m_kernel_image = this_is_kernel;
694 if (this_is_kernel) {
698 "KextImageInfo::ReadMemoryModule read the kernel binary out "
701 if (memory_module_sp->GetArchitecture().IsValid()) {
710 return m_kernel_image;
719 Log *log =
GetLog(LLDBLog::DynamicLoader);
727 if (m_uuid.IsValid() ==
false) {
728 if (ReadMemoryModule(process) ==
false) {
729 Log *log =
GetLog(LLDBLog::DynamicLoader);
731 "Unable to read '%s' from memory at address 0x%" PRIx64
732 " to get the segment load addresses.",
733 m_name.c_str(), m_load_address);
738 if (IsKernel() && m_uuid.IsValid()) {
740 s.
Printf(
"Kernel UUID: %s\n", m_uuid.GetAsString().c_str());
741 s.
Printf(
"Load Address: 0x%" PRIx64
"\n", m_load_address);
749 if (
is_kernel(module_sp.get()) && module_sp->GetUUID() != m_uuid)
750 incorrect_kernels.
Append(module_sp);
759 m_module_sp = target_images.
FindModule(m_uuid);
764 if (
GetName() !=
"mach_kernel")
766 if (GetUUID().IsValid())
767 prog_str << GetUUID().GetAsString() <<
" ";
770 prog_str.
PutHex64(GetLoadAddress());
773 std::unique_ptr<Progress> progress_up;
778 progress_up = std::make_unique<Progress>(
"Loading kernel",
781 progress_up = std::make_unique<Progress>(
"Loading kext",
786 if (!m_module_sp && m_uuid.IsValid()) {
788 module_spec.
GetUUID() = m_uuid;
789 if (!m_uuid.IsValid())
801 platform_sp->GetSharedModule(module_spec, process, m_module_sp,
802 &search_paths,
nullptr,
nullptr);
818 Status kernel_search_error;
820 (!m_module_sp || !m_module_sp->GetSymbolFileFileSpec())) {
822 module_spec, kernel_search_error,
true)) {
824 m_module_sp = std::make_shared<Module>(module_spec.
GetFileSpec(),
830 if (IsKernel() && !m_module_sp) {
832 s.
Printf(
"WARNING: Unable to locate kernel binary on the debugger "
834 if (kernel_search_error.
Fail() && kernel_search_error.
AsCString(
"") &&
835 kernel_search_error.
AsCString(
"")[0] !=
'\0') {
841 if (m_module_sp && m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid &&
842 m_module_sp->GetObjectFile()) {
844 llvm::dyn_cast<ObjectFileMachO>(m_module_sp->GetObjectFile())) {
845 if (!IsKernel() && !ondisk_objfile_macho->IsKext()) {
849 if (existing_module_sp &&
850 existing_module_sp->IsLoadedInTarget(&target)) {
852 "'%s' with UUID %s is not a kext or kernel, and is "
853 "already registered in target, not loading.",
854 m_name.c_str(), m_uuid.GetAsString().c_str());
866 if (m_uuid.IsValid() && m_module_sp->GetUUID() == m_uuid) {
875 ReadMemoryModule (process);
877 static ConstString g_section_name_LINKEDIT(
"__LINKEDIT");
879 if (m_memory_module_sp && m_module_sp) {
880 if (m_module_sp->GetUUID() == m_memory_module_sp->GetUUID()) {
881 ObjectFile *ondisk_object_file = m_module_sp->GetObjectFile();
882 ObjectFile *memory_object_file = m_memory_module_sp->GetObjectFile();
884 if (memory_object_file && ondisk_object_file) {
887 const bool ignore_linkedit = !IsKernel();
903 llvm::dyn_cast<ObjectFileMachO>(memory_object_file)) {
905 memory_objfile_macho->GetMachHeaderSection()) {
906 if (header_sect->GetFileAddress() != m_load_address) {
907 fixed_slide = m_load_address - header_sect->GetFileAddress();
910 "kext %s in-memory LC_SEGMENT vmaddr is not correct, using a "
911 "fixed slide of 0x%" PRIx64,
912 m_name.c_str(), fixed_slide);
919 if (memory_section_list && ondisk_section_list) {
920 const uint32_t num_ondisk_sections = ondisk_section_list->
GetSize();
924 uint32_t sect_idx = 0;
931 uint32_t num_sections_loaded = 0;
932 for (sect_idx = 0; sect_idx < num_ondisk_sections; ++sect_idx) {
935 if (ondisk_section_sp) {
939 if (ignore_linkedit &&
940 ondisk_section_sp->GetName() == g_section_name_LINKEDIT)
946 ondisk_section_sp->GetFileAddress() + fixed_slide);
948 const Section *memory_section =
952 if (memory_section) {
955 ++num_sections_loaded;
960 if (num_sections_loaded > 0)
961 m_load_process_stop_id = process->
GetStopID();
972 bool is_loaded = IsLoaded();
974 if (is_loaded && m_module_sp && IsKernel()) {
976 ObjectFile *kernel_object_file = m_module_sp->GetObjectFile();
977 if (kernel_object_file) {
982 s.
Printf(
"Kernel slid 0x%" PRIx64
" in memory.\n",
983 m_load_address - file_address);
987 s.
Printf(
"Loaded kernel file %s\n",
988 m_module_sp->GetFileSpec().GetPath().c_str());
995 if (is_loaded && m_module_sp) {
997 loaded_module_list.
Append(m_module_sp);
1005 if (m_memory_module_sp)
1006 return m_memory_module_sp->GetArchitecture().GetAddressByteSize();
1008 return m_module_sp->GetArchitecture().GetAddressByteSize();
1013 if (m_memory_module_sp)
1014 return m_memory_module_sp->GetArchitecture().GetByteOrder();
1016 return m_module_sp->GetArchitecture().GetByteOrder();
1022 if (m_memory_module_sp)
1023 return m_memory_module_sp->GetArchitecture();
1025 return m_module_sp->GetArchitecture();
1060 if (kernel_object_file) {
1068 if (load_address != file_address) {
1091 static ConstString kext_summary_symbol(
"gLoadedKextSummaries");
1118 const size_t sym_bytesize = 8;
1119 uint64_t sym_value =
1122 if (
error.Success()) {
1128 uint32_t virt_addr_bits = 64 - sym_value;
1151 context, break_id, break_loc_id);
1157 Log *log =
GetLog(LLDBLog::DynamicLoader);
1158 LLDB_LOGF(log,
"DynamicLoaderDarwinKernel::BreakpointHit (...)\n");
1169 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1180 DataExtractor data(buf,
sizeof(buf), byte_order, addr_size);
1181 const size_t count = 4 *
sizeof(uint32_t) + addr_size;
1182 const bool force_live_memory =
true;
1192 if (bytes_read == count) {
1197 s.
Printf(
"WARNING: Unable to read kext summary header, got "
1198 "improbable version number %u\n",
1212 s.
Printf(
"WARNING: Unable to read kext summary header, got "
1213 "improbable entry_size %u\n",
1229 s.
Printf(
"WARNING: Unable to read kext summary header, got "
1230 "improbable number of kexts %u\n",
1251 const Address &kext_summary_addr, uint32_t count) {
1253 Log *log =
GetLog(LLDBLog::DynamicLoader);
1255 "Kexts-changed breakpoint hit, there are %d kexts currently.\n",
1258 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1271 std::vector<bool> to_be_removed(
m_known_kexts.size(),
true);
1272 std::vector<bool> to_be_added(count,
true);
1274 int number_of_new_kexts_being_added = 0;
1275 int number_of_old_kexts_being_removed =
m_known_kexts.size();
1277 const uint32_t new_kexts_size = kext_summaries.size();
1282 for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) {
1283 bool ignore =
false;
1293 number_of_old_kexts_being_removed--;
1294 to_be_removed[old_kext] =
false;
1300 for (uint32_t new_kext = 0; new_kext < new_kexts_size; new_kext++) {
1301 bool add_this_one =
true;
1302 for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) {
1305 to_be_added[new_kext] =
false;
1307 to_be_removed[old_kext] =
false;
1309 number_of_old_kexts_being_removed--;
1310 add_this_one =
false;
1317 if (kext_summaries[new_kext].GetUUID().IsValid() &&
1320 to_be_added[new_kext] =
false;
1324 number_of_new_kexts_being_added++;
1328 if (number_of_new_kexts_being_added == 0 &&
1329 number_of_old_kexts_being_removed == 0)
1334 if (number_of_new_kexts_being_added > 0 &&
1335 number_of_old_kexts_being_removed > 0) {
1336 s.
Printf(
"Loading %d kext modules and unloading %d kext modules ",
1337 number_of_new_kexts_being_added,
1338 number_of_old_kexts_being_removed);
1339 }
else if (number_of_new_kexts_being_added > 0) {
1340 s.
Printf(
"Loading %d kext modules ", number_of_new_kexts_being_added);
1341 }
else if (number_of_old_kexts_being_removed > 0) {
1342 s.
Printf(
"Unloading %d kext modules ", number_of_old_kexts_being_removed);
1349 "DynamicLoaderDarwinKernel::ParseKextSummaries: %d kexts "
1350 "added, %d kexts removed",
1351 number_of_new_kexts_being_added,
1352 number_of_old_kexts_being_removed);
1355 "DynamicLoaderDarwinKernel::ParseKextSummaries kext loading is "
1356 "disabled, else would have %d kexts added, %d kexts removed",
1357 number_of_new_kexts_being_added,
1358 number_of_old_kexts_being_removed);
1363 std::vector<std::pair<std::string, UUID>> kexts_failed_to_load;
1364 if (number_of_new_kexts_being_added > 0) {
1366 Progress progress(
"Loading kext",
"", number_of_new_kexts_being_added);
1368 const uint32_t num_of_new_kexts = kext_summaries.size();
1369 for (uint32_t new_kext = 0; new_kext < num_of_new_kexts; new_kext++) {
1370 if (to_be_added[new_kext]) {
1374 kexts_failed_to_load.push_back(std::pair<std::string, UUID>(
1375 kext_summaries[new_kext].
GetName(),
1376 kext_summaries[new_kext].GetUUID()));
1388 kext_summaries[new_kext].PutToLog(log);
1394 if (number_of_old_kexts_being_removed > 0) {
1397 for (uint32_t old_kext = 0; old_kext < num_of_old_kexts; old_kext++) {
1399 if (to_be_removed[old_kext]) {
1419 if (kexts_failed_to_load.size() > 0 && number_of_new_kexts_being_added > 0) {
1420 s.
Printf(
"Failed to load %d of %d kexts:\n",
1421 (
int)kexts_failed_to_load.size(),
1422 number_of_new_kexts_being_added);
1424 unsigned longest_name = 0;
1425 std::sort(kexts_failed_to_load.begin(), kexts_failed_to_load.end());
1426 for (
const auto &ku : kexts_failed_to_load) {
1427 if (ku.first.size() > longest_name)
1428 longest_name = ku.first.size();
1430 for (
const auto &ku : kexts_failed_to_load) {
1432 if (ku.second.IsValid())
1433 uuid = ku.second.GetAsString();
1434 s.
Printf(
" %-*s %s\n", longest_name, ku.first.c_str(), uuid.c_str());
1444 const Address &kext_summary_addr, uint32_t image_infos_count,
1449 image_infos.resize(image_infos_count);
1454 const bool force_live_memory =
true;
1457 if (bytes_read == count) {
1462 for (uint32_t kext_summary_offset = 0;
1463 i < image_infos.size() &&
1468 const void *name_data =
1470 if (name_data ==
nullptr)
1472 image_infos[i].SetName((
const char *)name_data);
1474 image_infos[i].SetUUID(uuid);
1475 image_infos[i].SetLoadAddress(extractor.
GetU64(&offset));
1476 image_infos[i].SetSize(extractor.
GetU64(&offset));
1478 if (i < image_infos.size())
1479 image_infos.resize(i);
1481 image_infos.clear();
1483 return image_infos.size();
1487 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1507 LLDB_LOG(log,
"uuid={0} name=\"{1}\" (UNLOADED)", m_uuid.GetAsString(),
1510 LLDB_LOG(log,
"addr={0:x+16} size={1:x+16} uuid={2} name=\"{3}\"",
1511 m_load_address, m_size, m_uuid.GetAsString(), m_name);
1521 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1523 "gLoadedKextSummaries = 0x%16.16" PRIx64
1524 " { version=%u, entry_size=%u, entry_count=%u }",
1533 for (i = 0; i < count; i++)
1539 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s() process state = %s\n",
1547 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s() process state = %s\n",
1550 const bool internal_bp =
true;
1551 const bool hardware =
false;
1558 "OSKextLoadedKextSummariesUpdated",
1560 skip_prologue, internal_bp, hardware)
1572 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s(%s)\n", __FUNCTION__,
1602 LLDB_LOGF(log,
"Could not find symbol for step through.");
1603 return thread_plan_sp;
1608 error.SetErrorString(
1609 "always unsafe to load or unload shared libraries in the darwin kernel");
1627 const bool is_global_setting =
true;
1630 "Properties for the DynamicLoaderDarwinKernel plug-in.",
1636 return "Dynamic loader plug-in that watches for shared library loads/unloads "
1637 "in the MacOSX kernel.";
1643 case llvm::MachO::MH_MAGIC:
1644 case llvm::MachO::MH_MAGIC_64:
1647 case llvm::MachO::MH_CIGAM:
1648 case llvm::MachO::MH_CIGAM_64:
static llvm::raw_ostream & error(Stream &strm)
static constexpr OptionEnumValueElement g_kaslr_kernel_scan_enum_values[]
@ eKASLRScanLowgloAddresses
@ eKASLRScanExhaustiveScan
#define DEBUG_PRINTF(fmt,...)
static bool is_kernel(Module *module)
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_PLUGIN_DEFINE(PluginName)
static llvm::StringRef GetName(XcodeSDK::Type type)
bool GetLoadKexts() const
KASLRScanType GetScanType() const
DynamicLoaderDarwinKernelProperties()
~DynamicLoaderDarwinKernelProperties() override=default
static llvm::StringRef GetSettingName()
uint32_t m_load_process_stop_id
void PutToLog(lldb_private::Log *log) const
bool operator==(const KextImageInfo &rhs) const
void SetLoadAddress(lldb::addr_t load_addr)
uint32_t GetAddressByteSize()
bool ReadMemoryModule(lldb_private::Process *process)
void SetProcessStopId(uint32_t stop_id)
lldb_private::ArchSpec GetArchitecture() const
lldb::ModuleSP GetModule()
void SetUUID(const lldb_private::UUID &uuid)
void SetName(const char *)
void SetModule(lldb::ModuleSP module)
bool LoadImageUsingMemoryModule(lldb_private::Process *process, lldb_private::Progress *progress=nullptr)
bool LoadImageAtFileAddress(lldb_private::Process *process)
void SetSize(uint64_t size)
lldb::addr_t GetLoadAddress() const
lldb::ByteOrder GetByteOrder()
std::string GetName() const
lldb::ModuleSP m_module_sp
void SetIsKernel(bool is_kernel)
uint32_t GetProcessStopId() const
lldb_private::UUID GetUUID() const
std::vector< KextImageInfo > collection
void DidLaunch() override
Called after attaching a process.
lldb_private::Address m_kext_summary_header_ptr_addr
void PrivateProcessStateChanged(lldb_private::Process *process, lldb::StateType state)
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override
Provides a plan to step through the dynamic loader trampoline for the current state of thread.
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
lldb_private::Address m_kext_summary_header_addr
static void DebuggerInitialize(lldb_private::Debugger &debugger)
static bool ReadMachHeader(lldb::addr_t addr, lldb_private::Process *process, llvm::MachO::mach_header &mh, bool *read_error=nullptr)
void PutToLog(lldb_private::Log *log) const
static lldb::addr_t SearchForKernelViaExhaustiveSearch(lldb_private::Process *process)
lldb::user_id_t m_break_id
static llvm::StringRef GetPluginDescriptionStatic()
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
void DidAttach() override
Called after attaching a process.
~DynamicLoaderDarwinKernel() override
static lldb::addr_t SearchForKernelAtSameLoadAddr(lldb_private::Process *process)
static llvm::StringRef GetPluginNameStatic()
bool ReadAllKextSummaries()
OSKextLoadedKextSummaryHeader m_kext_summary_header
void PrivateInitialize(lldb_private::Process *process)
DynamicLoaderDarwinKernel(lldb_private::Process *process, lldb::addr_t kernel_addr)
static lldb_private::UUID CheckForKernelImageAtAddress(lldb::addr_t addr, lldb_private::Process *process, bool *read_error=nullptr)
static bool BreakpointHitCallback(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
void Clear(bool clear_process)
static lldb::ByteOrder GetByteOrderFromMagic(uint32_t magic)
bool BreakpointHit(lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
std::recursive_mutex m_mutex
static lldb::addr_t SearchForKernelNearPC(lldb_private::Process *process)
uint32_t ReadKextSummaries(const lldb_private::Address &kext_summary_addr, uint32_t image_infos_count, KextImageInfo::collection &image_infos)
static lldb::addr_t SearchForDarwinKernel(lldb_private::Process *process)
KextImageInfo::collection m_known_kexts
void SetNotificationBreakpointIfNeeded()
lldb::addr_t m_kernel_load_address
void LoadKernelModuleIfNeeded()
bool ReadKextSummaryHeader()
static lldb::addr_t SearchForKernelWithDebugHints(lldb_private::Process *process)
bool ParseKextSummaries(const lldb_private::Address &kext_summary_addr, uint32_t count)
@ KERNEL_MODULE_ENTRY_SIZE_VERSION_1
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
void Clear()
Clear the object's state.
bool Slide(int64_t offset)
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsValid() const
Check if the object state is valid.
static lldb::addr_t AddressableBitToMask(uint32_t addressable_bits)
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::offset_t GetByteSize() const override
Get the number of bytes in the data buffer.
A class to manage flag bits.
StreamFile & GetOutputStream()
StreamFile & GetErrorStream()
PlatformList & GetPlatformList()
A plug-in interface definition class for dynamic loaders.
void LoadOperatingSystemPlugin(bool flush)
Process * m_process
The process that this dynamic loader plug-in is tracking.
bool GetStopWhenImagesChange() const
Get whether the process should stop when images change.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
static FileSystem & Instance()
void PutCString(const char *cstr)
A collection class for Module objects.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
lldb::ModuleSP FindModule(const Module *module_ptr) const
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
ModuleIterable Modules() const
ArchSpec & GetArchitecture()
A class that describes an executable image and its associated object and symbol files.
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
A plug-in interface definition class for object file parsers.
@ eTypeExecutable
A normal executable.
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
virtual lldb_private::Address GetBaseAddress()
Returns base address of this object file.
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static lldb::OptionValuePropertiesSP GetSettingForDynamicLoaderPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForDynamicLoaderPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
ThreadList & GetThreadList()
size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::ByteOrder GetByteOrder() const
void SetCodeAddressMask(lldb::addr_t code_address_mask)
lldb::StateType GetState()
Get accessor for the current process state.
void SetDataAddressMask(lldb::addr_t data_address_mask)
virtual lldb::addr_t GetImageInfoAddress()
Get the image information address for the current process.
void SetCanRunCode(bool can_run_code)
Sets whether executing code in this process is possible.
Status ClearBreakpointSiteByID(lldb::user_id_t break_id)
virtual bool IsAlive()
Check if a process is still alive.
uint32_t GetAddressByteSize() const
uint32_t GetStopID() const
lldb::addr_t GetDataAddressMask()
lldb::addr_t GetCodeAddressMask()
Get the current address mask in the Process.
lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, size_t size_to_read=512)
Target & GetTarget()
Get the target object pointer for this module.
A Progress indicator helper class.
void Increment(uint64_t amount=1, std::optional< std::string > updated_detail={})
Increment the progress and send a notification to the installed callback.
lldb::OptionValuePropertiesSP m_collection_sp
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
lldb::SectionSP GetSectionAtIndex(size_t idx) const
lldb::addr_t GetFileAddress() const
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
lldb::break_id_t GetID() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t PutHex64(uint64_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
virtual void Flush()=0
Flush the stream.
Address GetAddress() const
FileSpecList GetExecutableSearchPaths()
void ModulesDidLoad(ModuleList &module_list)
Module * GetExecutableModulePointer()
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
bool ReadPointerFromMemory(const Address &addr, Status &error, Address &pointer_addr, bool force_live_memory=false)
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr)
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
lldb::PlatformSP GetPlatform()
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
uint64_t ReadUnsignedIntegerFromMemory(const Address &addr, size_t integer_byte_size, uint64_t fail_value, Status &error, bool force_live_memory=false)
void SetPlatform(const lldb::PlatformSP &platform_sp)
bool SetSectionLoadAddress(const lldb::SectionSP §ion, lldb::addr_t load_addr, bool warn_multiple=false)
lldb::ThreadSP GetSelectedThread()
uint8_t * GetBytes()
Get a pointer to the data.
#define LLDB_INVALID_BREAK_ID
#define LLDB_BREAK_ID_IS_VALID(bid)
#define LLDB_INVALID_ADDRESS
lldb::ByteOrder InlHostByteOrder()
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.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::Platform > PlatformSP
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateLaunching
Process is in the process of launching.
@ eStateAttaching
Process is currently trying to attach.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateCrashed
Process or thread has crashed and can be examined.
@ eLanguageTypeUnknown
Unknown or invalid language value.
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Module > ModuleSP