xref: /freebsd/contrib/llvm-project/lldb/source/Plugins/Trace/common/ThreadPostMortemTrace.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1 //===-- ThreadPostMortemTrace.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_TARGET_THREADPOSTMORTEMTRACE_H
10 #define LLDB_TARGET_THREADPOSTMORTEMTRACE_H
11 
12 #include "lldb/Target/Thread.h"
13 #include <optional>
14 
15 namespace lldb_private {
16 
17 /// \class ThreadPostMortemTrace ThreadPostMortemTrace.h
18 ///
19 /// Thread implementation used for representing threads gotten from trace
20 /// session files, which are similar to threads from core files.
21 ///
22 class ThreadPostMortemTrace : public Thread {
23 public:
24   /// \param[in] process
25   ///     The process who owns this thread.
26   ///
27   /// \param[in] tid
28   ///     The tid of this thread.
29   ///
30   /// \param[in] trace_file
31   ///     The file that contains the list of instructions that were traced when
32   ///     this thread was being executed.
ThreadPostMortemTrace(Process & process,lldb::tid_t tid,const std::optional<FileSpec> & trace_file)33   ThreadPostMortemTrace(Process &process, lldb::tid_t tid,
34                         const std::optional<FileSpec> &trace_file)
35       : Thread(process, tid), m_trace_file(trace_file) {}
36 
37   void RefreshStateAfterStop() override;
38 
39   lldb::RegisterContextSP GetRegisterContext() override;
40 
41   lldb::RegisterContextSP
42   CreateRegisterContextForFrame(StackFrame *frame) override;
43 
44   /// \return
45   ///   The trace file of this thread.
46   const std::optional<FileSpec> &GetTraceFile() const;
47 
48 protected:
49   bool CalculateStopInfo() override;
50 
51   lldb::RegisterContextSP m_thread_reg_ctx_sp;
52 
53 private:
54   std::optional<FileSpec> m_trace_file;
55 };
56 
57 } // namespace lldb_private
58 
59 #endif // LLDB_TARGET_THREADPOSTMORTEMTRACE_H
60