1 //===-- DynamicLoaderMacOS.h -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This is the DynamicLoader plugin for Darwin (macOS / iPhoneOS / tvOS /
12 // platforms late 2016 and newer, where lldb will call dyld SPI functions to get
13 // information about shared libraries, information about the shared cache, and
14 // the _dyld_debugger_notification function we put a breakpoint on give us an
15 // array of load addresses for solibs loaded and unloaded. The SPI will tell us
16 // about both dyld and the executable, in addition to all of the usual solibs.
18 #ifndef liblldb_DynamicLoaderMacOS_h_
19 #define liblldb_DynamicLoaderMacOS_h_
26 // Other libraries and framework includes
28 #include "lldb/Core/StructuredData.h"
29 #include "lldb/Core/UUID.h"
30 #include "lldb/Host/FileSpec.h"
31 #include "lldb/Target/DynamicLoader.h"
32 #include "lldb/Target/Process.h"
33 #include "lldb/Utility/SafeMachO.h"
35 #include "DynamicLoaderDarwin.h"
37 class DynamicLoaderMacOS : public lldb_private::DynamicLoaderDarwin {
39 DynamicLoaderMacOS(lldb_private::Process *process);
41 virtual ~DynamicLoaderMacOS() override;
43 //------------------------------------------------------------------
45 //------------------------------------------------------------------
46 static void Initialize();
48 static void Terminate();
50 static lldb_private::ConstString GetPluginNameStatic();
52 static const char *GetPluginDescriptionStatic();
54 static lldb_private::DynamicLoader *
55 CreateInstance(lldb_private::Process *process, bool force);
57 //------------------------------------------------------------------
58 /// Called after attaching a process.
60 /// Allow DynamicLoader plug-ins to execute some code after
61 /// attaching to a process.
62 //------------------------------------------------------------------
63 bool ProcessDidExec() override;
65 lldb_private::Error CanLoadImage() override;
67 bool GetSharedCacheInformation(
68 lldb::addr_t &base_address, lldb_private::UUID &uuid,
69 lldb_private::LazyBool &using_shared_cache,
70 lldb_private::LazyBool &private_shared_cache) override;
72 //------------------------------------------------------------------
73 // PluginInterface protocol
74 //------------------------------------------------------------------
75 lldb_private::ConstString GetPluginName() override;
77 uint32_t GetPluginVersion() override;
80 void PutToLog(lldb_private::Log *log) const;
82 void DoInitialImageFetch() override;
84 bool NeedToDoInitialImageFetch() override;
86 bool DidSetNotificationBreakpoint() override;
88 void AddBinaries(const std::vector<lldb::addr_t> &load_addresses);
90 void DoClear() override;
93 NotifyBreakpointHit(void *baton,
94 lldb_private::StoppointCallbackContext *context,
95 lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
97 bool SetNotificationBreakpoint() override;
99 void ClearNotificationBreakpoint() override;
101 void UpdateImageInfosHeaderAndLoadCommands(ImageInfo::collection &image_infos,
102 uint32_t infos_count,
103 bool update_executable);
106 GetDyldLockVariableAddressFromModule(lldb_private::Module *module);
108 uint32_t m_image_infos_stop_id; // The Stop ID the last time we
109 // loaded/unloaded images
110 lldb::user_id_t m_break_id;
111 mutable std::recursive_mutex m_mutex;
114 DISALLOW_COPY_AND_ASSIGN(DynamicLoaderMacOS);
117 #endif // liblldb_DynamicLoaderMacOS_h_