Debugger: Stack frame support (not finished)

stable-5.1
Martin Plicht 2010-01-15 05:46:16 +01:00
parent db281e3d10
commit cee326dd57
3 changed files with 39 additions and 5 deletions

View File

@ -18,8 +18,10 @@ C4AulDebug::C4AulDebug()
}
C4AulDebug::~C4AulDebug()
{
}
{
for (std::list<StdStrBuf*>::iterator it = StackTrace.begin(); it != StackTrace.end(); it++)
{delete *it;}
}
void C4AulDebug::PackPacket(const C4NetIOPacket &rPacket, StdBuf &rOutBuf)
{
@ -182,7 +184,7 @@ void C4AulDebug::ProcessLine(const StdStrBuf &Line)
else if (SEqualNoCase(szCmd, "LST"))
{
for (C4AulScript* script = ScriptEngine.Child0; script; script = script->Next) {
DebugLog(Config.AtRelativePath(script->ScriptName.getData()));
SendLine(Config.AtRelativePath(script->ScriptName.getData()));
}
}
@ -244,6 +246,15 @@ void C4AulDebug::ProcessLine(const StdStrBuf &Line)
}
}
else if (SEqualNoCase(szCmd, "SST"))
{
std::list<StdStrBuf*>::iterator it = StackTrace.begin();
for (it++; it != StackTrace.end(); it++)
{
SendLine("AT", (*it)->getData());
}
SendLine("EST");
}
else
{
@ -371,7 +382,8 @@ void C4AulDebug::StepPoint(C4AulBCC *pCPos, C4AulScriptContext *pRetCtx, C4Value
SendLine("STP", "Stepped");
// Position
SendLine("POS", FormatCodePos(pCtx, pCPos).getData());
ObtainStackTrace(pCtx, pCPos);
SendLine("POS", StackTrace.front()->getData());
// Suspend until we get some command
while(eState == DS_Stop)
@ -385,6 +397,23 @@ void C4AulDebug::StepPoint(C4AulBCC *pCPos, C4AulScriptContext *pRetCtx, C4Value
Game.HaltCount--;
}
void C4AulDebug::ObtainStackTrace(C4AulScriptContext* pCtx, C4AulBCC* pCPos)
{
for (std::list<StdStrBuf*>::iterator it = StackTrace.begin(); it != StackTrace.end(); it++)
{delete *it;}
StackTrace.clear();
for (int ctxNum = pExec->GetContextDepth()-1; ctxNum >= 0; ctxNum--)
{
C4AulScriptContext* c = pExec->GetContext(ctxNum);
C4AulBCC* _cpos = c == pCtx ? pCPos : c->CPos;
if (_cpos)
{
StdStrBuf* format = new StdStrBuf(FormatCodePos(c, _cpos));
StackTrace.push_back(format);
}
}
}
StdStrBuf C4AulDebug::FormatCodePos(C4AulScriptContext *pCtx, C4AulBCC *pCPos)
{
// Get position in script

View File

@ -28,6 +28,11 @@ class C4AulDebug : public C4NetIOTCP, private C4NetIO::CBClass
};
DebugState eState;
int iStepCallDepth;
// temporary stuff
std::list<StdStrBuf*> StackTrace;
void ObtainStackTrace(C4AulScriptContext* pCtx, C4AulBCC* pCPos);
private:

View File

@ -1020,7 +1020,7 @@ C4AulBCC *C4AulExec::Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4
ctx.Func = pSFunc;
ctx.TemporaryScript = false;
ctx.CPos = NULL;
pDebug->DebugStepOut(pCurCtx->CPos + 1, &ctx, pReturn);
pDebug->DebugStepOut(pCurCtx->CPos + 1, pCurCtx, pReturn);
}
// Remove parameters from stack