From 3f474a9db4f95677fa74eab0471eb989e311f020 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Sat, 20 Nov 2021 07:53:39 +0800 Subject: [PATCH] work save --- RedPandaIDE/debugger.cpp | 27 +++++++++++++++++++-------- RedPandaIDE/debugger.h | 7 ++++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 58816a66..a873db04 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -12,10 +12,6 @@ #include #include #include -#include -#include -#include -#include 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(); + 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) { diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index 0b0a122b..50259460 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -13,6 +13,8 @@ #include #include #include +#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;