blob: e7330f223ff42abcab1e69b3def68722a99a3160 [file] [log] [blame]
Greg Claytona63d08c2011-07-19 03:57:15 +00001//===-- ThreadKDP.h ---------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Claytona63d08c2011-07-19 03:57:15 +00006//
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
17class ProcessKDP;
18
Kate Stoneb9c1b512016-09-06 20:57:50 +000019class ThreadKDP : public lldb_private::Thread {
Greg Claytona63d08c2011-07-19 03:57:15 +000020public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000021 ThreadKDP(lldb_private::Process &process, lldb::tid_t tid);
Greg Claytona63d08c2011-07-19 03:57:15 +000022
Kate Stoneb9c1b512016-09-06 20:57:50 +000023 virtual ~ThreadKDP();
Greg Claytona63d08c2011-07-19 03:57:15 +000024
Kate Stoneb9c1b512016-09-06 20:57:50 +000025 virtual void RefreshStateAfterStop();
Greg Claytona63d08c2011-07-19 03:57:15 +000026
Kate Stoneb9c1b512016-09-06 20:57:50 +000027 virtual const char *GetName();
Greg Claytona63d08c2011-07-19 03:57:15 +000028
Kate Stoneb9c1b512016-09-06 20:57:50 +000029 virtual const char *GetQueueName();
Greg Claytona63d08c2011-07-19 03:57:15 +000030
Kate Stoneb9c1b512016-09-06 20:57:50 +000031 virtual lldb::RegisterContextSP GetRegisterContext();
Greg Claytona63d08c2011-07-19 03:57:15 +000032
Kate Stoneb9c1b512016-09-06 20:57:50 +000033 virtual lldb::RegisterContextSP
34 CreateRegisterContextForFrame(lldb_private::StackFrame *frame);
Greg Claytona63d08c2011-07-19 03:57:15 +000035
Kate Stoneb9c1b512016-09-06 20:57:50 +000036 void Dump(lldb_private::Log *log, uint32_t index);
Greg Claytona63d08c2011-07-19 03:57:15 +000037
Kate Stoneb9c1b512016-09-06 20:57:50 +000038 static bool ThreadIDIsValid(lldb::tid_t thread);
Greg Claytona63d08c2011-07-19 03:57:15 +000039
Kate Stoneb9c1b512016-09-06 20:57:50 +000040 bool ShouldStop(bool &step_more);
Greg Claytona63d08c2011-07-19 03:57:15 +000041
Kate Stoneb9c1b512016-09-06 20:57:50 +000042 const char *GetBasicInfoAsString();
Greg Claytona63d08c2011-07-19 03:57:15 +000043
Kate Stoneb9c1b512016-09-06 20:57:50 +000044 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 Claytona63d08c2011-07-19 03:57:15 +000050
Kate Stoneb9c1b512016-09-06 20:57:50 +000051 lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; }
Greg Claytona63d08c2011-07-19 03:57:15 +000052
Kate Stoneb9c1b512016-09-06 20:57:50 +000053 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 Claytona63d08c2011-07-19 03:57:15 +000059
60protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +000061 friend class ProcessKDP;
Greg Claytona63d08c2011-07-19 03:57:15 +000062
Kate Stoneb9c1b512016-09-06 20:57:50 +000063 //------------------------------------------------------------------
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 Claytona63d08c2011-07-19 03:57:15 +000074};
75
Kate Stoneb9c1b512016-09-06 20:57:50 +000076#endif // liblldb_ThreadKDP_h_