From f834a6dfbfb95cc4c5057d04847b8464999b49a6 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 31 Mar 2024 09:36:37 +0800 Subject: [PATCH] - enhancement: By default, use monospaced font to display register values in the CPU Info dialog. - fix: Negative values in register like AH/AL are wrongs displayed as 32/64-bit number. --- NEWS.md | 2 ++ RedPandaIDE/debugger/debugger.cpp | 7 ++++++- RedPandaIDE/debugger/gdbmidebugger.cpp | 23 +++++++++++++++-------- RedPandaIDE/debugger/gdbmidebugger.h | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5c3f8a7b..8b95d220 100644 --- a/NEWS.md +++ b/NEWS.md @@ -105,6 +105,8 @@ Red Panda C++ Version 2.27 - fix: Compile info for project doesn't have name of the project executable. - enhancement: Highlight words in the string/comments. - fix: If there are only 1 line in the editor, shift+down can't select it. + - enhancement: By default, use monospaced font to display register values in the CPU Info dialog. + - fix: Negative values in register like AH/AL are wrongs displayed as 32/64-bit number. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/debugger/debugger.cpp b/RedPandaIDE/debugger/debugger.cpp index b0c1f200..3c52c0f7 100644 --- a/RedPandaIDE/debugger/debugger.cpp +++ b/RedPandaIDE/debugger/debugger.cpp @@ -34,6 +34,7 @@ #include #include #include "widgets/signalmessagedialog.h" +#include Debugger::Debugger(QObject *parent) : QObject(parent), mForceUTF8(false), @@ -2219,6 +2220,8 @@ QVariant RegisterModel::data(const QModelIndex &index, int role) const ,""); } break; + case Qt::FontRole: + return QFont{pSettings->debugger().fontName(),pSettings->debugger().fontSize()}; case Qt::ToolTipRole: switch (index.column()) { case 0: @@ -2265,7 +2268,9 @@ void RegisterModel::updateNames(const QStringList ®Names) void RegisterModel::updateValues(const QHash registerValues) { - mRegisterValues= registerValues; + foreach(int row, registerValues.keys()){ + mRegisterValues[row] = registerValues[row]; + } emit dataChanged(createIndex(0,1), createIndex(mRegisterNames.count()-1,1)); } diff --git a/RedPandaIDE/debugger/gdbmidebugger.cpp b/RedPandaIDE/debugger/gdbmidebugger.cpp index 2be3ce86..1e055438 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.cpp +++ b/RedPandaIDE/debugger/gdbmidebugger.cpp @@ -471,20 +471,26 @@ void GDBMIDebuggerClient::handleRegisterNames(const QList &values) +void GDBMIDebuggerClient::handleRegisterValue(const QList &values, bool hexValue) { QHash result; foreach (const GDBMIResultParser::ParseValue& val, values) { GDBMIResultParser::ParseObject obj = val.object(); int number = obj["number"].intValue(); QString value = obj["value"].value(); - bool ok; - long long intVal; - intVal = value.toLongLong(&ok,10); - if (ok) { - value = QString("0x%1").arg(intVal,0,16); + if (hexValue) { + bool ok; + long long intVal; + intVal = value.toLongLong(&ok,16); + if (ok) + result.insert(number,value); + } else { + bool ok; + long long intVal; + intVal = value.toLongLong(&ok,10); + if (!ok) + result.insert(number,value); } - result.insert(number,value); } emit registerValuesUpdated(result); } @@ -712,7 +718,7 @@ void GDBMIDebuggerClient::processResult(const QByteArray &result) handleRegisterNames(multiValues["register-names"].array()); break; case GDBMIResultType::RegisterValues: - handleRegisterValue(multiValues["register-values"].array()); + handleRegisterValue(multiValues["register-values"].array(), mCurrentCmd->params=="x"); break; case GDBMIResultType::CreateVar: handleCreateVar(multiValues); @@ -1207,6 +1213,7 @@ void GDBMIDebuggerClient::refreshFrame() void GDBMIDebuggerClient::refreshRegisters() { postCommand("-data-list-register-names",""); + postCommand("-data-list-register-values", "x"); postCommand("-data-list-register-values", "N"); } diff --git a/RedPandaIDE/debugger/gdbmidebugger.h b/RedPandaIDE/debugger/gdbmidebugger.h index 43b761ea..0690355e 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.h +++ b/RedPandaIDE/debugger/gdbmidebugger.h @@ -105,7 +105,7 @@ private: void handleMemory(const QList & rows); void handleMemoryBytes(const QList & rows); void handleRegisterNames(const QList & names); - void handleRegisterValue(const QList & values); + void handleRegisterValue(const QList & values, bool hexValue); void handleListVarChildren(const GDBMIResultParser::ParseObject& multiVars); void handleUpdateVarValue(const QList &changes); void handleDisassembly(const QList &instructions);