//===-- DynamicLoaderMacOS.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Target/ABI.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "DynamicLoaderDarwin.h" #include "DynamicLoaderMacOS.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" usingnamespacelldb; usingnamespacelldb_private; // Create an instance of this class. This function is filled into the plugin // info class that gets handed out by the plugin factory and allows the lldb to // instantiate an instance of this class. DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process, bool force) { … } // Constructor DynamicLoaderMacOS::DynamicLoaderMacOS(Process *process) : … { … } // Destructor DynamicLoaderMacOS::~DynamicLoaderMacOS() { … } bool DynamicLoaderMacOS::ProcessDidExec() { … } // Clear out the state of this class. void DynamicLoaderMacOS::DoClear() { … } bool DynamicLoaderMacOS::IsFullyInitialized() { … } // Check if we have found DYLD yet bool DynamicLoaderMacOS::DidSetNotificationBreakpoint() { … } void DynamicLoaderMacOS::ClearNotificationBreakpoint() { … } // Try and figure out where dyld is by first asking the Process if it knows // (which currently calls down in the lldb::Process to get the DYLD info // (available on SnowLeopard only). If that fails, then check in the default // addresses. void DynamicLoaderMacOS::DoInitialImageFetch() { … } bool DynamicLoaderMacOS::NeedToDoInitialImageFetch() { … } // Static callback function that gets called when our DYLD notification // breakpoint gets hit. We update all of our image infos and then let our super // class DynamicLoader class decide if we should stop or not (based on global // preference). bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id) { … } void DynamicLoaderMacOS::AddBinaries( const std::vector<lldb::addr_t> &load_addresses) { … } // Dump the _dyld_all_image_infos members and all current image infos that we // have parsed to the file handle provided. void DynamicLoaderMacOS::PutToLog(Log *log) const { … } // Look in dyld's dyld_all_image_infos structure for the address // of the notification function. // We can find the address of dyld_all_image_infos by a system // call, even if we don't have a dyld binary registered in lldb's // image list. // At process launch time - before dyld has executed any instructions - // the address of the notification function is not a resolved vm address // yet. dyld_all_image_infos also has a field with its own address // in it, and this will also be unresolved when we're at this state. // So we can compare the address of the object with this field and if // they differ, dyld hasn't started executing yet and we can't get the // notification address this way. addr_t DynamicLoaderMacOS::GetNotificationFuncAddrFromImageInfos() { … } // We want to put a breakpoint on dyld's lldb_image_notifier() // but we may have attached to the process during the // transition from on-disk-dyld to shared-cache-dyld, so there's // officially no dyld binary loaded in the process (libdyld will // report none when asked), but the kernel can find the dyld_all_image_infos // struct and the function pointer for lldb_image_notifier is in // that struct. bool DynamicLoaderMacOS::SetNotificationBreakpoint() { … } bool DynamicLoaderMacOS::SetDYLDHandoverBreakpoint( addr_t notification_address) { … } void DynamicLoaderMacOS::ClearDYLDHandoverBreakpoint() { … } addr_t DynamicLoaderMacOS::GetDyldLockVariableAddressFromModule(Module *module) { … } // Look for this symbol: // // int __attribute__((visibility("hidden"))) _dyld_global_lock_held = // 0; // // in libdyld.dylib. Status DynamicLoaderMacOS::CanLoadImage() { … } bool DynamicLoaderMacOS::GetSharedCacheInformation( lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache) { … } void DynamicLoaderMacOS::Initialize() { … } void DynamicLoaderMacOS::Terminate() { … } llvm::StringRef DynamicLoaderMacOS::GetPluginDescriptionStatic() { … }