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