1 //===-- ThreadKDP.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 liblldb_ThreadKDP_h_
10 #define liblldb_ThreadKDP_h_
11 
12 #include <string>
13 
14 #include "lldb/Target/Process.h"
15 #include "lldb/Target/Thread.h"
16 
17 class ProcessKDP;
18 
19 class ThreadKDP : public lldb_private::Thread {
20 public:
21   ThreadKDP(lldb_private::Process &process, lldb::tid_t tid);
22 
23   virtual ~ThreadKDP();
24 
25   virtual void RefreshStateAfterStop();
26 
27   virtual const char *GetName();
28 
29   virtual const char *GetQueueName();
30 
31   virtual lldb::RegisterContextSP GetRegisterContext();
32 
33   virtual lldb::RegisterContextSP
34   CreateRegisterContextForFrame(lldb_private::StackFrame *frame);
35 
36   void Dump(lldb_private::Log *log, uint32_t index);
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) {
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   void SetStopInfoFrom_KDP_EXCEPTION(
58       const lldb_private::DataExtractor &exc_reply_packet);
59 
60 protected:
61   friend class ProcessKDP;
62 
63   // Member variables.
64   std::string m_thread_name;
65   std::string m_dispatch_queue_name;
66   lldb::addr_t m_thread_dispatch_qaddr;
67   lldb::StopInfoSP m_cached_stop_info_sp;
68   // Protected member functions.
69   virtual bool CalculateStopInfo();
70 };
71 
72 #endif // liblldb_ThreadKDP_h_
73