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