RemoteDebuggerBase.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _REMOTE_DEBUGGER_BASE_H_
  23. #define _REMOTE_DEBUGGER_BASE_H_
  24. #ifndef _PLATFORM_H_
  25. #include "platform/platform.h"
  26. #endif
  27. #ifndef _VECTOR_H_
  28. #include "collection/vector.h"
  29. #endif
  30. #ifndef _SIM_OBJECT_H_
  31. #include "sim/simObject.h"
  32. #endif
  33. #ifndef _TICKABLE_H_
  34. #include "platform/Tickable.h"
  35. #endif
  36. //-----------------------------------------------------------------------------
  37. #define REMOTE_DEBUGGER_MAX_COMMAND_SIZE 4096
  38. #define REMOTE_DEBUGGER_NAME "NucleusDebugger"
  39. #define REMOTE_DEBUGGER_RESPONSE_START REMOTE_DEBUGGER_NAME"_ResponseStart\n\r"
  40. #define REMOTE_DEBUGGER_RESPONSE_END REMOTE_DEBUGGER_NAME"_ResponseEnd\n\r"
  41. //-----------------------------------------------------------------------------
  42. class CodeBlock;
  43. //-----------------------------------------------------------------------------
  44. class RemoteDebuggerBase : public SimObject, public virtual Tickable
  45. {
  46. friend class RemoteDebuggerBridge;
  47. private:
  48. typedef SimObject Parent;
  49. NetSocket mClientSocket;
  50. bool mClientAuthenticated;
  51. char mReceiveCommandBuffer[REMOTE_DEBUGGER_MAX_COMMAND_SIZE];
  52. U32 mReceiveCommandCursor;
  53. public:
  54. RemoteDebuggerBase();
  55. virtual ~RemoteDebuggerBase();
  56. bool login( const char* pPassword );
  57. inline bool isClientAuthenticated( void ) { return mClientAuthenticated; }
  58. /// Virtual functionality.
  59. virtual bool addCodeBlock( CodeBlock* pCodeBlock );
  60. virtual bool removeCodeBlock( CodeBlock* pCodeBlock );
  61. virtual bool pushStackFrame( void );
  62. virtual bool popStackFrame( void );
  63. virtual bool executionStopped( CodeBlock *code, U32 lineNumber );
  64. /// Fetch remote debugger.
  65. static RemoteDebuggerBase* getRemoteDebugger( void );
  66. DECLARE_CONOBJECT(RemoteDebuggerBase);
  67. protected:
  68. virtual void processTick( void );
  69. virtual void interpolateTick( F32 delta ) {}
  70. virtual void advanceTime( F32 timeDelta ) {}
  71. virtual void onClientLogin( void ) {}
  72. private:
  73. void receiveCommand( const char* pCommand );
  74. bool sendCommand( const char* pCommand );
  75. };
  76. #endif // _REMOTE_DEBUGGER_BASE_H_