LLDB mainline
ThreadDecoder.h
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H
10#define LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H
11
12#include "DecodedThread.h"
14#include "intel-pt.h"
15#include "lldb/Target/Process.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.
24public:
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);
31
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();
38
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();
44
45 ThreadDecoder(const ThreadDecoder &other) = delete;
46 ThreadDecoder &operator=(const ThreadDecoder &other) = delete;
47
48private:
49 llvm::Expected<DecodedThreadSP> DoDecode();
50
53 std::optional<DecodedThreadSP> m_decoded_thread;
54};
55
56} // namespace trace_intel_pt
57} // namespace lldb_private
58
59#endif // LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H
Class that handles the decoding of a thread and caches the result.
Definition: ThreadDecoder.h:23
ThreadDecoder(const ThreadDecoder &other)=delete
llvm::Expected< DecodedThreadSP > Decode()
Decode the thread and store the result internally, to avoid recomputations.
llvm::Expected< std::optional< uint64_t > > FindLowestTSC()
std::optional< DecodedThreadSP > m_decoded_thread
Definition: ThreadDecoder.h:53
llvm::Expected< DecodedThreadSP > DoDecode()
ThreadDecoder & operator=(const ThreadDecoder &other)=delete
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:450