1 //===-- DynamicLoaderHexagonDYLD.h ------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_DynamicLoaderHexagonDYLD_h_
10 #define liblldb_DynamicLoaderHexagonDYLD_h_
12 #include "lldb/Breakpoint/StoppointCallbackContext.h"
13 #include "lldb/Target/DynamicLoader.h"
15 #include "HexagonDYLDRendezvous.h"
17 class DynamicLoaderHexagonDYLD : public lldb_private::DynamicLoader {
19 DynamicLoaderHexagonDYLD(lldb_private::Process *process);
21 ~DynamicLoaderHexagonDYLD() override;
23 static void Initialize();
25 static void Terminate();
27 static lldb_private::ConstString GetPluginNameStatic();
29 static const char *GetPluginDescriptionStatic();
31 static lldb_private::DynamicLoader *
32 CreateInstance(lldb_private::Process *process, bool force);
34 // DynamicLoader protocol
36 void DidAttach() override;
38 void DidLaunch() override;
40 lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
41 bool stop_others) override;
43 lldb_private::Status CanLoadImage() override;
45 lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module,
46 const lldb::ThreadSP thread,
47 lldb::addr_t tls_file_addr) override;
49 // PluginInterface protocol
50 lldb_private::ConstString GetPluginName() override;
52 uint32_t GetPluginVersion() override;
55 /// Runtime linker rendezvous structure.
56 HexagonDYLDRendezvous m_rendezvous;
58 /// Virtual load address of the inferior process.
59 lldb::addr_t m_load_offset;
61 /// Virtual entry address of the inferior process.
62 lldb::addr_t m_entry_point;
64 /// Rendezvous breakpoint.
65 lldb::break_id_t m_dyld_bid;
67 /// Loaded module list. (link map for each module)
68 std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>
71 /// Enables a breakpoint on a function called by the runtime
72 /// linker each time a module is loaded or unloaded.
73 bool SetRendezvousBreakpoint();
75 /// Callback routine which updates the current list of loaded modules based
76 /// on the information supplied by the runtime linker.
77 static bool RendezvousBreakpointHit(
78 void *baton, lldb_private::StoppointCallbackContext *context,
79 lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
81 /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
82 /// of loaded modules.
83 void RefreshModules();
85 /// Updates the load address of every allocatable section in \p module.
87 /// \param module The module to traverse.
89 /// \param link_map_addr The virtual address of the link map for the @p
92 /// \param base_addr The virtual base address \p module is loaded at.
93 void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr,
94 lldb::addr_t base_addr,
95 bool base_addr_is_offset) override;
97 /// Removes the loaded sections from the target in \p module.
99 /// \param module The module to traverse.
100 void UnloadSections(const lldb::ModuleSP module) override;
102 /// Callback routine invoked when we hit the breakpoint on process entry.
104 /// This routine is responsible for resolving the load addresses of all
105 /// dependent modules required by the inferior and setting up the rendezvous
108 EntryBreakpointHit(void *baton,
109 lldb_private::StoppointCallbackContext *context,
110 lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
112 /// Helper for the entry breakpoint callback. Resolves the load addresses
113 /// of all dependent modules.
114 void LoadAllCurrentModules();
116 /// Computes a value for m_load_offset returning the computed address on
117 /// success and LLDB_INVALID_ADDRESS on failure.
118 lldb::addr_t ComputeLoadOffset();
120 /// Computes a value for m_entry_point returning the computed address on
121 /// success and LLDB_INVALID_ADDRESS on failure.
122 lldb::addr_t GetEntryPoint();
124 /// Checks to see if the target module has changed, updates the target
125 /// accordingly and returns the target executable module.
126 lldb::ModuleSP GetTargetExecutable();
128 /// return the address of the Rendezvous breakpoint
129 lldb::addr_t FindRendezvousBreakpointAddress();
132 const lldb_private::SectionList *
133 GetSectionListFromModule(const lldb::ModuleSP module) const;
135 DISALLOW_COPY_AND_ASSIGN(DynamicLoaderHexagonDYLD);
138 #endif // liblldb_DynamicLoaderHexagonDYLD_h_