breakpoint / run / evaluation / memory view ok

This commit is contained in:
Roy Qu 2021-11-24 22:16:40 +08:00
parent 5c17096e00
commit de0f176284
8 changed files with 35 additions and 66 deletions

View File

@ -623,8 +623,10 @@ void DebugReader::processResult(const QByteArray &result)
{ {
GDBMIResultParser parser; GDBMIResultParser parser;
GDBMIResultType resultType; GDBMIResultType resultType;
GDBMIResultParser::ParseValue parseValue; GDBMIResultParser::ParseObject multiValues;
bool parseOk = parser.parse(result,resultType,parseValue); if (!mCurrentCmd)
return;
bool parseOk = parser.parse(result, mCurrentCmd->command, resultType,multiValues);
if (!parseOk) if (!parseOk)
return; return;
switch(resultType) { switch(resultType) {
@ -633,16 +635,19 @@ void DebugReader::processResult(const QByteArray &result)
case GDBMIResultType::Locals: case GDBMIResultType::Locals:
break; break;
case GDBMIResultType::Breakpoint: case GDBMIResultType::Breakpoint:
handleBreakpoint(parseValue.object()); handleBreakpoint(multiValues["bkpt"].object());
return; return;
case GDBMIResultType::FrameStack: case GDBMIResultType::FrameStack:
handleStack(parseValue.array()); handleStack(multiValues["stack"].array());
return; return;
case GDBMIResultType::LocalVariables: case GDBMIResultType::LocalVariables:
handleLocalVariables(parseValue.array()); handleLocalVariables(multiValues["variables"].array());
return; return;
case GDBMIResultType::Evaluation: case GDBMIResultType::Evaluation:
handleEvaluation(parseValue.value()); handleEvaluation(multiValues["value"].value());
return;
case GDBMIResultType::Memory:
handleMemory(multiValues["memory"].array());
return; return;
} }
@ -1005,9 +1010,9 @@ void DebugReader::runNextCmd()
if (pSettings->debugger().showCommandLog() ) { if (pSettings->debugger().showCommandLog() ) {
//update debug console //update debug console
if (!pSettings->debugger().showAnnotations()) { if (!pSettings->debugger().showAnnotations()) {
emit changeDebugConsoleLastLine("(gdb)"+pCmd->command + ' ' + pCmd->params); emit changeDebugConsoleLastLine(pCmd->command + ' ' + pCmd->params);
} else { } 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) void DebugReader::handleBreakpoint(const GDBMIResultParser::ParseObject& breakpoint)
{ {
// gdb use system encoding for file path // gdb use system encoding for file path
QString filename = breakpoint["fullname"].value(); QString filename = breakpoint["fullname"].pathValue();
int line = breakpoint["line"].intValue(); int line = breakpoint["line"].intValue();
int number = breakpoint["number"].intValue(); int number = breakpoint["number"].intValue();
emit breakpointInfoGetted(filename, line , number); emit breakpointInfoGetted(filename, line , number);
@ -1322,10 +1327,6 @@ void DebugReader::run()
readed = mProcess->readAll(); readed = mProcess->readAll();
buffer += readed; buffer += readed;
if (!readed.isEmpty()) {
qDebug()<<"*******";
qDebug()<<readed;
}
if (readed.endsWith("\n")&& outputTerminated(buffer)) { if (readed.endsWith("\n")&& outputTerminated(buffer)) {
processDebugOutput(buffer); processDebugOutput(buffer);
buffer.clear(); buffer.clear();
@ -1342,8 +1343,6 @@ void DebugReader::run()
} }
} }
BreakpointModel::BreakpointModel(QObject *parent):QAbstractTableModel(parent) BreakpointModel::BreakpointModel(QObject *parent):QAbstractTableModel(parent)
{ {

View File

@ -2826,7 +2826,7 @@ void Editor::showDebugHint(const QString &s, int line)
connect(pMainWindow->debugger(), &Debugger::evalValueReady, connect(pMainWindow->debugger(), &Debugger::evalValueReady,
this, &Editor::onTipEvalValueReady); this, &Editor::onTipEvalValueReady);
mCurrentDebugTipWord = s; mCurrentDebugTipWord = s;
pMainWindow->debugger()->sendCommand("print",s); pMainWindow->debugger()->sendCommand("-data-evaluate-expression",s);
} }
QString Editor::getErrorHint(const PSyntaxIssue& issue) QString Editor::getErrorHint(const PSyntaxIssue& issue)

View File

@ -6,30 +6,29 @@
GDBMIResultParser::GDBMIResultParser() GDBMIResultParser::GDBMIResultParser()
{ {
mResultTypes.insert("bkpt",GDBMIResultType::Breakpoint); mResultTypes.insert("-break-insert",GDBMIResultType::Breakpoint);
mResultTypes.insert("BreakpointTable",GDBMIResultType::BreakpointTable); //mResultTypes.insert("BreakpointTable",GDBMIResultType::BreakpointTable);
mResultTypes.insert("stack",GDBMIResultType::FrameStack); mResultTypes.insert("-stack-list-frames",GDBMIResultType::FrameStack);
mResultTypes.insert("variables", GDBMIResultType::LocalVariables); mResultTypes.insert("-stack-list-variables", GDBMIResultType::LocalVariables);
mResultTypes.insert("frame",GDBMIResultType::Frame); //mResultTypes.insert("frame",GDBMIResultType::Frame);
mResultTypes.insert("asm_insns",GDBMIResultType::Disassembly); mResultTypes.insert("-data-disassemble",GDBMIResultType::Disassembly);
mResultTypes.insert("value",GDBMIResultType::Evaluation); mResultTypes.insert("-data-evaluate-expression",GDBMIResultType::Evaluation);
mResultTypes.insert("register-names",GDBMIResultType::RegisterNames); // mResultTypes.insert("register-names",GDBMIResultType::RegisterNames);
mResultTypes.insert("register-values",GDBMIResultType::RegisterValues); // mResultTypes.insert("register-values",GDBMIResultType::RegisterValues);
mResultTypes.insert("memory",GDBMIResultType::Memory); 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(); const char* p = record.data();
QByteArray name; bool result = parseMultiValues(p,multiValues);
bool result = parseNameAndValue(p,name,value);
if (!result) if (!result)
return false; return false;
// if (*p!=0) // if (*p!=0)
// return false; // return false;
if (!mResultTypes.contains(name)) if (!mResultTypes.contains(command))
return false; return false;
type = mResultTypes[name]; type = mResultTypes[command];
return true; return true;
} }

View File

@ -76,7 +76,7 @@ public:
public: public:
GDBMIResultParser(); 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); bool parseAsyncResult(const QByteArray& record, QByteArray& result, ParseObject& multiValue);
private: private:
bool parseMultiValues(const char*p, ParseObject& multiValue); bool parseMultiValues(const char*p, ParseObject& multiValue);
@ -89,7 +89,7 @@ private:
bool isNameChar(char ch); bool isNameChar(char ch);
bool isSpaceChar(char ch); bool isSpaceChar(char ch);
private: private:
QHash<QByteArray, GDBMIResultType> mResultTypes; QHash<QString, GDBMIResultType> mResultTypes;
}; };
#endif // GDBMIRESULTPARSER_H #endif // GDBMIRESULTPARSER_H

View File

@ -1410,9 +1410,6 @@ void MainWindow::debug()
updateEditorActions(); updateEditorActions();
return; return;
} }
mDebugger->sendCommand("-gdb-set","mi-async on");
mDebugger->sendCommand("-gdb-set","target-async on");
mDebugger->sendCommand("-gdb-show", "mi-async");
updateEditorActions(); updateEditorActions();
@ -4069,7 +4066,7 @@ void MainWindow::onDebugEvaluateInput()
if (!s.isEmpty()) { if (!s.isEmpty()) {
connect(mDebugger, &Debugger::evalValueReady, connect(mDebugger, &Debugger::evalValueReady,
this, &MainWindow::onEvalValueReady); this, &MainWindow::onEvalValueReady);
mDebugger->sendCommand("print",s); mDebugger->sendCommand("-data-evaluate-expression",s);
} }
} }
@ -4079,7 +4076,7 @@ void MainWindow::onDebugMemoryAddressInput()
if (!s.isEmpty()) { if (!s.isEmpty()) {
connect(mDebugger, &Debugger::memoryExamineReady, connect(mDebugger, &Debugger::memoryExamineReady,
this, &MainWindow::onMemoryExamineReady); 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() void MainWindow::on_actionDelete_to_BOL_triggered()
{ {
Editor *e=mEditorList->getEditor(); Editor *e=mEditorList->getEditor();
@ -5742,12 +5738,3 @@ void MainWindow::on_actionDelete_to_BOL_triggered()
e->deleteToBOL(); e->deleteToBOL();
} }
} }
void MainWindow::on_actionPause_triggered()
{
if (mDebugger->executing()) {
mDebugger->sendCommand("-exec-interrupt","-a");
}
}

View File

@ -528,8 +528,6 @@ private slots:
void on_actionDelete_to_BOL_triggered(); void on_actionDelete_to_BOL_triggered();
void on_actionPause_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
EditorList *mEditorList; EditorList *mEditorList;

View File

@ -1424,7 +1424,6 @@
<addaction name="actionStep_Over"/> <addaction name="actionStep_Over"/>
<addaction name="actionStep_Into"/> <addaction name="actionStep_Into"/>
<addaction name="actionRun_To_Cursor"/> <addaction name="actionRun_To_Cursor"/>
<addaction name="actionPause"/>
<addaction name="actionContinue"/> <addaction name="actionContinue"/>
<addaction name="actionStop_Execution"/> <addaction name="actionStop_Execution"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -1643,7 +1642,6 @@
<addaction name="actionStep_Over"/> <addaction name="actionStep_Over"/>
<addaction name="actionStep_Into"/> <addaction name="actionStep_Into"/>
<addaction name="actionStep_Out"/> <addaction name="actionStep_Out"/>
<addaction name="actionPause"/>
<addaction name="actionContinue"/> <addaction name="actionContinue"/>
<addaction name="actionStop_Execution"/> <addaction name="actionStop_Execution"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -2651,18 +2649,6 @@
<string>Ctrl+Backspace</string> <string>Ctrl+Backspace</string>
</property> </property>
</action> </action>
<action name="actionPause">
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/images/newlook24/093-pause.png</normaloff>:/icons/images/newlook24/093-pause.png</iconset>
</property>
<property name="text">
<string>Pause</string>
</property>
<property name="shortcut">
<string>F3</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -87,9 +87,9 @@ void CPUDialog::sendSyntaxCommand()
{ {
// Set disassembly flavor // Set disassembly flavor
if (ui->rdIntel->isChecked()) { if (ui->rdIntel->isChecked()) {
pMainWindow->debugger()->sendCommand("set disassembly-flavor", "intel"); pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor intel");
} else { } else {
pMainWindow->debugger()->sendCommand("set disassembly-flavor", "att"); pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor att");
} }
} }