diff --git a/NEWS.md b/NEWS.md index 06bc38c4..900d5204 100644 --- a/NEWS.md +++ b/NEWS.md @@ -52,7 +52,8 @@ Red Panda C++ Version 2.27 - fix: In the debugger console, Auto-wrapped lines can't be correctly selected. - enhancement: Auto choose a better font for theme choosing dialog in the first run. - fix: Debugger console's background not correctly cleared before redrawn. - - enhancement: Make output in the debugger console cleaner. + - enhancement: Make output in the debug console cleaner. + - enhancement: Execute the last debug command in the debug console if ENTER pressed. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/debugger/gdbmidebugger.cpp b/RedPandaIDE/debugger/gdbmidebugger.cpp index 225a3acb..c9bb7b0d 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.cpp +++ b/RedPandaIDE/debugger/gdbmidebugger.cpp @@ -42,11 +42,24 @@ void GDBMIDebuggerClient::postCommand(const QString &command, const QString &par DebugCommandSource source) { QMutexLocker locker(&mCmdQueueMutex); - PDebugCommand pCmd = std::make_shared(); + PGDBMICommand pCmd; + if (source == DebugCommandSource::Console) { + if (command.trimmed().isEmpty()) { + if (mLastConsoleCmd) { + pCmd = mLastConsoleCmd; + mCmdQueue.enqueue(pCmd); + return; + } + } + } + pCmd = std::make_shared(); + if (source == DebugCommandSource::Console) + mLastConsoleCmd = pCmd; pCmd->command = command; pCmd->params = params; pCmd->source = source; mCmdQueue.enqueue(pCmd); + // if (!mCmdRunning) // runNextCmd(); } @@ -54,7 +67,7 @@ void GDBMIDebuggerClient::postCommand(const QString &command, const QString &par void GDBMIDebuggerClient::registerInferiorStoppedCommand(const QString &command, const QString ¶ms) { QMutexLocker locker(&mCmdQueueMutex); - PDebugCommand pCmd = std::make_shared(); + PGDBMICommand pCmd = std::make_shared(); pCmd->command = command; pCmd->params = params; pCmd->source = DebugCommandSource::Other; @@ -171,7 +184,7 @@ void GDBMIDebuggerClient::runNextCmd() return; } - PDebugCommand pCmd = mCmdQueue.dequeue(); + PGDBMICommand pCmd = mCmdQueue.dequeue(); mCmdRunning = true; mCurrentCmd = pCmd; if (pCmd->source!=DebugCommandSource::HeartBeat) @@ -779,16 +792,17 @@ void GDBMIDebuggerClient::processExecAsyncRecord(const QByteArray &line) runInferiorStoppedHook(); if (reason.isEmpty()) { QMutexLocker locker(&mCmdQueueMutex); - foreach (const PDebugCommand& cmd, mCmdQueue) { + foreach (const PGDBMICommand& cmd, mCmdQueue) { //gdb-server connected, just ignore it if (cmd->command=="-exec-continue") return; } } - if (mCurrentCmd && mCurrentCmd->source == DebugCommandSource::Console) - emit inferiorStopped(mCurrentFile, mCurrentLine, false); - else - emit inferiorStopped(mCurrentFile, mCurrentLine, true); +// if (mCurrentCmd && mCurrentCmd->source == DebugCommandSource::Console) +// emit inferiorStopped(mCurrentFile, mCurrentLine, false); +// else +// emit inferiorStopped(mCurrentFile, mCurrentLine, true); + emit inferiorStopped(mCurrentFile, mCurrentLine, false); } } @@ -953,7 +967,7 @@ void GDBMIDebuggerClient::asyncUpdate() mAsyncUpdated = false; } -const PDebugCommand &GDBMIDebuggerClient::currentCmd() const +const PGDBMICommand &GDBMIDebuggerClient::currentCmd() const { return mCurrentCmd; } @@ -1242,7 +1256,7 @@ void GDBMIDebuggerClient::addSymbolSearchDirectories(const QStringList &lst) void GDBMIDebuggerClient::runInferiorStoppedHook() { QMutexLocker locker(&mCmdQueueMutex); - foreach (const PDebugCommand& cmd, mInferiorStoppedHookCommands) { + foreach (const PGDBMICommand& cmd, mInferiorStoppedHookCommands) { mCmdQueue.push_front(cmd); } } diff --git a/RedPandaIDE/debugger/gdbmidebugger.h b/RedPandaIDE/debugger/gdbmidebugger.h index b19c1e9c..43b761ea 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.h +++ b/RedPandaIDE/debugger/gdbmidebugger.h @@ -27,13 +27,13 @@ #include #include -struct DebugCommand{ +struct GDBMICommand{ QString command; QString params; DebugCommandSource source; }; -using PDebugCommand = std::shared_ptr; +using PGDBMICommand = std::shared_ptr; class GDBMIDebuggerClient: public DebuggerClient { Q_OBJECT @@ -46,7 +46,7 @@ public: void stopDebug() override; DebuggerType clientType() override; - const PDebugCommand ¤tCmd() const; + const PGDBMICommand ¤tCmd() const; bool commandRunning() override; void initialize(const QString& inferior, bool hasSymbols) override; @@ -135,9 +135,10 @@ private: static const QRegularExpression REGdbSourceLine; - QQueue mCmdQueue; - PDebugCommand mCurrentCmd; - QList mInferiorStoppedHookCommands; + QQueue mCmdQueue; + PGDBMICommand mCurrentCmd; + PGDBMICommand mLastConsoleCmd; + QList mInferiorStoppedHookCommands; DebuggerType mClientType; }; diff --git a/RedPandaIDE/widgets/qconsole.cpp b/RedPandaIDE/widgets/qconsole.cpp index 40ef9ce8..867afc83 100644 --- a/RedPandaIDE/widgets/qconsole.cpp +++ b/RedPandaIDE/widgets/qconsole.cpp @@ -570,7 +570,7 @@ void QConsole::keyPressEvent(QKeyEvent *event) if (mReadonly) return; emit commandInput(mCommand); - if (mHistorySize>0) { + if (mHistorySize>0 && !mCommand.trimmed().isEmpty()) { if (mCommandHistory.size()==mHistorySize) { mCommandHistory.pop_front(); mHistoryIndex--;