LLDB  mainline
IntelPTThreadTraceCollection.h
Go to the documentation of this file.
1 //===-- IntelPTThreadTraceCollection.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_IntelPTPerThreadTraceCollection_H_
10 #define liblldb_IntelPTPerThreadTraceCollection_H_
11 
13 
14 namespace lldb_private {
15 namespace process_linux {
16 
17 /// Manages a list of thread traces.
19 public:
21 
22  /// Dispose of all traces
23  void Clear();
24 
25  /// \return
26  /// \b true if and only if this instance of tracing the provided \p tid.
27  bool TracesThread(lldb::tid_t tid) const;
28 
29  /// \return
30  /// The total sum of the intel pt trace buffer sizes used by this
31  /// collection.
32  size_t GetTotalBufferSize() const;
33 
34  /// Execute the provided callback on each thread that is being traced.
35  ///
36  /// \param[in] callback.tid
37  /// The id of the thread that is being traced.
38  ///
39  /// \param[in] callback.core_trace
40  /// The single-buffer trace instance for the given core.
41  void ForEachThread(std::function<void(lldb::tid_t tid,
42  IntelPTSingleBufferTrace &thread_trace)>
43  callback);
44 
45  llvm::Expected<IntelPTSingleBufferTrace &> GetTracedThread(lldb::tid_t tid);
46 
47  /// Start tracing the thread given by its \p tid.
48  ///
49  /// \return
50  /// An error if the operation failed.
52  const TraceIntelPTStartRequest &request);
53 
54  /// Stop tracing the thread given by its \p tid.
55  ///
56  /// \return
57  /// An error if the given thread is not being traced or tracing couldn't be
58  /// stopped.
60 
61  size_t GetTracedThreadsCount() const;
62 
63  /// \copydoc IntelPTProcessTrace::TryGetBinaryData()
64  llvm::Expected<llvm::Optional<std::vector<uint8_t>>>
66 
67 private:
68  llvm::DenseMap<lldb::tid_t, IntelPTSingleBufferTrace> m_thread_traces;
69  /// Total actual thread buffer size in bytes
70  size_t m_total_buffer_size = 0;
71 };
72 
73 } // namespace process_linux
74 } // namespace lldb_private
75 
76 #endif // liblldb_IntelPTPerThreadTraceCollection_H_
lldb_private::process_linux::IntelPTThreadTraceCollection::m_total_buffer_size
size_t m_total_buffer_size
Total actual thread buffer size in bytes.
Definition: IntelPTThreadTraceCollection.h:70
lldb_private::process_linux::IntelPTThreadTraceCollection::GetTotalBufferSize
size_t GetTotalBufferSize() const
Definition: IntelPTThreadTraceCollection.cpp:46
lldb_private::TraceGetBinaryDataRequest
jLLDBTraceGetBinaryData gdb-remote packet
Definition: TraceGDBRemotePackets.h:149
lldb_private::process_linux::IntelPTThreadTraceCollection::m_thread_traces
llvm::DenseMap< lldb::tid_t, IntelPTSingleBufferTrace > m_thread_traces
Definition: IntelPTThreadTraceCollection.h:68
lldb_private::process_linux::IntelPTThreadTraceCollection
Manages a list of thread traces.
Definition: IntelPTThreadTraceCollection.h:18
lldb_private::process_linux::IntelPTThreadTraceCollection::TracesThread
bool TracesThread(lldb::tid_t tid) const
Definition: IntelPTThreadTraceCollection.cpp:16
lldb_private::process_linux::IntelPTSingleBufferTrace
This class wraps a single perf event collecting intel pt data in a single buffer.
Definition: IntelPTSingleBufferTrace.h:25
lldb_private::TraceIntelPTStartRequest
jLLDBTraceStart gdb-remote packet
Definition: TraceIntelPTGDBRemotePackets.h:33
lldb_private::process_linux::IntelPTThreadTraceCollection::IntelPTThreadTraceCollection
IntelPTThreadTraceCollection()
Definition: IntelPTThreadTraceCollection.h:20
lldb_private::process_linux::IntelPTThreadTraceCollection::ForEachThread
void ForEachThread(std::function< void(lldb::tid_t tid, IntelPTSingleBufferTrace &thread_trace)> callback)
Execute the provided callback on each thread that is being traced.
Definition: IntelPTThreadTraceCollection.cpp:50
lldb_private::process_linux::IntelPTThreadTraceCollection::TraceStart
llvm::Error TraceStart(lldb::tid_t tid, const TraceIntelPTStartRequest &request)
Start tracing the thread given by its tid.
Definition: IntelPTThreadTraceCollection.cpp:30
lldb_private::process_linux::IntelPTThreadTraceCollection::Clear
void Clear()
Dispose of all traces.
Definition: IntelPTThreadTraceCollection.cpp:66
lldb_private::process_linux::IntelPTThreadTraceCollection::GetTracedThread
llvm::Expected< IntelPTSingleBufferTrace & > GetTracedThread(lldb::tid_t tid)
Definition: IntelPTThreadTraceCollection.cpp:58
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::process_linux::IntelPTThreadTraceCollection::TraceStop
llvm::Error TraceStop(lldb::tid_t tid)
Stop tracing the thread given by its tid.
Definition: IntelPTThreadTraceCollection.cpp:20
lldb_private::process_linux::IntelPTThreadTraceCollection::GetTracedThreadsCount
size_t GetTracedThreadsCount() const
Definition: IntelPTThreadTraceCollection.cpp:71
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:30
IntelPTSingleBufferTrace.h
lldb_private::process_linux::IntelPTThreadTraceCollection::TryGetBinaryData
llvm::Expected< llvm::Optional< std::vector< uint8_t > > > TryGetBinaryData(const TraceGetBinaryDataRequest &request)
Definition: IntelPTThreadTraceCollection.cpp:76
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86