JITLoader.h revision 276479
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    virtual
54    ~JITLoader ();
55
56    //------------------------------------------------------------------
57    /// Called after attaching a process.
58    ///
59    /// Allow JITLoader plug-ins to execute some code after
60    /// attaching to a process.
61    //------------------------------------------------------------------
62    virtual void
63    DidAttach () = 0;
64
65    //------------------------------------------------------------------
66    /// Called after launching a process.
67    ///
68    /// Allow JITLoader plug-ins to execute some code after
69    /// the process has stopped for the first time on launch.
70    //------------------------------------------------------------------
71    virtual void
72    DidLaunch () = 0;
73
74    //------------------------------------------------------------------
75    /// Called after a new shared object has been loaded so that it can
76    /// be probed for JIT entry point hooks.
77    //------------------------------------------------------------------
78    virtual void
79    ModulesDidLoad (lldb_private::ModuleList &module_list) = 0;
80
81protected:
82    //------------------------------------------------------------------
83    // Member variables.
84    //------------------------------------------------------------------
85    Process* m_process;
86};
87
88} // namespace lldb_private
89
90#endif // liblldb_JITLoader_h_
91