1 //===-- IntelPTDecoder.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 LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_DECODER_H 10 #define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_DECODER_H 11 12 #include "intel-pt.h" 13 14 #include "DecodedThread.h" 15 #include "lldb/Target/Process.h" 16 #include "lldb/Utility/FileSpec.h" 17 18 namespace lldb_private { 19 namespace trace_intel_pt { 20 21 /// \a lldb_private::ThreadTrace decoder that stores the output from decoding, 22 /// avoiding recomputations, as decoding is expensive. 23 class ThreadTraceDecoder { 24 public: 25 /// \param[in] trace_thread 26 /// The thread whose trace file will be decoded. 27 /// 28 /// \param[in] pt_cpu 29 /// The libipt cpu used when recording the trace. ThreadTraceDecoder(const std::shared_ptr<ThreadTrace> & trace_thread,const pt_cpu & pt_cpu)30 ThreadTraceDecoder(const std::shared_ptr<ThreadTrace> &trace_thread, 31 const pt_cpu &pt_cpu) 32 : m_trace_thread(trace_thread), m_pt_cpu(pt_cpu), m_decoded_thread() {} 33 34 /// Decode the thread and store the result internally. 35 /// 36 /// \return 37 /// A \a DecodedThread instance. 38 const DecodedThread &Decode(); 39 40 private: 41 ThreadTraceDecoder(const ThreadTraceDecoder &other) = delete; 42 ThreadTraceDecoder &operator=(const ThreadTraceDecoder &other) = delete; 43 44 std::shared_ptr<ThreadTrace> m_trace_thread; 45 pt_cpu m_pt_cpu; 46 llvm::Optional<DecodedThread> m_decoded_thread; 47 }; 48 49 } // namespace trace_intel_pt 50 } // namespace lldb_private 51 52 #endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_DECODER_H 53