xref: /freebsd-src/contrib/llvm-project/lldb/source/Plugins/Trace/common/ThreadPostMortemTrace.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1fe6060f1SDimitry Andric //===-- ThreadPostMortemTrace.h ---------------------------------*- C++ -*-===//
2fe6060f1SDimitry Andric //
3fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe6060f1SDimitry Andric //
7fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
8fe6060f1SDimitry Andric 
9fe6060f1SDimitry Andric #ifndef LLDB_TARGET_THREADPOSTMORTEMTRACE_H
10fe6060f1SDimitry Andric #define LLDB_TARGET_THREADPOSTMORTEMTRACE_H
11fe6060f1SDimitry Andric 
12fe6060f1SDimitry Andric #include "lldb/Target/Thread.h"
13*bdd1243dSDimitry Andric #include <optional>
14fe6060f1SDimitry Andric 
15fe6060f1SDimitry Andric namespace lldb_private {
16fe6060f1SDimitry Andric 
17fe6060f1SDimitry Andric /// \class ThreadPostMortemTrace ThreadPostMortemTrace.h
18fe6060f1SDimitry Andric ///
19fe6060f1SDimitry Andric /// Thread implementation used for representing threads gotten from trace
20fe6060f1SDimitry Andric /// session files, which are similar to threads from core files.
21fe6060f1SDimitry Andric ///
22fe6060f1SDimitry Andric class ThreadPostMortemTrace : public Thread {
23fe6060f1SDimitry Andric public:
24fe6060f1SDimitry Andric   /// \param[in] process
25fe6060f1SDimitry Andric   ///     The process who owns this thread.
26fe6060f1SDimitry Andric   ///
27fe6060f1SDimitry Andric   /// \param[in] tid
28fe6060f1SDimitry Andric   ///     The tid of this thread.
29fe6060f1SDimitry Andric   ///
30fe6060f1SDimitry Andric   /// \param[in] trace_file
31fe6060f1SDimitry Andric   ///     The file that contains the list of instructions that were traced when
32fe6060f1SDimitry Andric   ///     this thread was being executed.
ThreadPostMortemTrace(Process & process,lldb::tid_t tid,const std::optional<FileSpec> & trace_file)33fe6060f1SDimitry Andric   ThreadPostMortemTrace(Process &process, lldb::tid_t tid,
34*bdd1243dSDimitry Andric                         const std::optional<FileSpec> &trace_file)
35fe6060f1SDimitry Andric       : Thread(process, tid), m_trace_file(trace_file) {}
36fe6060f1SDimitry Andric 
37fe6060f1SDimitry Andric   void RefreshStateAfterStop() override;
38fe6060f1SDimitry Andric 
39fe6060f1SDimitry Andric   lldb::RegisterContextSP GetRegisterContext() override;
40fe6060f1SDimitry Andric 
41fe6060f1SDimitry Andric   lldb::RegisterContextSP
42fe6060f1SDimitry Andric   CreateRegisterContextForFrame(StackFrame *frame) override;
43fe6060f1SDimitry Andric 
44fe6060f1SDimitry Andric   /// \return
45fe6060f1SDimitry Andric   ///   The trace file of this thread.
46*bdd1243dSDimitry Andric   const std::optional<FileSpec> &GetTraceFile() const;
47fe6060f1SDimitry Andric 
48fe6060f1SDimitry Andric protected:
49fe6060f1SDimitry Andric   bool CalculateStopInfo() override;
50fe6060f1SDimitry Andric 
51fe6060f1SDimitry Andric   lldb::RegisterContextSP m_thread_reg_ctx_sp;
52fe6060f1SDimitry Andric 
53fe6060f1SDimitry Andric private:
54*bdd1243dSDimitry Andric   std::optional<FileSpec> m_trace_file;
55fe6060f1SDimitry Andric };
56fe6060f1SDimitry Andric 
57fe6060f1SDimitry Andric } // namespace lldb_private
58fe6060f1SDimitry Andric 
59fe6060f1SDimitry Andric #endif // LLDB_TARGET_THREADPOSTMORTEMTRACE_H
60