blob: 01c37d8b5df67b3f684045d4163ac56560697cbf [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"
Greg Clayton54e7afa2010-07-09 20:39:50 +000017#include "libunwind/include/libunwind.h"
Chris Lattner24943d22010-06-08 16:52:24 +000018
19class StringExtractor;
20class ProcessGDBRemote;
21
22class ThreadGDBRemote : public lldb_private::Thread
23{
24public:
25 ThreadGDBRemote (ProcessGDBRemote &process, lldb::tid_t tid);
26
27 virtual
28 ~ThreadGDBRemote ();
29
30 virtual bool
31 WillResume (lldb::StateType resume_state);
32
33 virtual void
34 RefreshStateAfterStop();
35
36 virtual const char *
37 GetInfo ();
38
39 virtual const char *
40 GetName ();
41
42 virtual const char *
43 GetQueueName ();
44
45 virtual lldb_private::RegisterContext *
46 GetRegisterContext ();
47
48 virtual lldb_private::RegisterContext *
49 CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
50
51 virtual bool
52 SaveFrameZeroState (RegisterCheckpoint &checkpoint);
53
54 virtual bool
55 RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint);
56
57 virtual uint32_t
58 GetStackFrameCount();
59
60 virtual lldb::StackFrameSP
61 GetStackFrameAtIndex (uint32_t idx);
62
63 virtual void
64 ClearStackFrames ();
65
66 ProcessGDBRemote &
67 GetGDBProcess ()
68 {
69 return (ProcessGDBRemote &)m_process;
70 }
71
72 const ProcessGDBRemote &
73 GetGDBProcess () const
74 {
75 return (ProcessGDBRemote &)m_process;
76 }
77
78 void
79 Dump (lldb_private::Log *log, uint32_t index);
80
81 static bool
82 ThreadIDIsValid (lldb::tid_t thread);
83
84 bool
85 ShouldStop (bool &step_more);
86
87 const char *
88 GetBasicInfoAsString ();
89
Chris Lattner24943d22010-06-08 16:52:24 +000090 void
Greg Clayton643ee732010-08-04 01:40:35 +000091 SetStopInfo (const lldb::StopInfoSP &stop_info)
Chris Lattner24943d22010-06-08 16:52:24 +000092 {
Greg Clayton643ee732010-08-04 01:40:35 +000093 m_actual_stop_info_sp = stop_info;
Chris Lattner24943d22010-06-08 16:52:24 +000094 }
95
96 void
97 SetName (const char *name)
98 {
99 if (name && name[0])
100 m_thread_name.assign (name);
101 else
102 m_thread_name.clear();
103 }
104
105 lldb::addr_t
106 GetThreadDispatchQAddr ()
107 {
108 return m_thread_dispatch_qaddr;
109 }
110
111 void
112 SetThreadDispatchQAddr (lldb::addr_t thread_dispatch_qaddr)
113 {
114 m_thread_dispatch_qaddr = thread_dispatch_qaddr;
115 }
116
117protected:
118 //------------------------------------------------------------------
119 // Member variables.
120 //------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +0000121 std::string m_thread_name;
122 std::string m_dispatch_queue_name;
123 lldb::addr_t m_thread_dispatch_qaddr;
124 std::auto_ptr<lldb_private::Unwind> m_unwinder_ap;
125 //------------------------------------------------------------------
126 // Member variables.
127 //------------------------------------------------------------------
128
129 lldb_private::Unwind *
130 GetUnwinder ();
131
132 void
133 SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id);
134
Greg Clayton643ee732010-08-04 01:40:35 +0000135 virtual lldb::StopInfoSP
136 GetPrivateStopReason ();
Chris Lattner24943d22010-06-08 16:52:24 +0000137
138
139};
140
141#endif // liblldb_ThreadGDBRemote_h_