diff options
| author | Dentomologist <dentomologist@gmail.com> | 2025-07-17 12:05:29 -0700 |
|---|---|---|
| committer | Dentomologist <dentomologist@gmail.com> | 2025-07-17 13:45:08 -0700 |
| commit | 43ab79ae23fbfd104890bd63dd7bdc4ff480a19c (patch) | |
| tree | f15d4c31a0fbcce65463c89f302ad2ba14c2a897 /Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp | |
| parent | b6be5ee5d3a9b26880d860c614f578e643caadd4 (diff) | |
MemoryViewWidget: Fix updates at end of address space
Fix two bugs that occurred when viewing a memory range starting shortly
before 0xffffffff.
Bug 1: When there was at least one visible memory address at or after
0x0 none of the values would be displayed even when some of the
addresses were valid. This happened because the loop condition in
GetValues immediately returned false since m_address_range.first >
m_address_range.second, causing m_values to be empty. This in turn led
every address to be considered INVALID_MEMORY in UpdateColumns.
Bug 2: When m_address_range.second was equal to 0xffffffff GetValues
would enter an infinite loop. This happened because address would
overflow to 0 after printing the last value in the table, causing the
loop condition address <= m_address_range.second to be true forever.
Diffstat (limited to 'Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index ef39421294..2cd85627b2 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -473,7 +473,7 @@ void MemoryViewWidget::Update() const int data_span = m_bytes_per_row / GetTypeSize(m_type); m_address_range.first = row_address; - m_address_range.second = row_address + m_table->rowCount() * m_bytes_per_row - 1; + m_address_range.second = row_address + m_table->rowCount() * m_bytes_per_row; for (int i = 0; i < m_table->rowCount(); i++, row_address += m_bytes_per_row) { @@ -611,9 +611,13 @@ void MemoryViewWidget::GetValues() // Grab memory values as QStrings Core::CPUThreadGuard guard(m_system); - for (u32 address = m_address_range.first; address <= m_address_range.second; - address += GetTypeSize(m_type)) + const u32 type_size = static_cast<u32>(GetTypeSize(m_type)); + const auto& [range_begin, range_end] = m_address_range; + const u32 address_count = (range_end - range_begin) / type_size; + + for (u32 i = 0; i < address_count; ++i) { + const u32 address = range_begin + i * type_size; m_values.insert(std::pair(address, ValueToString(guard, address, m_type))); if (m_dual_view) |
