From 30d6d250531e14ce947c6911cb01606703c0783d Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 4 Oct 2021 13:29:25 -0400 Subject: Fix multiple issues with debug memory tracking - Track write accesses rather than read accesses - Actually install the taps when the trackmem command is executed - Correct cell addresses for address-shifted spaces in Qt and Windows memory viewers --- src/emu/debug/debugcpu.cpp | 23 +++++++++++++++++++---- src/emu/debug/debugcpu.h | 2 +- src/osd/modules/debugger/qt/memorywindow.cpp | 7 +++++-- src/osd/modules/debugger/win/memoryviewinfo.cpp | 7 +++++-- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index d28265d7b33..04cce887484 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -566,10 +566,10 @@ void device_debug::reinstall(address_space &space, read_or_write mode) if (m_track_mem) switch (space.data_width()) { - case 8: m_phw[id] = space.install_read_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u8 &data, u8 ) { write_tracking(space, address, data); }, m_phw[id]); break; - case 16: m_phw[id] = space.install_read_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u16 &data, u16) { write_tracking(space, address, data); }, m_phw[id]); break; - case 32: m_phw[id] = space.install_read_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u32 &data, u32) { write_tracking(space, address, data); }, m_phw[id]); break; - case 64: m_phw[id] = space.install_read_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u64 &data, u64) { write_tracking(space, address, data); }, m_phw[id]); break; + case 8: m_phw[id] = space.install_write_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u8 &data, u8 ) { write_tracking(space, address, data); }, m_phw[id]); break; + case 16: m_phw[id] = space.install_write_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u16 &data, u16) { write_tracking(space, address, data); }, m_phw[id]); break; + case 32: m_phw[id] = space.install_write_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u32 &data, u32) { write_tracking(space, address, data); }, m_phw[id]); break; + case 64: m_phw[id] = space.install_write_tap(0, space.addrmask(), "track_mem", [this, &space](offs_t address, u64 &data, u64) { write_tracking(space, address, data); }, m_phw[id]); break; } } } @@ -582,6 +582,21 @@ void device_debug::reinstall_all(read_or_write mode) reinstall(m_memory->space(i), mode); } +//------------------------------------------------- +// set_track_mem - start or stop tracking memory +// writes +//------------------------------------------------- + +void device_debug::set_track_mem(bool value) +{ + if (m_track_mem != value) + { + m_track_mem = value; + reinstall_all(read_or_write::WRITE); + } +} + + //------------------------------------------------- // start_hook - the scheduler calls this hook // before beginning execution for the given device diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 11a2f55843e..eba89367c2c 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -138,7 +138,7 @@ public: void track_pc_data_clear() { m_track_pc_set.clear(); } // memory tracking - void set_track_mem(bool value) { m_track_mem = value; } + void set_track_mem(bool value); offs_t track_mem_pc_from_space_address_data(const int& space, const offs_t& address, const u64& data) const; diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp index c4b4ce9a429..c2ed7dc404e 100644 --- a/src/osd/modules/debugger/qt/memorywindow.cpp +++ b/src/osd/modules/debugger/qt/memorywindow.cpp @@ -330,7 +330,7 @@ void DebuggerMemView::addItemsToContextMenu(QMenu *menu) { // get the last known PC to write to this memory location debug_view_xy const pos = memView.cursor_position(); - offs_t const address = memView.addressAtCursorPosition(pos); + offs_t const address = addressSpace->byte_to_address(memView.addressAtCursorPosition(pos)); offs_t a = address & addressSpace->logaddrmask(); bool good = false; if (!addressSpace->device().memory().translate(addressSpace->spacenum(), TRANSLATE_READ_DEBUG, a)) @@ -355,7 +355,10 @@ void DebuggerMemView::addItemsToContextMenu(QMenu *menu) memValue); if (pc != offs_t(-1)) { - m_lastPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); + if (addressSpace->is_octal()) + m_lastPc = QString("Address %1 written at PC=%2").arg(address, 2, 8).arg(pc, 2, 8); + else + m_lastPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); good = true; } else diff --git a/src/osd/modules/debugger/win/memoryviewinfo.cpp b/src/osd/modules/debugger/win/memoryviewinfo.cpp index 15dc46ebb98..4b6f33bcd85 100644 --- a/src/osd/modules/debugger/win/memoryviewinfo.cpp +++ b/src/osd/modules/debugger/win/memoryviewinfo.cpp @@ -95,7 +95,7 @@ void memoryview_info::update_context_menu(HMENU menu) { // get the last known PC to write to this memory location debug_view_xy const pos = memview.cursor_position(); - offs_t const address = memview.addressAtCursorPosition(pos); + offs_t const address = space->byte_to_address(memview.addressAtCursorPosition(pos)); offs_t a = address & space->logaddrmask(); if (!space->device().memory().translate(space->spacenum(), TRANSLATE_READ_DEBUG, a)) { @@ -119,7 +119,10 @@ void memoryview_info::update_context_menu(HMENU menu) memval); if (pc != offs_t(-1)) { - m_lastpc = util::string_format("Address %x written at PC=%x", address, pc); + if (space->is_octal()) + m_lastpc = util::string_format("Address %o written at PC=%o", address, pc); + else + m_lastpc = util::string_format("Address %x written at PC=%x", address, pc); enable = true; } else -- cgit v1.2.3