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

@ -522,69 +522,126 @@ AnnotationType DebugReader::peekNextAnnotation()
void DebugReader::processDebugOutput() void DebugReader::processDebugOutput()
{ {
// Only update once per update at most // Only update once per update at most
//WatchView.Items.BeginUpdate; //WatchView.Items.BeginUpdate;
if fInvalidateAllVars then begin if (mInvalidateAllVars) {
//invalidate all vars when there's first output //invalidate all vars when there's first output
if Assigned(fOnInvalidateAllVars) then invalidateAllVars();
fOnInvalidateAllVars; mInvalidateAllVars = false;
fInvalidateAllVars := False; }
end;
//try emit parseStarted();
dobacktraceready := false; //try
dodisassemblerready := false;
doregistersready := false;
dorescanwatches := false;
doevalready := false;
doprocessexited := false;
doupdateexecution := false;
doreceivedsignal := false;
doupdatecpuwindow := false;
doreceivedsfwarning := false;
// Global checks dobacktraceready = false;
if Pos('warning: Source file is more recent than executable.', fOutput) > 0 then dodisassemblerready = false;
doreceivedsfwarning := true; doregistersready = false;
dorescanwatches = false;
doevalready = false;
doprocessexited = false;
doupdateexecution = false;
doreceivedsignal = false;
doupdatecpuwindow = false;
doreceivedsfwarning = false;
fIndex := 1; // Global checks
repeat if (mOutput.indexOf("warning: Source file is more recent than executable.") >= 0)
NextAnnotation := GetNextAnnotation; doreceivedsfwarning = true;
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;
// Only update once per update at most mIndex = 0;
//finally AnnotationType nextAnnotation;
//WatchView.Items.EndUpdate; do {
//end; 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);
Synchronize(SyncFinishedParsing); // Only update once per update at most
//finally
//WatchView.Items.EndUpdate;
//end;
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: public:
explicit DebugReader(QObject *parent = nullptr); explicit DebugReader(QObject *parent = nullptr);
signals:
void parseStarted();
void invalidateAllVars();
void parseFinished();
private: private:
void clearCmdQueue(); void clearCmdQueue();
bool findAnnotation(AnnotationType annotation); bool findAnnotation(AnnotationType annotation);
@ -153,6 +157,8 @@ private:
void handleValueHistoryValue(); void handleValueHistoryValue();
AnnotationType peekNextAnnotation(); AnnotationType peekNextAnnotation();
void processDebugOutput(); void processDebugOutput();
QString processEvalOutput();
void processWatchOutput(PWatchVar WatchVar);
private: private:
QMutex mMutex; QMutex mMutex;
QQueue<PDebugCommand> mCmdQueue; QQueue<PDebugCommand> mCmdQueue;