blob: 3fa4ae09a2a28b6387ddcf618ded28a48efc7541 [file] [log] [blame]
Chris Lattner24943d22010-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
13#include <string>
14
15#include "lldb/Target/Process.h"
16#include "lldb/Target/Thread.h"
17#include "MachException.h"
18#include "libunwind.h"
19
20class StringExtractor;
21class ProcessGDBRemote;
22
23class ThreadGDBRemote : public lldb_private::Thread
24{
25public:
26 ThreadGDBRemote (ProcessGDBRemote &process, lldb::tid_t tid);
27
28 virtual
29 ~ThreadGDBRemote ();
30
31 virtual bool
32 WillResume (lldb::StateType resume_state);
33
34 virtual void
35 RefreshStateAfterStop();
36
37 virtual const char *
38 GetInfo ();
39
40 virtual const char *
41 GetName ();
42
43 virtual const char *
44 GetQueueName ();
45
46 virtual lldb_private::RegisterContext *
47 GetRegisterContext ();
48
49 virtual lldb_private::RegisterContext *
50 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
51
52 virtual bool
53 SaveFrameZeroState (RegisterCheckpoint &checkpoint);
54
55 virtual bool
56 RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint);
57
58 virtual uint32_t
59 GetStackFrameCount();
60
61 virtual lldb::StackFrameSP
62 GetStackFrameAtIndex (uint32_t idx);
63
64 virtual void
65 ClearStackFrames ();
66
67 ProcessGDBRemote &
68 GetGDBProcess ()
69 {
70 return (ProcessGDBRemote &)m_process;
71 }
72
73 const ProcessGDBRemote &
74 GetGDBProcess () const
75 {
76 return (ProcessGDBRemote &)m_process;
77 }
78
79 void
80 Dump (lldb_private::Log *log, uint32_t index);
81
82 static bool
83 ThreadIDIsValid (lldb::tid_t thread);
84
85 bool
86 ShouldStop (bool &step_more);
87
88 const char *
89 GetBasicInfoAsString ();
90
91 lldb_private::Thread::StopInfo &
92 GetStopInfoRef ()
93 {
94 return m_stop_info;
95 }
96
97 uint32_t
98 GetStopInfoStopID()
99 {
100 return m_stop_info_stop_id;
101 }
102
103 void
104 SetStopInfoStopID (uint32_t stop_id)
105 {
106 m_stop_info_stop_id = stop_id;
107 }
108
109 void
110 SetName (const char *name)
111 {
112 if (name && name[0])
113 m_thread_name.assign (name);
114 else
115 m_thread_name.clear();
116 }
117
118 lldb::addr_t
119 GetThreadDispatchQAddr ()
120 {
121 return m_thread_dispatch_qaddr;
122 }
123
124 void
125 SetThreadDispatchQAddr (lldb::addr_t thread_dispatch_qaddr)
126 {
127 m_thread_dispatch_qaddr = thread_dispatch_qaddr;
128 }
129
130protected:
131 //------------------------------------------------------------------
132 // Member variables.
133 //------------------------------------------------------------------
134 uint32_t m_stop_info_stop_id;
135 lldb_private::Thread::StopInfo m_stop_info;
136 std::string m_thread_name;
137 std::string m_dispatch_queue_name;
138 lldb::addr_t m_thread_dispatch_qaddr;
139 std::auto_ptr<lldb_private::Unwind> m_unwinder_ap;
140 //------------------------------------------------------------------
141 // Member variables.
142 //------------------------------------------------------------------
143
144 lldb_private::Unwind *
145 GetUnwinder ();
146
147 void
148 SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id);
149
150 virtual bool
151 GetRawStopReason (StopInfo *stop_info);
152
153
154};
155
156#endif // liblldb_ThreadGDBRemote_h_