LLDB  mainline
IntelPTCollector.h
Go to the documentation of this file.
1 //===-- IntelPTCollector.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_IntelPTCollector_H_
10 #define liblldb_IntelPTCollector_H_
11 
12 #include "IntelPTMultiCoreTrace.h"
15 #include "Perf.h"
17 #include "lldb/Utility/Status.h"
19 #include "lldb/lldb-types.h"
20 #include <linux/perf_event.h>
21 #include <sys/mman.h>
22 #include <unistd.h>
23 
24 namespace lldb_private {
25 
26 namespace process_linux {
27 
28 /// Main class that manages intel-pt process and thread tracing.
30 public:
31  /// \param[in] process
32  /// Process to be traced.
34 
35  static bool IsSupported();
36 
37  /// To be invoked as soon as we know the process stopped.
38  void ProcessDidStop();
39 
40  /// To be invoked before the process will resume, so that we can capture the
41  /// first instructions after the resume.
42  void ProcessWillResume();
43 
44  /// If "process tracing" is enabled, then trace the given thread.
46 
47  /// Stops tracing a tracing upon a destroy event.
49 
50  /// Implementation of the jLLDBTraceStop packet
51  llvm::Error TraceStop(const TraceStopRequest &request);
52 
53  /// Implementation of the jLLDBTraceStart packet
55 
56  /// Implementation of the jLLDBTraceGetState packet
57  llvm::Expected<llvm::json::Value> GetState();
58 
59  /// Implementation of the jLLDBTraceGetBinaryData packet
60  llvm::Expected<std::vector<uint8_t>>
62 
63  /// Dispose of all traces
64  void Clear();
65 
66 private:
68 
69  /// Start tracing a specific thread.
71  const TraceIntelPTStartRequest &request);
72 
73  /// \return
74  /// The conversion object between TSC and wall time.
75  llvm::Expected<LinuxPerfZeroTscConversion &>
77 
78  /// The target process.
80  /// Threads traced due to "thread tracing"
82 
83  /// Only one instance of "process trace" can be active at a given time.
84  /// It might be \b nullptr.
86 };
87 
88 } // namespace process_linux
89 } // namespace lldb_private
90 
91 #endif // liblldb_IntelPTCollector_H_
lldb_private::process_linux::IntelPTCollector::IsSupported
static bool IsSupported()
Definition: IntelPTCollector.cpp:252
lldb_private::TraceGetBinaryDataRequest
jLLDBTraceGetBinaryData gdb-remote packet
Definition: TraceGDBRemotePackets.h:149
IntelPTMultiCoreTrace.h
lldb_private::process_linux::IntelPTCollector::TraceStop
llvm::Error TraceStop(const TraceStopRequest &request)
Implementation of the jLLDBTraceStop packet.
Definition: IntelPTCollector.cpp:52
lldb_private::process_linux::IntelPTCollector::m_process
NativeProcessProtocol & m_process
The target process.
Definition: IntelPTCollector.h:79
lldb_private::process_linux::IntelPTThreadTraceCollection
Manages a list of thread traces.
Definition: IntelPTThreadTraceCollection.h:18
lldb_private::process_linux::IntelPTCollector::GetBinaryData
llvm::Expected< std::vector< uint8_t > > GetBinaryData(const TraceGetBinaryDataRequest &request)
Implementation of the jLLDBTraceGetBinaryData packet.
Definition: IntelPTCollector.cpp:222
TraceIntelPTGDBRemotePackets.h
lldb_private::process_linux::IntelPTCollector::IntelPTCollector
IntelPTCollector(NativeProcessProtocol &process)
Definition: IntelPTCollector.cpp:32
lldb_private::process_linux::IntelPTCollector::Clear
void Clear()
Dispose of all traces.
Definition: IntelPTCollector.cpp:261
lldb_private::process_linux::IntelPTCollector::TraceStart
llvm::Error TraceStart(const TraceIntelPTStartRequest &request)
Implementation of the jLLDBTraceStart packet.
Definition: IntelPTCollector.cpp:98
lldb_private::process_linux::IntelPTCollector
Main class that manages intel-pt process and thread tracing.
Definition: IntelPTCollector.h:29
lldb_private::process_linux::IntelPTCollector::OnThreadCreated
llvm::Error OnThreadCreated(lldb::tid_t tid)
If "process tracing" is enabled, then trace the given thread.
Definition: IntelPTCollector.cpp:179
lldb_private::TraceIntelPTStartRequest
jLLDBTraceStart gdb-remote packet
Definition: TraceIntelPTGDBRemotePackets.h:33
lldb_private::process_linux::IntelPTCollector::ProcessWillResume
void ProcessWillResume()
To be invoked before the process will resume, so that we can capture the first instructions after the...
Definition: IntelPTCollector.cpp:169
NativeProcessProtocol.h
lldb-types.h
lldb_private::TraceStopRequest
jLLDBTraceStop gdb-remote packet
Definition: TraceGDBRemotePackets.h:64
lldb_private::process_linux::IntelPTCollector::OnThreadDestroyed
llvm::Error OnThreadDestroyed(lldb::tid_t tid)
Stops tracing a tracing upon a destroy event.
Definition: IntelPTCollector.cpp:186
lldb_private::NativeProcessProtocol
Definition: NativeProcessProtocol.h:48
lldb_private::process_linux::IntelPTCollector::m_thread_traces
IntelPTThreadTraceCollection m_thread_traces
Threads traced due to "thread tracing".
Definition: IntelPTCollector.h:81
Perf.h
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::process_linux::IntelPTCollector::ProcessDidStop
void ProcessDidStop()
To be invoked as soon as we know the process stopped.
Definition: IntelPTCollector.cpp:174
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:30
lldb_private::process_linux::IntelPTProcessTraceUP
std::unique_ptr< IntelPTProcessTrace > IntelPTProcessTraceUP
Definition: IntelPTProcessTrace.h:47
IntelPTSingleBufferTrace.h
lldb_private::process_linux::IntelPTCollector::GetState
llvm::Expected< llvm::json::Value > GetState()
Implementation of the jLLDBTraceGetState packet.
Definition: IntelPTCollector.cpp:194
lldb_private::process_linux::IntelPTCollector::m_process_trace_up
IntelPTProcessTraceUP m_process_trace_up
Only one instance of "process trace" can be active at a given time.
Definition: IntelPTCollector.h:85
lldb_private::process_linux::IntelPTCollector::FetchPerfTscConversionParameters
llvm::Expected< LinuxPerfZeroTscConversion & > FetchPerfTscConversionParameters()
Definition: IntelPTCollector.cpp:36
IntelPTPerThreadProcessTrace.h
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86