[memprof] Move YAML traits to MemProf.h (NFC) (#118668)
[llvm-project.git] / lldb / source / Plugins / DynamicLoader / Hexagon-DYLD / DynamicLoaderHexagonDYLD.h
blob54711f5e6bb33be270665279aaaabcb9e19d6ff4
1 //===-- DynamicLoaderHexagonDYLD.h ------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H
10 #define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_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 {
18 public:
19 DynamicLoaderHexagonDYLD(lldb_private::Process *process);
21 ~DynamicLoaderHexagonDYLD() override;
23 static void Initialize();
25 static void Terminate();
27 static llvm::StringRef GetPluginNameStatic() { return "hexagon-dyld"; }
29 static llvm::StringRef 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 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
52 protected:
53 /// Runtime linker rendezvous structure.
54 HexagonDYLDRendezvous m_rendezvous;
56 /// Virtual load address of the inferior process.
57 lldb::addr_t m_load_offset;
59 /// Virtual entry address of the inferior process.
60 lldb::addr_t m_entry_point;
62 /// Rendezvous breakpoint.
63 lldb::break_id_t m_dyld_bid;
65 /// Loaded module list. (link map for each module)
66 std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>
67 m_loaded_modules;
69 /// Enables a breakpoint on a function called by the runtime
70 /// linker each time a module is loaded or unloaded.
71 bool SetRendezvousBreakpoint();
73 /// Callback routine which updates the current list of loaded modules based
74 /// on the information supplied by the runtime linker.
75 static bool RendezvousBreakpointHit(
76 void *baton, lldb_private::StoppointCallbackContext *context,
77 lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
79 /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
80 /// of loaded modules.
81 void RefreshModules();
83 /// Updates the load address of every allocatable section in \p module.
84 ///
85 /// \param module The module to traverse.
86 ///
87 /// \param link_map_addr The virtual address of the link map for the @p
88 /// module.
89 ///
90 /// \param base_addr The virtual base address \p module is loaded at.
91 void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr,
92 lldb::addr_t base_addr,
93 bool base_addr_is_offset) override;
95 /// Removes the loaded sections from the target in \p module.
96 ///
97 /// \param module The module to traverse.
98 void UnloadSections(const lldb::ModuleSP module) override;
100 /// Callback routine invoked when we hit the breakpoint on process entry.
102 /// This routine is responsible for resolving the load addresses of all
103 /// dependent modules required by the inferior and setting up the rendezvous
104 /// breakpoint.
105 static bool
106 EntryBreakpointHit(void *baton,
107 lldb_private::StoppointCallbackContext *context,
108 lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
110 /// Helper for the entry breakpoint callback. Resolves the load addresses
111 /// of all dependent modules.
112 void LoadAllCurrentModules();
114 /// Computes a value for m_load_offset returning the computed address on
115 /// success and LLDB_INVALID_ADDRESS on failure.
116 lldb::addr_t ComputeLoadOffset();
118 /// Computes a value for m_entry_point returning the computed address on
119 /// success and LLDB_INVALID_ADDRESS on failure.
120 lldb::addr_t GetEntryPoint();
122 /// Checks to see if the target module has changed, updates the target
123 /// accordingly and returns the target executable module.
124 lldb::ModuleSP GetTargetExecutable();
126 /// return the address of the Rendezvous breakpoint
127 lldb::addr_t FindRendezvousBreakpointAddress();
129 private:
130 const lldb_private::SectionList *
131 GetSectionListFromModule(const lldb::ModuleSP module) const;
134 #endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H