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

View File

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