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  uint32_t GetPluginVersion() override;
53 
54 protected:
55  /// Runtime linker rendezvous structure.
57 
58  /// Virtual load address of the inferior process.
60 
61  /// Virtual entry address of the inferior process.
63 
64  /// Rendezvous breakpoint.
66 
67  /// Loaded module list. (link map for each module)
68  std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>
70 
71  /// Enables a breakpoint on a function called by the runtime
72  /// linker each time a module is loaded or unloaded.
74 
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);
80 
81  /// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
82  /// of loaded modules.
83  void RefreshModules();
84 
85  /// Updates the load address of every allocatable section in \p module.
86  ///
87  /// \param module The module to traverse.
88  ///
89  /// \param link_map_addr The virtual address of the link map for the @p
90  /// module.
91  ///
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;
96 
97  /// Removes the loaded sections from the target in \p module.
98  ///
99  /// \param module The module to traverse.
100  void UnloadSections(const lldb::ModuleSP module) override;
101 
102  /// Callback routine invoked when we hit the breakpoint on process entry.
103  ///
104  /// This routine is responsible for resolving the load addresses of all
105  /// dependent modules required by the inferior and setting up the rendezvous
106  /// breakpoint.
107  static bool
108  EntryBreakpointHit(void *baton,
110  lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
111 
112  /// Helper for the entry breakpoint callback. Resolves the load addresses
113  /// of all dependent modules.
114  void LoadAllCurrentModules();
115 
116  /// Computes a value for m_load_offset returning the computed address on
117  /// success and LLDB_INVALID_ADDRESS on failure.
119 
120  /// Computes a value for m_entry_point returning the computed address on
121  /// success and LLDB_INVALID_ADDRESS on failure.
123 
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();
127 
128  /// return the address of the Rendezvous breakpoint
130 
131 private:
133  GetSectionListFromModule(const lldb::ModuleSP module) const;
134 };
135 
136 #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:251
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:169
HexagonDYLDRendezvous.h
DynamicLoaderHexagonDYLD::~DynamicLoaderHexagonDYLD
~DynamicLoaderHexagonDYLD() override
Definition: DynamicLoaderHexagonDYLD.cpp:117
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:522
lldb_private::SectionList
Definition: Section.h:34
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
DynamicLoaderHexagonDYLD::GetPluginVersion
uint32_t GetPluginVersion() override
Definition: DynamicLoaderHexagonDYLD.cpp:95
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:315
DynamicLoaderHexagonDYLD::CreateInstance
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
Definition: DynamicLoaderHexagonDYLD.cpp:97
DynamicLoaderHexagonDYLD::LoadAllCurrentModules
void LoadAllCurrentModules()
Helper for the entry breakpoint callback.
Definition: DynamicLoaderHexagonDYLD.cpp:465
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:350
lldb_private::Thread
Definition: Thread.h:62
DynamicLoaderHexagonDYLD::DidAttach
void DidAttach() override
Called after attaching a process.
Definition: DynamicLoaderHexagonDYLD.cpp:124
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:505
DynamicLoaderHexagonDYLD::DynamicLoaderHexagonDYLD
DynamicLoaderHexagonDYLD(lldb_private::Process *process)
Definition: DynamicLoaderHexagonDYLD.cpp:112
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:62
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:69
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:215
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:566
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
uint32_t
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:412
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:267
DynamicLoaderHexagonDYLD::Initialize
static void Initialize()
Definition: DynamicLoaderHexagonDYLD.cpp:74
DynamicLoaderHexagonDYLD::m_rendezvous
HexagonDYLDRendezvous m_rendezvous
Runtime linker rendezvous structure.
Definition: DynamicLoaderHexagonDYLD.h:56
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:543
DynamicLoaderHexagonDYLD::m_dyld_bid
lldb::break_id_t m_dyld_bid
Rendezvous breakpoint.
Definition: DynamicLoaderHexagonDYLD.h:65
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:173
DynamicLoaderHexagonDYLD::m_load_offset
lldb::addr_t m_load_offset
Virtual load address of the inferior process.
Definition: DynamicLoaderHexagonDYLD.h:59
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:217