9#include "../common/ThreadPostMortemTrace.h"
12#include "llvm/Support/MemoryBuffer.h"
22 : m_thread_sp(thread_sp), m_trace(trace) {}
25 std::optional<uint64_t> lowest_tsc;
27 m_thread_sp->GetID(), [&](llvm::ArrayRef<uint8_t> data) -> llvm::Error {
28 Expected<std::optional<uint64_t>> tsc =
29 FindLowestTSCInTrace(m_trace, data);
31 return tsc.takeError();
33 return Error::success();
36 return std::move(err);
42 if (Expected<DecodedThreadSP> decoded_thread =
DoDecode()) {
45 return decoded_thread.takeError();
53 .
TimeTask(
"Decoding instructions", [&]() -> Expected<DecodedThreadSP> {
58 m_thread_sp->GetID(), [&](llvm::ArrayRef<uint8_t> data) {
59 return DecodeSingleTraceForThread(*decoded_thread_sp, m_trace,
64 return std::move(err);
65 return decoded_thread_sp;
auto TimeTask(llvm::StringRef name, C task)
Execute the given task and record its duration.
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
llvm::Expected< DecodedThreadSP > DoDecode()
lldb::ThreadSP m_thread_sp
ThreadDecoder(const lldb::ThreadSP &thread_sp, TraceIntelPT &trace)
llvm::Error OnThreadBufferRead(lldb::tid_t tid, OnBinaryDataReadCallback callback)
See Trace::OnThreadBinaryDataRead().
ScopedTaskTimer & GetThreadTimer(lldb::tid_t tid)
std::optional< LinuxPerfZeroTscConversion > GetPerfZeroTscConversion()
Get or fetch the values used to convert to and from TSCs and nanos.
std::shared_ptr< DecodedThread > DecodedThreadSP
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Thread > ThreadSP