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