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