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/lldb-private.h" 20 #include "lldb/Core/Broadcaster.h" 21 #include "lldb/Core/Event.h" 22 #include "lldb/Core/UserID.h" 23 #include "lldb/Core/UserSettingsController.h" 24 #include "lldb/Target/ExecutionContextScope.h" 25 #include "lldb/Target/StackFrameList.h" 26 #include "lldb/Target/Thread.h" 27 28 namespace lldb_private { 29 30 //---------------------------------------------------------------------- 31 /// @class HistoryThread HistoryThread.h "HistoryThread.h" 32 /// @brief A thread object representing a backtrace from a previous point in the process execution 33 /// 34 /// This subclass of Thread is used to provide a backtrace from earlier in 35 /// process execution. It is given a backtrace list of pc addresses and 36 /// optionally a stop_id of when those pc addresses were collected, and it will 37 /// create stack frames for them. 38 //---------------------------------------------------------------------- 39 40 class HistoryThread : public lldb_private::Thread 41 { 42 public: 43 HistoryThread (lldb_private::Process &process, lldb::tid_t tid, std::vector<lldb::addr_t> pcs, uint32_t stop_id, bool stop_id_is_valid); 44 45 ~HistoryThread() override; 46 47 lldb::RegisterContextSP 48 GetRegisterContext() override; 49 50 lldb::RegisterContextSP 51 CreateRegisterContextForFrame(StackFrame *frame) override; 52 53 void 54 RefreshStateAfterStop() override { } 55 56 bool 57 CalculateStopInfo() override 58 { 59 return false; 60 } 61 62 void 63 SetExtendedBacktraceToken(uint64_t token) override 64 { 65 m_extended_unwind_token = token; 66 } 67 68 uint64_t 69 GetExtendedBacktraceToken() override 70 { 71 return m_extended_unwind_token; 72 } 73 74 const char * 75 GetQueueName() override 76 { 77 return m_queue_name.c_str(); 78 } 79 80 void 81 SetQueueName(const char *name) override 82 { 83 m_queue_name = name; 84 } 85 86 lldb::queue_id_t 87 GetQueueID() override 88 { 89 return m_queue_id; 90 } 91 92 void 93 SetQueueID(lldb::queue_id_t queue) override 94 { 95 m_queue_id = queue; 96 } 97 98 const char * 99 GetThreadName () 100 { 101 return m_thread_name.c_str(); 102 } 103 104 uint32_t 105 GetExtendedBacktraceOriginatingIndexID() override; 106 107 void 108 SetThreadName (const char *name) 109 { 110 m_thread_name = name; 111 } 112 113 const char * 114 GetName() override 115 { 116 return m_thread_name.c_str(); 117 } 118 119 void 120 SetName(const char *name) override 121 { 122 m_thread_name = name; 123 } 124 125 protected: 126 virtual lldb::StackFrameListSP 127 GetStackFrameList (); 128 129 mutable std::mutex m_framelist_mutex; 130 lldb::StackFrameListSP m_framelist; 131 std::vector<lldb::addr_t> m_pcs; 132 uint32_t m_stop_id; 133 bool m_stop_id_is_valid; 134 135 uint64_t m_extended_unwind_token; 136 std::string m_queue_name; 137 std::string m_thread_name; 138 lldb::tid_t m_originating_unique_thread_id; 139 lldb::queue_id_t m_queue_id; 140 }; 141 142 } // namespace lldb_private 143 144 #endif // liblldb_HistoryThread_h_ 145