]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
Update to bmake 20170413
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / DynamicLoader / POSIX-DYLD / DynamicLoaderPOSIXDYLD.h
1 //===-- DynamicLoaderPOSIXDYLD.h --------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_DynamicLoaderPOSIXDYLD_h_
11 #define liblldb_DynamicLoaderPOSIXDYLD_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Breakpoint/StoppointCallbackContext.h"
18 #include "lldb/Target/DynamicLoader.h"
19
20 #include "DYLDRendezvous.h"
21
22 class AuxVector;
23
24 class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader {
25 public:
26   DynamicLoaderPOSIXDYLD(lldb_private::Process *process);
27
28   ~DynamicLoaderPOSIXDYLD() override;
29
30   static void Initialize();
31
32   static void Terminate();
33
34   static lldb_private::ConstString GetPluginNameStatic();
35
36   static const char *GetPluginDescriptionStatic();
37
38   static lldb_private::DynamicLoader *
39   CreateInstance(lldb_private::Process *process, bool force);
40
41   //------------------------------------------------------------------
42   // DynamicLoader protocol
43   //------------------------------------------------------------------
44
45   void DidAttach() override;
46
47   void DidLaunch() override;
48
49   lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
50                                                   bool stop_others) override;
51
52   lldb_private::Error CanLoadImage() override;
53
54   lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module,
55                                   const lldb::ThreadSP thread,
56                                   lldb::addr_t tls_file_addr) override;
57
58   //------------------------------------------------------------------
59   // PluginInterface protocol
60   //------------------------------------------------------------------
61   lldb_private::ConstString GetPluginName() override;
62
63   uint32_t GetPluginVersion() override;
64
65 protected:
66   /// Runtime linker rendezvous structure.
67   DYLDRendezvous m_rendezvous;
68
69   /// Virtual load address of the inferior process.
70   lldb::addr_t m_load_offset;
71
72   /// Virtual entry address of the inferior process.
73   lldb::addr_t m_entry_point;
74
75   /// Auxiliary vector of the inferior process.
76   std::unique_ptr<AuxVector> m_auxv;
77
78   /// Rendezvous breakpoint.
79   lldb::break_id_t m_dyld_bid;
80
81   /// Contains AT_SYSINFO_EHDR, which means a vDSO has been
82   /// mapped to the address space
83   lldb::addr_t m_vdso_base;
84
85   /// Loaded module list. (link map for each module)
86   std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>
87       m_loaded_modules;
88
89   /// Enables a breakpoint on a function called by the runtime
90   /// linker each time a module is loaded or unloaded.
91   virtual void SetRendezvousBreakpoint();
92
93   /// Callback routine which updates the current list of loaded modules based
94   /// on the information supplied by the runtime linker.
95   static bool RendezvousBreakpointHit(
96       void *baton, lldb_private::StoppointCallbackContext *context,
97       lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
98
99   /// Helper method for RendezvousBreakpointHit.  Updates LLDB's current set
100   /// of loaded modules.
101   void RefreshModules();
102
103   /// Updates the load address of every allocatable section in @p module.
104   ///
105   /// @param module The module to traverse.
106   ///
107   /// @param link_map_addr The virtual address of the link map for the @p
108   /// module.
109   ///
110   /// @param base_addr The virtual base address @p module is loaded at.
111   void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr,
112                             lldb::addr_t base_addr,
113                             bool base_addr_is_offset) override;
114
115   /// Removes the loaded sections from the target in @p module.
116   ///
117   /// @param module The module to traverse.
118   void UnloadSections(const lldb::ModuleSP module) override;
119
120   /// Resolves the entry point for the current inferior process and sets a
121   /// breakpoint at that address.
122   void ProbeEntry();
123
124   /// Callback routine invoked when we hit the breakpoint on process entry.
125   ///
126   /// This routine is responsible for resolving the load addresses of all
127   /// dependent modules required by the inferior and setting up the rendezvous
128   /// breakpoint.
129   static bool
130   EntryBreakpointHit(void *baton,
131                      lldb_private::StoppointCallbackContext *context,
132                      lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
133
134   /// Helper for the entry breakpoint callback.  Resolves the load addresses
135   /// of all dependent modules.
136   virtual void LoadAllCurrentModules();
137
138   /// Computes a value for m_load_offset returning the computed address on
139   /// success and LLDB_INVALID_ADDRESS on failure.
140   lldb::addr_t ComputeLoadOffset();
141
142   /// Computes a value for m_entry_point returning the computed address on
143   /// success and LLDB_INVALID_ADDRESS on failure.
144   lldb::addr_t GetEntryPoint();
145
146   /// Evaluate if Aux vectors contain vDSO information
147   /// in case they do, read and assign the address to m_vdso_base
148   void EvalVdsoStatus();
149
150   /// Loads Module from inferior process.
151   void ResolveExecutableModule(lldb::ModuleSP &module_sp);
152
153   bool AlwaysRelyOnEHUnwindInfo(lldb_private::SymbolContext &sym_ctx) override;
154
155 private:
156   DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
157 };
158
159 #endif // liblldb_DynamicLoaderPOSIXDYLD_h_