1
#ifndef _SQ_DBGSERVER_H_
2
#define _SQ_DBGSERVER_H_
4
#define MAX_BP_PATH 512
5
#define MAX_MSG_LEN 2049
11
see copyright notice in sqrdbg.h
15
typedef std::basic_string<SQChar> SQDBGString;
17
inline bool dbg_less(const SQChar *x,const SQChar *y)
21
int xl = *x == '\\' ? '/' : tolower(*x);
22
int yl = *y == '\\' ? '/' : tolower(*y);
25
return diff > 0?true:false;
27
}while(*x != 0 && *y != 0);
32
BreakPoint(){_line=0;}
33
BreakPoint(int line, const SQChar *src){ _line = line; _src = src; }
34
BreakPoint(const BreakPoint& bp){ _line = bp._line; _src=bp._src; }
35
inline bool operator<(const BreakPoint& bp) const
40
return dbg_less(_src.c_str(),bp._src.c_str());
51
Watch(int id,const SQChar *exp) { _id = id; _exp = exp; }
52
Watch(const Watch &w) { _id = w._id; _exp = w._exp; }
53
bool operator<(const Watch& w) const { return _id<w._id; }
54
bool operator==(const Watch& w) const { return _id == w._id; }
59
typedef std::set<BreakPoint> BreakPointSet;
60
typedef BreakPointSet::iterator BreakPointSetItor;
62
typedef std::set<Watch> WatchSet;
63
typedef WatchSet::iterator WatchSetItor;
65
typedef std::vector<SQChar> SQCharVec;
77
SQDbgServer(HSQUIRRELVM v);
80
//returns true if a message has been received
84
void Hook(int type,int line,const SQChar *src,const SQChar *func);
85
void ParseMsg(const char *msg);
86
bool ParseBreakpoint(const char *msg,BreakPoint &out);
87
bool ParseWatch(const char *msg,Watch &out);
88
bool ParseRemoveWatch(const char *msg,int &id);
91
void BreakExecution();
92
void Send(const SQChar *s,...);
93
void SendChunk(const SQChar *chunk);
94
void Break(int line,const SQChar *src,const SQChar *type,const SQChar *error=NULL);
97
void SerializeState();
99
void AddBreakpoint(BreakPoint &bp);
100
void AddWatch(Watch &w);
101
void RemoveWatch(int id);
102
void RemoveBreakpoint(BreakPoint &bp);
105
void SetErrorHandlers();
107
//XML RELATED STUFF///////////////////////
108
#define MAX_NESTING 10
109
struct XMLElementState {
114
XMLElementState xmlstate[MAX_NESTING];
115
int _xmlcurrentement;
117
void BeginDocument() { _xmlcurrentement = -1; }
118
void BeginElement(const SQChar *name);
119
void Attribute(const SQChar *name, const SQChar *value);
120
void EndElement(const SQChar *name);
123
const SQChar *escape_xml(const SQChar *x);
124
//////////////////////////////////////////////
126
HSQOBJECT _debugroot;
130
BreakPointSet _breakpoints;
137
HSQOBJECT _serializefunc;
138
SQCharVec _scratchstring;
143
#define sqdbg_closesocket(x) closesocket((x))
145
#define sqdbg_closesocket(x) close((x))
148
#endif //_SQ_DBGSERVER_H_