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 LLDB_TARGET_INSTRUMENTATIONRUNTIME_H
10 #define LLDB_TARGET_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.
38 
39  /// Indicates whether or not breakpoints have been registered in the
40  /// instrumentation runtime.
42 
43 protected:
44  InstrumentationRuntime(const lldb::ProcessSP &process_sp)
45  : m_breakpoint_id(0), m_is_active(false) {
46  if (process_sp)
47  m_process_wp = process_sp;
48  }
49 
50  lldb::ProcessSP GetProcessSP() { return m_process_wp.lock(); }
51 
52  lldb::ModuleSP GetRuntimeModuleSP() { return m_runtime_module; }
53 
54  void SetRuntimeModuleSP(lldb::ModuleSP module_sp) {
55  m_runtime_module = std::move(module_sp);
56  }
57 
59 
61 
63 
64  /// Return a regular expression which can be used to identify a valid version
65  /// of the runtime library.
67 
68  /// Check whether \p module_sp corresponds to a valid runtime library.
69  virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) = 0;
70 
71  /// Register a breakpoint in the runtime library and perform any other
72  /// necessary initialization. The runtime library
73  /// is guaranteed to be loaded.
74  virtual void Activate() = 0;
75 
76 public:
77  static void ModulesDidLoad(lldb_private::ModuleList &module_list,
78  Process *process,
80 
81  /// Look for the instrumentation runtime in \p module_list. Register and
82  /// activate the runtime if this hasn't already
83  /// been done.
84  void ModulesDidLoad(lldb_private::ModuleList &module_list);
85 
86  bool IsActive() const { return m_is_active; }
87 
88  virtual lldb::ThreadCollectionSP
90 };
91 
92 } // namespace lldb_private
93 
94 #endif // LLDB_TARGET_INSTRUMENTATIONRUNTIME_H
lldb_private::InstrumentationRuntime::Activate
virtual void Activate()=0
Register a breakpoint in the runtime library and perform any other necessary initialization.
lldb_private::InstrumentationRuntime::m_is_active
bool m_is_active
Indicates whether or not breakpoints have been registered in the instrumentation runtime.
Definition: InstrumentationRuntime.h:41
lldb_private::InstrumentationRuntime::m_breakpoint_id
lldb::user_id_t m_breakpoint_id
The breakpoint in the instrumentation runtime.
Definition: InstrumentationRuntime.h:37
lldb_private::InstrumentationRuntime::GetBacktracesFromExtendedStopInfo
virtual lldb::ThreadCollectionSP GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info)
Definition: InstrumentationRuntime.cpp:72
lldb_private::RegularExpression
Definition: RegularExpression.h:18
StructuredData.h
lldb_private::PluginInterface
Definition: PluginInterface.h:16
lldb_private::InstrumentationRuntime::GetRuntimeModuleSP
lldb::ModuleSP GetRuntimeModuleSP()
Definition: InstrumentationRuntime.h:52
lldb_private::Process
Definition: Process.h:338
lldb_private::InstrumentationRuntime
Definition: InstrumentationRuntime.h:27
lldb_private::InstrumentationRuntime::m_runtime_module
lldb::ModuleSP m_runtime_module
The module containing the instrumentation runtime.
Definition: InstrumentationRuntime.h:34
lldb_private::InstrumentationRuntimeCollection
std::map< lldb::InstrumentationRuntimeType, lldb::InstrumentationRuntimeSP > InstrumentationRuntimeCollection
Definition: InstrumentationRuntime.h:25
lldb_private::InstrumentationRuntime::SetBreakpointID
void SetBreakpointID(lldb::user_id_t ID)
Definition: InstrumentationRuntime.h:60
lldb_private::InstrumentationRuntime::ModulesDidLoad
static void ModulesDidLoad(lldb_private::ModuleList &module_list, Process *process, InstrumentationRuntimeCollection &runtimes)
Definition: InstrumentationRuntime.cpp:20
ID
static char ID
Definition: IRDynamicChecks.cpp:33
lldb_private::ModuleList
Definition: ModuleList.h:82
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
PluginInterface.h
lldb_private::InstrumentationRuntime::GetPatternForRuntimeLibrary
virtual const RegularExpression & GetPatternForRuntimeLibrary()=0
Return a regular expression which can be used to identify a valid version of the runtime library.
lldb_private::InstrumentationRuntime::GetBreakpointID
lldb::user_id_t GetBreakpointID() const
Definition: InstrumentationRuntime.h:58
lldb_private::InstrumentationRuntime::SetRuntimeModuleSP
void SetRuntimeModuleSP(lldb::ModuleSP module_sp)
Definition: InstrumentationRuntime.h:54
lldb-private.h
lldb-types.h
lldb_private::InstrumentationRuntime::CheckIfRuntimeIsValid
virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp)=0
Check whether module_sp corresponds to a valid runtime library.
lldb-forward.h
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private::InstrumentationRuntime::InstrumentationRuntime
InstrumentationRuntime(const lldb::ProcessSP &process_sp)
Definition: InstrumentationRuntime.h:44
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::InstrumentationRuntime::m_process_wp
lldb::ProcessWP m_process_wp
The instrumented process.
Definition: InstrumentationRuntime.h:31
lldb_private::InstrumentationRuntime::SetActive
void SetActive(bool IsActive)
Definition: InstrumentationRuntime.h:62
lldb_private::InstrumentationRuntime::GetProcessSP
lldb::ProcessSP GetProcessSP()
Definition: InstrumentationRuntime.h:50
lldb_private::InstrumentationRuntime::IsActive
bool IsActive() const
Definition: InstrumentationRuntime.h:86
lldb::InstrumentationRuntimeType
InstrumentationRuntimeType
Definition: lldb-enumerations.h:489