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
64 //------------------------------------------------------------------
65 // PluginInterface protocol
66 //------------------------------------------------------------------
67 virtual lldb_private::ConstString
74 GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
76 virtual lldb_private::Error
77 ExecutePluginCommand(lldb_private::Args &command, lldb_private::Stream *strm);
79 virtual lldb_private::Log *
80 EnablePluginLogging(lldb_private::Stream *strm, lldb_private::Args &command);
83 /// Runtime linker rendezvous structure.
84 DYLDRendezvous m_rendezvous;
86 /// Virtual load address of the inferior process.
87 lldb::addr_t m_load_offset;
89 /// Virtual entry address of the inferior process.
90 lldb::addr_t m_entry_point;
92 /// Auxiliary vector of the inferior process.
93 std::unique_ptr<AuxVector> m_auxv;
95 /// Rendezvous breakpoint.
96 lldb::break_id_t m_dyld_bid;
98 /// Enables a breakpoint on a function called by the runtime
99 /// linker each time a module is loaded or unloaded.
101 SetRendezvousBreakpoint();
103 /// Callback routine which updates the current list of loaded modules based
104 /// on the information supplied by the runtime linker.
106 RendezvousBreakpointHit(void *baton,
107 lldb_private::StoppointCallbackContext *context,
108 lldb::user_id_t break_id,
109 lldb::user_id_t break_loc_id);
111 /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
112 /// of loaded modules.
116 /// Updates the load address of every allocatable section in @p module.
118 /// @param module The module to traverse.
120 /// @param base_addr The virtual base address @p module is loaded at.
122 UpdateLoadedSections(lldb::ModuleSP module,
123 lldb::addr_t base_addr = 0);
125 /// Locates or creates a module given by @p file and updates/loads the
126 /// resulting module at the virtual base address @p base_addr.
128 LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t base_addr);
130 /// Resolves the entry point for the current inferior process and sets a
131 /// breakpoint at that address.
135 /// Callback routine invoked when we hit the breakpoint on process entry.
137 /// This routine is responsible for resolving the load addresses of all
138 /// dependent modules required by the inferior and setting up the rendezvous
141 EntryBreakpointHit(void *baton,
142 lldb_private::StoppointCallbackContext *context,
143 lldb::user_id_t break_id,
144 lldb::user_id_t break_loc_id);
146 /// Helper for the entry breakpoint callback. Resolves the load addresses
147 /// of all dependent modules.
149 LoadAllCurrentModules();
151 /// Computes a value for m_load_offset returning the computed address on
152 /// success and LLDB_INVALID_ADDRESS on failure.
156 /// Computes a value for m_entry_point returning the computed address on
157 /// success and LLDB_INVALID_ADDRESS on failure.
161 /// Checks to see if the target module has changed, updates the target
162 /// accordingly and returns the target executable module.
164 GetTargetExecutable();
167 DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
170 #endif // liblldb_DynamicLoaderPOSIXDYLD_H_