LLDB  mainline
InstrumentationRuntime.h
Go to the documentation of this file.
1 //===-- InstrumentationRuntime.h --------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_InstrumentationRuntime_h_
10 #define liblldb_InstrumentationRuntime_h_
11 
12 #include <map>
13 #include <vector>
14 
17 #include "lldb/lldb-forward.h"
18 #include "lldb/lldb-private.h"
19 #include "lldb/lldb-types.h"
20 
21 namespace lldb_private {
22 
23 typedef std::map<lldb::InstrumentationRuntimeType,
24  lldb::InstrumentationRuntimeSP>
26 
28  : public std::enable_shared_from_this<InstrumentationRuntime>,
29  public PluginInterface {
30  /// The instrumented process.
31  lldb::ProcessWP m_process_wp;
32 
33  /// The module containing the instrumentation runtime.
34  lldb::ModuleSP m_runtime_module;
35 
36  /// The breakpoint in the instrumentation runtime.
37  lldb::user_id_t m_breakpoint_id;
38 
39  /// Indicates whether or not breakpoints have been registered in the
40  /// instrumentation runtime.
41  bool m_is_active;
42 
43 protected:
44  InstrumentationRuntime(const lldb::ProcessSP &process_sp)
45  : m_process_wp(), m_runtime_module(), m_breakpoint_id(0),
46  m_is_active(false) {
47  if (process_sp)
48  m_process_wp = process_sp;
49  }
50 
51  lldb::ProcessSP GetProcessSP() { return m_process_wp.lock(); }
52 
53  lldb::ModuleSP GetRuntimeModuleSP() { return m_runtime_module; }
54 
55  void SetRuntimeModuleSP(lldb::ModuleSP module_sp) {
56  m_runtime_module = module_sp;
57  }
58 
59  lldb::user_id_t GetBreakpointID() const { return m_breakpoint_id; }
60 
61  void SetBreakpointID(lldb::user_id_t ID) { m_breakpoint_id = ID; }
62 
63  void SetActive(bool IsActive) { m_is_active = IsActive; }
64 
65  /// Return a regular expression which can be used to identify a valid version
66  /// of the runtime library.
68 
69  /// Check whether \p module_sp corresponds to a valid runtime library.
70  virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) = 0;
71 
72  /// Register a breakpoint in the runtime library and perform any other
73  /// necessary initialization. The runtime library
74  /// is guaranteed to be loaded.
75  virtual void Activate() = 0;
76 
77 public:
78  static void ModulesDidLoad(lldb_private::ModuleList &module_list,
79  Process *process,
81 
82  /// Look for the instrumentation runtime in \p module_list. Register and
83  /// activate the runtime if this hasn't already
84  /// been done.
85  void ModulesDidLoad(lldb_private::ModuleList &module_list);
86 
87  bool IsActive() const { return m_is_active; }
88 
89  virtual lldb::ThreadCollectionSP
91 };
92 
93 } // namespace lldb_private
94 
95 #endif // liblldb_InstrumentationRuntime_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual void Activate()=0
Register a breakpoint in the runtime library and perform any other necessary initialization.
"lldb/Utility/RegularExpression.h" A C++ wrapper class for regex.
InstrumentationRuntime(const lldb::ProcessSP &process_sp)
static void ModulesDidLoad(lldb_private::ModuleList &module_list, Process *process, InstrumentationRuntimeCollection &runtimes)
std::map< lldb::InstrumentationRuntimeType, lldb::InstrumentationRuntimeSP > InstrumentationRuntimeCollection
uint64_t user_id_t
Definition: lldb-types.h:84
InstrumentationRuntimeType
A collection class for Module objects.
Definition: ModuleList.h:91
virtual lldb::ThreadCollectionSP GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info)
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
static char ID
virtual const RegularExpression & GetPatternForRuntimeLibrary()=0
Return a regular expression which can be used to identify a valid version of the runtime library...
virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp)=0
Check whether module_sp corresponds to a valid runtime library.
std::shared_ptr< Object > ObjectSP
void SetRuntimeModuleSP(lldb::ModuleSP module_sp)