]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/HistoryThread.h
Merge clang 7.0.1 and several follow-up changes
[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 // C Includes
14 // C++ Includes
15 #include <mutex>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Core/Broadcaster.h"
20 #include "lldb/Core/Event.h"
21 #include "lldb/Core/UserSettingsController.h"
22 #include "lldb/Target/ExecutionContextScope.h"
23 #include "lldb/Target/StackFrameList.h"
24 #include "lldb/Target/Thread.h"
25 #include "lldb/Utility/UserID.h"
26 #include "lldb/lldb-private.h"
27
28 namespace lldb_private {
29
30 //----------------------------------------------------------------------
31 /// @class HistoryThread HistoryThread.h "HistoryThread.h"
32 /// A thread object representing a backtrace from a previous point in the
33 /// process execution
34 ///
35 /// This subclass of Thread is used to provide a backtrace from earlier in
36 /// process execution.  It is given a backtrace list of pc addresses and
37 /// optionally a stop_id of when those pc addresses were collected, and it
38 /// will create stack frames for them.
39 //----------------------------------------------------------------------
40
41 class HistoryThread : public lldb_private::Thread {
42 public:
43   HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
44                 std::vector<lldb::addr_t> pcs, uint32_t stop_id,
45                 bool stop_id_is_valid);
46
47   ~HistoryThread() override;
48
49   lldb::RegisterContextSP GetRegisterContext() override;
50
51   lldb::RegisterContextSP
52   CreateRegisterContextForFrame(StackFrame *frame) override;
53
54   void RefreshStateAfterStop() override {}
55
56   bool CalculateStopInfo() override { return false; }
57
58   void SetExtendedBacktraceToken(uint64_t token) override {
59     m_extended_unwind_token = token;
60   }
61
62   uint64_t GetExtendedBacktraceToken() override {
63     return m_extended_unwind_token;
64   }
65
66   const char *GetQueueName() override { return m_queue_name.c_str(); }
67
68   void SetQueueName(const char *name) override { m_queue_name = name; }
69
70   lldb::queue_id_t GetQueueID() override { return m_queue_id; }
71
72   void SetQueueID(lldb::queue_id_t queue) override { m_queue_id = queue; }
73
74   const char *GetThreadName() { return m_thread_name.c_str(); }
75
76   uint32_t GetExtendedBacktraceOriginatingIndexID() override;
77
78   void SetThreadName(const char *name) { m_thread_name = name; }
79
80   const char *GetName() override { return m_thread_name.c_str(); }
81
82   void SetName(const char *name) override { m_thread_name = name; }
83
84 protected:
85   virtual lldb::StackFrameListSP GetStackFrameList();
86
87   mutable std::mutex m_framelist_mutex;
88   lldb::StackFrameListSP m_framelist;
89   std::vector<lldb::addr_t> m_pcs;
90   uint32_t m_stop_id;
91   bool m_stop_id_is_valid;
92
93   uint64_t m_extended_unwind_token;
94   std::string m_queue_name;
95   std::string m_thread_name;
96   lldb::tid_t m_originating_unique_thread_id;
97   lldb::queue_id_t m_queue_id;
98 };
99
100 } // namespace lldb_private
101
102 #endif // liblldb_HistoryThread_h_