work save

This commit is contained in:
royqh1979@gmail.com 2021-07-30 23:28:58 +08:00
parent b04972ddb4
commit 66da8f2df8
4 changed files with 28 additions and 5 deletions

View File

@ -43,6 +43,7 @@ void Debugger::start()
mReader->setDebuggerPath(debuggerPath); mReader->setDebuggerPath(debuggerPath);
connect(mReader, &QThread::finished,this,&Debugger::stop); connect(mReader, &QThread::finished,this,&Debugger::stop);
connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection); connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection);
connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline,Qt::BlockingQueuedConnection);
mReader->start(); mReader->start();
mReader->mStartSemaphore.acquire(1); mReader->mStartSemaphore.acquire(1);
@ -418,6 +419,12 @@ void Debugger::syncFinishedParsing()
} }
} }
void Debugger::onChangeDebugConsoleLastline(const QString &text)
{
//pMainWindow->changeDebugOutputLastline(text);
pMainWindow->addDebugOutput(text);
}
int Debugger::leftPageIndexBackup() const int Debugger::leftPageIndexBackup() const
{ {
return mLeftPageIndexBackup; return mLeftPageIndexBackup;
@ -455,8 +462,8 @@ void DebugReader::postCommand(const QString &Command, const QString &Params, boo
pCmd->showInConsole = ShowInConsole; pCmd->showInConsole = ShowInConsole;
pCmd->source = Source; pCmd->source = Source;
mCmdQueue.enqueue(pCmd); mCmdQueue.enqueue(pCmd);
if (!mCmdRunning) // if (!mCmdRunning)
runNextCmd(); // runNextCmd();
} }
void DebugReader::clearCmdQueue() void DebugReader::clearCmdQueue()
@ -1131,16 +1138,18 @@ void DebugReader::runNextCmd()
} }
// if devDebugger.ShowCommandLog or pCmd^.ShowInConsole then begin // if devDebugger.ShowCommandLog or pCmd^.ShowInConsole then begin
if (true || pCmd->showInConsole) { if (pSettings->debugger().showCommandLog() || pCmd->showInConsole) {
//update debug console //update debug console
// if not devDebugger.ShowAnnotations then begin // if not devDebugger.ShowAnnotations then begin
if (true) { if (!pSettings->debugger().showAnnotations()) {
// if MainForm.DebugOutput.Lines.Count>0 then begin // if MainForm.DebugOutput.Lines.Count>0 then begin
// MainForm.DebugOutput.Lines.Delete(MainForm.DebugOutput.Lines.Count-1); // MainForm.DebugOutput.Lines.Delete(MainForm.DebugOutput.Lines.Count-1);
// end; // end;
emit changeDebugConsoleLastLine("(gdb)"+pCmd->command + ' ' + pCmd->params);
// MainForm.DebugOutput.Lines.Add('(gdb)'+pCmd^.Cmd + ' ' + pCmd^.params); // MainForm.DebugOutput.Lines.Add('(gdb)'+pCmd^.Cmd + ' ' + pCmd^.params);
// MainForm.DebugOutput.Lines.Add(''); // MainForm.DebugOutput.Lines.Add('');
} else { } else {
emit changeDebugConsoleLastLine("(gdb)"+pCmd->command + ' ' + pCmd->params);
// MainForm.DebugOutput.Lines.Add(pCmd^.Cmd + ' ' + pCmd^.params); // MainForm.DebugOutput.Lines.Add(pCmd^.Cmd + ' ' + pCmd^.params);
// MainForm.DebugOutput.Lines.Add(''); // MainForm.DebugOutput.Lines.Add('');
} }
@ -1212,6 +1221,7 @@ void DebugReader::run()
mProcess->waitForStarted(5000); mProcess->waitForStarted(5000);
mStartSemaphore.release(1); mStartSemaphore.release(1);
QByteArray buffer; QByteArray buffer;
QByteArray readed;
while (true) { while (true) {
mProcess->waitForFinished(100); mProcess->waitForFinished(100);
if (mProcess->state()!=QProcess::Running) { if (mProcess->state()!=QProcess::Running) {
@ -1222,12 +1232,16 @@ void DebugReader::run()
} }
if (errorOccurred) if (errorOccurred)
break; break;
buffer += mProcess->readAll(); readed = mProcess->readAll();
buffer += readed;
if (getLastAnnotation(buffer) == AnnotationType::TPrompt) { if (getLastAnnotation(buffer) == AnnotationType::TPrompt) {
mOutput = buffer; mOutput = buffer;
processDebugOutput(); processDebugOutput();
buffer.clear();
mCmdRunning = false; mCmdRunning = false;
runNextCmd(); runNextCmd();
} else if (!mCmdRunning && readed.isEmpty()){
runNextCmd();
} }
} }
if (errorOccurred) { if (errorOccurred) {

View File

@ -180,6 +180,7 @@ private:
void sendClearBreakpointCommand(PBreakpoint breakpoint); void sendClearBreakpointCommand(PBreakpoint breakpoint);
private slots: private slots:
void syncFinishedParsing(); void syncFinishedParsing();
void onChangeDebugConsoleLastline(const QString& text);
private: private:
bool mExecuting; bool mExecuting;
bool mCommandChanged; bool mCommandChanged;
@ -209,6 +210,7 @@ signals:
void pauseWatchUpdate(); void pauseWatchUpdate();
void updateWatch(); void updateWatch();
void processError(QProcess::ProcessError error); void processError(QProcess::ProcessError error);
void changeDebugConsoleLastLine(const QString& test);
private: private:
void clearCmdQueue(); void clearCmdQueue();
bool findAnnotation(AnnotationType annotation); bool findAnnotation(AnnotationType annotation);

View File

@ -296,9 +296,15 @@ void MainWindow::addDebugOutput(const QString &text)
ui->debugConsole->addLine(""); ui->debugConsole->addLine("");
} else { } else {
ui->debugConsole->addText(text); ui->debugConsole->addText(text);
qDebug()<<"add text"<<text;
} }
} }
void MainWindow::changeDebugOutputLastline(const QString &test)
{
ui->debugConsole->changeLastLine(test);
}
void MainWindow::updateStatusbarForLineCol() void MainWindow::updateStatusbarForLineCol()
{ {
Editor* e = mEditorList->getEditor(); Editor* e = mEditorList->getEditor();

View File

@ -63,6 +63,7 @@ public:
void setActiveBreakpoint(QString FileName, int Line, bool setFocus=true); void setActiveBreakpoint(QString FileName, int Line, bool setFocus=true);
void updateAppTitle(); void updateAppTitle();
void addDebugOutput(const QString& text); void addDebugOutput(const QString& text);
void changeDebugOutputLastline(const QString& text);
CPUDialog *cpuDialog() const; CPUDialog *cpuDialog() const;