work save

This commit is contained in:
royqh1979@gmail.com 2021-07-18 08:52:53 +08:00
parent 3d95415f57
commit 549defdf16
2 changed files with 119 additions and 56 deletions

View File

@ -524,67 +524,124 @@ void DebugReader::processDebugOutput()
// Only update once per update at most
//WatchView.Items.BeginUpdate;
if fInvalidateAllVars then begin
if (mInvalidateAllVars) {
//invalidate all vars when there's first output
if Assigned(fOnInvalidateAllVars) then
fOnInvalidateAllVars;
fInvalidateAllVars := False;
end;
invalidateAllVars();
mInvalidateAllVars = false;
}
emit parseStarted();
//try
dobacktraceready := false;
dodisassemblerready := false;
doregistersready := false;
dorescanwatches := false;
doevalready := false;
doprocessexited := false;
doupdateexecution := false;
doreceivedsignal := false;
doupdatecpuwindow := false;
doreceivedsfwarning := false;
dobacktraceready = false;
dodisassemblerready = false;
doregistersready = false;
dorescanwatches = false;
doevalready = false;
doprocessexited = false;
doupdateexecution = false;
doreceivedsignal = false;
doupdatecpuwindow = false;
doreceivedsfwarning = false;
// Global checks
if Pos('warning: Source file is more recent than executable.', fOutput) > 0 then
doreceivedsfwarning := true;
if (mOutput.indexOf("warning: Source file is more recent than executable.") >= 0)
doreceivedsfwarning = true;
fIndex := 1;
repeat
NextAnnotation := GetNextAnnotation;
case NextAnnotation of
TValueHistoryValue:
HandleValueHistoryValue;
TSignal:
HandleSignal;
TExit:
HandleExit;
TFrameBegin:
HandleFrames;
TInfoAsm:
HandleDisassembly;
TInfoReg:
HandleRegisters;
TLocal:
HandleLocals;
TParam:
HandleParams;
TErrorBegin:
HandleError;
TDisplayBegin:
HandleDisplay;
TSource:
HandleSource
//else
// break;
end;
until NextAnnotation = TEOF;
mIndex = 0;
AnnotationType nextAnnotation;
do {
nextAnnotation = getNextAnnotation();
switch(nextAnnotation) {
case AnnotationType::TValueHistoryValue:
handleValueHistoryValue();
break;
case AnnotationType::TSignal:
handleSignal();
break;
case AnnotationType::TExit:
handleExit();
break;
case AnnotationType::TFrameBegin:
handleFrames();
break;
case AnnotationType::TInfoAsm:
handleDisassembly();
break;
case AnnotationType::TInfoReg:
handleRegisters();
break;
case AnnotationType::TLocal:
handleLocals();
break;
case AnnotationType::TParam:
handleParams();
break;
case AnnotationType::TErrorBegin:
handleError();
break;
case AnnotationType::TDisplayBegin:
handleDisplay();
break;
case AnnotationType::TSource:
handleSource();
break;
}
} while (nextAnnotation != AnnotationType::TEOF);
// Only update once per update at most
//finally
//WatchView.Items.EndUpdate;
//end;
Synchronize(SyncFinishedParsing);
emit parseFinished();
}
QString DebugReader::processEvalOutput()
{
int indent = 0;
// First line gets special treatment
QString result = getNextLine();
if (result.startsWith('{'))
indent+=4;
// Collect all data, add formatting in between
AnnotationType nextAnnotation;
QString nextLine;
bool shouldExit = false;
do {
nextAnnotation = getNextAnnotation();
nextLine = getNextLine();
switch(nextAnnotation) {
// Change indent if { or } is found
case AnnotationType::TFieldBegin:
result += "\r\n" + QString(4,' ');
break;
case AnnotationType::TFieldValue:
if (nextLine.startsWith('{') && (peekNextAnnotation() !=
AnnotationType::TArrayBegin))
indent+=4;
break;
case AnnotationType::TFieldEnd:
if (nextLine.endsWith('}')) {
indent-=4;
result += "\r\n" + QString(4,' ');
}
break;
case AnnotationType::TEOF:
case AnnotationType::TValueHistoryEnd:
case AnnotationType::TDisplayEnd:
shouldExit = true;
}
result += nextLine;
} while (!shouldExit);
}
void DebugReader::processWatchOutput(PWatchVar WatchVar)
{
//todo
}

View File

@ -129,6 +129,10 @@ class DebugReader : public QObject
public:
explicit DebugReader(QObject *parent = nullptr);
signals:
void parseStarted();
void invalidateAllVars();
void parseFinished();
private:
void clearCmdQueue();
bool findAnnotation(AnnotationType annotation);
@ -153,6 +157,8 @@ private:
void handleValueHistoryValue();
AnnotationType peekNextAnnotation();
void processDebugOutput();
QString processEvalOutput();
void processWatchOutput(PWatchVar WatchVar);
private:
QMutex mMutex;
QQueue<PDebugCommand> mCmdQueue;