DebuggerServer.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #ifndef DEBUGGERSERVER_H_
  21. #define DEBUGGERSERVER_H_
  22. #ifndef DEBUGGERMESSAGES_H_
  23. #include "DebuggerMessages.h"
  24. #endif
  25. #ifndef DEBUGGERBREAKPOINT_H_
  26. #include "DebuggerBreakpoint.h"
  27. #endif
  28. #ifndef __GAME_LOCAL_H__
  29. #include "../../game/Game.h"
  30. #endif
  31. class idInterpreter;
  32. class idProgram;
  33. class rvDebuggerServer
  34. {
  35. public:
  36. rvDebuggerServer ( );
  37. ~rvDebuggerServer ( );
  38. bool Initialize ( void );
  39. void Shutdown ( void );
  40. bool ProcessMessages ( void );
  41. bool IsConnected ( void );
  42. void CheckBreakpoints ( idInterpreter* interpreter, idProgram* program, int instructionPointer );
  43. void Print ( const char* text );
  44. void OSPathToRelativePath( const char *osPath, idStr &qpath );
  45. protected:
  46. // protected member variables
  47. bool mConnected;
  48. netadr_t mClientAdr;
  49. idPort mPort;
  50. idList<rvDebuggerBreakpoint*> mBreakpoints;
  51. CRITICAL_SECTION mCriticalSection;
  52. HANDLE mGameThread;
  53. bool mBreak;
  54. bool mBreakNext;
  55. bool mBreakStepOver;
  56. bool mBreakStepInto;
  57. int mBreakStepOverDepth;
  58. const function_t* mBreakStepOverFunc1;
  59. const function_t* mBreakStepOverFunc2;
  60. idProgram* mBreakProgram;
  61. int mBreakInstructionPointer;
  62. idInterpreter* mBreakInterpreter;
  63. idStr mLastStatementFile;
  64. int mLastStatementLine;
  65. private:
  66. void ClearBreakpoints ( void );
  67. void Break ( idInterpreter* interpreter, idProgram* program, int instructionPointer );
  68. void Resume ( void );
  69. void SendMessage ( EDebuggerMessage dbmsg );
  70. void SendPacket ( void* data, int datasize );
  71. // Message handlers
  72. void HandleAddBreakpoint ( msg_t* msg );
  73. void HandleRemoveBreakpoint ( msg_t* msg );
  74. void HandleResume ( msg_t* msg );
  75. void HandleInspectVariable ( msg_t* msg );
  76. void HandleInspectCallstack ( msg_t* msg );
  77. void HandleInspectThreads ( msg_t* msg );
  78. // MSG helper routines
  79. void MSG_WriteCallstackFunc ( msg_t* msg, const prstack_t* stack );
  80. };
  81. /*
  82. ================
  83. rvDebuggerServer::IsConnected
  84. ================
  85. */
  86. ID_INLINE bool rvDebuggerServer::IsConnected ( void )
  87. {
  88. return mConnected;
  89. }
  90. /*
  91. ================
  92. rvDebuggerServer::SendPacket
  93. ================
  94. */
  95. ID_INLINE void rvDebuggerServer::SendPacket ( void* data, int size )
  96. {
  97. mPort.SendPacket ( mClientAdr, data, size );
  98. }
  99. #endif // DEBUGGERSERVER_H_