diff options
Diffstat (limited to 'lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h')
-rw-r--r-- | lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h b/lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h index 2e67f9bf6da7..e969db579e52 100644 --- a/lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h @@ -12,38 +12,73 @@ #include "intel-pt.h" #include "DecodedThread.h" +#include "forward-declarations.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" namespace lldb_private { namespace trace_intel_pt { -/// \a lldb_private::ThreadTrace decoder that stores the output from decoding, -/// avoiding recomputations, as decoding is expensive. -class ThreadTraceDecoder { +/// Base class that handles the decoding of a thread and caches the result. +class ThreadDecoder { public: - /// \param[in] trace_thread - /// The thread whose trace file will be decoded. + virtual ~ThreadDecoder() = default; + + ThreadDecoder() = default; + + /// Decode the thread and store the result internally, to avoid + /// recomputations. /// - /// \param[in] pt_cpu - /// The libipt cpu used when recording the trace. - ThreadTraceDecoder(const std::shared_ptr<ThreadTrace> &trace_thread, - const pt_cpu &pt_cpu) - : m_trace_thread(trace_thread), m_pt_cpu(pt_cpu), m_decoded_thread() {} + /// \return + /// A \a DecodedThread instance. + DecodedThreadSP Decode(); - /// Decode the thread and store the result internally. + ThreadDecoder(const ThreadDecoder &other) = delete; + ThreadDecoder &operator=(const ThreadDecoder &other) = delete; + +protected: + /// Decode the thread. /// /// \return /// A \a DecodedThread instance. - const DecodedThread &Decode(); + virtual DecodedThreadSP DoDecode() = 0; + + llvm::Optional<DecodedThreadSP> m_decoded_thread; +}; + +/// Decoder implementation for \a lldb_private::ThreadPostMortemTrace, which are +/// non-live processes that come trace session files. +class PostMortemThreadDecoder : public ThreadDecoder { +public: + /// \param[in] trace_thread + /// The thread whose trace file will be decoded. + /// + /// \param[in] trace + /// The main Trace object who owns this decoder and its data. + PostMortemThreadDecoder(const lldb::ThreadPostMortemTraceSP &trace_thread, + TraceIntelPT &trace); + +private: + DecodedThreadSP DoDecode() override; + + lldb::ThreadPostMortemTraceSP m_trace_thread; + TraceIntelPT &m_trace; +}; + +class LiveThreadDecoder : public ThreadDecoder { +public: + /// \param[in] thread + /// The thread whose traces will be decoded. + /// + /// \param[in] trace + /// The main Trace object who owns this decoder and its data. + LiveThreadDecoder(Thread &thread, TraceIntelPT &trace); private: - ThreadTraceDecoder(const ThreadTraceDecoder &other) = delete; - ThreadTraceDecoder &operator=(const ThreadTraceDecoder &other) = delete; + DecodedThreadSP DoDecode() override; - std::shared_ptr<ThreadTrace> m_trace_thread; - pt_cpu m_pt_cpu; - llvm::Optional<DecodedThread> m_decoded_thread; + lldb::ThreadSP m_thread_sp; + TraceIntelPT &m_trace; }; } // namespace trace_intel_pt |