1//===-- IntelPTPerThreadProcessTrace.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_IntelPTPerThreadProcessTrace_H_
10#define liblldb_IntelPTPerThreadProcessTrace_H_
11
12#include "IntelPTProcessTrace.h"
13#include "IntelPTSingleBufferTrace.h"
14#include "IntelPTThreadTraceCollection.h"
15#include <optional>
16
17namespace lldb_private {
18namespace process_linux {
19
20/// Manages a "process trace" instance by tracing each thread individually.
21class IntelPTPerThreadProcessTrace : public IntelPTProcessTrace {
22public:
23 /// Start tracing the current process by tracing each of its tids
24 /// individually.
25 ///
26 /// \param[in] request
27 /// Intel PT configuration parameters.
28 ///
29 /// \param[in] current_tids
30 /// List of tids currently alive. In the future, whenever a new thread is
31 /// spawned, they should be traced by calling the \a TraceStart(tid) method.
32 ///
33 /// \return
34 /// An \a IntelPTMultiCoreTrace instance if tracing was successful, or
35 /// an \a llvm::Error otherwise.
36 static llvm::Expected<std::unique_ptr<IntelPTPerThreadProcessTrace>>
37 Start(const TraceIntelPTStartRequest &request,
38 llvm::ArrayRef<lldb::tid_t> current_tids);
39
40 bool TracesThread(lldb::tid_t tid) const override;
41
42 llvm::Error TraceStart(lldb::tid_t tid) override;
43
44 llvm::Error TraceStop(lldb::tid_t tid) override;
45
46 TraceIntelPTGetStateResponse GetState() override;
47
48 llvm::Expected<std::optional<std::vector<uint8_t>>>
49 TryGetBinaryData(const TraceGetBinaryDataRequest &request) override;
50
51private:
52 IntelPTPerThreadProcessTrace(const TraceIntelPTStartRequest &request)
53 : m_tracing_params(request) {}
54
55 IntelPTThreadTraceCollection m_thread_traces;
56 /// Params used to trace threads when the user started "process tracing".
57 TraceIntelPTStartRequest m_tracing_params;
58};
59
60} // namespace process_linux
61} // namespace lldb_private
62
63#endif // liblldb_IntelPTPerThreadProcessTrace_H_
64

source code of lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.h