1 //===-- DynamicLoaderHexagonDYLD.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_DynamicLoaderHexagonDYLD_h_
11 #define liblldb_DynamicLoaderHexagonDYLD_h_
13 #include "lldb/Breakpoint/StoppointCallbackContext.h"
14 #include "lldb/Target/DynamicLoader.h"
16 #include "HexagonDYLDRendezvous.h"
18 class DynamicLoaderHexagonDYLD : public lldb_private::DynamicLoader {
20 DynamicLoaderHexagonDYLD(lldb_private::Process *process);
22 ~DynamicLoaderHexagonDYLD() override;
24 static void Initialize();
26 static void Terminate();
28 static lldb_private::ConstString GetPluginNameStatic();
30 static const char *GetPluginDescriptionStatic();
32 static lldb_private::DynamicLoader *
33 CreateInstance(lldb_private::Process *process, bool force);
35 //------------------------------------------------------------------
36 // DynamicLoader protocol
37 //------------------------------------------------------------------
39 void DidAttach() override;
41 void DidLaunch() override;
43 lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
44 bool stop_others) override;
46 lldb_private::Status CanLoadImage() override;
48 lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module,
49 const lldb::ThreadSP thread,
50 lldb::addr_t tls_file_addr) override;
52 //------------------------------------------------------------------
53 // PluginInterface protocol
54 //------------------------------------------------------------------
55 lldb_private::ConstString GetPluginName() override;
57 uint32_t GetPluginVersion() override;
60 /// Runtime linker rendezvous structure.
61 HexagonDYLDRendezvous m_rendezvous;
63 /// Virtual load address of the inferior process.
64 lldb::addr_t m_load_offset;
66 /// Virtual entry address of the inferior process.
67 lldb::addr_t m_entry_point;
69 /// Rendezvous breakpoint.
70 lldb::break_id_t m_dyld_bid;
72 /// Loaded module list. (link map for each module)
73 std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>
76 /// Enables a breakpoint on a function called by the runtime
77 /// linker each time a module is loaded or unloaded.
78 bool SetRendezvousBreakpoint();
80 /// Callback routine which updates the current list of loaded modules based
81 /// on the information supplied by the runtime linker.
82 static bool RendezvousBreakpointHit(
83 void *baton, lldb_private::StoppointCallbackContext *context,
84 lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
86 /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
87 /// of loaded modules.
88 void RefreshModules();
90 /// Updates the load address of every allocatable section in @p module.
92 /// @param module The module to traverse.
94 /// @param link_map_addr The virtual address of the link map for the @p
97 /// @param base_addr The virtual base address @p module is loaded at.
98 void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr,
99 lldb::addr_t base_addr,
100 bool base_addr_is_offset) override;
102 /// Removes the loaded sections from the target in @p module.
104 /// @param module The module to traverse.
105 void UnloadSections(const lldb::ModuleSP module) override;
107 /// Callback routine invoked when we hit the breakpoint on process entry.
109 /// This routine is responsible for resolving the load addresses of all
110 /// dependent modules required by the inferior and setting up the rendezvous
113 EntryBreakpointHit(void *baton,
114 lldb_private::StoppointCallbackContext *context,
115 lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
117 /// Helper for the entry breakpoint callback. Resolves the load addresses
118 /// of all dependent modules.
119 void LoadAllCurrentModules();
121 /// Computes a value for m_load_offset returning the computed address on
122 /// success and LLDB_INVALID_ADDRESS on failure.
123 lldb::addr_t ComputeLoadOffset();
125 /// Computes a value for m_entry_point returning the computed address on
126 /// success and LLDB_INVALID_ADDRESS on failure.
127 lldb::addr_t GetEntryPoint();
129 /// Checks to see if the target module has changed, updates the target
130 /// accordingly and returns the target executable module.
131 lldb::ModuleSP GetTargetExecutable();
133 /// return the address of the Rendezvous breakpoint
134 lldb::addr_t FindRendezvousBreakpointAddress();
137 const lldb_private::SectionList *
138 GetSectionListFromModule(const lldb::ModuleSP module) const;
140 DISALLOW_COPY_AND_ASSIGN(DynamicLoaderHexagonDYLD);
143 #endif // liblldb_DynamicLoaderHexagonDYLD_h_