Torque3D Documentation / _generateds / telnetDebugger.h

telnetDebugger.h

Engine/source/console/telnetDebugger.h

More...

Classes:

class

Telnet debug service implementation.

Public Variables

Detailed Description

Public Variables

TelnetDebugger * TelDebugger 
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _TELNETDEBUGGER_H_
 25#define _TELNETDEBUGGER_H_
 26
 27#ifndef _PLATFORM_PLATFORMNET_H_
 28#include "platform/platformNet.h"
 29#endif
 30
 31class CodeBlock;
 32
 33/// Telnet debug service implementation.
 34///
 35/// This is the C++ side of the built-in Torque debugger.
 36///
 37/// To use the debugger, use dbgSetParameters(port, password); in the console
 38/// of the server to enable debugger connections.  Then on some other system,
 39/// start up the app (you don't have to start a game or connect to the
 40/// server) and exec("common/debugger/debugger.tscript"); in the console.  Then use
 41/// the debugger GUI to connect to the server with the right port and password.
 42///
 43/// @see http://www.planettribes.com/tribes2/editing.shtml for more thorough discussion.
 44class TelnetDebugger
 45{
 46   S32 mAcceptPort;
 47   NetSocket mAcceptSocket;
 48   NetSocket mDebugSocket;
 49
 50   enum {
 51      
 52      // We should only change this is we truely 
 53      // break the protocol in a future version.
 54      Version = 2,
 55
 56      PasswordMaxLength = 32,
 57      MaxCommandSize = 2048
 58   };
 59
 60   char mDebuggerPassword[PasswordMaxLength+1];
 61   enum State
 62   {
 63      NotConnected,
 64      PasswordTry,
 65      Initialize,
 66      Connected
 67   };
 68   S32 mState;
 69   char mLineBuffer[MaxCommandSize];
 70   S32 mCurPos;
 71   bool mWaitForClient;
 72
 73   TelnetDebugger();
 74   ~<a href="/coding/class/classtelnetdebugger/">TelnetDebugger</a>();
 75
 76   struct Breakpoint
 77   {
 78      StringTableEntry fileName;
 79      CodeBlock *code;
 80      U32 lineNumber;
 81      S32 passCount;
 82      S32 curCount;
 83      char *testExpression;
 84      bool clearOnHit;
 85      Breakpoint *next;
 86   };
 87   Breakpoint *mBreakpoints;
 88
 89   Breakpoint **findBreakpoint(StringTableEntry fileName, S32 lineNumber);
 90
 91   bool mProgramPaused;
 92   bool mBreakOnNextStatement;
 93   S32 mStackPopBreakIndex;
 94
 95   void addVariableBreakpoint(const char *varName, S32 passCount, const char *evalString);
 96   void removeVariableBreakpoint(const char *varName);
 97   void addBreakpoint(const char *fileName, S32 line, bool clear, S32 passCount, const char *evalString);
 98   void removeBreakpoint(const char *fileName, S32 line);
 99   void removeAllBreakpoints();
100
101   void debugBreakNext();
102   void debugContinue();
103   void debugStepIn();
104   void debugStepOver();
105   void debugStepOut();
106   void evaluateExpression(const char *tag, S32 frame, const char *evalBuffer);
107   void dumpFileList();
108   void dumpBreakableList(const char *fileName);
109   void removeBreakpointsFromCode(CodeBlock *code);
110
111   void checkDebugRecv();
112   void processLineBuffer(S32);
113   void sendBreak();
114   void setBreakOnNextStatement( bool enabled );
115public:
116   static void create();
117   static void destroy();
118
119   void disconnect();
120   bool isConnected() const { return mState == Connected; }
121
122   void process();
123   void popStackFrame();
124   void pushStackFrame();
125   void addAllBreakpoints(CodeBlock *code);
126
127   void clearCodeBlockPointers(CodeBlock *code);
128
129   void breakProcess();
130
131   void executionStopped(CodeBlock *code, U32 lineNumber);
132   void send(const char *s);
133   void setDebugParameters(S32 port, const char *password, bool waitForClient);
134   void processConsoleLine(const char *consoleLine);
135};
136
137extern TelnetDebugger *TelDebugger;
138
139#endif
140
141