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;
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()<<readed;
}
if (readed.endsWith("\n")&& outputTerminated(buffer)) {
processDebugOutput(buffer);
buffer.clear();
@ -1342,8 +1343,6 @@ void DebugReader::run()
}
}
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,
this, &Editor::onTipEvalValueReady);
mCurrentDebugTipWord = s;
pMainWindow->debugger()->sendCommand("print",s);
pMainWindow->debugger()->sendCommand("-data-evaluate-expression",s);
}
QString Editor::getErrorHint(const PSyntaxIssue& issue)

View File

@ -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;
}

View File

@ -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<QByteArray, GDBMIResultType> mResultTypes;
QHash<QString, GDBMIResultType> mResultTypes;
};
#endif // GDBMIRESULTPARSER_H

View File

@ -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");
}
}

View File

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

View File

@ -1424,7 +1424,6 @@
<addaction name="actionStep_Over"/>
<addaction name="actionStep_Into"/>
<addaction name="actionRun_To_Cursor"/>
<addaction name="actionPause"/>
<addaction name="actionContinue"/>
<addaction name="actionStop_Execution"/>
<addaction name="separator"/>
@ -1643,7 +1642,6 @@
<addaction name="actionStep_Over"/>
<addaction name="actionStep_Into"/>
<addaction name="actionStep_Out"/>
<addaction name="actionPause"/>
<addaction name="actionContinue"/>
<addaction name="actionStop_Execution"/>
<addaction name="separator"/>
@ -2651,18 +2649,6 @@
<string>Ctrl+Backspace</string>
</property>
</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>
<customwidgets>
<customwidget>

View File

@ -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");
}
}