blob: 24693ba891ccb4daa1bd69ec61ef37429a085dd0 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- ThreadGDBRemote.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_ThreadGDBRemote_h_
11#define liblldb_ThreadGDBRemote_h_
12
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000013// C Includes
14// C++ Includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000015#include <string>
16
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000017// Other libraries and framework includes
18// Project includes
Jason Molenda705b1802014-06-13 02:37:02 +000019#include "lldb/Core/StructuredData.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020#include "lldb/Target/Process.h"
21#include "lldb/Target/Thread.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022
23class StringExtractor;
Tamas Berghammerdb264a62015-03-31 09:52:22 +000024
25namespace lldb_private {
26namespace process_gdb_remote {
27
Chris Lattner30fdc8d2010-06-08 16:52:24 +000028class ProcessGDBRemote;
29
Tamas Berghammerdb264a62015-03-31 09:52:22 +000030class ThreadGDBRemote : public Thread
Chris Lattner30fdc8d2010-06-08 16:52:24 +000031{
32public:
Tamas Berghammerdb264a62015-03-31 09:52:22 +000033 ThreadGDBRemote (Process &process, lldb::tid_t tid);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000034
Eugene Zelenkoedb35d92015-10-24 01:08:35 +000035 ~ThreadGDBRemote() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000036
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000037 void
38 WillResume (lldb::StateType resume_state) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000040 void
41 RefreshStateAfterStop() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000042
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000043 const char *
44 GetName () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000045
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000046 const char *
47 GetQueueName () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000048
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000049 lldb::queue_id_t
50 GetQueueID () override;
Jason Molenda3dc4f442013-10-18 05:55:24 +000051
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000052 lldb::QueueSP
53 GetQueue () override;
Jason Molenda2dd5deb2014-04-25 00:02:11 +000054
Jason Molendaaac16e02014-03-13 02:54:54 +000055 lldb::addr_t
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000056 GetQueueLibdispatchQueueAddress () override;
Jason Molendaaac16e02014-03-13 02:54:54 +000057
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000058 lldb::RegisterContextSP
59 GetRegisterContext () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000060
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000061 lldb::RegisterContextSP
Tamas Berghammerdb264a62015-03-31 09:52:22 +000062 CreateRegisterContextForFrame (StackFrame *frame) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000063
Chris Lattner30fdc8d2010-06-08 16:52:24 +000064 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +000065 Dump (Log *log, uint32_t index);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000066
67 static bool
68 ThreadIDIsValid (lldb::tid_t thread);
69
70 bool
71 ShouldStop (bool &step_more);
72
73 const char *
74 GetBasicInfoAsString ();
75
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076 void
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000077 SetName (const char *name) override
Chris Lattner30fdc8d2010-06-08 16:52:24 +000078 {
79 if (name && name[0])
80 m_thread_name.assign (name);
81 else
82 m_thread_name.clear();
83 }
84
85 lldb::addr_t
86 GetThreadDispatchQAddr ()
87 {
88 return m_thread_dispatch_qaddr;
89 }
90
91 void
92 SetThreadDispatchQAddr (lldb::addr_t thread_dispatch_qaddr)
93 {
94 m_thread_dispatch_qaddr = thread_dispatch_qaddr;
95 }
96
Greg Clayton0b90be12015-06-23 21:27:50 +000097 void
98 ClearQueueInfo ();
99
100 void
101 SetQueueInfo (std::string &&queue_name, lldb::QueueKind queue_kind, uint64_t queue_serial);
102
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000103 StructuredData::ObjectSP
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000104 FetchThreadExtendedInfo () override;
Jason Molenda705b1802014-06-13 02:37:02 +0000105
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000106protected:
Greg Clayton3e06bd92011-01-09 21:07:35 +0000107 friend class ProcessGDBRemote;
108
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000109 std::string m_thread_name;
110 std::string m_dispatch_queue_name;
111 lldb::addr_t m_thread_dispatch_qaddr;
112 lldb::QueueKind m_queue_kind; // Queue info from stop reply/stop info for thread
113 uint64_t m_queue_serial; // Queue info from stop reply/stop info for thread
114
Greg Claytone576ab22011-02-15 00:19:15 +0000115 bool
Greg Clayton3e06bd92011-01-09 21:07:35 +0000116 PrivateSetRegisterValue (uint32_t reg,
117 StringExtractor &response);
Greg Clayton0b90be12015-06-23 21:27:50 +0000118
119 bool
Jason Molenda545304d2015-12-18 00:45:35 +0000120 PrivateSetRegisterValue (uint32_t reg,
121 uint64_t regval);
122
123 bool
Greg Clayton0b90be12015-06-23 21:27:50 +0000124 CachedQueueInfoIsValid() const
125 {
126 return m_queue_kind != lldb::eQueueKindUnknown;
127 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000128 void
129 SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id);
130
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000131 bool
132 CalculateStopInfo () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000133};
134
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000135} // namespace process_gdb_remote
136} // namespace lldb_private
137
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000138#endif // liblldb_ThreadGDBRemote_h_