work save

This commit is contained in:
royqh1979@gmail.com 2021-11-20 07:53:39 +08:00
parent e044bb0703
commit 3f474a9db4
2 changed files with 25 additions and 9 deletions

View File

@ -12,10 +12,6 @@
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonDocument>
Debugger::Debugger(QObject *parent) : QObject(parent) Debugger::Debugger(QObject *parent) : QObject(parent)
{ {
@ -150,6 +146,7 @@ void Debugger::addBreakpoint(int line, const Editor* editor)
void Debugger::addBreakpoint(int line, const QString &filename) void Debugger::addBreakpoint(int line, const QString &filename)
{ {
PBreakpoint bp=std::make_shared<Breakpoint>(); PBreakpoint bp=std::make_shared<Breakpoint>();
bp->number = -1;
bp->line = line; bp->line = line;
bp->filename = filename; bp->filename = filename;
bp->condition = ""; bp->condition = "";
@ -422,13 +419,12 @@ void Debugger::sendClearBreakpointCommand(int index)
void Debugger::sendClearBreakpointCommand(PBreakpoint breakpoint) void Debugger::sendClearBreakpointCommand(PBreakpoint breakpoint)
{ {
// Debugger already running? Remove it from GDB // Debugger already running? Remove it from GDB
if (breakpoint && mExecuting) { if (breakpoint && breakpoint->number>=0 && mExecuting) {
//clear "filename":linenum //clear "filename":linenum
QString filename = breakpoint->filename; QString filename = breakpoint->filename;
filename.replace('\\','/'); filename.replace('\\','/');
sendCommand("clear", sendCommand("-break-delete",
QString("\"%1\":%2").arg(filename) QString("%1").arg(breakpoint->number));
.arg(breakpoint->line));
} }
} }
@ -1162,6 +1158,18 @@ void DebugReader::processConsoleOutput(const QByteArray& line)
void DebugReader::processResult(const QByteArray &result) void DebugReader::processResult(const QByteArray &result)
{ {
int pos = result.indexOf('='); int pos = result.indexOf('=');
GDBMIResultParser parser;
GDBMIResultType resultType;
GDBMIResultParser::ParseValue parseValue;
bool parseOk = parser.parse(result,resultType,parseValue);
if (!parseOk)
return;
switch(resultType) {
case GDBMIResultType::Breakpoint:
handleBreakpoint(parseValue.object());
return;
}
QByteArray name = result.mid(0,pos); QByteArray name = result.mid(0,pos);
QByteArray value = result.mid(pos+1); QByteArray value = result.mid(pos+1);
if (name == "bkpt") { if (name == "bkpt") {
@ -1711,6 +1719,9 @@ void DebugReader::handleBreakpoint(const QByteArray &breakpointRecord)
//because QJsonDocument only handle utf8-encoded json strings //because QJsonDocument only handle utf8-encoded json strings
QString temp = QString::fromLocal8Bit(breakpointRecord); QString temp = QString::fromLocal8Bit(breakpointRecord);
QByteArray record = temp.toUtf8(); QByteArray record = temp.toUtf8();
GDBMIResultParser parser;
GDBMIR
parser.parse(breakpointRecord,)
QJsonParseError error; QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(record,&error); QJsonDocument doc = QJsonDocument::fromJson(record,&error);
if (error.error!=QJsonParseError::NoError) { if (error.error!=QJsonParseError::NoError) {

View File

@ -13,6 +13,8 @@
#include <QSemaphore> #include <QSemaphore>
#include <QThread> #include <QThread>
#include <memory> #include <memory>
#include "gdbmiresultparser.h"
enum class DebugCommandSource { enum class DebugCommandSource {
Console, Console,
Other Other
@ -188,6 +190,8 @@ public:
PBreakpoint breakpointAt(int line, const Editor* editor, int &index); PBreakpoint breakpointAt(int line, const Editor* editor, int &index);
void setBreakPointCondition(int index, const QString& condition); void setBreakPointCondition(int index, const QString& condition);
void sendAllBreakpointsToDebugger(); void sendAllBreakpointsToDebugger();
void validateBreakpoint(int line, const QString& filename, int number);
void invalidateAllBreakpoints();
//watch vars //watch vars
void addWatchVar(const QString& namein); void addWatchVar(const QString& namein);
@ -310,7 +314,7 @@ private:
void runNextCmd(); void runNextCmd();
QStringList tokenize(const QString& s); QStringList tokenize(const QString& s);
void handleBreakpoint(const QByteArray& breakpointRecord); void handleBreakpoint(const GDBMIResultParser::ParseObject& breakpoint);
void processConsoleOutput(const QByteArray& line); void processConsoleOutput(const QByteArray& line);
void processResult(const QByteArray& result); void processResult(const QByteArray& result);
void processExecAsyncRecord(const QByteArray& line); void processExecAsyncRecord(const QByteArray& line);
@ -357,6 +361,7 @@ private:
bool doupdatememoryview; bool doupdatememoryview;
bool doupdatelocal; bool doupdatelocal;
//
bool mInferiorPaused; bool mInferiorPaused;
bool mProcessExited; bool mProcessExited;
QStringList mConsoleOutput; QStringList mConsoleOutput;