disassembly finished

This commit is contained in:
Roy Qu 2021-11-24 23:32:34 +08:00
parent de0f176284
commit 777d11cdcb
3 changed files with 156 additions and 33 deletions

View File

@ -77,6 +77,8 @@ bool Debugger::start()
connect(mReader, &DebugReader::evalUpdated,[this](const QString& value) { connect(mReader, &DebugReader::evalUpdated,[this](const QString& value) {
emit evalValueReady(value); emit evalValueReady(value);
}); });
connect(mReader, &DebugReader::disassemblyUpdate,this,
&Debugger::updateDisassembly);
connect(mReader, &DebugReader::inferiorContinued,pMainWindow, connect(mReader, &DebugReader::inferiorContinued,pMainWindow,
&MainWindow::removeActiveBreakpoints); &MainWindow::removeActiveBreakpoints);
connect(mReader, &DebugReader::inferiorStopped,pMainWindow, connect(mReader, &DebugReader::inferiorStopped,pMainWindow,
@ -552,6 +554,13 @@ void Debugger::syncFinishedParsing()
} }
} }
void Debugger::updateDisassembly(const QStringList &value)
{
if (pMainWindow->cpuDialog()) {
pMainWindow->cpuDialog()->setDisassembly(value);
}
}
void Debugger::onChangeDebugConsoleLastline(const QString& text) void Debugger::onChangeDebugConsoleLastline(const QString& text)
{ {
//pMainWindow->changeDebugOutputLastline(text); //pMainWindow->changeDebugOutputLastline(text);
@ -615,7 +624,85 @@ void DebugReader::clearCmdQueue()
void DebugReader::processConsoleOutput(const QByteArray& line) void DebugReader::processConsoleOutput(const QByteArray& line)
{ {
if (line.length()>3 && line.startsWith("~\"") && line.endsWith("\"")) { if (line.length()>3 && line.startsWith("~\"") && line.endsWith("\"")) {
mConsoleOutput.append(QString::fromLocal8Bit(line.mid(2,line.length()-3))); QByteArray s=line.mid(2,line.length()-3);
QByteArray stringValue;
const char *p=s.data();
while (*p!=0) {
if (*p=='\\' && *(p+1)!=0) {
p++;
switch (*p) {
case '\'':
stringValue+=0x27;
p++;
break;
case '"':
stringValue+=0x22;
p++;
break;
case '?':
stringValue+=0x3f;
p++;
break;
case '\\':
stringValue+=0x5c;
p++;
break;
case 'a':
stringValue+=0x07;
p++;
break;
case 'b':
stringValue+=0x08;
p++;
break;
case 'f':
stringValue+=0x0c;
p++;
break;
case 'n':
stringValue+=0x0a;
p++;
break;
case 'r':
stringValue+=0x0d;
p++;
break;
case 't':
stringValue+=0x09;
p++;
break;
case 'v':
stringValue+=0x0b;
p++;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
int i=0;
for (i=0;i<3;i++) {
if (*(p+i)<'0' || *(p+i)>'7')
break;
}
QByteArray numStr(p,i);
bool ok;
unsigned char ch = numStr.toInt(&ok,8);
stringValue+=ch;
p+=i;
break;
}
}
} else {
stringValue+=*p;
p++;
}
}
mConsoleOutput.append(QString::fromLocal8Bit(stringValue));
} }
} }
@ -713,6 +800,7 @@ 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;
@ -724,9 +812,27 @@ 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('-'))) {
qDebug()<<"yes";
qDebug()<<mCurrentCmd->command;
if (mCurrentCmd->command == "disas") {
qDebug()<<"yest0";
QStringList disOutput = mConsoleOutput;
qDebug()<<"yest1";
if (disOutput.length()>=2) {
qDebug()<<"yest2";
disOutput.pop_back();
disOutput.pop_front();
qDebug()<<"yest4";
}
qDebug()<<"yest5";
emit disassemblyUpdate(disOutput);
qDebug()<<"yest6";
}
} }
return ; return ;
} }
@ -755,16 +861,20 @@ 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);
@ -782,11 +892,14 @@ 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()
@ -985,11 +1098,13 @@ 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;
@ -1002,6 +1117,7 @@ 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();
} }
@ -1328,10 +1444,15 @@ 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,6 +241,7 @@ private:
private slots: private slots:
void syncFinishedParsing(); void syncFinishedParsing();
void updateDisassembly(const QStringList& value);
void onChangeDebugConsoleLastline(const QString& text); void onChangeDebugConsoleLastline(const QString& text);
void clearUpReader(); void clearUpReader();
@ -323,6 +324,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);
private: private:
void clearCmdQueue(); void clearCmdQueue();

View File

@ -57,7 +57,7 @@ void CPUDialog::updateInfo()
if (pMainWindow->debugger()->executing()) { if (pMainWindow->debugger()->executing()) {
// Load the registers.. // Load the registers..
sendSyntaxCommand(); sendSyntaxCommand();
pMainWindow->debugger()->sendCommand("info", "registers"); //pMainWindow->debugger()->sendCommand("info", "registers");
if (ui->chkBlendMode->isChecked()) if (ui->chkBlendMode->isChecked())
pMainWindow->debugger()->sendCommand("disas", "/s"); pMainWindow->debugger()->sendCommand("disas", "/s");
else else