1 //===-- ThreadMachCore.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_ThreadMachCore_h_
11 #define liblldb_ThreadMachCore_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <string>
16 
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Target/Thread.h"
20 
21 class ProcessMachCore;
22 
23 class ThreadMachCore : public lldb_private::Thread {
24 public:
25   ThreadMachCore(lldb_private::Process &process, lldb::tid_t tid);
26 
27   ~ThreadMachCore() override;
28 
29   void RefreshStateAfterStop() override;
30 
31   const char *GetName() override;
32 
33   lldb::RegisterContextSP GetRegisterContext() override;
34 
35   lldb::RegisterContextSP
36   CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
37 
38   static bool ThreadIDIsValid(lldb::tid_t thread);
39 
40   bool ShouldStop(bool &step_more);
41 
42   const char *GetBasicInfoAsString();
43 
44   void SetName(const char *name) override {
45     if (name && name[0])
46       m_thread_name.assign(name);
47     else
48       m_thread_name.clear();
49   }
50 
51   lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; }
52 
53   void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr) {
54     m_thread_dispatch_qaddr = thread_dispatch_qaddr;
55   }
56 
57 protected:
58   friend class ProcessMachCore;
59 
60   //------------------------------------------------------------------
61   // Member variables.
62   //------------------------------------------------------------------
63   std::string m_thread_name;
64   std::string m_dispatch_queue_name;
65   lldb::addr_t m_thread_dispatch_qaddr;
66   lldb::RegisterContextSP m_thread_reg_ctx_sp;
67 
68   //------------------------------------------------------------------
69   // Protected member functions.
70   //------------------------------------------------------------------
71   bool CalculateStopInfo() override;
72 };
73 
74 #endif // liblldb_ThreadMachCore_h_
75