Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:53

0001 //===-- InstrumentationRuntime.h --------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_TARGET_INSTRUMENTATIONRUNTIME_H
0010 #define LLDB_TARGET_INSTRUMENTATIONRUNTIME_H
0011 
0012 #include <map>
0013 #include <vector>
0014 
0015 #include "lldb/Core/PluginInterface.h"
0016 #include "lldb/Utility/StructuredData.h"
0017 #include "lldb/lldb-forward.h"
0018 #include "lldb/lldb-private.h"
0019 #include "lldb/lldb-types.h"
0020 
0021 namespace lldb_private {
0022 
0023 typedef std::map<lldb::InstrumentationRuntimeType,
0024                  lldb::InstrumentationRuntimeSP>
0025     InstrumentationRuntimeCollection;
0026 
0027 class InstrumentationRuntime
0028     : public std::enable_shared_from_this<InstrumentationRuntime>,
0029       public PluginInterface {
0030   /// The instrumented process.
0031   lldb::ProcessWP m_process_wp;
0032 
0033   /// The module containing the instrumentation runtime.
0034   lldb::ModuleSP m_runtime_module;
0035 
0036   /// The breakpoint in the instrumentation runtime.
0037   lldb::user_id_t m_breakpoint_id;
0038 
0039   /// Indicates whether or not breakpoints have been registered in the
0040   /// instrumentation runtime.
0041   bool m_is_active;
0042 
0043 protected:
0044   InstrumentationRuntime(const lldb::ProcessSP &process_sp)
0045       : m_breakpoint_id(0), m_is_active(false) {
0046     if (process_sp)
0047       m_process_wp = process_sp;
0048   }
0049 
0050   lldb::ProcessSP GetProcessSP() { return m_process_wp.lock(); }
0051 
0052   lldb::ModuleSP GetRuntimeModuleSP() { return m_runtime_module; }
0053 
0054   void SetRuntimeModuleSP(lldb::ModuleSP module_sp) {
0055     m_runtime_module = std::move(module_sp);
0056   }
0057 
0058   lldb::user_id_t GetBreakpointID() const { return m_breakpoint_id; }
0059 
0060   void SetBreakpointID(lldb::user_id_t ID) { m_breakpoint_id = ID; }
0061 
0062   void SetActive(bool IsActive) { m_is_active = IsActive; }
0063 
0064   /// Return a regular expression which can be used to identify a valid version
0065   /// of the runtime library.
0066   virtual const RegularExpression &GetPatternForRuntimeLibrary() = 0;
0067 
0068   /// Check whether \p module_sp corresponds to a valid runtime library.
0069   virtual bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) = 0;
0070 
0071   /// Register a breakpoint in the runtime library and perform any other
0072   /// necessary initialization. The runtime library
0073   /// is guaranteed to be loaded.
0074   virtual void Activate() = 0;
0075 
0076 public:
0077   static void ModulesDidLoad(lldb_private::ModuleList &module_list,
0078                              Process *process,
0079                              InstrumentationRuntimeCollection &runtimes);
0080 
0081   /// Look for the instrumentation runtime in \p module_list. Register and
0082   /// activate the runtime if this hasn't already
0083   /// been done.
0084   void ModulesDidLoad(lldb_private::ModuleList &module_list);
0085 
0086   bool IsActive() const { return m_is_active; }
0087 
0088   virtual lldb::ThreadCollectionSP
0089   GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info);
0090 };
0091 
0092 } // namespace lldb_private
0093 
0094 #endif // LLDB_TARGET_INSTRUMENTATIONRUNTIME_H