From 777d11cdcbcbc14362ba26955b96ec21bbbb169e Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 24 Nov 2021 23:32:34 +0800 Subject: [PATCH] disassembly finished --- RedPandaIDE/debugger.cpp | 185 ++++++++++++++++++++++++------ RedPandaIDE/debugger.h | 2 + RedPandaIDE/widgets/cpudialog.cpp | 2 +- 3 files changed, 156 insertions(+), 33 deletions(-) diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 9ce941da..a52dc5f9 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -77,6 +77,8 @@ bool Debugger::start() connect(mReader, &DebugReader::evalUpdated,[this](const QString& value) { emit evalValueReady(value); }); + connect(mReader, &DebugReader::disassemblyUpdate,this, + &Debugger::updateDisassembly); connect(mReader, &DebugReader::inferiorContinued,pMainWindow, &MainWindow::removeActiveBreakpoints); 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) { //pMainWindow->changeDebugOutputLastline(text); @@ -615,7 +624,85 @@ void DebugReader::clearCmdQueue() void DebugReader::processConsoleOutput(const QByteArray& line) { 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) { + qDebug()<<"process Result:"<=0) { QByteArray result = line.mid(pos+1); processResult(result); + } else if (mCurrentCmd && !(mCurrentCmd->command.startsWith('-'))) { + qDebug()<<"yes"; + qDebug()<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 ; } @@ -755,38 +861,45 @@ void DebugReader::processDebugOutput(const QByteArray& debugOutput) mSignalReceived = false; mUpdateCPUInfo = false; mReceivedSFWarning = false; + qDebug()<<"before split"; + QList lines = splitByteArrayToLines(debugOutput); + qDebug()<<"after split"; - QList lines = splitByteArrayToLines(debugOutput); - - for (int i=0;iparams.toLocal8Bit(); } s+= "\n"; + qDebug()<write(s)<0) { emit writeToDebugFailed(); } @@ -1328,10 +1444,15 @@ void DebugReader::run() buffer += readed; if (readed.endsWith("\n")&& outputTerminated(buffer)) { + qDebug()<<"-----"; processDebugOutput(buffer); + qDebug()<<"---1----"; buffer.clear(); + qDebug()<<"---2----"; mCmdRunning = false; + qDebug()<<"---3----"; runNextCmd(); + qDebug()<<"---4----"; } else if (!mCmdRunning && readed.isEmpty()){ runNextCmd(); } else if (readed.isEmpty()){ diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index 51f8a9a6..17199644 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -241,6 +241,7 @@ private: private slots: void syncFinishedParsing(); + void updateDisassembly(const QStringList& value); void onChangeDebugConsoleLastline(const QString& text); void clearUpReader(); @@ -323,6 +324,7 @@ signals: void localsUpdated(const QStringList& localsValue); void evalUpdated(const QString& value); void memoryUpdated(const QStringList& memoryValues); + void disassemblyUpdate(const QStringList& result); private: void clearCmdQueue(); diff --git a/RedPandaIDE/widgets/cpudialog.cpp b/RedPandaIDE/widgets/cpudialog.cpp index 2e1610ba..577e9fd0 100644 --- a/RedPandaIDE/widgets/cpudialog.cpp +++ b/RedPandaIDE/widgets/cpudialog.cpp @@ -57,7 +57,7 @@ void CPUDialog::updateInfo() if (pMainWindow->debugger()->executing()) { // Load the registers.. sendSyntaxCommand(); - pMainWindow->debugger()->sendCommand("info", "registers"); + //pMainWindow->debugger()->sendCommand("info", "registers"); if (ui->chkBlendMode->isChecked()) pMainWindow->debugger()->sendCommand("disas", "/s"); else