Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 1 | //===-- ThreadKDP.h ---------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 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 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 19 | class ThreadKDP : public lldb_private::Thread { |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 20 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 21 | ThreadKDP(lldb_private::Process &process, lldb::tid_t tid); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 22 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 23 | virtual ~ThreadKDP(); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 24 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 25 | virtual void RefreshStateAfterStop(); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 26 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 27 | virtual const char *GetName(); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 28 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 29 | virtual const char *GetQueueName(); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 30 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 31 | virtual lldb::RegisterContextSP GetRegisterContext(); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 32 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 33 | virtual lldb::RegisterContextSP |
| 34 | CreateRegisterContextForFrame(lldb_private::StackFrame *frame); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 35 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 36 | void Dump(lldb_private::Log *log, uint32_t index); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 37 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 38 | static bool ThreadIDIsValid(lldb::tid_t thread); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 39 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 40 | bool ShouldStop(bool &step_more); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 41 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 42 | const char *GetBasicInfoAsString(); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 43 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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 | } |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 50 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 51 | lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; } |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 52 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 59 | |
| 60 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 61 | friend class ProcessKDP; |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 62 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 63 | //------------------------------------------------------------------ |
| 64 | // Member variables. |
| 65 | //------------------------------------------------------------------ |
| 66 | std::string m_thread_name; |
| 67 | std::string m_dispatch_queue_name; |
| 68 | lldb::addr_t m_thread_dispatch_qaddr; |
| 69 | lldb::StopInfoSP m_cached_stop_info_sp; |
| 70 | //------------------------------------------------------------------ |
| 71 | // Protected member functions. |
| 72 | //------------------------------------------------------------------ |
| 73 | virtual bool CalculateStopInfo(); |
Greg Clayton | a63d08c | 2011-07-19 03:57:15 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | #endif // liblldb_ThreadKDP_h_ |