work save

This commit is contained in:
Roy Qu 2021-11-25 07:42:56 +08:00
parent 777d11cdcb
commit 73c88065f8
4 changed files with 32 additions and 46 deletions

View File

@ -71,12 +71,10 @@ bool Debugger::start()
&BreakpointModel::updateBreakpointNumber); &BreakpointModel::updateBreakpointNumber);
connect(mReader, &DebugReader::localsUpdated, pMainWindow, connect(mReader, &DebugReader::localsUpdated, pMainWindow,
&MainWindow::onLocalsReady); &MainWindow::onLocalsReady);
connect(mReader, &DebugReader::memoryUpdated,[this](const QStringList& memory) { connect(mReader, &DebugReader::memoryUpdated,this,
emit memoryExamineReady(memory); &Debugger::updateMemory);
}); connect(mReader, &DebugReader::evalUpdated,this,
connect(mReader, &DebugReader::evalUpdated,[this](const QString& value) { &Debugger::updateEval);
emit evalValueReady(value);
});
connect(mReader, &DebugReader::disassemblyUpdate,this, connect(mReader, &DebugReader::disassemblyUpdate,this,
&Debugger::updateDisassembly); &Debugger::updateDisassembly);
connect(mReader, &DebugReader::inferiorContinued,pMainWindow, connect(mReader, &DebugReader::inferiorContinued,pMainWindow,
@ -554,10 +552,20 @@ void Debugger::syncFinishedParsing()
} }
} }
void Debugger::updateDisassembly(const QStringList &value) void Debugger::updateMemory(const QStringList &value)
{
emit memoryExamineReady(value);
}
void Debugger::updateEval(const QString &value)
{
emit evalValueReady(value);
}
void Debugger::updateDisassembly(const QString& file, const QString& func, const QStringList &value)
{ {
if (pMainWindow->cpuDialog()) { if (pMainWindow->cpuDialog()) {
pMainWindow->cpuDialog()->setDisassembly(value); pMainWindow->cpuDialog()->setDisassembly(file,func,value);
} }
} }
@ -752,6 +760,7 @@ void DebugReader::processExecAsyncRecord(const QByteArray &line)
mCurrentAddress=0; mCurrentAddress=0;
mCurrentFile.clear(); mCurrentFile.clear();
mCurrentLine=-1; mCurrentLine=-1;
mCurrentFunc.clear();
emit inferiorContinued(); emit inferiorContinued();
return; return;
} }
@ -781,6 +790,7 @@ void DebugReader::processExecAsyncRecord(const QByteArray &line)
mCurrentAddress = frameObj["addr"].hexValue(); mCurrentAddress = frameObj["addr"].hexValue();
mCurrentLine = frameObj["line"].intValue(); mCurrentLine = frameObj["line"].intValue();
mCurrentFile = frameObj["fullname"].pathValue(); mCurrentFile = frameObj["fullname"].pathValue();
mCurrentFunc = frameObj["func"].value();
} }
if (reason == "signal-received") { if (reason == "signal-received") {
mSignalReceived = true; mSignalReceived = true;
@ -800,7 +810,6 @@ void DebugReader::processError(const QByteArray &errorLine)
void DebugReader::processResultRecord(const QByteArray &line) void DebugReader::processResultRecord(const QByteArray &line)
{ {
qDebug()<<"process Result:"<<line;
if (line.startsWith("^exit")) { if (line.startsWith("^exit")) {
mProcessExited = true; mProcessExited = true;
return; return;
@ -812,26 +821,18 @@ void DebugReader::processResultRecord(const QByteArray &line)
if (line.startsWith("^done") if (line.startsWith("^done")
|| line.startsWith("^running")) { || line.startsWith("^running")) {
int pos = line.indexOf(','); int pos = line.indexOf(',');
qDebug()<<pos<<mCurrentCmd.get();
if (pos>=0) { if (pos>=0) {
QByteArray result = line.mid(pos+1); QByteArray result = line.mid(pos+1);
processResult(result); processResult(result);
} else if (mCurrentCmd && !(mCurrentCmd->command.startsWith('-'))) { } else if (mCurrentCmd && !(mCurrentCmd->command.startsWith('-'))) {
qDebug()<<"yes";
qDebug()<<mCurrentCmd->command;
if (mCurrentCmd->command == "disas") { if (mCurrentCmd->command == "disas") {
qDebug()<<"yest0"; QStringList disOutput = mConsoleOutput;
QStringList disOutput = mConsoleOutput; if (disOutput.length()>=3) {
qDebug()<<"yest1";
if (disOutput.length()>=2) {
qDebug()<<"yest2";
disOutput.pop_back(); disOutput.pop_back();
disOutput.pop_front(); disOutput.pop_front();
qDebug()<<"yest4"; disOutput.pop_front();
} }
qDebug()<<"yest5"; emit disassemblyUpdate(mCurrentFile,mCurrentFunc, disOutput);
emit disassemblyUpdate(disOutput);
qDebug()<<"yest6";
} }
} }
return ; return ;
@ -861,20 +862,15 @@ void DebugReader::processDebugOutput(const QByteArray& debugOutput)
mSignalReceived = false; mSignalReceived = false;
mUpdateCPUInfo = false; mUpdateCPUInfo = false;
mReceivedSFWarning = false; mReceivedSFWarning = false;
qDebug()<<"before split";
QList<QByteArray> lines = splitByteArrayToLines(debugOutput); QList<QByteArray> lines = splitByteArrayToLines(debugOutput);
qDebug()<<"after split";
for (int i=0;i<lines.count();i++) { for (int i=0;i<lines.count();i++) {
QByteArray line = lines[i]; QByteArray line = lines[i];
qDebug()<<i<<line;
mFullOutput.append(line); mFullOutput.append(line);
qDebug()<<"token removed";
line = removeToken(line); line = removeToken(line);
if (line.isEmpty()) { if (line.isEmpty()) {
continue; continue;
} }
qDebug()<<"parse line";
switch (line[0]) { switch (line[0]) {
case '~': // console stream output case '~': // console stream output
processConsoleOutput(line); processConsoleOutput(line);
@ -892,14 +888,10 @@ void DebugReader::processDebugOutput(const QByteArray& debugOutput)
case '=': // notify async output case '=': // notify async output
break; break;
} }
qDebug()<<"parse line finished";
} }
qDebug()<<"after parse";
emit parseFinished(); emit parseFinished();
qDebug()<<"after parse sync";
mConsoleOutput.clear(); mConsoleOutput.clear();
mFullOutput.clear(); mFullOutput.clear();
qDebug()<<"parseFinished";
} }
void DebugReader::runInferiorStoppedHook() void DebugReader::runInferiorStoppedHook()
@ -1098,13 +1090,11 @@ void DebugReader::runNextCmd()
QMutexLocker locker(&mCmdQueueMutex); QMutexLocker locker(&mCmdQueueMutex);
if (mCurrentCmd) { if (mCurrentCmd) {
qDebug()<<"--- reset ---";
mCurrentCmd.reset(); mCurrentCmd.reset();
emit cmdFinished(); emit cmdFinished();
} }
if (mCmdQueue.isEmpty()) if (mCmdQueue.isEmpty())
return; return;
qDebug()<<"****************";
PDebugCommand pCmd = mCmdQueue.dequeue(); PDebugCommand pCmd = mCmdQueue.dequeue();
mCmdRunning = true; mCmdRunning = true;
@ -1117,7 +1107,6 @@ void DebugReader::runNextCmd()
s+= ' '+pCmd->params.toLocal8Bit(); s+= ' '+pCmd->params.toLocal8Bit();
} }
s+= "\n"; s+= "\n";
qDebug()<<s;
if (mProcess->write(s)<0) { if (mProcess->write(s)<0) {
emit writeToDebugFailed(); emit writeToDebugFailed();
} }
@ -1444,15 +1433,10 @@ void DebugReader::run()
buffer += readed; buffer += readed;
if (readed.endsWith("\n")&& outputTerminated(buffer)) { if (readed.endsWith("\n")&& outputTerminated(buffer)) {
qDebug()<<"-----";
processDebugOutput(buffer); processDebugOutput(buffer);
qDebug()<<"---1----";
buffer.clear(); buffer.clear();
qDebug()<<"---2----";
mCmdRunning = false; mCmdRunning = false;
qDebug()<<"---3----";
runNextCmd(); runNextCmd();
qDebug()<<"---4----";
} else if (!mCmdRunning && readed.isEmpty()){ } else if (!mCmdRunning && readed.isEmpty()){
runNextCmd(); runNextCmd();
} else if (readed.isEmpty()){ } else if (readed.isEmpty()){

View File

@ -241,7 +241,9 @@ private:
private slots: private slots:
void syncFinishedParsing(); void syncFinishedParsing();
void updateDisassembly(const QStringList& value); void updateMemory(const QStringList& value);
void updateEval(const QString& value);
void updateDisassembly(const QString& file, const QString& func,const QStringList& value);
void onChangeDebugConsoleLastline(const QString& text); void onChangeDebugConsoleLastline(const QString& text);
void clearUpReader(); void clearUpReader();
@ -324,7 +326,7 @@ signals:
void localsUpdated(const QStringList& localsValue); void localsUpdated(const QStringList& localsValue);
void evalUpdated(const QString& value); void evalUpdated(const QString& value);
void memoryUpdated(const QStringList& memoryValues); void memoryUpdated(const QStringList& memoryValues);
void disassemblyUpdate(const QStringList& result); void disassemblyUpdate(const QString& filename, const QString& funcName, const QStringList& result);
private: private:
void clearCmdQueue(); void clearCmdQueue();
@ -379,6 +381,7 @@ private:
int mCurrentLine; int mCurrentLine;
int mCurrentAddress; int mCurrentAddress;
QString mCurrentFunc;
QString mCurrentFile; QString mCurrentFile;
QStringList mConsoleOutput; QStringList mConsoleOutput;
QStringList mFullOutput; QStringList mFullOutput;

View File

@ -65,14 +65,12 @@ void CPUDialog::updateInfo()
} }
} }
void CPUDialog::setDisassembly(const QStringList &lines) void CPUDialog::setDisassembly(const QString& file, const QString& funcName,const QStringList& lines)
{ {
if (lines.size()>0) { ui->txtFunctionName->setText(QString("%1:%2").arg(file, funcName));
ui->txtFunctionName->setText(lines[0]);
}
int activeLine = -1; int activeLine = -1;
ui->txtCode->lines()->clear(); ui->txtCode->lines()->clear();
for (int i=1;i<lines.size();i++) { for (int i=0;i<lines.size();i++) {
QString line = lines[i]; QString line = lines[i];
if (line.startsWith("=>")) { if (line.startsWith("=>")) {
activeLine = i; activeLine = i;

View File

@ -15,7 +15,8 @@ public:
explicit CPUDialog(QWidget *parent = nullptr); explicit CPUDialog(QWidget *parent = nullptr);
~CPUDialog(); ~CPUDialog();
void updateInfo(); void updateInfo();
void setDisassembly(const QStringList& lines); public slots:
void setDisassembly(const QString& file, const QString& funcName,const QStringList& lines);
signals: signals:
void closed(); void closed();
private: private: