From 80ec88e5529e2143ef52a5b092c7770a55218075 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 12 Mar 2024 18:59:26 +0800 Subject: [PATCH] - fix: Failed to evaluate expressions while debugging, if the expression has spaces in it. --- NEWS.md | 3 ++- RedPandaIDE/debugger/gdbmidebugger.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 460b9320..e401f3e6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -43,7 +43,8 @@ Red Panda C++ Version 2.27 - fix: Function tips contains functions that not in the scope. - fix: Hint for bold text () are not correctly handled in the function tips. - enhancement: Improve lldb-mi compatibility. - - fix: Full scope typed variables in lambda expressions is not correctly parsed. + - fix: Full scope typed variables in lambda expressions is not correctly parsed. + - fix: Failed to evaluate expressions while debugging, if the expression has spaces in it. 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 7493a3e5..82a57863 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.cpp +++ b/RedPandaIDE/debugger/gdbmidebugger.cpp @@ -1166,7 +1166,14 @@ void GDBMIDebuggerClient::fetchWatchVarChildren(const QString& varName) void GDBMIDebuggerClient::evalExpression(const QString &expression) { - postCommand("-data-evaluate-expression", expression); + QString escaped; + foreach(const QChar& ch, expression) { + if (ch.unicode()<=32) { + escaped+=QString("\\%1").arg(ch.unicode(),0,8); + } else + escaped+=ch; + } + postCommand("-data-evaluate-expression", QString("\"%1\"").arg(escaped)); } void GDBMIDebuggerClient::selectFrame(PTrace trace)