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