From fe8d3e96634ba7c220435badec4e3d260952117c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 27 Dec 2021 21:32:30 +0800 Subject: [PATCH] - fix: compile error in linux - fix: can't receive gdb async output for commands --- NEWS.md | 4 ++++ RedPandaIDE/debugger.cpp | 26 +++++++++++++++++--------- RedPandaIDE/debugger.h | 5 +++-- RedPandaIDE/settings.cpp | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index fa4da537..5212ff5d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +Version 0.12.5 For Dev-C++ 7 Beta + - fix: compile error in linux + - fix: can't receive gdb async output for commands + Version 0.12.4 For Dev-C++ 7 Beta - change: add copyright infos to each source file - fix: watch and local infos not updated when changing current frame in the call stack panel diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index a91ccd82..30c26f0f 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -246,8 +246,6 @@ bool Debugger::inferiorRunning() void Debugger::interrupt() { sendCommand("-exec-interrupt", ""); - QTimer::singleShot(1000,this, &Debugger::interruptRefresh); - } void Debugger::addBreakpoint(int line, const Editor* editor) @@ -408,11 +406,6 @@ void Debugger::fetchVarChildren(const QString &varName) } } -void Debugger::interruptRefresh() -{ - sendCommand("noop",""); -} - void Debugger::removeWatchVars(bool deleteparent) { if (deleteparent) { @@ -617,6 +610,7 @@ DebugReader::DebugReader(Debugger* debugger, QObject *parent) : QThread(parent), mDebugger = debugger; mProcess = std::make_shared(); mCmdRunning = false; + mAsyncUpdated = false; } void DebugReader::postCommand(const QString &Command, const QString &Params, @@ -936,12 +930,18 @@ void DebugReader::runNextCmd() { QMutexLocker locker(&mCmdQueueMutex); + PDebugCommand lastCmd = mCurrentCmd; if (mCurrentCmd) { - mCurrentCmd.reset(); + mCurrentCmd=nullptr; emit cmdFinished(); } - if (mCmdQueue.isEmpty()) + if (mCmdQueue.isEmpty()) { + if (pSettings->debugger().useGDBServer() && mInferiorRunning && !mAsyncUpdated) { + mAsyncUpdated = true; + QTimer::singleShot(1000,this,&DebugReader::asyncUpdate); + } return; + } PDebugCommand pCmd = mCmdQueue.dequeue(); mCmdRunning = true; @@ -1237,6 +1237,14 @@ QByteArray DebugReader::removeToken(const QByteArray &line) return line; } +void DebugReader::asyncUpdate() +{ + QMutexLocker locker(&mCmdQueueMutex); + if (mCmdQueue.isEmpty()) + postCommand("noop","",DebugCommandSource::Other); + mAsyncUpdated = false; +} + const QString &DebugReader::signalMeaning() const { return mSignalMeaning; diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index df43b4d6..18e6080c 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -275,7 +275,6 @@ private slots: void updateRegisterValues(const QHash& values); void refreshWatchVars(); void fetchVarChildren(const QString& varName); - void interruptRefresh(); private: bool mExecuting; bool mCommandChanged; @@ -424,6 +423,8 @@ private: void processDebugOutput(const QByteArray& debugOutput); void runInferiorStoppedHook(); QByteArray removeToken(const QByteArray& line); +private slots: + void asyncUpdate(); private: Debugger *mDebugger; QString mDebuggerPath; @@ -431,7 +432,7 @@ private: QSemaphore mStartSemaphore; QQueue mCmdQueue; bool mErrorOccured; - + bool mAsyncUpdated; //fOnInvalidateAllVars: TInvalidateAllVarsEvent; bool mCmdRunning; PDebugCommand mCurrentCmd; diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 587a4318..27abeb49 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -178,7 +178,7 @@ QString Settings::Dirs::appLibDir() const return appDir(); #elif defined(Q_OS_LINUX) if (isGreenEdition()) { - return app(); + return appDir(); } return includeTrailingPathDelimiter(PREFIX)+"lib"; #endif