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;
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) {
470 if (!memory_module_sp.get())
473 ObjectFile *exe_objfile = memory_module_sp->GetObjectFile();
474 if (exe_objfile ==
nullptr) {
476 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress "
477 "found a binary at 0x%" PRIx64
478 " but could not create an object file from memory",
490 std::string uuid_str;
491 if (memory_module_sp->GetUUID().IsValid()) {
492 uuid_str =
"with UUID ";
493 uuid_str += memory_module_sp->GetUUID().GetAsString();
495 uuid_str =
"and no LC_UUID found in load commands ";
499 "DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress: "
500 "kernel binary image found at 0x%" PRIx64
" with arch '%s' %s",
501 addr, kernel_arch.
GetTriple().str().c_str(), uuid_str.c_str());
503 return memory_module_sp->GetUUID();
520 process->
GetTarget().GetDebugger().GetPlatformList().Create(
522 if (platform_sp.get())
553 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
573 bool changed =
false;
656 llvm::MachO::mach_header mh;
657 size_t size_to_read = 512;
659 if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC)
660 size_to_read =
sizeof(llvm::MachO::mach_header) + mh.sizeofcmds;
661 if (mh.magic == llvm::MachO::MH_CIGAM_64 ||
662 mh.magic == llvm::MachO::MH_MAGIC_64)
663 size_to_read =
sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
669 if (memory_module_sp.get() ==
nullptr)
672 bool this_is_kernel =
is_kernel(memory_module_sp.get());
678 if (
m_uuid != memory_module_sp->GetUUID()) {
681 "KextImageInfo::ReadMemoryModule the kernel said to find "
682 "uuid %s at 0x%" PRIx64
683 " but instead we found uuid %s, throwing it away",
685 memory_module_sp->GetUUID().GetAsString().c_str());
692 if (!
m_uuid.IsValid() && memory_module_sp->GetUUID().IsValid()) {
693 m_uuid = memory_module_sp->GetUUID();
698 if (this_is_kernel) {
702 "KextImageInfo::ReadMemoryModule read the kernel binary out "
705 if (memory_module_sp->GetArchitecture().IsValid()) {
731 if (
m_uuid.IsValid() ==
false) {
735 "Unable to read '%s' from memory at address 0x%" PRIx64
736 " to get the segment load addresses.",
744 s->Printf(
"Kernel UUID: %s\n",
m_uuid.GetAsString().c_str());
754 incorrect_kernels.
Append(module_sp);
768 if (
GetName() !=
"mach_kernel")
771 prog_str <<
GetUUID().GetAsString() <<
" ";
777 std::unique_ptr<Progress> progress_up;
782 progress_up = std::make_unique<Progress>(
"Loading kernel",
785 progress_up = std::make_unique<Progress>(
"Loading kext",
805 platform_sp->GetSharedModule(module_spec, process,
m_module_sp,
806 &search_paths,
nullptr,
nullptr);
822 Status kernel_search_error;
826 module_spec, kernel_search_error,
true)) {
836 s->Printf(
"WARNING: Unable to locate kernel binary on the debugger "
838 if (kernel_search_error.
Fail() && kernel_search_error.
AsCString(
"") &&
839 kernel_search_error.
AsCString(
"")[0] !=
'\0') {
848 llvm::dyn_cast<ObjectFileMachO>(
m_module_sp->GetObjectFile())) {
849 if (!
IsKernel() && !ondisk_objfile_macho->IsKext()) {
853 if (existing_module_sp &&
854 existing_module_sp->IsLoadedInTarget(&target)) {
856 "'%s' with UUID %s is not a kext or kernel, and is "
857 "already registered in target, not loading.",
881 static ConstString g_section_name_LINKEDIT(
"__LINKEDIT");
888 if (memory_object_file && ondisk_object_file) {
891 const bool ignore_linkedit = !
IsKernel();
907 llvm::dyn_cast<ObjectFileMachO>(memory_object_file)) {
909 memory_objfile_macho->GetMachHeaderSection()) {
914 "kext %s in-memory LC_SEGMENT vmaddr is not correct, using a "
915 "fixed slide of 0x%" PRIx64,
916 m_name.c_str(), fixed_slide);
923 if (memory_section_list && ondisk_section_list) {
924 const uint32_t num_ondisk_sections = ondisk_section_list->
GetSize();
928 uint32_t sect_idx = 0;
935 uint32_t num_sections_loaded = 0;
936 for (sect_idx = 0; sect_idx < num_ondisk_sections; ++sect_idx) {
939 if (ondisk_section_sp) {
943 if (ignore_linkedit &&
944 ondisk_section_sp->GetName() == g_section_name_LINKEDIT)
950 ondisk_section_sp->GetFileAddress() + fixed_slide);
952 const Section *memory_section =
956 if (memory_section) {
959 ++num_sections_loaded;
964 if (num_sections_loaded > 0)
981 if (kernel_object_file) {
986 s->Printf(
"Kernel slid 0x%" PRIx64
" in memory.\n",
990 s->Printf(
"Loaded kernel file %s\n",
1009 return m_module_sp->GetArchitecture().GetAddressByteSize();
1017 return m_module_sp->GetArchitecture().GetByteOrder();
1050 m_kernel.GetModule()->GetObjectFile()->GetFileSpec().GetFilename();
1061 if (kernel_object_file) {
1068 m_kernel.SetLoadAddress(load_address);
1069 if (load_address != file_address) {
1076 m_kernel.SetLoadAddress(file_address);
1092 static ConstString kext_summary_symbol(
"gLoadedKextSummaries");
1095 m_kernel.GetModule()->FindFirstSymbolWithNameAndType(
1108 symbol =
m_kernel.GetModule()->FindFirstSymbolWithNameAndType(
1119 const size_t sym_bytesize = 8;
1120 uint64_t sym_value =
1121 m_process->GetTarget().ReadUnsignedIntegerFromMemory(
1123 if (
error.Success()) {
1129 uint32_t virt_addr_bits = 64 - sym_value;
1134 m_process->SetCodeAddressMask(orig_code_mask);
1135 m_process->SetDataAddressMask(orig_data_mask);
1152 context, break_id, break_loc_id);
1159 LLDB_LOGF(log,
"DynamicLoaderDarwinKernel::BreakpointHit (...)\n");
1170 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1175 const uint32_t addr_size =
m_kernel.GetAddressByteSize();
1181 DataExtractor data(buf,
sizeof(buf), byte_order, addr_size);
1182 const size_t count = 4 *
sizeof(uint32_t) + addr_size;
1183 const bool force_live_memory =
true;
1184 if (
m_process->GetTarget().ReadPointerFromMemory(
1191 const size_t bytes_read =
m_process->GetTarget().ReadMemory(
1193 if (bytes_read == count) {
1198 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1199 s->Printf(
"WARNING: Unable to read kext summary header, got "
1200 "improbable version number %u\n",
1213 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1214 s->Printf(
"WARNING: Unable to read kext summary header, got "
1215 "improbable entry_size %u\n",
1231 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1232 s->Printf(
"WARNING: Unable to read kext summary header, got "
1233 "improbable number of kexts %u\n",
1254 const Address &kext_summary_addr, uint32_t count) {
1258 "Kexts-changed breakpoint hit, there are %d kexts currently.\n",
1261 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1274 std::vector<bool> to_be_removed(
m_known_kexts.size(),
true);
1275 std::vector<bool> to_be_added(count,
true);
1277 int number_of_new_kexts_being_added = 0;
1278 int number_of_old_kexts_being_removed =
m_known_kexts.size();
1280 const uint32_t new_kexts_size = kext_summaries.size();
1285 for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) {
1286 bool ignore =
false;
1296 number_of_old_kexts_being_removed--;
1297 to_be_removed[old_kext] =
false;
1303 for (uint32_t new_kext = 0; new_kext < new_kexts_size; new_kext++) {
1304 bool add_this_one =
true;
1305 for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) {
1308 to_be_added[new_kext] =
false;
1310 to_be_removed[old_kext] =
false;
1312 number_of_old_kexts_being_removed--;
1313 add_this_one =
false;
1320 if (kext_summaries[new_kext].GetUUID().IsValid() &&
1322 kext_summaries[new_kext].GetUUID() ==
m_kernel.GetUUID()) {
1323 to_be_added[new_kext] =
false;
1327 number_of_new_kexts_being_added++;
1331 if (number_of_new_kexts_being_added == 0 &&
1332 number_of_old_kexts_being_removed == 0)
1336 m_process->GetTarget().GetDebugger().GetAsyncOutputStream();
1338 if (number_of_new_kexts_being_added > 0 &&
1339 number_of_old_kexts_being_removed > 0) {
1340 s->Printf(
"Loading %d kext modules and unloading %d kext modules ",
1341 number_of_new_kexts_being_added,
1342 number_of_old_kexts_being_removed);
1343 }
else if (number_of_new_kexts_being_added > 0) {
1344 s->Printf(
"Loading %d kext modules ", number_of_new_kexts_being_added);
1345 }
else if (number_of_old_kexts_being_removed > 0) {
1346 s->Printf(
"Unloading %d kext modules ",
1347 number_of_old_kexts_being_removed);
1354 "DynamicLoaderDarwinKernel::ParseKextSummaries: %d kexts "
1355 "added, %d kexts removed",
1356 number_of_new_kexts_being_added,
1357 number_of_old_kexts_being_removed);
1360 "DynamicLoaderDarwinKernel::ParseKextSummaries kext loading is "
1361 "disabled, else would have %d kexts added, %d kexts removed",
1362 number_of_new_kexts_being_added,
1363 number_of_old_kexts_being_removed);
1368 std::vector<std::pair<std::string, UUID>> kexts_failed_to_load;
1369 if (number_of_new_kexts_being_added > 0) {
1371 Progress progress(
"Loading kext",
"", number_of_new_kexts_being_added);
1373 const uint32_t num_of_new_kexts = kext_summaries.size();
1374 for (uint32_t new_kext = 0; new_kext < num_of_new_kexts; new_kext++) {
1375 if (to_be_added[new_kext]) {
1379 kexts_failed_to_load.push_back(std::pair<std::string, UUID>(
1380 kext_summaries[new_kext].
GetName(),
1381 kext_summaries[new_kext].GetUUID()));
1393 kext_summaries[new_kext].PutToLog(log);
1396 m_process->GetTarget().ModulesDidLoad(loaded_module_list);
1399 if (number_of_old_kexts_being_removed > 0) {
1402 for (uint32_t old_kext = 0; old_kext < num_of_old_kexts; old_kext++) {
1404 if (to_be_removed[old_kext]) {
1418 m_process->GetTarget().ModulesDidUnload(unloaded_module_list,
false);
1423 s->Printf(
" done.\n");
1424 if (kexts_failed_to_load.size() > 0 && number_of_new_kexts_being_added > 0) {
1425 s->Printf(
"Failed to load %d of %d kexts:\n",
1426 (
int)kexts_failed_to_load.size(),
1427 number_of_new_kexts_being_added);
1429 unsigned longest_name = 0;
1430 std::sort(kexts_failed_to_load.begin(), kexts_failed_to_load.end());
1431 for (
const auto &ku : kexts_failed_to_load) {
1432 if (ku.first.size() > longest_name)
1433 longest_name = ku.first.size();
1435 for (
const auto &ku : kexts_failed_to_load) {
1437 if (ku.second.IsValid())
1438 uuid = ku.second.GetAsString();
1439 s->Printf(
" %-*s %s\n", longest_name, ku.first.c_str(), uuid.c_str());
1448 const Address &kext_summary_addr, uint32_t image_infos_count,
1451 const uint32_t addr_size =
m_kernel.GetAddressByteSize();
1453 image_infos.resize(image_infos_count);
1458 const bool force_live_memory =
true;
1459 const size_t bytes_read =
m_process->GetTarget().ReadMemory(
1461 if (bytes_read == count) {
1466 for (uint32_t kext_summary_offset = 0;
1467 i < image_infos.size() &&
1472 const void *name_data =
1474 if (name_data ==
nullptr)
1476 image_infos[i].SetName((
const char *)name_data);
1478 image_infos[i].SetUUID(uuid);
1479 image_infos[i].SetLoadAddress(extractor.
GetU64(&offset));
1480 image_infos[i].SetSize(extractor.
GetU64(&offset));
1482 if (i < image_infos.size())
1483 image_infos.resize(i);
1485 image_infos.clear();
1487 return image_infos.size();
1491 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1511 LLDB_LOG(log,
"uuid={0} name=\"{1}\" (UNLOADED)",
m_uuid.GetAsString(),
1514 LLDB_LOG(log,
"addr={0:x+16} size={1:x+16} uuid={2} name=\"{3}\"",
1525 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1527 "gLoadedKextSummaries = 0x%16.16" PRIx64
1528 " { version=%u, entry_size=%u, entry_count=%u }",
1537 for (i = 0; i < count; i++)
1543 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s() process state = %s\n",
1551 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s() process state = %s\n",
1554 const bool internal_bp =
true;
1555 const bool hardware =
false;
1561 .CreateBreakpoint(&module_spec_list,
nullptr,
1562 "OSKextLoadedKextSummariesUpdated",
1564 false, skip_prologue,
1565 internal_bp, hardware)
1577 DEBUG_PRINTF(
"DynamicLoaderDarwinKernel::%s(%s)\n", __FUNCTION__,
1607 LLDB_LOGF(log,
"Could not find symbol for step through.");
1608 return thread_plan_sp;
1614 "always unsafe to load or unload shared libraries in the darwin kernel");
1632 const bool is_global_setting =
true;
1635 "Properties for the DynamicLoaderDarwinKernel plug-in.",
1641 return "Dynamic loader plug-in that watches for shared library loads/unloads "
1642 "in the MacOSX kernel.";
1648 case llvm::MachO::MH_MAGIC:
1649 case llvm::MachO::MH_MAGIC_64:
1652 case llvm::MachO::MH_CIGAM:
1653 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
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
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)
@ KERNEL_MODULE_ENTRY_SIZE_VERSION_1
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()
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
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
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
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
FileSpecList GetExecutableSearchPaths()
void ModulesDidLoad(ModuleList &module_list)
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