]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/tools/debugger/DebuggerServer.h
hello world
[icculus/iodoom3.git] / neo / tools / debugger / DebuggerServer.h
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 DEBUGGERSERVER_H_
29 #define DEBUGGERSERVER_H_
30
31 #ifndef DEBUGGERMESSAGES_H_
32 #include "DebuggerMessages.h"
33 #endif
34
35 #ifndef DEBUGGERBREAKPOINT_H_
36 #include "DebuggerBreakpoint.h"
37 #endif
38
39 #ifndef __GAME_LOCAL_H__
40 #include "../../game/Game.h"
41 #endif
42
43 class idInterpreter;
44 class idProgram;
45
46 class rvDebuggerServer
47 {
48 public:
49
50         rvDebuggerServer ( );
51         ~rvDebuggerServer ( );
52
53         bool            Initialize                      ( void );
54         void            Shutdown                        ( void );
55         
56         bool            ProcessMessages         ( void );
57         
58         bool            IsConnected                     ( void );
59         
60         void            CheckBreakpoints        ( idInterpreter* interpreter, idProgram* program, int instructionPointer );
61         
62         void            Print                           ( const char* text );
63
64         void            OSPathToRelativePath( const char *osPath, idStr &qpath );
65                 
66 protected:
67
68         // protected member variables
69         bool                                                    mConnected;
70         netadr_t                                                mClientAdr;
71         idPort                                                  mPort;
72         idList<rvDebuggerBreakpoint*>   mBreakpoints;
73         CRITICAL_SECTION                                mCriticalSection;
74         
75         HANDLE                                                  mGameThread;
76         
77         bool                                                    mBreak;
78         bool                                                    mBreakNext;
79         bool                                                    mBreakStepOver;
80         bool                                                    mBreakStepInto;
81         int                                                             mBreakStepOverDepth;
82         const function_t*                               mBreakStepOverFunc1;
83         const function_t*                               mBreakStepOverFunc2;
84         idProgram*                                              mBreakProgram;
85         int                                                             mBreakInstructionPointer;
86         idInterpreter*                                  mBreakInterpreter;
87         
88         idStr                                                   mLastStatementFile;
89         int                                                             mLastStatementLine;     
90         
91 private:
92
93         void            ClearBreakpoints                                ( void );
94
95         void            Break                                                   ( idInterpreter* interpreter, idProgram* program, int instructionPointer );
96         void            Resume                                                  ( void );
97
98         void            SendMessage                                             ( EDebuggerMessage dbmsg );
99         void            SendPacket                                              ( void* data, int datasize );
100
101         // Message handlers
102         void            HandleAddBreakpoint                             ( msg_t* msg );
103         void            HandleRemoveBreakpoint                  ( msg_t* msg );
104         void            HandleResume                                    ( msg_t* msg );
105         void            HandleInspectVariable                   ( msg_t* msg );
106         void            HandleInspectCallstack                  ( msg_t* msg );
107         void            HandleInspectThreads                    ( msg_t* msg );
108         
109         // MSG helper routines
110         void            MSG_WriteCallstackFunc                  ( msg_t* msg, const prstack_t* stack );
111 };
112
113 /*
114 ================
115 rvDebuggerServer::IsConnected
116 ================
117 */
118 ID_INLINE bool rvDebuggerServer::IsConnected ( void )
119 {
120         return mConnected;
121 }
122
123 /*
124 ================
125 rvDebuggerServer::SendPacket
126 ================
127 */
128 ID_INLINE void rvDebuggerServer::SendPacket ( void* data, int size )
129 {
130         mPort.SendPacket ( mClientAdr, data, size );
131 }
132
133 #endif // DEBUGGERSERVER_H_