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;
109 m_collection_sp->Initialize(g_dynamicloaderdarwinkernel_properties_def);
115 const uint32_t idx = ePropertyLoadKexts;
118 g_dynamicloaderdarwinkernel_properties[idx].default_uint_value != 0);
122 const uint32_t idx = ePropertyScanType;
126 g_dynamicloaderdarwinkernel_properties[idx].default_uint_value));
138 ObjectFile *objfile =
module->GetObjectFile();
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::BridgeOS:
172 case llvm::Triple::DriverKit:
173 case llvm::Triple::XROS:
174 if (triple_ref.getVendor() != llvm::Triple::Apple) {
180 case llvm::Triple::UnknownOS:
210 return kernel_load_address;
245 addr_t kernel_addresses_64[] = {
246 0xfffffff000002010ULL,
247 0xfffffe0000004010ULL,
248 0xfffffff000004010ULL,
249 0xffffff8000004010ULL,
250 0xffffff8000002010ULL,
252 addr_t kernel_addresses_32[] = {0xffff0110,
263 uint64_t addr = data.
GetU64(&offset);
278 uint32_t addr = data.
GetU32(&offset);
302 if (thread.get() ==
nullptr)
311 if ((
pc & (1ULL << 63)) == 0) {
315 if ((
pc & (1ULL << 31)) == 0) {
323 int pagesize = 0x4000;
329 addr_t addr =
pc & ~(pagesize - 1ULL);
332 while (
pc - addr < 128 * 0x100000) {
339 if (read_error ==
true)
358 addr_t kernel_range_low, kernel_range_high;
360 kernel_range_low = 1ULL << 63;
363 kernel_range_low = 1ULL << 31;
374 addr_t addr = kernel_range_low;
376 while (addr >= kernel_range_low && addr < kernel_range_high) {
382 return addr + 0x1000;
385 return addr + 0x4000;
411 const uint32_t magicks[] = { llvm::MachO::MH_MAGIC_64, llvm::MachO::MH_MAGIC, llvm::MachO::MH_CIGAM, llvm::MachO::MH_CIGAM_64};
413 bool found_matching_pattern =
false;
414 for (
size_t i = 0; i < std::size(magicks); i++)
415 if (::memcmp (&header.magic, &magicks[i], sizeof (uint32_t)) == 0)
416 found_matching_pattern =
true;
418 if (!found_matching_pattern)
421 if (header.magic == llvm::MachO::MH_CIGAM ||
422 header.magic == llvm::MachO::MH_CIGAM_64) {
423 header.magic = llvm::byteswap<uint32_t>(header.magic);
424 header.cputype = llvm::byteswap<uint32_t>(header.cputype);
425 header.cpusubtype = llvm::byteswap<uint32_t>(header.cpusubtype);
426 header.filetype = llvm::byteswap<uint32_t>(header.filetype);
427 header.ncmds = llvm::byteswap<uint32_t>(header.ncmds);
428 header.sizeofcmds = llvm::byteswap<uint32_t>(header.sizeofcmds);
429 header.flags = llvm::byteswap<uint32_t>(header.flags);
451 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
452 "looking for kernel binary at 0x%" PRIx64,
455 llvm::MachO::mach_header header;
465 if (header.filetype == llvm::MachO::MH_EXECUTE &&
466 (header.flags & llvm::MachO::MH_DYLDLINK) == 0) {
468 llvm::Expected<ModuleSP> memory_module_sp_or_err =
470 if (
auto err = memory_module_sp_or_err.takeError()) {
472 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
473 "Failed to read module in memory -- {0}");
476 ModuleSP memory_module_sp = *memory_module_sp_or_err;
477 if (!memory_module_sp.get())
480 ObjectFile *exe_objfile = memory_module_sp->GetObjectFile();
481 if (exe_objfile ==
nullptr) {
483 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress "
484 "found a binary at 0x%" PRIx64
485 " but could not create an object file from memory",
497 std::string uuid_str;
498 if (memory_module_sp->GetUUID().IsValid()) {
499 uuid_str =
"with UUID ";
500 uuid_str += memory_module_sp->GetUUID().GetAsString();
502 uuid_str =
"and no LC_UUID found in load commands ";
506 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
507 "kernel binary image found at 0x%" PRIx64
" with arch '%s' %s",
508 addr, kernel_arch.
GetTriple().str().c_str(), uuid_str.c_str());
510 return memory_module_sp->GetUUID();
527 process->
GetTarget().GetDebugger().GetPlatformList().Create(
529 if (platform_sp.get())
560 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
580 bool changed =
false;
663 llvm::MachO::mach_header mh;
664 size_t size_to_read = 512;
666 if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC)
667 size_to_read =
sizeof(llvm::MachO::mach_header) + mh.sizeofcmds;
668 if (mh.magic == llvm::MachO::MH_CIGAM_64 ||
669 mh.magic == llvm::MachO::MH_MAGIC_64)
670 size_to_read =
sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
673 llvm::Expected<ModuleSP> memory_module_sp_or_err =
675 if (
auto err = memory_module_sp_or_err.takeError()) {
677 "KextImageInfo::ReadMemoryModule failed to read module from "
682 ModuleSP memory_module_sp = *memory_module_sp_or_err;
683 if (memory_module_sp.get() ==
nullptr)
686 bool this_is_kernel =
is_kernel(memory_module_sp.get());
692 if (
m_uuid != memory_module_sp->GetUUID()) {
695 "KextImageInfo::ReadMemoryModule the kernel said to find "
696 "uuid %s at 0x%" PRIx64
697 " but instead we found uuid %s, throwing it away",
699 memory_module_sp->GetUUID().GetAsString().c_str());
706 if (!
m_uuid.IsValid() && memory_module_sp->GetUUID().IsValid()) {
707 m_uuid = memory_module_sp->GetUUID();
712 if (this_is_kernel) {
716 "KextImageInfo::ReadMemoryModule read the kernel binary out "
719 if (memory_module_sp->GetArchitecture().IsValid()) {
745 if (
m_uuid.IsValid() ==
false) {
749 "Unable to read '%s' from memory at address 0x%" PRIx64
750 " to get the segment load addresses.",
758 s->Printf(
"Kernel UUID: %s\n",
m_uuid.GetAsString().c_str());
768 incorrect_kernels.
Append(module_sp);
782 if (
GetName() !=
"mach_kernel")
785 prog_str <<
GetUUID().GetAsString() <<
" ";
791 std::unique_ptr<Progress> progress_up;
796 progress_up = std::make_unique<Progress>(
"Loading kernel",
799 progress_up = std::make_unique<Progress>(
"Loading kext",
806 module_spec.
SetTarget(target.shared_from_this());
819 platform_sp->GetSharedModule(module_spec, process,
m_module_sp,
nullptr,
836 Status kernel_search_error;
840 module_spec, kernel_search_error,
true)) {
850 s->Printf(
"WARNING: Unable to locate kernel binary on the debugger "
852 if (kernel_search_error.
Fail() && kernel_search_error.
AsCString(
"") &&
853 kernel_search_error.
AsCString(
"")[0] !=
'\0') {
862 llvm::dyn_cast<ObjectFileMachO>(
m_module_sp->GetObjectFile())) {
863 if (!
IsKernel() && !ondisk_objfile_macho->IsKext()) {
867 if (existing_module_sp &&
868 existing_module_sp->IsLoadedInTarget(&target)) {
870 "'%s' with UUID %s is not a kext or kernel, and is "
871 "already registered in target, not loading.",
895 static ConstString g_section_name_LINKEDIT(
"__LINKEDIT");
902 if (memory_object_file && ondisk_object_file) {
905 const bool ignore_linkedit = !
IsKernel();
921 llvm::dyn_cast<ObjectFileMachO>(memory_object_file)) {
923 memory_objfile_macho->GetMachHeaderSection()) {
928 "kext %s in-memory LC_SEGMENT vmaddr is not correct, using a "
929 "fixed slide of 0x%" PRIx64,
930 m_name.c_str(), fixed_slide);
937 if (memory_section_list && ondisk_section_list) {
938 const uint32_t num_ondisk_sections = ondisk_section_list->
GetSize();
942 uint32_t sect_idx = 0;
949 uint32_t num_sections_loaded = 0;
950 for (sect_idx = 0; sect_idx < num_ondisk_sections; ++sect_idx) {
953 if (ondisk_section_sp) {
957 if (ignore_linkedit &&
958 ondisk_section_sp->GetName() == g_section_name_LINKEDIT)
964 ondisk_section_sp->GetFileAddress() + fixed_slide);
966 const Section *memory_section =
970 if (memory_section) {
973 ++num_sections_loaded;
978 if (num_sections_loaded > 0)
995 if (kernel_object_file) {
1000 s->Printf(
"Kernel slid 0x%" PRIx64
" in memory.\n",
1004 s->Printf(
"Loaded kernel file %s\n",
1023 return m_module_sp->GetArchitecture().GetAddressByteSize();
1031 return m_module_sp->GetArchitecture().GetByteOrder();
1064 m_kernel.GetModule()->GetObjectFile()->GetFileSpec().GetFilename();
1075 if (kernel_object_file) {
1082 m_kernel.SetLoadAddress(load_address);
1083 if (load_address != file_address) {
1090 m_kernel.SetLoadAddress(file_address);
1106 static ConstString kext_summary_symbol(
"gLoadedKextSummaries");
1109 m_kernel.GetModule()->FindFirstSymbolWithNameAndType(
1122 symbol =
m_kernel.GetModule()->FindFirstSymbolWithNameAndType(
1133 const size_t sym_bytesize = 8;
1134 uint64_t sym_value =
1135 m_process->GetTarget().ReadUnsignedIntegerFromMemory(
1137 if (
error.Success()) {
1143 uint32_t virt_addr_bits = 64 - sym_value;
1148 m_process->SetCodeAddressMask(orig_code_mask);
1149 m_process->SetDataAddressMask(orig_data_mask);
1166 context, break_id, break_loc_id);
1173 LLDB_LOGF(log,
"DynamicLoaderDarwinKernel::BreakpointHit (...)\n");
1184 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1189 const uint32_t addr_size =
m_kernel.GetAddressByteSize();
1195 DataExtractor data(buf,
sizeof(buf), byte_order, addr_size);
1196 const size_t count = 4 *
sizeof(uint32_t) + addr_size;
1197 const bool force_live_memory =
true;
1198 if (
m_process->GetTarget().ReadPointerFromMemory(
1205 const size_t bytes_read =
m_process->GetTarget().ReadMemory(
1207 if (bytes_read == count) {
1212 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1213 s->Printf(
"WARNING: Unable to read kext summary header, got "
1214 "improbable version number %u\n",
1227 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1228 s->Printf(
"WARNING: Unable to read kext summary header, got "
1229 "improbable entry_size %u\n",
1245 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1246 s->Printf(
"WARNING: Unable to read kext summary header, got "
1247 "improbable number of kexts %u\n",
1268 const Address &kext_summary_addr, uint32_t count) {
1272 "Kexts-changed breakpoint hit, there are %d kexts currently.\n",
1275 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1288 std::vector<bool> to_be_removed(
m_known_kexts.size(),
true);
1289 std::vector<bool> to_be_added(count,
true);
1291 int number_of_new_kexts_being_added = 0;
1292 int number_of_old_kexts_being_removed =
m_known_kexts.size();
1294 const uint32_t new_kexts_size = kext_summaries.size();
1299 for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) {
1300 bool ignore =
false;
1310 number_of_old_kexts_being_removed--;
1311 to_be_removed[old_kext] =
false;
1317 for (uint32_t new_kext = 0; new_kext < new_kexts_size; new_kext++) {
1318 bool add_this_one =
true;
1319 for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) {
1322 to_be_added[new_kext] =
false;
1324 to_be_removed[old_kext] =
false;
1326 number_of_old_kexts_being_removed--;
1327 add_this_one =
false;
1334 if (kext_summaries[new_kext].GetUUID().IsValid() &&
1336 kext_summaries[new_kext].GetUUID() ==
m_kernel.GetUUID()) {
1337 to_be_added[new_kext] =
false;
1341 number_of_new_kexts_being_added++;
1345 if (number_of_new_kexts_being_added == 0 &&
1346 number_of_old_kexts_being_removed == 0)
1350 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1352 if (number_of_new_kexts_being_added > 0 &&
1353 number_of_old_kexts_being_removed > 0) {
1354 s->Printf(
"Loading %d kext modules and unloading %d kext modules ",
1355 number_of_new_kexts_being_added,
1356 number_of_old_kexts_being_removed);
1357 }
else if (number_of_new_kexts_being_added > 0) {
1358 s->Printf(
"Loading %d kext modules ", number_of_new_kexts_being_added);
1359 }
else if (number_of_old_kexts_being_removed > 0) {
1360 s->Printf(
"Unloading %d kext modules ",
1361 number_of_old_kexts_being_removed);
1368 "DynamicLoaderDarwinKernel::ParseKextSummaries: %d kexts "
1369 "added, %d kexts removed",
1370 number_of_new_kexts_being_added,
1371 number_of_old_kexts_being_removed);
1374 "DynamicLoaderDarwinKernel::ParseKextSummaries kext loading is "
1375 "disabled, else would have %d kexts added, %d kexts removed",
1376 number_of_new_kexts_being_added,
1377 number_of_old_kexts_being_removed);
1382 std::vector<std::pair<std::string, UUID>> kexts_failed_to_load;
1383 if (number_of_new_kexts_being_added > 0) {
1385 Progress progress(
"Loading kext",
"", number_of_new_kexts_being_added);
1387 const uint32_t num_of_new_kexts = kext_summaries.size();
1388 for (uint32_t new_kext = 0; new_kext < num_of_new_kexts; new_kext++) {
1389 if (to_be_added[new_kext]) {
1393 kexts_failed_to_load.push_back(std::pair<std::string, UUID>(
1394 kext_summaries[new_kext].
GetName(),
1395 kext_summaries[new_kext].GetUUID()));
1407 kext_summaries[new_kext].PutToLog(log);
1410 m_process->GetTarget().ModulesDidLoad(loaded_module_list);
1413 if (number_of_old_kexts_being_removed > 0) {
1416 for (uint32_t old_kext = 0; old_kext < num_of_old_kexts; old_kext++) {
1418 if (to_be_removed[old_kext]) {
1432 m_process->GetTarget().ModulesDidUnload(unloaded_module_list,
false);
1437 s->Printf(
" done.\n");
1438 if (kexts_failed_to_load.size() > 0 && number_of_new_kexts_being_added > 0) {
1439 s->Printf(
"Failed to load %d of %d kexts:\n",
1440 (
int)kexts_failed_to_load.size(),
1441 number_of_new_kexts_being_added);
1443 unsigned longest_name = 0;
1444 std::sort(kexts_failed_to_load.begin(), kexts_failed_to_load.end());
1445 for (
const auto &ku : kexts_failed_to_load) {
1446 if (ku.first.size() > longest_name)
1447 longest_name = ku.first.size();
1449 for (
const auto &ku : kexts_failed_to_load) {
1451 if (ku.second.IsValid())
1452 uuid = ku.second.GetAsString();
1453 s->Printf(
" %-*s %s\n", longest_name, ku.first.c_str(), uuid.c_str());
1462 const Address &kext_summary_addr, uint32_t image_infos_count,
1465 const uint32_t addr_size =
m_kernel.GetAddressByteSize();
1467 image_infos.resize(image_infos_count);
1472 const bool force_live_memory =
true;
1473 const size_t bytes_read =
m_process->GetTarget().ReadMemory(
1475 if (bytes_read == count) {
1480 for (uint32_t kext_summary_offset = 0;
1481 i < image_infos.size() &&
1486 const void *name_data =
1488 if (name_data ==
nullptr)
1490 image_infos[i].SetName((
const char *)name_data);
1492 image_infos[i].SetUUID(uuid);
1493 image_infos[i].SetLoadAddress(extractor.
GetU64(&offset));
1494 image_infos[i].SetSize(extractor.
GetU64(&offset));
1496 if (i < image_infos.size())
1497 image_infos.resize(i);
1499 image_infos.clear();
1501 return image_infos.size();
1505 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1525 LLDB_LOG(log,
"uuid={0} name=\"{1}\" (UNLOADED)",
m_uuid.GetAsString(),
1528 LLDB_LOG(log,
"addr={0:x+16} size={1:x+16} uuid={2} name=\"{3}\"",
1539 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1541 "gLoadedKextSummaries = 0x%16.16" PRIx64
1542 " { version=%u, entry_size=%u, entry_count=%u }",
1551 for (i = 0; i < count; i++)
1557 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s() process state = %s\n",
1566 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s() process state = %s\n",
1569 const bool internal_bp =
true;
1570 const bool hardware =
false;
1576 .CreateBreakpoint(&module_spec_list,
nullptr,
1577 "OSKextLoadedKextSummariesUpdated",
1579 false, skip_prologue,
1580 internal_bp, hardware)
1592 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s(%s)\n", __FUNCTION__,
1622 LLDB_LOGF(log,
"Could not find symbol for step through.");
1623 return thread_plan_sp;
1629 "always unsafe to load or unload shared libraries in the darwin kernel");
1647 const bool is_global_setting =
true;
1650 "Properties for the DynamicLoaderDarwinKernel plug-in.",
1656 return "Dynamic loader plug-in that watches for shared library loads/unloads "
1657 "in the MacOSX kernel.";
1663 case llvm::MachO::MH_MAGIC:
1664 case llvm::MachO::MH_MAGIC_64:
1667 case llvm::MachO::MH_CIGAM:
1668 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_LOG_ERROR(log, error,...)
#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
lldb::ModuleSP m_memory_module_sp
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_private::UUID m_uuid
lldb::addr_t m_load_address
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
@ KERNEL_MODULE_ENTRY_SIZE_VERSION_1
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)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
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.
lldb::StreamUP GetAsyncErrorStream()
lldb::StreamUP GetAsyncOutputStream()
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.
DynamicLoader(Process *process)
Construct with a process.
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()
void SetTarget(lldb::TargetSP target)
Set the target to be used when resolving a module.
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
llvm::Expected< lldb::ModuleSP > ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, size_t size_to_read=512)
Creates and populates a module using an in-memory object file.
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.
uint32_t GetAddressByteSize() const
uint32_t GetStopID() const
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
T GetPropertyAtIndexAs(uint32_t idx, T default_value, const ExecutionContext *exe_ctx=nullptr) const
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
lldb::SectionSP GetSectionAtIndex(size_t idx) const
lldb::addr_t GetFileAddress() const
static Status FromErrorString(const char *str)
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
size_t PutHex64(uint64_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Address GetAddress() const
void ModulesDidLoad(ModuleList &module_list)
This call may preload module symbols, and may do so in parallel depending on the following target set...
Module * GetExecutableModulePointer()
Debugger & GetDebugger() const
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 SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
lldb::PlatformSP GetPlatform()
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
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()
Represents UUID's of various sizes.
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.
std::shared_ptr< lldb_private::Stream > StreamSP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::Section > SectionSP
std::unique_ptr< lldb_private::Stream > StreamUP
std::shared_ptr< lldb_private::Module > ModuleSP