123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- /*
- ===========================================================================
- Doom 3 GPL Source Code
- Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
- This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
- Doom 3 Source Code is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- Doom 3 Source Code is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
- 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.
- 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.
- ===========================================================================
- */
- #ifndef DEBUGGERCLIENT_H_
- #define DEBUGGERCLIENT_H_
- class rvDebuggerCallstack
- {
- public:
- idStr mFilename;
- int mLineNumber;
- idStr mFunction;
- };
- class rvDebuggerThread
- {
- public:
- idStr mName;
- int mID;
- bool mCurrent;
- bool mDying;
- bool mWaiting;
- bool mDoneProcessing;
- };
- #ifndef DEBUGGERBREAKPOINT_H_
- #include "DebuggerBreakpoint.h"
- #endif
- typedef idList<rvDebuggerCallstack*> rvDebuggerCallstackList;
- typedef idList<rvDebuggerThread*> rvDebuggerThreadList;
- typedef idList<rvDebuggerBreakpoint*> rvDebuggerBreakpointList;
- class rvDebuggerClient
- {
- public:
- rvDebuggerClient ( );
- ~rvDebuggerClient ( );
- bool Initialize ( void );
- void Shutdown ( void );
- bool ProcessMessages ( void );
- bool WaitFor ( EDebuggerMessage msg, int time );
-
- bool IsConnected ( void );
- bool IsStopped ( void );
-
- int GetActiveBreakpointID ( void );
- const char* GetBreakFilename ( void );
- int GetBreakLineNumber ( void );
- rvDebuggerCallstackList& GetCallstack ( void );
- rvDebuggerThreadList& GetThreads ( void );
- const char* GetVariableValue ( const char* name, int stackDepth );
-
- void InspectVariable ( const char* name, int callstackDepth );
-
- void Break ( void );
- void Resume ( void );
- void StepInto ( void );
- void StepOver ( void );
- // Breakpoints
- int AddBreakpoint ( const char* filename, int lineNumber, bool onceOnly = false );
- bool RemoveBreakpoint ( int bpID );
- void ClearBreakpoints ( void );
- int GetBreakpointCount ( void );
- rvDebuggerBreakpoint* GetBreakpoint ( int index );
- rvDebuggerBreakpoint* FindBreakpoint ( const char* filename, int linenumber );
-
- protected:
- void SendMessage ( EDebuggerMessage dbmsg );
- void SendBreakpoints ( void );
- void SendAddBreakpoint ( rvDebuggerBreakpoint& bp, bool onceOnly = false );
- void SendRemoveBreakpoint ( rvDebuggerBreakpoint& bp );
- void SendPacket ( void* data, int datasize );
- bool mConnected;
- netadr_t mServerAdr;
- idPort mPort;
-
- bool mBreak;
- int mBreakID;
- int mBreakLineNumber;
- idStr mBreakFilename;
-
- idDict mVariables;
- rvDebuggerCallstackList mCallstack;
- rvDebuggerThreadList mThreads;
- rvDebuggerBreakpointList mBreakpoints;
- EDebuggerMessage mWaitFor;
-
- private:
- void ClearCallstack ( void );
- void ClearThreads ( void );
-
- void UpdateWatches ( void );
-
- // Network message handlers
- void HandleBreak ( msg_t* msg );
- void HandleInspectCallstack ( msg_t* msg );
- void HandleInspectThreads ( msg_t* msg );
- void HandleInspectVariable ( msg_t* msg );
- };
- /*
- ================
- rvDebuggerClient::IsConnected
- ================
- */
- ID_INLINE bool rvDebuggerClient::IsConnected ( void )
- {
- return mConnected;
- }
- /*
- ================
- rvDebuggerClient::IsStopped
- ================
- */
- ID_INLINE bool rvDebuggerClient::IsStopped ( void )
- {
- return mBreak;
- }
- /*
- ================
- rvDebuggerClient::GetActiveBreakpointID
- ================
- */
- ID_INLINE int rvDebuggerClient::GetActiveBreakpointID ( void )
- {
- return mBreakID;
- }
- /*
- ================
- rvDebuggerClient::GetBreakFilename
- ================
- */
- ID_INLINE const char* rvDebuggerClient::GetBreakFilename ( void )
- {
- return mBreakFilename;
- }
- /*
- ================
- rvDebuggerClient::GetBreakLineNumber
- ================
- */
- ID_INLINE int rvDebuggerClient::GetBreakLineNumber ( void )
- {
- return mBreakLineNumber;
- }
- /*
- ================
- rvDebuggerClient::GetCallstack
- ================
- */
- ID_INLINE rvDebuggerCallstackList& rvDebuggerClient::GetCallstack ( void )
- {
- return mCallstack;
- }
- /*
- ================
- rvDebuggerClient::GetThreads
- ================
- */
- ID_INLINE rvDebuggerThreadList& rvDebuggerClient::GetThreads ( void )
- {
- return mThreads;
- }
- /*
- ================
- rvDebuggerClient::GetVariableValue
- ================
- */
- ID_INLINE const char* rvDebuggerClient::GetVariableValue ( const char* var, int stackDepth )
- {
- return mVariables.GetString ( va("%d:%s",stackDepth,var), "" );
- }
- /*
- ================
- rvDebuggerClient::GetBreakpointCount
- ================
- */
- ID_INLINE int rvDebuggerClient::GetBreakpointCount ( void )
- {
- return mBreakpoints.Num ( );
- }
- /*
- ================
- rvDebuggerClient::GetBreakpoint
- ================
- */
- ID_INLINE rvDebuggerBreakpoint* rvDebuggerClient::GetBreakpoint ( int index )
- {
- return mBreakpoints[index];
- }
- /*
- ================
- rvDebuggerClient::Break
- ================
- */
- ID_INLINE void rvDebuggerClient::Break ( void )
- {
- SendMessage ( DBMSG_BREAK );
- }
- /*
- ================
- rvDebuggerClient::Resume
- ================
- */
- ID_INLINE void rvDebuggerClient::Resume ( void )
- {
- mBreak = false;
- SendMessage ( DBMSG_RESUME );
- }
- /*
- ================
- rvDebuggerClient::StepOver
- ================
- */
- ID_INLINE void rvDebuggerClient::StepOver ( void )
- {
- mBreak = false;
- SendMessage ( DBMSG_STEPOVER );
- }
- /*
- ================
- rvDebuggerClient::StepInto
- ================
- */
- ID_INLINE void rvDebuggerClient::StepInto ( void )
- {
- mBreak = false;
- SendMessage ( DBMSG_STEPINTO );
- }
- /*
- ================
- rvDebuggerClient::SendPacket
- ================
- */
- ID_INLINE void rvDebuggerClient::SendPacket ( void* data, int size )
- {
- mPort.SendPacket ( mServerAdr, data, size );
- }
- #endif // DEBUGGERCLIENT_H_
|