1 #ifndef _SQ_DBGSERVER_H_
\r
2 #define _SQ_DBGSERVER_H_
\r
4 #define MAX_BP_PATH 512
\r
5 #define MAX_MSG_LEN 2049
\r
11 #include <winsock.h>
\r
13 typedef std::basic_string<SQChar> SQDBGString;
\r
16 BreakPoint(){_line=0;}
\r
17 BreakPoint(SQInteger line, const SQChar *src){ _line = line; _src = src; }
\r
18 BreakPoint(const BreakPoint& bp){ _line = bp._line; _src=bp._src; }
\r
19 bool operator<(const BreakPoint& bp) const
\r
23 if(_line==bp._line){
\r
31 bool operator==(const BreakPoint& other)
\r
33 if(_line==other._line
\r
34 && (_src==other._src))
\r
43 Watch() { _id = 0; }
\r
44 Watch(SQInteger id,const SQChar *exp) { _id = id; _exp = exp; }
\r
45 Watch(const Watch &w) { _id = w._id; _exp = w._exp; }
\r
46 bool operator<(const Watch& w) const { return _id<w._id; }
\r
47 bool operator==(const Watch& w) const { return _id == w._id; }
\r
53 VMState() { _nestedcalls = 0;}
\r
54 SQInteger _nestedcalls;
\r
56 typedef std::map<HSQUIRRELVM,VMState*> VMStateMap;
\r
57 typedef std::set<BreakPoint> BreakPointSet;
\r
58 typedef BreakPointSet::iterator BreakPointSetItor;
\r
60 typedef std::set<Watch> WatchSet;
\r
61 typedef WatchSet::iterator WatchSetItor;
\r
63 typedef std::vector<SQChar> SQCharVec;
\r
75 SQDbgServer(HSQUIRRELVM v);
\r
78 //returns true if a message has been received
\r
79 bool WaitForClient();
\r
82 void Hook(HSQUIRRELVM v,SQInteger type,SQInteger line,const SQChar *src,const SQChar *func);
\r
83 void ParseMsg(const char *msg);
\r
84 bool ParseBreakpoint(const char *msg,BreakPoint &out);
\r
85 bool ParseWatch(const char *msg,Watch &out);
\r
86 bool ParseRemoveWatch(const char *msg,SQInteger &id);
\r
89 void BreakExecution();
\r
90 void Send(const SQChar *s,...);
\r
91 void SendChunk(const SQChar *chunk);
\r
92 void Break(HSQUIRRELVM v,SQInteger line,const SQChar *src,const SQChar *type,const SQChar *error=NULL);
\r
95 void SerializeState(HSQUIRRELVM v);
\r
97 void AddBreakpoint(BreakPoint &bp);
\r
98 void AddWatch(Watch &w);
\r
99 void RemoveWatch(SQInteger id);
\r
100 void RemoveBreakpoint(BreakPoint &bp);
\r
103 void SetErrorHandlers(HSQUIRRELVM v);
\r
104 VMState *GetVMState(HSQUIRRELVM v);
\r
106 //XML RELATED STUFF///////////////////////
\r
107 #define MAX_NESTING 10
\r
108 struct XMLElementState {
\r
113 XMLElementState xmlstate[MAX_NESTING];
\r
114 SQInteger _xmlcurrentement;
\r
116 void BeginDocument();
\r
117 void BeginElement(const SQChar *name);
\r
118 void Attribute(const SQChar *name, const SQChar *value);
\r
119 void EndElement(const SQChar *name);
\r
120 void EndDocument();
\r
122 const SQChar *escape_xml(const SQChar *x);
\r
123 //////////////////////////////////////////////
\r
125 HSQOBJECT _debugroot;
\r
129 BreakPointSet _breakpoints;
\r
131 //int _recursionlevel;
\r
132 //int _maxrecursion;
\r
136 HSQOBJECT _serializefunc;
\r
137 SQCharVec _scratchstring;
\r
141 SQDBGString _break_type;
\r
142 VMStateMap _vmstate;
\r
146 #define sqdbg_closesocket(x) closesocket((x))
\r
148 #define sqdbg_closesocket(x) close((x))
\r
151 #endif //_SQ_DBGSERVER_H_