blob: d7619f491e664be31be3e8e7a3ccac0e3a4e20fd [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
Jason Molenda77f89352016-01-12 07:09:16 +000049 lldb::QueueKind
50 GetQueueKind () override;
51
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000052 lldb::queue_id_t
53 GetQueueID () override;
Jason Molenda3dc4f442013-10-18 05:55:24 +000054
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000055 lldb::QueueSP
56 GetQueue () override;
Jason Molenda2dd5deb2014-04-25 00:02:11 +000057
Jason Molendaaac16e02014-03-13 02:54:54 +000058 lldb::addr_t
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000059 GetQueueLibdispatchQueueAddress () override;
Jason Molendaaac16e02014-03-13 02:54:54 +000060
Jason Molenda77f89352016-01-12 07:09:16 +000061 void
62 SetQueueLibdispatchQueueAddress (lldb::addr_t dispatch_queue_t) override;
63
64 bool
65 ThreadHasQueueInformation () const override;
66
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000067 lldb::RegisterContextSP
68 GetRegisterContext () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000069
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000070 lldb::RegisterContextSP
Tamas Berghammerdb264a62015-03-31 09:52:22 +000071 CreateRegisterContextForFrame (StackFrame *frame) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000072
Chris Lattner30fdc8d2010-06-08 16:52:24 +000073 void
Tamas Berghammerdb264a62015-03-31 09:52:22 +000074 Dump (Log *log, uint32_t index);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000075
76 static bool
77 ThreadIDIsValid (lldb::tid_t thread);
78
79 bool
80 ShouldStop (bool &step_more);
81
82 const char *
83 GetBasicInfoAsString ();
84
Chris Lattner30fdc8d2010-06-08 16:52:24 +000085 void
Tamas Berghammer30b8cd32015-03-23 15:50:03 +000086 SetName (const char *name) override
Chris Lattner30fdc8d2010-06-08 16:52:24 +000087 {
88 if (name && name[0])
89 m_thread_name.assign (name);
90 else
91 m_thread_name.clear();
92 }
93
94 lldb::addr_t
95 GetThreadDispatchQAddr ()
96 {
97 return m_thread_dispatch_qaddr;
98 }
99
100 void
101 SetThreadDispatchQAddr (lldb::addr_t thread_dispatch_qaddr)
102 {
103 m_thread_dispatch_qaddr = thread_dispatch_qaddr;
104 }
105
Greg Clayton0b90be12015-06-23 21:27:50 +0000106 void
107 ClearQueueInfo ();
108
109 void
Jason Molenda77f89352016-01-12 07:09:16 +0000110 SetQueueInfo (std::string &&queue_name, lldb::QueueKind queue_kind, uint64_t queue_serial, lldb::addr_t dispatch_queue_t, lldb_private::LazyBool associated_with_libdispatch_queue);
111
112 lldb_private::LazyBool
113 GetAssociatedWithLibdispatchQueue () override;
114
115 void
116 SetAssociatedWithLibdispatchQueue (lldb_private::LazyBool associated_with_libdispatch_queue) override;
Greg Clayton0b90be12015-06-23 21:27:50 +0000117
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000118 StructuredData::ObjectSP
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000119 FetchThreadExtendedInfo () override;
Jason Molenda705b1802014-06-13 02:37:02 +0000120
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000121protected:
Greg Clayton3e06bd92011-01-09 21:07:35 +0000122 friend class ProcessGDBRemote;
123
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000124 std::string m_thread_name;
125 std::string m_dispatch_queue_name;
126 lldb::addr_t m_thread_dispatch_qaddr;
Jason Molenda77f89352016-01-12 07:09:16 +0000127 lldb::addr_t m_dispatch_queue_t;
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000128 lldb::QueueKind m_queue_kind; // Queue info from stop reply/stop info for thread
Jason Molenda77f89352016-01-12 07:09:16 +0000129 uint64_t m_queue_serial_number; // Queue info from stop reply/stop info for thread
130 lldb_private::LazyBool m_associated_with_libdispatch_queue;
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000131
Greg Claytone576ab22011-02-15 00:19:15 +0000132 bool
Greg Clayton3e06bd92011-01-09 21:07:35 +0000133 PrivateSetRegisterValue (uint32_t reg,
134 StringExtractor &response);
Greg Clayton0b90be12015-06-23 21:27:50 +0000135
136 bool
Jason Molenda545304d2015-12-18 00:45:35 +0000137 PrivateSetRegisterValue (uint32_t reg,
138 uint64_t regval);
139
140 bool
Greg Clayton0b90be12015-06-23 21:27:50 +0000141 CachedQueueInfoIsValid() const
142 {
143 return m_queue_kind != lldb::eQueueKindUnknown;
144 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000145 void
146 SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id);
147
Tamas Berghammer30b8cd32015-03-23 15:50:03 +0000148 bool
149 CalculateStopInfo () override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000150};
151
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000152} // namespace process_gdb_remote
153} // namespace lldb_private
154
Eugene Zelenkoedb35d92015-10-24 01:08:35 +0000155#endif // liblldb_ThreadGDBRemote_h_