1 //===-- InstrumentationRuntime.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_InstrumentationRuntime_h_
11 #define liblldb_InstrumentationRuntime_h_
18 // Other libraries and framework includes
20 #include "lldb/Core/PluginInterface.h"
21 #include "lldb/Utility/StructuredData.h"
22 #include "lldb/lldb-forward.h"
23 #include "lldb/lldb-private.h"
24 #include "lldb/lldb-types.h"
26 namespace lldb_private {
28 typedef std::map<lldb::InstrumentationRuntimeType,
29 lldb::InstrumentationRuntimeSP>
30 InstrumentationRuntimeCollection;
32 class InstrumentationRuntime
33 : public std::enable_shared_from_this<InstrumentationRuntime>,
34 public PluginInterface {
35 /// The instrumented process.
36 lldb::ProcessWP m_process_wp;
38 /// The module containing the instrumentation runtime.
39 lldb::ModuleSP m_runtime_module;
41 /// The breakpoint in the instrumentation runtime.
42 lldb::user_id_t m_breakpoint_id;
44 /// Indicates whether or not breakpoints have been registered in the
45 /// instrumentation runtime.
49 InstrumentationRuntime(const lldb::ProcessSP &process_sp)
50 : m_process_wp(), m_runtime_module(), m_breakpoint_id(0),
53 m_process_wp = process_sp;
56 lldb::ProcessSP GetProcessSP() { return m_process_wp.lock(); }
58 lldb::ModuleSP GetRuntimeModuleSP() { return m_runtime_module; }
60 void SetRuntimeModuleSP(lldb::ModuleSP module_sp) {
61 m_runtime_module = module_sp;
64 lldb::user_id_t GetBreakpointID() const { return m_breakpoint_id; }
66 void SetBreakpointID(lldb::user_id_t ID) { m_breakpoint_id = ID; }
68 void SetActive(bool IsActive) { m_is_active = IsActive; }
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;
74 /// Check whether \p module_sp corresponds to a valid runtime library.
75 virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) = 0;
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;
83 static void ModulesDidLoad(lldb_private::ModuleList &module_list,
85 InstrumentationRuntimeCollection &runtimes);
87 /// Look for the instrumentation runtime in \p module_list. Register and
88 /// activate the runtime if this hasn't already
90 void ModulesDidLoad(lldb_private::ModuleList &module_list);
92 bool IsActive() const { return m_is_active; }
94 virtual lldb::ThreadCollectionSP
95 GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info);
98 } // namespace lldb_private
100 #endif // liblldb_InstrumentationRuntime_h_