1 //===-- DynamicLoaderPOSIX.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 #ifndef liblldb_DynamicLoaderPOSIX_H_
11 #define liblldb_DynamicLoaderPOSIX_H_
15 // Other libraries and framework includes
16 #include "lldb/Breakpoint/StoppointCallbackContext.h"
17 #include "lldb/Target/DynamicLoader.h"
19 #include "DYLDRendezvous.h"
23 class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader
33 static lldb_private::ConstString
34 GetPluginNameStatic();
37 GetPluginDescriptionStatic();
39 static lldb_private::DynamicLoader *
40 CreateInstance(lldb_private::Process *process, bool force);
42 DynamicLoaderPOSIXDYLD(lldb_private::Process *process);
45 ~DynamicLoaderPOSIXDYLD();
47 //------------------------------------------------------------------
48 // DynamicLoader protocol
49 //------------------------------------------------------------------
57 virtual lldb::ThreadPlanSP
58 GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
61 virtual lldb_private::Error
65 GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread);
67 //------------------------------------------------------------------
68 // PluginInterface protocol
69 //------------------------------------------------------------------
70 virtual lldb_private::ConstString
77 GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
79 virtual lldb_private::Error
80 ExecutePluginCommand(lldb_private::Args &command, lldb_private::Stream *strm);
82 virtual lldb_private::Log *
83 EnablePluginLogging(lldb_private::Stream *strm, lldb_private::Args &command);
86 /// Runtime linker rendezvous structure.
87 DYLDRendezvous m_rendezvous;
89 /// Virtual load address of the inferior process.
90 lldb::addr_t m_load_offset;
92 /// Virtual entry address of the inferior process.
93 lldb::addr_t m_entry_point;
95 /// Auxiliary vector of the inferior process.
96 std::unique_ptr<AuxVector> m_auxv;
98 /// Rendezvous breakpoint.
99 lldb::break_id_t m_dyld_bid;
101 /// Loaded module list. (link map for each module)
102 std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>> m_loaded_modules;
104 /// Enables a breakpoint on a function called by the runtime
105 /// linker each time a module is loaded or unloaded.
107 SetRendezvousBreakpoint();
109 /// Callback routine which updates the current list of loaded modules based
110 /// on the information supplied by the runtime linker.
112 RendezvousBreakpointHit(void *baton,
113 lldb_private::StoppointCallbackContext *context,
114 lldb::user_id_t break_id,
115 lldb::user_id_t break_loc_id);
117 /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
118 /// of loaded modules.
122 /// Updates the load address of every allocatable section in @p module.
124 /// @param module The module to traverse.
126 /// @param link_map_addr The virtual address of the link map for the @p module.
128 /// @param base_addr The virtual base address @p module is loaded at.
130 UpdateLoadedSections(lldb::ModuleSP module,
131 lldb::addr_t link_map_addr,
132 lldb::addr_t base_addr);
134 /// Removes the loaded sections from the target in @p module.
136 /// @param module The module to traverse.
138 UnloadSections(const lldb::ModuleSP module);
140 /// Resolves the entry point for the current inferior process and sets a
141 /// breakpoint at that address.
145 /// Callback routine invoked when we hit the breakpoint on process entry.
147 /// This routine is responsible for resolving the load addresses of all
148 /// dependent modules required by the inferior and setting up the rendezvous
151 EntryBreakpointHit(void *baton,
152 lldb_private::StoppointCallbackContext *context,
153 lldb::user_id_t break_id,
154 lldb::user_id_t break_loc_id);
156 /// Helper for the entry breakpoint callback. Resolves the load addresses
157 /// of all dependent modules.
159 LoadAllCurrentModules();
161 /// Computes a value for m_load_offset returning the computed address on
162 /// success and LLDB_INVALID_ADDRESS on failure.
166 /// Computes a value for m_entry_point returning the computed address on
167 /// success and LLDB_INVALID_ADDRESS on failure.
172 DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
175 #endif // liblldb_DynamicLoaderPOSIXDYLD_H_