From 9fe20f1a9adbe4cc642ef152154bad63b2f469a0 Mon Sep 17 00:00:00 2001 From: sowens99 Date: Thu, 25 Apr 2024 16:15:07 -0400 Subject: [PATCH] Show address pointed to by the chain --- Source/GUI/MemWatcher/MemWatchModel.cpp | 13 +++++++------ Source/GUI/MemWatcher/MemWatchModel.h | 2 +- Source/MemoryWatch/MemWatchEntry.cpp | 4 ++-- Source/MemoryWatch/MemWatchEntry.h | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Source/GUI/MemWatcher/MemWatchModel.cpp b/Source/GUI/MemWatcher/MemWatchModel.cpp index c571075c..0864eda1 100644 --- a/Source/GUI/MemWatcher/MemWatchModel.cpp +++ b/Source/GUI/MemWatcher/MemWatchModel.cpp @@ -200,9 +200,7 @@ QVariant MemWatchModel::data(const QModelIndex& index, int role) const } case WATCH_COL_ADDRESS: { - u32 address = entry->getConsoleAddress(); - bool isPointer = entry->isBoundToPointer(); - return getAddressString(address, isPointer); + return getAddressString(entry); } case WATCH_COL_VALUE: { @@ -624,14 +622,17 @@ void MemWatchModel::sortRecursive(int column, Qt::SortOrder order, MemWatchTreeN } } -QString MemWatchModel::getAddressString(u32 address, bool isPointer) const +QString MemWatchModel::getAddressString(const MemWatchEntry* entry) const { std::stringstream ss; - if (isPointer) + if (entry->isBoundToPointer()) { - ss << "P->" << std::hex << std::uppercase << address; + int level = static_cast(entry->getPointerLevel()); + std::string strAddress = entry->getAddressStringForPointerLevel(level); + ss << "(" << level << "*)" << std::hex << std::uppercase << strAddress; return QString::fromStdString(ss.str()); } + u32 address = entry->getConsoleAddress(); ss << std::hex << std::uppercase << address; return QString::fromStdString(ss.str()); } diff --git a/Source/GUI/MemWatcher/MemWatchModel.h b/Source/GUI/MemWatcher/MemWatchModel.h index 5a08aa41..1e89fead 100644 --- a/Source/GUI/MemWatcher/MemWatchModel.h +++ b/Source/GUI/MemWatcher/MemWatchModel.h @@ -79,7 +79,7 @@ class MemWatchModel : public QAbstractItemModel const bool readSucess = true); bool freezeNodeValueRecursive(MemWatchTreeNode* node, const QModelIndex& parent = QModelIndex(), const bool writeSucess = true); - QString getAddressString(u32 address, bool isPointer) const; + QString getAddressString(const MemWatchEntry* entry) const; MemWatchTreeNode* getLeastDeepNodeFromList(const QList nodes) const; int getNodeDeepness(const MemWatchTreeNode* node) const; diff --git a/Source/MemoryWatch/MemWatchEntry.cpp b/Source/MemoryWatch/MemWatchEntry.cpp index cd2f8034..e6bacd31 100644 --- a/Source/MemoryWatch/MemWatchEntry.cpp +++ b/Source/MemoryWatch/MemWatchEntry.cpp @@ -186,7 +186,7 @@ Common::MemOperationReturnCode MemWatchEntry::freeze() return writeCode; } -u32 MemWatchEntry::getAddressForPointerLevel(const int level) +u32 MemWatchEntry::getAddressForPointerLevel(const int level) const { if (!m_boundToPointer && level > m_pointerOffsets.size() && level > 0) return 0; @@ -213,7 +213,7 @@ u32 MemWatchEntry::getAddressForPointerLevel(const int level) return address; } -std::string MemWatchEntry::getAddressStringForPointerLevel(const int level) +std::string MemWatchEntry::getAddressStringForPointerLevel(const int level) const { u32 address = getAddressForPointerLevel(level); if (address == 0) diff --git a/Source/MemoryWatch/MemWatchEntry.h b/Source/MemoryWatch/MemWatchEntry.h index b9df7909..781bbd6d 100644 --- a/Source/MemoryWatch/MemWatchEntry.h +++ b/Source/MemoryWatch/MemWatchEntry.h @@ -44,8 +44,8 @@ class MemWatchEntry Common::MemOperationReturnCode freeze(); - u32 getAddressForPointerLevel(const int level); - std::string getAddressStringForPointerLevel(const int level); + u32 getAddressForPointerLevel(const int level) const; + std::string getAddressStringForPointerLevel(const int level) const; Common::MemOperationReturnCode readMemoryFromRAM(); std::string getStringFromMemory() const;