work save

This commit is contained in:
Roy Qu 2021-11-24 21:22:01 +08:00
parent b17406eb07
commit 5c17096e00
8 changed files with 89 additions and 47 deletions

View File

@ -65,6 +65,7 @@ bool Debugger::start()
connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline); connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline);
connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions); connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions);
connect(mReader, &DebugReader::cmdFinished,pMainWindow, &MainWindow::enableDebugActions); connect(mReader, &DebugReader::cmdFinished,pMainWindow, &MainWindow::enableDebugActions);
connect(mReader, &DebugReader::inferiorStopped, pMainWindow, &MainWindow::enableDebugActions);
connect(mReader, &DebugReader::breakpointInfoGetted, mBreakpointModel, connect(mReader, &DebugReader::breakpointInfoGetted, mBreakpointModel,
&BreakpointModel::updateBreakpointNumber); &BreakpointModel::updateBreakpointNumber);
@ -76,9 +77,13 @@ 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::inferiorContinued,pMainWindow,
&MainWindow::removeActiveBreakpoints);
connect(mReader, &DebugReader::inferiorStopped,pMainWindow, connect(mReader, &DebugReader::inferiorStopped,pMainWindow,
&MainWindow::setActiveBreakpoint); &MainWindow::setActiveBreakpoint);
mReader->registerInferiorStoppedCommand("-stack-list-frames","");
mReader->registerInferiorStoppedCommand("-stack-list-variables", "--all-values");
mReader->start(); mReader->start();
mReader->waitStart(); mReader->waitStart();
@ -153,6 +158,14 @@ bool Debugger::commandRunning()
return false; return false;
} }
bool Debugger::inferiorRunning()
{
if (mExecuting && mReader) {
return mReader->inferiorRunning();
}
return false;
}
void Debugger::addBreakpoint(int line, const Editor* editor) void Debugger::addBreakpoint(int line, const Editor* editor)
{ {
addBreakpoint(line,editor->filename()); addBreakpoint(line,editor->filename());
@ -373,12 +386,6 @@ void Debugger::notifyAfterProcessWatchVar()
mWatchModel->endUpdate(); mWatchModel->endUpdate();
} }
void Debugger::updateDebugInfo()
{
sendCommand("-stack-list-frames", "");
sendCommand("-stack-list-variables", "--skip-unavailable --allvalues");
}
bool Debugger::useUTF8() const bool Debugger::useUTF8() const
{ {
return mUseUTF8; return mUseUTF8;
@ -461,11 +468,7 @@ void Debugger::syncFinishedParsing()
} }
} }
// The program to debug has stopped. Stop the debugger
if (mReader->processExited()) {
stop();
return;
}
// show command output // show command output
if (pSettings->debugger().showCommandLog() ) { if (pSettings->debugger().showCommandLog() ) {
@ -480,6 +483,12 @@ void Debugger::syncFinishedParsing()
} }
} }
// The program to debug has stopped. Stop the debugger
if (mReader->processExited()) {
stop();
return;
}
// Some part of the CPU form has been updated // Some part of the CPU form has been updated
if (pMainWindow->cpuDialog()!=nullptr && !mReader->signalReceived()) { if (pMainWindow->cpuDialog()!=nullptr && !mReader->signalReceived()) {
// if (mReader->doregistersready) { // if (mReader->doregistersready) {
@ -646,7 +655,6 @@ void DebugReader::processExecAsyncRecord(const QByteArray &line)
GDBMIResultParser parser; GDBMIResultParser parser;
if (!parser.parseAsyncResult(line,result,multiValues)) if (!parser.parseAsyncResult(line,result,multiValues))
return; return;
qDebug()<<result<<line;
if (result == "running") { if (result == "running") {
mInferiorRunning = true; mInferiorRunning = true;
mCurrentAddress=0; mCurrentAddress=0;
@ -682,7 +690,6 @@ void DebugReader::processExecAsyncRecord(const QByteArray &line)
mCurrentLine = frameObj["line"].intValue(); mCurrentLine = frameObj["line"].intValue();
mCurrentFile = frameObj["fullname"].pathValue(); mCurrentFile = frameObj["fullname"].pathValue();
} }
qDebug()<<mCurrentFile<<mCurrentLine;
if (reason == "signal-received") { if (reason == "signal-received") {
mSignalReceived = true; mSignalReceived = true;
} }
@ -773,6 +780,8 @@ void DebugReader::processDebugOutput(const QByteArray& debugOutput)
} }
emit parseFinished(); emit parseFinished();
mConsoleOutput.clear();
mFullOutput.clear();
} }
void DebugReader::runInferiorStoppedHook() void DebugReader::runInferiorStoppedHook()
@ -1126,7 +1135,7 @@ void DebugReader::handleStack(const QList<GDBMIResultParser::ParseValue> & stack
PTrace trace = std::make_shared<Trace>(); PTrace trace = std::make_shared<Trace>();
trace->funcname = frameObject["func"].value(); trace->funcname = frameObject["func"].value();
trace->filename = frameObject["fullname"].pathValue(); trace->filename = frameObject["fullname"].pathValue();
trace->line = frameObject["fullname"].intValue(); trace->line = frameObject["line"].intValue();
trace->level = frameObject["level"].intValue(0); trace->level = frameObject["level"].intValue(0);
trace->address = frameObject["addr"].value(); trace->address = frameObject["addr"].value();
mDebugger->backtraceModel()->addTrace(trace); mDebugger->backtraceModel()->addTrace(trace);
@ -1180,6 +1189,11 @@ QByteArray DebugReader::removeToken(const QByteArray &line)
return line; return line;
} }
bool DebugReader::inferiorRunning() const
{
return mInferiorRunning;
}
const QStringList &DebugReader::fullOutput() const const QStringList &DebugReader::fullOutput() const
{ {
return mFullOutput; return mFullOutput;
@ -1308,7 +1322,11 @@ void DebugReader::run()
readed = mProcess->readAll(); readed = mProcess->readAll();
buffer += readed; buffer += readed;
if ( readed.endsWith("\n")&& outputTerminated(buffer)) { if (!readed.isEmpty()) {
qDebug()<<"*******";
qDebug()<<readed;
}
if (readed.endsWith("\n")&& outputTerminated(buffer)) {
processDebugOutput(buffer); processDebugOutput(buffer);
buffer.clear(); buffer.clear();
mCmdRunning = false; mCmdRunning = false;
@ -1316,7 +1334,7 @@ void DebugReader::run()
} else if (!mCmdRunning && readed.isEmpty()){ } else if (!mCmdRunning && readed.isEmpty()){
runNextCmd(); runNextCmd();
} else if (readed.isEmpty()){ } else if (readed.isEmpty()){
msleep(1); msleep(100);
} }
} }
if (errorOccurred) { if (errorOccurred) {

View File

@ -176,6 +176,7 @@ public:
void sendCommand(const QString& command, const QString& params, void sendCommand(const QString& command, const QString& params,
DebugCommandSource source = DebugCommandSource::Other); DebugCommandSource source = DebugCommandSource::Other);
bool commandRunning(); bool commandRunning();
bool inferiorRunning();
//breakpoints //breakpoints
void addBreakpoint(int line, const Editor* editor); void addBreakpoint(int line, const Editor* editor);
@ -210,9 +211,6 @@ public:
void notifyBeforeProcessWatchVar(); void notifyBeforeProcessWatchVar();
void notifyAfterProcessWatchVar(); void notifyAfterProcessWatchVar();
void updateDebugInfo();
bool useUTF8() const; bool useUTF8() const;
void setUseUTF8(bool useUTF8); void setUseUTF8(bool useUTF8);
@ -307,6 +305,8 @@ public:
const QStringList &fullOutput() const; const QStringList &fullOutput() const;
bool inferiorRunning() const;
signals: signals:
void parseStarted(); void parseStarted();
void invalidateAllVars(); void invalidateAllVars();
@ -366,16 +366,6 @@ private:
QString mSignal; QString mSignal;
bool mUseUTF8; bool mUseUTF8;
// attempt to cut down on Synchronize calls
bool dodisassemblerready;
bool doregistersready;
bool doevalready;
bool doupdatecpuwindow;
bool doupdateexecution;
bool doreceivedsignal;
bool doreceivedsfwarning;
bool doupdatememoryview;
// //
QList<PDebugCommand> mInferiorStoppedHookCommands; QList<PDebugCommand> mInferiorStoppedHookCommands;
bool mInferiorRunning; bool mInferiorRunning;

View File

@ -51,8 +51,6 @@ bool GDBMIResultParser::parseAsyncResult(const QByteArray &record, QByteArray &r
bool GDBMIResultParser::parseMultiValues(const char* p, ParseObject &multiValue) bool GDBMIResultParser::parseMultiValues(const char* p, ParseObject &multiValue)
{ {
qDebug()<<"-------";
qDebug()<<QByteArray(p);
while (*p) { while (*p) {
QByteArray propName; QByteArray propName;
ParseValue propValue; ParseValue propValue;
@ -223,7 +221,6 @@ bool GDBMIResultParser::parseObject(const char *&p, ParseObject &obj)
QByteArray propName; QByteArray propName;
ParseValue propValue; ParseValue propValue;
bool result = parseNameAndValue(p,propName,propValue); bool result = parseNameAndValue(p,propName,propValue);
qDebug()<<result<<propName<<QByteArray(p);
if (result) { if (result) {
obj[propName]=propValue; obj[propName]=propValue;
} else { } else {
@ -254,14 +251,25 @@ bool GDBMIResultParser::parseArray(const char *&p, QList<GDBMIResultParser::Pars
if (*p!=']') { if (*p!=']') {
while (*p!=0) { while (*p!=0) {
skipSpaces(p); skipSpaces(p);
ParseValue val; if (*p=='{' || *p=='"' || *p=='[') {
bool result = parseValue(p,val); ParseValue val;
if (result) { bool result = parseValue(p,val);
array.append(val); if (result) {
array.append(val);
} else {
return false;
}
} else { } else {
return false; QByteArray name;
ParseValue val;
bool result = parseNameAndValue(p,name,val);
if (result) {
array.append(val);
} else {
return false;
}
} }
skipSpaces(p); skipSpaces(p);
if (*p==']') if (*p==']')
break; break;
if (*p!=',') if (*p!=',')

View File

@ -489,5 +489,6 @@
<file>images/editor/bookmark.png</file> <file>images/editor/bookmark.png</file>
<file>images/newlook24/091-openproblemanswer.png</file> <file>images/newlook24/091-openproblemanswer.png</file>
<file>images/newlook24/092-runallproblemcases.png</file> <file>images/newlook24/092-runallproblemcases.png</file>
<file>images/newlook24/093-pause.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1410,6 +1410,9 @@ 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();
@ -3013,13 +3016,13 @@ void MainWindow::disableDebugActions()
void MainWindow::enableDebugActions() void MainWindow::enableDebugActions()
{ {
ui->actionStep_Into->setEnabled(true); ui->actionStep_Into->setEnabled(!mDebugger->inferiorRunning());
ui->actionStep_Over->setEnabled(true); ui->actionStep_Over->setEnabled(!mDebugger->inferiorRunning());
ui->actionStep_Out->setEnabled(true); ui->actionStep_Out->setEnabled(!mDebugger->inferiorRunning());
ui->actionRun_To_Cursor->setEnabled(true); ui->actionRun_To_Cursor->setEnabled(!mDebugger->inferiorRunning());
ui->actionContinue->setEnabled(true); ui->actionContinue->setEnabled(!mDebugger->inferiorRunning());
ui->cbEvaluate->setEnabled(true); ui->cbEvaluate->setEnabled(!mDebugger->inferiorRunning());
ui->cbMemoryAddress->setEnabled(true); ui->cbMemoryAddress->setEnabled(!mDebugger->inferiorRunning());
} }
void MainWindow::onTodoParseStarted(const QString&) void MainWindow::onTodoParseStarted(const QString&)
@ -4018,8 +4021,6 @@ void MainWindow::on_actionContinue_triggered()
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->invalidateAllVars(); mDebugger->invalidateAllVars();
mDebugger->sendCommand("-exec-continue", ""); mDebugger->sendCommand("-exec-continue", "");
mDebugger->updateDebugInfo();
mDebugger->refreshWatchVars();
} }
} }
@ -5742,3 +5743,11 @@ void MainWindow::on_actionDelete_to_BOL_triggered()
} }
} }
void MainWindow::on_actionPause_triggered()
{
if (mDebugger->executing()) {
mDebugger->sendCommand("-exec-interrupt","-a");
}
}

View File

@ -528,6 +528,8 @@ 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,6 +1424,7 @@
<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"/>
@ -1642,6 +1643,7 @@
<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"/>
@ -2649,6 +2651,18 @@
<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>