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_
16 #include "lldb/Core/PluginInterface.h"
17 #include "lldb/Utility/StructuredData.h"
18 #include "lldb/lldb-forward.h"
19 #include "lldb/lldb-private.h"
20 #include "lldb/lldb-types.h"
22 namespace lldb_private {
24 typedef std::map<lldb::InstrumentationRuntimeType,
25 lldb::InstrumentationRuntimeSP>
26 InstrumentationRuntimeCollection;
28 class InstrumentationRuntime
29 : public std::enable_shared_from_this<InstrumentationRuntime>,
30 public PluginInterface {
31 /// The instrumented process.
32 lldb::ProcessWP m_process_wp;
34 /// The module containing the instrumentation runtime.
35 lldb::ModuleSP m_runtime_module;
37 /// The breakpoint in the instrumentation runtime.
38 lldb::user_id_t m_breakpoint_id;
40 /// Indicates whether or not breakpoints have been registered in the
41 /// instrumentation runtime.
45 InstrumentationRuntime(const lldb::ProcessSP &process_sp)
46 : m_process_wp(), m_runtime_module(), m_breakpoint_id(0),
49 m_process_wp = process_sp;
52 lldb::ProcessSP GetProcessSP() { return m_process_wp.lock(); }
54 lldb::ModuleSP GetRuntimeModuleSP() { return m_runtime_module; }
56 void SetRuntimeModuleSP(lldb::ModuleSP module_sp) {
57 m_runtime_module = module_sp;
60 lldb::user_id_t GetBreakpointID() const { return m_breakpoint_id; }
62 void SetBreakpointID(lldb::user_id_t ID) { m_breakpoint_id = ID; }
64 void SetActive(bool IsActive) { m_is_active = IsActive; }
66 /// Return a regular expression which can be used to identify a valid version
67 /// of the runtime library.
68 virtual const RegularExpression &GetPatternForRuntimeLibrary() = 0;
70 /// Check whether \p module_sp corresponds to a valid runtime library.
71 virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) = 0;
73 /// Register a breakpoint in the runtime library and perform any other
74 /// necessary initialization. The runtime library
75 /// is guaranteed to be loaded.
76 virtual void Activate() = 0;
79 static void ModulesDidLoad(lldb_private::ModuleList &module_list,
81 InstrumentationRuntimeCollection &runtimes);
83 /// Look for the instrumentation runtime in \p module_list. Register and
84 /// activate the runtime if this hasn't already
86 void ModulesDidLoad(lldb_private::ModuleList &module_list);
88 bool IsActive() const { return m_is_active; }
90 virtual lldb::ThreadCollectionSP
91 GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info);
94 } // namespace lldb_private
96 #endif // liblldb_InstrumentationRuntime_h_