]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/InstrumentationRuntime.h
MFV r319948: 5428 provide fts(), reallocarray(), and strtonum()
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / InstrumentationRuntime.h
1 //===-- InstrumentationRuntime.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_InstrumentationRuntime_h_
11 #define liblldb_InstrumentationRuntime_h_
12
13 // C Includes
14 // C++ Includes
15 #include <map>
16 #include <vector>
17
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/Core/PluginInterface.h"
21 #include "lldb/Core/StructuredData.h"
22 #include "lldb/lldb-forward.h"
23 #include "lldb/lldb-private.h"
24 #include "lldb/lldb-types.h"
25
26 namespace lldb_private {
27
28 typedef std::map<lldb::InstrumentationRuntimeType,
29                  lldb::InstrumentationRuntimeSP>
30     InstrumentationRuntimeCollection;
31
32 class InstrumentationRuntime
33     : public std::enable_shared_from_this<InstrumentationRuntime>,
34       public PluginInterface {
35   /// The instrumented process.
36   lldb::ProcessWP m_process_wp;
37
38   /// The module containing the instrumentation runtime.
39   lldb::ModuleSP m_runtime_module;
40
41   /// The breakpoint in the instrumentation runtime.
42   lldb::user_id_t m_breakpoint_id;
43
44   /// Indicates whether or not breakpoints have been registered in the
45   /// instrumentation runtime.
46   bool m_is_active;
47
48 protected:
49   InstrumentationRuntime(const lldb::ProcessSP &process_sp)
50       : m_process_wp(), m_runtime_module(), m_breakpoint_id(0),
51         m_is_active(false) {
52     if (process_sp)
53       m_process_wp = process_sp;
54   }
55
56   lldb::ProcessSP GetProcessSP() { return m_process_wp.lock(); }
57
58   lldb::ModuleSP GetRuntimeModuleSP() { return m_runtime_module; }
59
60   void SetRuntimeModuleSP(lldb::ModuleSP module_sp) {
61     m_runtime_module = module_sp;
62   }
63
64   lldb::user_id_t GetBreakpointID() const { return m_breakpoint_id; }
65
66   void SetBreakpointID(lldb::user_id_t ID) { m_breakpoint_id = ID; }
67
68   void SetActive(bool IsActive) { m_is_active = IsActive; }
69
70   /// Return a regular expression which can be used to identify a valid version
71   /// of the runtime library.
72   virtual const RegularExpression &GetPatternForRuntimeLibrary() = 0;
73
74   /// Check whether \p module_sp corresponds to a valid runtime library.
75   virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) = 0;
76
77   /// Register a breakpoint in the runtime library and perform any other
78   /// necessary initialization. The runtime library
79   /// is guaranteed to be loaded.
80   virtual void Activate() = 0;
81
82 public:
83   static void ModulesDidLoad(lldb_private::ModuleList &module_list,
84                              Process *process,
85                              InstrumentationRuntimeCollection &runtimes);
86
87   /// Look for the instrumentation runtime in \p module_list. Register and
88   /// activate the runtime if this hasn't already
89   /// been done.
90   void ModulesDidLoad(lldb_private::ModuleList &module_list);
91
92   bool IsActive() const { return m_is_active; }
93
94   virtual lldb::ThreadCollectionSP
95   GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info);
96 };
97
98 } // namespace lldb_private
99
100 #endif // liblldb_InstrumentationRuntime_h_