LLDB  mainline
DynamicLoaderHexagonDYLD.h
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H
10 #define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H
11 
14 
15 #include "HexagonDYLDRendezvous.h"
16 
18 public:
20 
21  ~DynamicLoaderHexagonDYLD() override;
22 
23  static void Initialize();
24 
25  static void Terminate();
26 
28 
29  static const char *GetPluginDescriptionStatic();
30 
32  CreateInstance(lldb_private::Process *process, bool force);
33 
34  // DynamicLoader protocol
35 
36  void DidAttach() override;
37 
38  void DidLaunch() override;
39 
40  lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
41  bool stop_others) override;
42 
44 
45  lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module,
46  const lldb::ThreadSP thread,
47  lldb::addr_t tls_file_addr) override;
48 
49  // PluginInterface protocol
51 
52 protected:
53  /// Runtime linker rendezvous structure.
55 
56  /// Virtual load address of the inferior process.
58 
59  /// Virtual entry address of the inferior process.
61 
62  /// Rendezvous breakpoint.
64 
65  /// Loaded module list. (link map for each module)
66  std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>
68 
69  /// Enables a breakpoint on a function called by the runtime
70  /// linker each time a module is loaded or unloaded.
72 
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);
78 
79  /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
80  /// of loaded modules.
81  void RefreshModules();
82 
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;
94 
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;
99 
100  /// Callback routine invoked when we hit the breakpoint on process entry.
101  ///
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,
108  lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
109 
110  /// Helper for the entry breakpoint callback. Resolves the load addresses
111  /// of all dependent modules.
112  void LoadAllCurrentModules();
113 
114  /// Computes a value for m_load_offset returning the computed address on
115  /// success and LLDB_INVALID_ADDRESS on failure.
117 
118  /// Computes a value for m_entry_point returning the computed address on
119  /// success and LLDB_INVALID_ADDRESS on failure.
121 
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();
125 
126  /// return the address of the Rendezvous breakpoint
128 
129 private:
131  GetSectionListFromModule(const lldb::ModuleSP module) const;
132 };
133 
134 #endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H
DynamicLoaderHexagonDYLD::UnloadSections
void UnloadSections(const lldb::ModuleSP module) override
Removes the loaded sections from the target in module.
Definition: DynamicLoaderHexagonDYLD.cpp:249
lldb_private::StoppointCallbackContext
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
Definition: StoppointCallbackContext.h:26
DynamicLoaderHexagonDYLD::DidLaunch
void DidLaunch() override
Called after launching a process.
Definition: DynamicLoaderHexagonDYLD.cpp:167
HexagonDYLDRendezvous.h
DynamicLoaderHexagonDYLD::~DynamicLoaderHexagonDYLD
~DynamicLoaderHexagonDYLD() override
Definition: DynamicLoaderHexagonDYLD.cpp:115
lldb_private::Process
Definition: Process.h:342
StoppointCallbackContext.h
DynamicLoaderHexagonDYLD::GetEntryPoint
lldb::addr_t GetEntryPoint()
Computes a value for m_entry_point returning the computed address on success and LLDB_INVALID_ADDRESS...
Definition: DynamicLoaderHexagonDYLD.cpp:520
lldb_private::SectionList
Definition: Section.h:34
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
DynamicLoaderHexagonDYLD::RendezvousBreakpointHit
static bool RendezvousBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Callback routine which updates the current list of loaded modules based on the information supplied b...
Definition: DynamicLoaderHexagonDYLD.cpp:313
DynamicLoaderHexagonDYLD::CreateInstance
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
Definition: DynamicLoaderHexagonDYLD.cpp:95
DynamicLoaderHexagonDYLD::LoadAllCurrentModules
void LoadAllCurrentModules()
Helper for the entry breakpoint callback.
Definition: DynamicLoaderHexagonDYLD.cpp:463
DynamicLoaderHexagonDYLD
Definition: DynamicLoaderHexagonDYLD.h:17
DynamicLoaderHexagonDYLD::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: DynamicLoaderHexagonDYLD.cpp:85
DynamicLoaderHexagonDYLD::FindRendezvousBreakpointAddress
lldb::addr_t FindRendezvousBreakpointAddress()
return the address of the Rendezvous breakpoint
DynamicLoaderHexagonDYLD::RefreshModules
void RefreshModules()
Helper method for RendezvousBreakpointHit.
Definition: DynamicLoaderHexagonDYLD.cpp:348
lldb_private::Thread
Definition: Thread.h:62
DynamicLoaderHexagonDYLD::DidAttach
void DidAttach() override
Called after attaching a process.
Definition: DynamicLoaderHexagonDYLD.cpp:122
DynamicLoaderHexagonDYLD::ComputeLoadOffset
lldb::addr_t ComputeLoadOffset()
Computes a value for m_load_offset returning the computed address on success and LLDB_INVALID_ADDRESS...
Definition: DynamicLoaderHexagonDYLD.cpp:503
DynamicLoaderHexagonDYLD::DynamicLoaderHexagonDYLD
DynamicLoaderHexagonDYLD(lldb_private::Process *process)
Definition: DynamicLoaderHexagonDYLD.cpp:110
lldb::break_id_t
int32_t break_id_t
Definition: lldb-types.h:88
lldb_private::ConstString
Definition: ConstString.h:40
DynamicLoaderHexagonDYLD::m_entry_point
lldb::addr_t m_entry_point
Virtual entry address of the inferior process.
Definition: DynamicLoaderHexagonDYLD.h:60
lldb_private::DynamicLoader
Definition: DynamicLoader.h:52
DynamicLoaderHexagonDYLD::GetPluginName
lldb_private::ConstString GetPluginName() override
Definition: DynamicLoaderHexagonDYLD.cpp:81
HexagonDYLDRendezvous
Definition: HexagonDYLDRendezvous.h:31
DynamicLoaderHexagonDYLD::m_loaded_modules
std::map< lldb::ModuleWP, lldb::addr_t, std::owner_less< lldb::ModuleWP > > m_loaded_modules
Loaded module list. (link map for each module)
Definition: DynamicLoaderHexagonDYLD.h:67
DynamicLoaderHexagonDYLD::CanLoadImage
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
Definition: DynamicLoaderHexagonDYLD.cpp:213
DynamicLoaderHexagonDYLD::GetThreadLocalData
lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) override
Retrieves the per-module TLS block for a given thread.
Definition: DynamicLoaderHexagonDYLD.cpp:564
DynamicLoaderHexagonDYLD::Terminate
static void Terminate()
Definition: DynamicLoaderHexagonDYLD.cpp:79
lldb_private::Status
Definition: Status.h:44
DynamicLoaderHexagonDYLD::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: DynamicLoaderHexagonDYLD.cpp:90
DynamicLoaderHexagonDYLD::GetStepThroughTrampolinePlan
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override
Provides a plan to step through the dynamic loader trampoline for the current state of thread.
Definition: DynamicLoaderHexagonDYLD.cpp:410
DynamicLoaderHexagonDYLD::SetRendezvousBreakpoint
bool SetRendezvousBreakpoint()
Enables a breakpoint on a function called by the runtime linker each time a module is loaded or unloa...
Definition: DynamicLoaderHexagonDYLD.cpp:265
DynamicLoaderHexagonDYLD::Initialize
static void Initialize()
Definition: DynamicLoaderHexagonDYLD.cpp:74
DynamicLoaderHexagonDYLD::m_rendezvous
HexagonDYLDRendezvous m_rendezvous
Runtime linker rendezvous structure.
Definition: DynamicLoaderHexagonDYLD.h:54
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
DynamicLoaderHexagonDYLD::GetSectionListFromModule
const lldb_private::SectionList * GetSectionListFromModule(const lldb::ModuleSP module) const
Definition: DynamicLoaderHexagonDYLD.cpp:541
DynamicLoaderHexagonDYLD::m_dyld_bid
lldb::break_id_t m_dyld_bid
Rendezvous breakpoint.
Definition: DynamicLoaderHexagonDYLD.h:63
DynamicLoader.h
DynamicLoaderHexagonDYLD::EntryBreakpointHit
static bool EntryBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Callback routine invoked when we hit the breakpoint on process entry.
DynamicLoaderHexagonDYLD::GetTargetExecutable
lldb::ModuleSP GetTargetExecutable()
Checks to see if the target module has changed, updates the target accordingly and returns the target...
Definition: DynamicLoaderHexagonDYLD.cpp:171
DynamicLoaderHexagonDYLD::m_load_offset
lldb::addr_t m_load_offset
Virtual load address of the inferior process.
Definition: DynamicLoaderHexagonDYLD.h:57
DynamicLoaderHexagonDYLD::UpdateLoadedSections
void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset) override
Updates the load address of every allocatable section in module.
Definition: DynamicLoaderHexagonDYLD.cpp:215