From de0f176284b4b756c83dbfcd2523bb0da4381030 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 24 Nov 2021 22:16:40 +0800 Subject: [PATCH] breakpoint / run / evaluation / memory view ok --- RedPandaIDE/debugger.cpp | 29 ++++++++++++++--------------- RedPandaIDE/editor.cpp | 2 +- RedPandaIDE/gdbmiresultparser.cpp | 29 ++++++++++++++--------------- RedPandaIDE/gdbmiresultparser.h | 4 ++-- RedPandaIDE/mainwindow.cpp | 17 ++--------------- RedPandaIDE/mainwindow.h | 2 -- RedPandaIDE/mainwindow.ui | 14 -------------- RedPandaIDE/widgets/cpudialog.cpp | 4 ++-- 8 files changed, 35 insertions(+), 66 deletions(-) diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 80903ef4..9ce941da 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -623,8 +623,10 @@ void DebugReader::processResult(const QByteArray &result) { GDBMIResultParser parser; GDBMIResultType resultType; - GDBMIResultParser::ParseValue parseValue; - bool parseOk = parser.parse(result,resultType,parseValue); + GDBMIResultParser::ParseObject multiValues; + if (!mCurrentCmd) + return; + bool parseOk = parser.parse(result, mCurrentCmd->command, resultType,multiValues); if (!parseOk) return; switch(resultType) { @@ -633,16 +635,19 @@ void DebugReader::processResult(const QByteArray &result) case GDBMIResultType::Locals: break; case GDBMIResultType::Breakpoint: - handleBreakpoint(parseValue.object()); + handleBreakpoint(multiValues["bkpt"].object()); return; case GDBMIResultType::FrameStack: - handleStack(parseValue.array()); + handleStack(multiValues["stack"].array()); return; case GDBMIResultType::LocalVariables: - handleLocalVariables(parseValue.array()); + handleLocalVariables(multiValues["variables"].array()); return; case GDBMIResultType::Evaluation: - handleEvaluation(parseValue.value()); + handleEvaluation(multiValues["value"].value()); + return; + case GDBMIResultType::Memory: + handleMemory(multiValues["memory"].array()); return; } @@ -1005,9 +1010,9 @@ void DebugReader::runNextCmd() if (pSettings->debugger().showCommandLog() ) { //update debug console if (!pSettings->debugger().showAnnotations()) { - emit changeDebugConsoleLastLine("(gdb)"+pCmd->command + ' ' + pCmd->params); + emit changeDebugConsoleLastLine(pCmd->command + ' ' + pCmd->params); } else { - emit changeDebugConsoleLastLine("(gdb)"+pCmd->command + ' ' + pCmd->params); + emit changeDebugConsoleLastLine(pCmd->command + ' ' + pCmd->params); } } } @@ -1121,7 +1126,7 @@ bool DebugReader::outputTerminated(const QByteArray &text) void DebugReader::handleBreakpoint(const GDBMIResultParser::ParseObject& breakpoint) { // gdb use system encoding for file path - QString filename = breakpoint["fullname"].value(); + QString filename = breakpoint["fullname"].pathValue(); int line = breakpoint["line"].intValue(); int number = breakpoint["number"].intValue(); emit breakpointInfoGetted(filename, line , number); @@ -1322,10 +1327,6 @@ void DebugReader::run() readed = mProcess->readAll(); buffer += readed; - if (!readed.isEmpty()) { - qDebug()<<"*******"; - qDebug()<debugger(), &Debugger::evalValueReady, this, &Editor::onTipEvalValueReady); mCurrentDebugTipWord = s; - pMainWindow->debugger()->sendCommand("print",s); + pMainWindow->debugger()->sendCommand("-data-evaluate-expression",s); } QString Editor::getErrorHint(const PSyntaxIssue& issue) diff --git a/RedPandaIDE/gdbmiresultparser.cpp b/RedPandaIDE/gdbmiresultparser.cpp index 35d256fb..0ebc5157 100644 --- a/RedPandaIDE/gdbmiresultparser.cpp +++ b/RedPandaIDE/gdbmiresultparser.cpp @@ -6,30 +6,29 @@ GDBMIResultParser::GDBMIResultParser() { - mResultTypes.insert("bkpt",GDBMIResultType::Breakpoint); - mResultTypes.insert("BreakpointTable",GDBMIResultType::BreakpointTable); - mResultTypes.insert("stack",GDBMIResultType::FrameStack); - mResultTypes.insert("variables", GDBMIResultType::LocalVariables); - mResultTypes.insert("frame",GDBMIResultType::Frame); - mResultTypes.insert("asm_insns",GDBMIResultType::Disassembly); - mResultTypes.insert("value",GDBMIResultType::Evaluation); - mResultTypes.insert("register-names",GDBMIResultType::RegisterNames); - mResultTypes.insert("register-values",GDBMIResultType::RegisterValues); - mResultTypes.insert("memory",GDBMIResultType::Memory); + mResultTypes.insert("-break-insert",GDBMIResultType::Breakpoint); + //mResultTypes.insert("BreakpointTable",GDBMIResultType::BreakpointTable); + mResultTypes.insert("-stack-list-frames",GDBMIResultType::FrameStack); + mResultTypes.insert("-stack-list-variables", GDBMIResultType::LocalVariables); + //mResultTypes.insert("frame",GDBMIResultType::Frame); + mResultTypes.insert("-data-disassemble",GDBMIResultType::Disassembly); + mResultTypes.insert("-data-evaluate-expression",GDBMIResultType::Evaluation); +// mResultTypes.insert("register-names",GDBMIResultType::RegisterNames); +// mResultTypes.insert("register-values",GDBMIResultType::RegisterValues); + mResultTypes.insert("-data-read-memory",GDBMIResultType::Memory); } -bool GDBMIResultParser::parse(const QByteArray &record, GDBMIResultType &type, ParseValue& value) +bool GDBMIResultParser::parse(const QByteArray &record, const QString& command, GDBMIResultType &type, ParseObject& multiValues) { const char* p = record.data(); - QByteArray name; - bool result = parseNameAndValue(p,name,value); + bool result = parseMultiValues(p,multiValues); if (!result) return false; // if (*p!=0) // return false; - if (!mResultTypes.contains(name)) + if (!mResultTypes.contains(command)) return false; - type = mResultTypes[name]; + type = mResultTypes[command]; return true; } diff --git a/RedPandaIDE/gdbmiresultparser.h b/RedPandaIDE/gdbmiresultparser.h index 13e0977c..f057ef2a 100644 --- a/RedPandaIDE/gdbmiresultparser.h +++ b/RedPandaIDE/gdbmiresultparser.h @@ -76,7 +76,7 @@ public: public: GDBMIResultParser(); - bool parse(const QByteArray& record, GDBMIResultType& type, ParseValue& value); + bool parse(const QByteArray& record, const QString& command, GDBMIResultType& type, ParseObject& multiValues); bool parseAsyncResult(const QByteArray& record, QByteArray& result, ParseObject& multiValue); private: bool parseMultiValues(const char*p, ParseObject& multiValue); @@ -89,7 +89,7 @@ private: bool isNameChar(char ch); bool isSpaceChar(char ch); private: - QHash mResultTypes; + QHash mResultTypes; }; #endif // GDBMIRESULTPARSER_H diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index bdb1e3a8..51bc48d8 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1410,9 +1410,6 @@ void MainWindow::debug() updateEditorActions(); return; } - mDebugger->sendCommand("-gdb-set","mi-async on"); - mDebugger->sendCommand("-gdb-set","target-async on"); - mDebugger->sendCommand("-gdb-show", "mi-async"); updateEditorActions(); @@ -4069,7 +4066,7 @@ void MainWindow::onDebugEvaluateInput() if (!s.isEmpty()) { connect(mDebugger, &Debugger::evalValueReady, this, &MainWindow::onEvalValueReady); - mDebugger->sendCommand("print",s); + mDebugger->sendCommand("-data-evaluate-expression",s); } } @@ -4079,7 +4076,7 @@ void MainWindow::onDebugMemoryAddressInput() if (!s.isEmpty()) { connect(mDebugger, &Debugger::memoryExamineReady, this, &MainWindow::onMemoryExamineReady); - mDebugger->sendCommand("-data-read-memory/64bx",s); + mDebugger->sendCommand("-data-read-memory",QString("%1 x 1 8 8 ").arg(s)); } } @@ -5734,7 +5731,6 @@ void MainWindow::on_actionDelete_to_EOL_triggered() } } - void MainWindow::on_actionDelete_to_BOL_triggered() { Editor *e=mEditorList->getEditor(); @@ -5742,12 +5738,3 @@ void MainWindow::on_actionDelete_to_BOL_triggered() e->deleteToBOL(); } } - - -void MainWindow::on_actionPause_triggered() -{ - if (mDebugger->executing()) { - mDebugger->sendCommand("-exec-interrupt","-a"); - } -} - diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index c6ad3f67..39550f94 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -528,8 +528,6 @@ private slots: void on_actionDelete_to_BOL_triggered(); - void on_actionPause_triggered(); - private: Ui::MainWindow *ui; EditorList *mEditorList; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 987029a3..d45c3e17 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -1424,7 +1424,6 @@ - @@ -1643,7 +1642,6 @@ - @@ -2651,18 +2649,6 @@ Ctrl+Backspace - - - - :/icons/images/newlook24/093-pause.png:/icons/images/newlook24/093-pause.png - - - Pause - - - F3 - - diff --git a/RedPandaIDE/widgets/cpudialog.cpp b/RedPandaIDE/widgets/cpudialog.cpp index 75d8ff4d..2e1610ba 100644 --- a/RedPandaIDE/widgets/cpudialog.cpp +++ b/RedPandaIDE/widgets/cpudialog.cpp @@ -87,9 +87,9 @@ void CPUDialog::sendSyntaxCommand() { // Set disassembly flavor if (ui->rdIntel->isChecked()) { - pMainWindow->debugger()->sendCommand("set disassembly-flavor", "intel"); + pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor intel"); } else { - pMainWindow->debugger()->sendCommand("set disassembly-flavor", "att"); + pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor att"); } }