1 //===-- ThreadDecoder.h --======---------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H
10 #define LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H
12 #include "DecodedThread.h"
13 #include "forward-declarations.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Utility/FileSpec.h"
19 namespace lldb_private
{
20 namespace trace_intel_pt
{
22 /// Class that handles the decoding of a thread and caches the result.
25 /// \param[in] thread_sp
26 /// The thread whose intel pt trace buffer will be decoded.
29 /// The main Trace object who owns this decoder and its data.
30 ThreadDecoder(const lldb::ThreadSP
&thread_sp
, TraceIntelPT
&trace
);
32 /// Decode the thread and store the result internally, to avoid
36 /// A \a DecodedThread instance.
37 llvm::Expected
<DecodedThreadSP
> Decode();
40 /// The lowest TSC value in this trace if available, \a std::nullopt if
41 /// the trace is empty or the trace contains no timing information, or an
42 /// \a llvm::Error if it was not possible to set up the decoder.
43 llvm::Expected
<std::optional
<uint64_t>> FindLowestTSC();
45 ThreadDecoder(const ThreadDecoder
&other
) = delete;
46 ThreadDecoder
&operator=(const ThreadDecoder
&other
) = delete;
49 llvm::Expected
<DecodedThreadSP
> DoDecode();
51 lldb::ThreadSP m_thread_sp
;
52 TraceIntelPT
&m_trace
;
53 std::optional
<DecodedThreadSP
> m_decoded_thread
;
56 } // namespace trace_intel_pt
57 } // namespace lldb_private
59 #endif // LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H