doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DebuggerClient.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 #ifndef DEBUGGERCLIENT_H_
29 #define DEBUGGERCLIENT_H_
30 
32 {
33 public:
34 
38 };
39 
41 {
42 public:
43 
45  int mID;
46  bool mCurrent;
47  bool mDying;
48  bool mWaiting;
50 };
51 
52 #ifndef DEBUGGERBREAKPOINT_H_
53 #include "DebuggerBreakpoint.h"
54 #endif
55 
59 
61 {
62 public:
63 
64  rvDebuggerClient ( );
66 
67  bool Initialize ( void );
68  void Shutdown ( void );
69  bool ProcessMessages ( void );
70  bool WaitFor ( EDebuggerMessage msg, int time );
71 
72  bool IsConnected ( void );
73  bool IsStopped ( void );
74 
75  int GetActiveBreakpointID ( void );
76  const char* GetBreakFilename ( void );
77  int GetBreakLineNumber ( void );
80  const char* GetVariableValue ( const char* name, int stackDepth );
81 
82  void InspectVariable ( const char* name, int callstackDepth );
83 
84  void Break ( void );
85  void Resume ( void );
86  void StepInto ( void );
87  void StepOver ( void );
88 
89  // Breakpoints
90  int AddBreakpoint ( const char* filename, int lineNumber, bool onceOnly = false );
91  bool RemoveBreakpoint ( int bpID );
92  void ClearBreakpoints ( void );
93  int GetBreakpointCount ( void );
95  rvDebuggerBreakpoint* FindBreakpoint ( const char* filename, int linenumber );
96 
97 protected:
98 
99  void SendMessage ( EDebuggerMessage dbmsg );
100  void SendBreakpoints ( void );
101  void SendAddBreakpoint ( rvDebuggerBreakpoint& bp, bool onceOnly = false );
103  void SendPacket ( void* data, int datasize );
104 
108 
109  bool mBreak;
110  int mBreakID;
113 
115 
119 
121 
122 private:
123 
124  void ClearCallstack ( void );
125  void ClearThreads ( void );
126 
127  void UpdateWatches ( void );
128 
129  // Network message handlers
130  void HandleBreak ( msg_t* msg );
131  void HandleInspectCallstack ( msg_t* msg );
132  void HandleInspectThreads ( msg_t* msg );
133  void HandleInspectVariable ( msg_t* msg );
134 };
135 
136 /*
137 ================
138 rvDebuggerClient::IsConnected
139 ================
140 */
141 ID_INLINE bool rvDebuggerClient::IsConnected ( void )
142 {
143  return mConnected;
144 }
145 
146 /*
147 ================
148 rvDebuggerClient::IsStopped
149 ================
150 */
151 ID_INLINE bool rvDebuggerClient::IsStopped ( void )
152 {
153  return mBreak;
154 }
155 
156 /*
157 ================
158 rvDebuggerClient::GetActiveBreakpointID
159 ================
160 */
162 {
163  return mBreakID;
164 }
165 
166 /*
167 ================
168 rvDebuggerClient::GetBreakFilename
169 ================
170 */
171 ID_INLINE const char* rvDebuggerClient::GetBreakFilename ( void )
172 {
173  return mBreakFilename;
174 }
175 
176 /*
177 ================
178 rvDebuggerClient::GetBreakLineNumber
179 ================
180 */
182 {
183  return mBreakLineNumber;
184 }
185 
186 /*
187 ================
188 rvDebuggerClient::GetCallstack
189 ================
190 */
192 {
193  return mCallstack;
194 }
195 
196 /*
197 ================
198 rvDebuggerClient::GetThreads
199 ================
200 */
202 {
203  return mThreads;
204 }
205 
206 /*
207 ================
208 rvDebuggerClient::GetVariableValue
209 ================
210 */
211 ID_INLINE const char* rvDebuggerClient::GetVariableValue ( const char* var, int stackDepth )
212 {
213  return mVariables.GetString ( va("%d:%s",stackDepth,var), "" );
214 }
215 
216 /*
217 ================
218 rvDebuggerClient::GetBreakpointCount
219 ================
220 */
222 {
223  return mBreakpoints.Num ( );
224 }
225 
226 /*
227 ================
228 rvDebuggerClient::GetBreakpoint
229 ================
230 */
232 {
233  return mBreakpoints[index];
234 }
235 
236 /*
237 ================
238 rvDebuggerClient::Break
239 ================
240 */
241 ID_INLINE void rvDebuggerClient::Break ( void )
242 {
244 }
245 
246 /*
247 ================
248 rvDebuggerClient::Resume
249 ================
250 */
251 ID_INLINE void rvDebuggerClient::Resume ( void )
252 {
253  mBreak = false;
255 }
256 
257 /*
258 ================
259 rvDebuggerClient::StepOver
260 ================
261 */
262 ID_INLINE void rvDebuggerClient::StepOver ( void )
263 {
264  mBreak = false;
266 }
267 
268 /*
269 ================
270 rvDebuggerClient::StepInto
271 ================
272 */
273 ID_INLINE void rvDebuggerClient::StepInto ( void )
274 {
275  mBreak = false;
277 }
278 
279 /*
280 ================
281 rvDebuggerClient::SendPacket
282 ================
283 */
284 ID_INLINE void rvDebuggerClient::SendPacket ( void* data, int size )
285 {
286  mPort.SendPacket ( mServerAdr, data, size );
287 }
288 
289 #endif // DEBUGGERCLIENT_H_
bool WaitFor(EDebuggerMessage msg, int time)
EDebuggerMessage mWaitFor
rvDebuggerThreadList mThreads
idList< rvDebuggerThread * > rvDebuggerThreadList
void InspectVariable(const char *name, int callstackDepth)
rvDebuggerBreakpoint * FindBreakpoint(const char *filename, int linenumber)
void SendBreakpoints(void)
rvDebuggerBreakpoint * GetBreakpoint(int index)
void ClearThreads(void)
void HandleInspectVariable(msg_t *msg)
void SendMessage(EDebuggerMessage dbmsg)
void SendPacket(const netadr_t to, const void *data, int size)
Definition: posix_net.cpp:572
GLuint index
Definition: glext.h:3476
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
void SendRemoveBreakpoint(rvDebuggerBreakpoint &bp)
rvDebuggerCallstackList mCallstack
Definition: Dict.h:65
void SendPacket(void *data, int datasize)
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:2853
bool ProcessMessages(void)
void SendAddBreakpoint(rvDebuggerBreakpoint &bp, bool onceOnly=false)
bool IsStopped(void)
int GetBreakLineNumber(void)
const char * GetBreakFilename(void)
void ClearBreakpoints(void)
void HandleInspectCallstack(msg_t *msg)
void StepInto(void)
bool Initialize(void)
rvDebuggerCallstackList & GetCallstack(void)
void HandleBreak(msg_t *msg)
int GetActiveBreakpointID(void)
idList< rvDebuggerCallstack * > rvDebuggerCallstackList
int Num(void) const
Definition: List.h:265
const GLcharARB * name
Definition: glext.h:3629
GLsizeiptr size
Definition: glext.h:3112
Definition: Str.h:116
bool RemoveBreakpoint(int bpID)
void StepOver(void)
bool IsConnected(void)
int GetBreakpointCount(void)
int AddBreakpoint(const char *filename, int lineNumber, bool onceOnly=false)
char * va(const char *fmt,...)
Definition: Str.cpp:1568
rvDebuggerThreadList & GetThreads(void)
rvDebuggerBreakpointList mBreakpoints
idList< rvDebuggerBreakpoint * > rvDebuggerBreakpointList
void UpdateWatches(void)
void ClearCallstack(void)
void HandleInspectThreads(msg_t *msg)
const char * GetVariableValue(const char *name, int stackDepth)
EDebuggerMessage