Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / Plugins / Trace / intel-pt / ThreadDecoder.h
blob289915c028105a0d502e4520583fd756ade00aa1
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-exception
6 //
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"
14 #include "intel-pt.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Utility/FileSpec.h"
17 #include <optional>
19 namespace lldb_private {
20 namespace trace_intel_pt {
22 /// Class that handles the decoding of a thread and caches the result.
23 class ThreadDecoder {
24 public:
25 /// \param[in] thread_sp
26 /// The thread whose intel pt trace buffer will be decoded.
27 ///
28 /// \param[in] trace
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
33 /// recomputations.
34 ///
35 /// \return
36 /// A \a DecodedThread instance.
37 llvm::Expected<DecodedThreadSP> Decode();
39 /// \return
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;
48 private:
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