1 //===-- JITLoaderGDB.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_JITLoaderGDB_h_ 11 #define liblldb_JITLoaderGDB_h_ 12 13 #include <map> 14 15 #include "lldb/Target/JITLoader.h" 16 #include "lldb/Target/Process.h" 17 18 class JITLoaderGDB : public lldb_private::JITLoader { 19 public: 20 JITLoaderGDB(lldb_private::Process *process); 21 22 ~JITLoaderGDB() override; 23 24 //------------------------------------------------------------------ 25 // Static Functions 26 //------------------------------------------------------------------ 27 static void Initialize(); 28 29 static void Terminate(); 30 31 static lldb_private::ConstString GetPluginNameStatic(); 32 33 static const char *GetPluginDescriptionStatic(); 34 35 static lldb::JITLoaderSP CreateInstance(lldb_private::Process *process, 36 bool force); 37 38 static void DebuggerInitialize(lldb_private::Debugger &debugger); 39 40 //------------------------------------------------------------------ 41 // PluginInterface protocol 42 //------------------------------------------------------------------ 43 lldb_private::ConstString GetPluginName() override; 44 45 uint32_t GetPluginVersion() override; 46 47 //------------------------------------------------------------------ 48 // JITLoader interface 49 //------------------------------------------------------------------ 50 void DidAttach() override; 51 52 void DidLaunch() override; 53 54 void ModulesDidLoad(lldb_private::ModuleList &module_list) override; 55 56 private: 57 lldb::addr_t GetSymbolAddress(lldb_private::ModuleList &module_list, 58 const lldb_private::ConstString &name, 59 lldb::SymbolType symbol_type) const; 60 61 void SetJITBreakpoint(lldb_private::ModuleList &module_list); 62 63 bool DidSetJITBreakpoint() const; 64 65 bool ReadJITDescriptor(bool all_entries); 66 67 template <typename ptr_t> bool ReadJITDescriptorImpl(bool all_entries); 68 69 static bool 70 JITDebugBreakpointHit(void *baton, 71 lldb_private::StoppointCallbackContext *context, 72 lldb::user_id_t break_id, lldb::user_id_t break_loc_id); 73 74 static void ProcessStateChangedCallback(void *baton, 75 lldb_private::Process *process, 76 lldb::StateType state); 77 78 // A collection of in-memory jitted object addresses and their corresponding 79 // modules 80 typedef std::map<lldb::addr_t, const lldb::ModuleSP> JITObjectMap; 81 JITObjectMap m_jit_objects; 82 83 lldb::user_id_t m_jit_break_id; 84 lldb::addr_t m_jit_descriptor_addr; 85 }; 86 87 #endif // liblldb_JITLoaderGDB_h_ 88