JITLoader.h revision 296417
1//===-- JITLoader.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_JITLoader_h_
11#define liblldb_JITLoader_h_
12
13#include <vector>
14
15#include "lldb/Core/PluginInterface.h"
16#include "lldb/Target/JITLoaderList.h"
17
18namespace lldb_private {
19
20//----------------------------------------------------------------------
21/// @class JITLoader JITLoader.h "lldb/Target/JITLoader.h"
22/// @brief A plug-in interface definition class for JIT loaders.
23///
24/// Plugins of this kind listen for code generated at runtime in the
25/// target. They are very similar to dynamic loader, with the difference
26/// that they do not have information about the target's dyld and
27/// that there may be multiple JITLoader plugins per process, while
28/// there is at most one DynamicLoader.
29//----------------------------------------------------------------------
30class JITLoader :
31    public PluginInterface
32{
33public:
34    //------------------------------------------------------------------
35    /// Find a JIT loader plugin for a given process.
36    ///
37    /// Scans the installed DynamicLoader plug-ins and tries to find
38    /// all applicable instances for the current process.
39    ///
40    /// @param[in] process
41    ///     The process for which to try and locate a JIT loader
42    ///     plug-in instance.
43    ///
44    //------------------------------------------------------------------
45    static void
46    LoadPlugins (Process *process, lldb_private::JITLoaderList &list);
47
48    //------------------------------------------------------------------
49    /// Construct with a process.
50    //------------------------------------------------------------------
51    JITLoader (Process *process);
52
53    ~JITLoader() override;
54
55    //------------------------------------------------------------------
56    /// Called after attaching a process.
57    ///
58    /// Allow JITLoader plug-ins to execute some code after
59    /// attaching to a process.
60    //------------------------------------------------------------------
61    virtual void
62    DidAttach () = 0;
63
64    //------------------------------------------------------------------
65    /// Called after launching a process.
66    ///
67    /// Allow JITLoader plug-ins to execute some code after
68    /// the process has stopped for the first time on launch.
69    //------------------------------------------------------------------
70    virtual void
71    DidLaunch () = 0;
72
73    //------------------------------------------------------------------
74    /// Called after a new shared object has been loaded so that it can
75    /// be probed for JIT entry point hooks.
76    //------------------------------------------------------------------
77    virtual void
78    ModulesDidLoad (lldb_private::ModuleList &module_list) = 0;
79
80protected:
81    //------------------------------------------------------------------
82    // Member variables.
83    //------------------------------------------------------------------
84    Process* m_process;
85};
86
87} // namespace lldb_private
88
89#endif // liblldb_JITLoader_h_
90