60 lines · c
1//===-- ThreadDecoder.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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H10#define LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H11 12#include "DecodedThread.h"13#include "forward-declarations.h"14#include "intel-pt.h"15#include "lldb/Target/Process.h"16#include "lldb/Utility/FileSpec.h"17#include <optional>18 19namespace lldb_private {20namespace trace_intel_pt {21 22/// Class that handles the decoding of a thread and caches the result.23class ThreadDecoder {24public:25 /// \param[in] thread_sp26 /// The thread whose intel pt trace buffer will be decoded.27 ///28 /// \param[in] trace29 /// The main Trace object who owns this decoder and its data.30 ThreadDecoder(const lldb::ThreadSP &thread_sp, TraceIntelPT &trace);31 32 /// Decode the thread and store the result internally, to avoid33 /// recomputations.34 ///35 /// \return36 /// A \a DecodedThread instance.37 llvm::Expected<DecodedThreadSP> Decode();38 39 /// \return40 /// The lowest TSC value in this trace if available, \a std::nullopt if41 /// the trace is empty or the trace contains no timing information, or an42 /// \a llvm::Error if it was not possible to set up the decoder.43 llvm::Expected<std::optional<uint64_t>> FindLowestTSC();44 45 ThreadDecoder(const ThreadDecoder &other) = delete;46 ThreadDecoder &operator=(const ThreadDecoder &other) = delete;47 48private:49 llvm::Expected<DecodedThreadSP> DoDecode();50 51 lldb::ThreadSP m_thread_sp;52 TraceIntelPT &m_trace;53 std::optional<DecodedThreadSP> m_decoded_thread;54};55 56} // namespace trace_intel_pt57} // namespace lldb_private58 59#endif // LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H60