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