50      const llvm::Triple &triple_ref =
 
   52      switch (triple_ref.getOS()) {
 
   53      case llvm::Triple::Darwin:
 
   54      case llvm::Triple::MacOSX:
 
   55      case llvm::Triple::IOS:
 
   56      case llvm::Triple::TvOS:
 
   57      case llvm::Triple::WatchOS:
 
   58      case llvm::Triple::BridgeOS:
 
   59      case llvm::Triple::DriverKit:
 
   60      case llvm::Triple::XROS:
 
   61        create = triple_ref.getVendor() == llvm::Triple::Apple;
 
 
   96  std::lock_guard<std::recursive_mutex> baseclass_guard(
GetMutex());
 
   97  bool did_exec = 
false;
 
  100    if (
m_process->GetThreadList().GetSize() == 1) {
 
  121                frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
 
  123              if (symbol->
GetName() == 
"_dyld_start")
 
 
  142  std::lock_guard<std::recursive_mutex> guard(
m_mutex);
 
 
  159      m_process->GetDynamicLoaderProcessState());
 
  160  if (!process_state_sp)
 
  162  if (process_state_sp->GetAsDictionary()->HasKey(
"error"))
 
  164  if (!process_state_sp->GetAsDictionary()->HasKey(
"process_state string"))
 
  166  std::string proc_state = process_state_sp->GetAsDictionary()
 
  167                               ->GetValueForKey(
"process_state string")
 
  171  if (proc_state == 
"dyld_process_state_not_started" ||
 
  172      proc_state == 
"dyld_process_state_dyld_initialized" ||
 
  173      proc_state == 
"dyld_process_state_terminated_before_inits") {
 
 
  206      m_process->GetLoadedDynamicLibrariesInfos());
 
  207  ImageInfo::collection image_infos;
 
  208  if (all_image_info_json_sp.get() &&
 
  209      all_image_info_json_sp->GetAsDictionary() &&
 
  210      all_image_info_json_sp->GetAsDictionary()->HasKey(
"images") &&
 
  211      all_image_info_json_sp->GetAsDictionary()
 
  212          ->GetValueForKey(
"images")
 
  216      LLDB_LOGF(log, 
"Initial module fetch:  Adding %" PRId64 
" modules.\n",
 
  217                (uint64_t)image_infos.size());
 
 
  300    argument_values.
PushValue(headers_value);
 
  302    if (abi->GetArgumentValues(exe_ctx.
GetThreadRef(), argument_values)) {
 
  305      if (dyld_mode != 
static_cast<uint32_t
>(-1)) {
 
  308        uint32_t image_infos_count =
 
  310        if (image_infos_count != 
static_cast<uint32_t
>(-1)) {
 
  313          if (header_array != 
static_cast<uint64_t
>(-1)) {
 
  314            std::vector<addr_t> image_load_addresses;
 
  327            for (uint64_t i = 0; i < image_infos_count; i++) {
 
  329              addr_t dyld_image_info = header_array + (addrsize * 3 * i);
 
  332              if (
error.Success()) {
 
  333                image_load_addresses.push_back(addr);
 
  336                    "DynamicLoaderMacOS::NotifyBreakpointHit unable " 
  337                    "to read binary mach-o load address at 0x%" PRIx64,
 
  341            if (dyld_mode == 0) {
 
  359            } 
else if (dyld_mode == 1) {
 
  362            } 
else if (dyld_mode == 2) {
 
  365            } 
else if (dyld_mode == 3 && image_infos_count == 1) {
 
  377              addr_t notification_location = all_image_infos + 4 + 
 
  381              addr_t notification_addr =
 
  383              if (!
error.Success()) {
 
  385                    "DynamicLoaderMacOS::NotifyBreakpointHit unable " 
  386                    "to read address of dyld-handover notification function at " 
  388                    notification_location);
 
  401        "no ABI plugin located for triple " +
 
  403            ": shared libraries will not be registered",
 
 
  412    const std::vector<lldb::addr_t> &load_addresses) {
 
  414  ImageInfo::collection image_infos;
 
  416  LLDB_LOGF(log, 
"Adding %" PRId64 
" modules.",
 
  417            (uint64_t)load_addresses.size());
 
  419      m_process->GetLoadedDynamicLibrariesInfos(load_addresses);
 
  420  if (binaries_info_sp.get() && binaries_info_sp->GetAsDictionary() &&
 
  421      binaries_info_sp->GetAsDictionary()->HasKey(
"images") &&
 
  422      binaries_info_sp->GetAsDictionary()
 
  423          ->GetValueForKey(
"images")
 
  425      binaries_info_sp->GetAsDictionary()
 
  426              ->GetValueForKey(
"images")
 
  428              ->GetSize() == load_addresses.size()) {
 
 
  460    return notification_addr;
 
  464    return notification_addr;
 
  466  const uint32_t addr_size =
 
  467      m_process->GetTarget().GetArchitecture().GetAddressByteSize();
 
  468  offset_t registered_infos_addr_offset =
 
  492      all_image_infos_addr + registered_infos_addr_offset, 
error);
 
  493  if (!
error.Success())
 
  494    return notification_addr;
 
  495  if (registered_infos_addr != all_image_infos_addr)
 
  496    return notification_addr;
 
  498  offset_t notification_fptr_offset = 
sizeof(uint32_t) + 
 
  503      all_image_infos_addr + notification_fptr_offset, 
error);
 
  505    notification_addr = 
m_process->FixCodeAddress(notification_fptr);
 
  506  return notification_addr;
 
 
  522      bool internal = 
true;
 
  523      bool hardware = 
false;
 
  527      dyld_filelist.
Append(dyld_sp->GetFileSpec());
 
  531              .CreateBreakpoint(&dyld_filelist, source_files,
 
  532                                "lldb_image_notifier", eFunctionNameTypeFull,
 
  547                .CreateBreakpoint(&dyld_filelist, source_files,
 
  548                                  "gdb_image_notifier", eFunctionNameTypeFull,
 
  551                                  skip_prologue, internal, hardware)
 
  575          m_process->GetTarget().CreateBreakpoint(so_addr, 
true, 
false).get();
 
 
  589    addr_t notification_address) {
 
  592        notification_address, 
true, 
false);
 
  595    dyld_handover_bp->SetOneShot(
true);
 
 
  613    std::vector<uint32_t> match_indexes;
 
  614    ConstString g_symbol_name(
"_dyld_global_lock_held");
 
  615    uint32_t num_matches = 0;
 
  617        symtab->AppendSymbolIndexesWithName(g_symbol_name, match_indexes);
 
  618    if (num_matches == 1) {
 
  619      Symbol *symbol = symtab->SymbolAtIndex(match_indexes[0]);
 
 
  641  std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
 
  646      if (module_sp->GetFileSpec().GetFilename() == g_libdyld_name) {
 
  673          m_process->ReadUnsignedIntegerFromMemory(symbol_address, 4, 0, 
error);
 
  674      if (lock_held != 0) {
 
  687                                      "the dyld lock symbol");
 
 
  703    if (info.get() && info->GetAsDictionary()) {
 
  711    if (info_dict && info_dict->
HasKey(
"shared_cache_uuid") &&
 
  712        info_dict->
HasKey(
"no_shared_cache") &&
 
  713        info_dict->
HasKey(
"shared_cache_base_address")) {
 
  714      base_address = info_dict->
GetValueForKey(
"shared_cache_base_address")
 
  716      std::string uuid_str = std::string(
 
  717          info_dict->
GetValueForKey(
"shared_cache_uuid")->GetStringValue());
 
  718      if (!uuid_str.empty())
 
  720      if (!info_dict->
GetValueForKey(
"no_shared_cache")->GetBooleanValue())
 
 
  746  return "Dynamic loader plug-in that watches for shared library loads/unloads " 
  747         "in MacOSX user processes.";
 
 
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
bool SetNotificationBreakpoint() override
bool GetSharedCacheInformation(lldb::addr_t &base_address, lldb_private::UUID &uuid, lldb_private::LazyBool &using_shared_cache, lldb_private::LazyBool &private_shared_cache) override
Get information about the shared cache for a process, if possible.
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
uint32_t m_image_infos_stop_id
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
void PutToLog(lldb_private::Log *log) const
bool IsFullyInitialized() override
Return whether the dynamic loader is fully initialized and it's safe to call its APIs.
lldb::addr_t GetDyldLockVariableAddressFromModule(lldb_private::Module *module)
bool m_libsystem_fully_initalized
bool NeedToDoInitialImageFetch() override
std::recursive_mutex m_mutex
void DoInitialImageFetch() override
static llvm::StringRef GetPluginNameStatic()
static llvm::StringRef GetPluginDescriptionStatic()
lldb::user_id_t m_break_id
lldb::addr_t GetNotificationFuncAddrFromImageInfos()
bool SetDYLDHandoverBreakpoint(lldb::addr_t notification_address)
void AddBinaries(const std::vector< lldb::addr_t > &load_addresses)
void ClearNotificationBreakpoint() override
void ClearDYLDHandoverBreakpoint()
static bool NotifyBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
lldb::addr_t m_maybe_image_infos_address
bool ProcessDidExec() override
Called after attaching a process.
~DynamicLoaderMacOS() override
lldb::user_id_t m_dyld_handover_break_id
DynamicLoaderMacOS(lldb_private::Process *process)
bool DidSetNotificationBreakpoint() override
A section + offset based address class.
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
void SetRawAddress(lldb::addr_t addr)
bool IsValid() const
Check if the object state is valid.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
llvm::Triple & GetTriple()
Architecture triple accessor.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
bool HasResolvedLocations() const
Return whether this breakpoint has any resolved locations.
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
Generic representation of a type in a programming language.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
A uniqued constant string class.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
lldb::ModuleSP GetDYLDModule()
DynamicLoaderDarwin(lldb_private::Process *process)
uint32_t m_dyld_image_infos_stop_id
std::recursive_mutex & GetMutex() const
std::vector< std::pair< ImageInfo, lldb::ModuleSP > > PreloadModulesFromImageInfos(const ImageInfo::collection &image_infos)
lldb::ModuleWP m_libpthread_module_wp
bool JSONImageInformationIntoImageInfo(lldb_private::StructuredData::ObjectSP image_details, ImageInfo::collection &image_infos)
void UpdateSpecialBinariesFromPreloadedModules(std::vector< std::pair< ImageInfo, lldb::ModuleSP > > &images)
bool AddModulesUsingPreloadedModules(std::vector< std::pair< ImageInfo, lldb::ModuleSP > > &images)
static bool UseDYLDSPI(lldb_private::Process *process)
lldb_private::Address m_pthread_getspecific_addr
void UnloadImages(const std::vector< lldb::addr_t > &solib_addresses)
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.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread & GetThreadRef() const
Returns a reference to the thread object.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
A collection class for Module objects.
ModuleIterableNoLocking ModulesNoLocking() const
std::recursive_mutex & GetMutex() const
void Clear()
Clear the object's state.
ModuleIterable Modules() const
size_t GetSize() const
Gets the size of the module list.
A class that describes an executable image and its associated object and symbol files.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Symtab * GetSymtab(bool can_create=true)
Get the module's symbol table.
A plug-in interface definition class for object file parsers.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
virtual lldb::addr_t GetImageInfoAddress()
Get the image information address for the current process.
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
lldb::addr_t FixCodeAddress(lldb::addr_t pc)
Some targets might use bits in a code address to indicate a mode switch, ARM uses bit zero to signify...
uint32_t GetStopID() const
const lldb::ABISP & GetABI()
Target & GetTarget()
Get the target object pointer for this module.
unsigned int UInt(unsigned int fail_value=0) const
unsigned long long ULongLong(unsigned long long fail_value=0) const
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
static Status FromErrorString(const char *str)
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
lldb::break_id_t GetID() const
ObjectSP GetValueForKey(llvm::StringRef key) const
bool HasKey(llvm::StringRef key) const
Dictionary * GetAsDictionary()
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
bool ValueIsAddress() const
Address & GetAddressRef()
ConstString GetName() const
Module * GetExecutableModulePointer()
Debugger & GetDebugger() const
void ClearSectionLoadList()
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
Represents UUID's of various sizes.
bool SetFromStringRef(llvm::StringRef str)
void PushValue(const Value &value)
Value * GetValueAtIndex(size_t idx)
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
@ Scalar
A raw scalar value.
void SetCompilerType(const CompilerType &compiler_type)
void SetValueType(ValueType value_type)
#define LLDB_INVALID_BREAK_ID
#define LLDB_BREAK_ID_IS_VALID(bid)
#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.
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
@ eEncodingUint
unsigned integer
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Module > ModuleSP
lldb::user_id_t GetID() const
Get accessor for the user ID.