]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/HistoryThread.h
MFV r348573: 9993 zil writes can get delayed in zio pipeline
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / HistoryThread.h
1 //===-- HistoryThread.h -----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_HistoryThread_h_
11 #define liblldb_HistoryThread_h_
12
13 #include <mutex>
14
15 #include "lldb/Core/UserSettingsController.h"
16 #include "lldb/Target/ExecutionContextScope.h"
17 #include "lldb/Target/StackFrameList.h"
18 #include "lldb/Target/Thread.h"
19 #include "lldb/Utility/Broadcaster.h"
20 #include "lldb/Utility/Event.h"
21 #include "lldb/Utility/UserID.h"
22 #include "lldb/lldb-private.h"
23
24 namespace lldb_private {
25
26 //----------------------------------------------------------------------
27 /// @class HistoryThread HistoryThread.h "HistoryThread.h"
28 /// A thread object representing a backtrace from a previous point in the
29 /// process execution
30 ///
31 /// This subclass of Thread is used to provide a backtrace from earlier in
32 /// process execution.  It is given a backtrace list of pc addresses and
33 /// optionally a stop_id of when those pc addresses were collected, and it
34 /// will create stack frames for them.
35 //----------------------------------------------------------------------
36
37 class HistoryThread : public lldb_private::Thread {
38 public:
39   HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
40                 std::vector<lldb::addr_t> pcs, uint32_t stop_id,
41                 bool stop_id_is_valid);
42
43   ~HistoryThread() override;
44
45   lldb::RegisterContextSP GetRegisterContext() override;
46
47   lldb::RegisterContextSP
48   CreateRegisterContextForFrame(StackFrame *frame) override;
49
50   void RefreshStateAfterStop() override {}
51
52   bool CalculateStopInfo() override { return false; }
53
54   void SetExtendedBacktraceToken(uint64_t token) override {
55     m_extended_unwind_token = token;
56   }
57
58   uint64_t GetExtendedBacktraceToken() override {
59     return m_extended_unwind_token;
60   }
61
62   const char *GetQueueName() override { return m_queue_name.c_str(); }
63
64   void SetQueueName(const char *name) override { m_queue_name = name; }
65
66   lldb::queue_id_t GetQueueID() override { return m_queue_id; }
67
68   void SetQueueID(lldb::queue_id_t queue) override { m_queue_id = queue; }
69
70   const char *GetThreadName() { return m_thread_name.c_str(); }
71
72   uint32_t GetExtendedBacktraceOriginatingIndexID() override;
73
74   void SetThreadName(const char *name) { m_thread_name = name; }
75
76   const char *GetName() override { return m_thread_name.c_str(); }
77
78   void SetName(const char *name) override { m_thread_name = name; }
79
80 protected:
81   virtual lldb::StackFrameListSP GetStackFrameList();
82
83   mutable std::mutex m_framelist_mutex;
84   lldb::StackFrameListSP m_framelist;
85   std::vector<lldb::addr_t> m_pcs;
86   uint32_t m_stop_id;
87   bool m_stop_id_is_valid;
88
89   uint64_t m_extended_unwind_token;
90   std::string m_queue_name;
91   std::string m_thread_name;
92   lldb::tid_t m_originating_unique_thread_id;
93   lldb::queue_id_t m_queue_id;
94 };
95
96 } // namespace lldb_private
97
98 #endif // liblldb_HistoryThread_h_