LLDB  mainline
JITLoaderGDB.h
Go to the documentation of this file.
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 
18 public:
20 
21  ~JITLoaderGDB() override;
22 
23  // Static Functions
24  static void Initialize();
25 
26  static void Terminate();
27 
28  static llvm::StringRef GetPluginNameStatic() { return "gdb"; }
29 
30  static llvm::StringRef 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  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
39 
40  // JITLoader interface
41  void DidAttach() override;
42 
43  void DidLaunch() override;
44 
45  void ModulesDidLoad(lldb_private::ModuleList &module_list) override;
46 
47 private:
50  lldb::SymbolType symbol_type) const;
51 
52  void SetJITBreakpoint(lldb_private::ModuleList &module_list);
53 
54  bool DidSetJITBreakpoint() const;
55 
56  bool ReadJITDescriptor(bool all_entries);
57 
58  template <typename ptr_t> bool ReadJITDescriptorImpl(bool all_entries);
59 
60  static bool
61  JITDebugBreakpointHit(void *baton,
63  lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
64 
65  static void ProcessStateChangedCallback(void *baton,
66  lldb_private::Process *process,
67  lldb::StateType state);
68 
69  // A collection of in-memory jitted object addresses and their corresponding
70  // modules
71  typedef std::map<lldb::addr_t, const lldb::ModuleSP> JITObjectMap;
73 
76 };
77 
78 #endif // LLDB_SOURCE_PLUGINS_JITLOADER_GDB_JITLOADERGDB_H
JITLoaderGDB::~JITLoaderGDB
~JITLoaderGDB() override
Definition: JITLoaderGDB.cpp:151
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
JITLoaderGDB::Terminate
static void Terminate()
Definition: JITLoaderGDB.cpp:436
lldb_private::Process
Definition: Process.h:341
JITLoaderGDB::ProcessStateChangedCallback
static void ProcessStateChangedCallback(void *baton, lldb_private::Process *process, lldb::StateType state)
JITLoaderGDB::CreateInstance
static lldb::JITLoaderSP CreateInstance(lldb_private::Process *process, bool force)
Definition: JITLoaderGDB.cpp:405
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
JITLoaderGDB::DebuggerInitialize
static void DebuggerInitialize(lldb_private::Debugger &debugger)
Definition: JITLoaderGDB.cpp:156
Process.h
JITLoaderGDB::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: JITLoaderGDB.h:28
JITLoaderGDB::DidSetJITBreakpoint
bool DidSetJITBreakpoint() const
Definition: JITLoaderGDB.cpp:440
JITLoaderGDB::JITDebugBreakpointHit
static bool JITDebugBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Definition: JITLoaderGDB.cpp:217
JITLoaderGDB::GetPluginName
llvm::StringRef GetPluginName() override
Definition: JITLoaderGDB.h:38
lldb_private::ModuleList
Definition: ModuleList.h:72
JITLoaderGDB::Initialize
static void Initialize()
Definition: JITLoaderGDB.cpp:430
JITLoaderGDB::m_jit_objects
JITObjectMap m_jit_objects
Definition: JITLoaderGDB.h:72
lldb_private::ConstString
Definition: ConstString.h:40
JITLoaderGDB::ReadJITDescriptorImpl
bool ReadJITDescriptorImpl(bool all_entries)
Definition: JITLoaderGDB.cpp:281
lldb_private::Debugger
Definition: Debugger.h:70
JITLoaderGDB::m_jit_break_id
lldb::user_id_t m_jit_break_id
Definition: JITLoaderGDB.h:74
JITLoaderGDB::DidLaunch
void DidLaunch() override
Called after launching a process.
Definition: JITLoaderGDB.cpp:173
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:612
JITLoaderGDB::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: JITLoaderGDB.cpp:425
JITLoaderGDB::ModulesDidLoad
void ModulesDidLoad(lldb_private::ModuleList &module_list) override
Called after a new shared object has been loaded so that it can be probed for JIT entry point hooks.
Definition: JITLoaderGDB.cpp:179
lldb_private::JITLoader
Definition: JITLoader.h:27
JITLoaderGDB::ReadJITDescriptor
bool ReadJITDescriptor(bool all_entries)
Definition: JITLoaderGDB.cpp:273
JITLoader.h
JITLoaderGDB::JITObjectMap
std::map< lldb::addr_t, const lldb::ModuleSP > JITObjectMap
Definition: JITLoaderGDB.h:71
JITLoaderGDB
Definition: JITLoaderGDB.h:17
JITLoaderGDB::GetSymbolAddress
lldb::addr_t GetSymbolAddress(lldb_private::ModuleList &module_list, lldb_private::ConstString name, lldb::SymbolType symbol_type) const
Definition: JITLoaderGDB.cpp:444
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
JITLoaderGDB::JITLoaderGDB
JITLoaderGDB(lldb_private::Process *process)
Definition: JITLoaderGDB.cpp:146
JITLoaderGDB::DidAttach
void DidAttach() override
Called after attaching a process.
Definition: JITLoaderGDB.cpp:167
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
JITLoaderGDB::SetJITBreakpoint
void SetJITBreakpoint(lldb_private::ModuleList &module_list)
Definition: JITLoaderGDB.cpp:185
JITLoaderGDB::m_jit_descriptor_addr
lldb::addr_t m_jit_descriptor_addr
Definition: JITLoaderGDB.h:75