diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index 6cdaaf019aead..de41e4b3c585c 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -488,7 +488,7 @@ device_debug::device_debug(device_t &device) , m_state(nullptr) , m_disasm(nullptr) , m_flags(0) - , m_symtable(std::make_unique(device.machine(), symbol_table::CPU_STATE, &device.machine().debugger().cpu().global_symtable(), &device)) + , m_symtable(nullptr) , m_stepaddr(0) , m_stepsleft(0) , m_delay_steps(0) @@ -542,36 +542,41 @@ device_debug::device_debug(device_t &device) // add global symbol for cycles and totalcycles if (m_exec != nullptr) { + m_symtable = std::make_unique(device.machine(), symbol_table::CPU_STATE, &device.machine().debugger().cpu().global_symtable(), &device); + m_symtable->add("cycles", [this]() { return m_exec->cycles_remaining(); }); m_symtable->add("totalcycles", symbol_table::READ_ONLY, &m_total_cycles); m_symtable->add("lastinstructioncycles", [this]() { return m_total_cycles - m_last_total_cycles; }); - } - // add entries to enable/disable unmap reporting for each space - if (m_memory != nullptr) - { - if (m_memory->has_space(AS_PROGRAM)) - m_symtable->add( - "logunmap", - [&space = m_memory->space(AS_PROGRAM)] () { return space.log_unmap(); }, - [&space = m_memory->space(AS_PROGRAM)] (u64 value) { return space.set_log_unmap(bool(value)); }); - if (m_memory->has_space(AS_DATA)) - m_symtable->add( - "logunmap", - [&space = m_memory->space(AS_DATA)] () { return space.log_unmap(); }, - [&space = m_memory->space(AS_DATA)] (u64 value) { return space.set_log_unmap(bool(value)); }); - if (m_memory->has_space(AS_IO)) - m_symtable->add( - "logunmap", - [&space = m_memory->space(AS_IO)] () { return space.log_unmap(); }, - [&space = m_memory->space(AS_IO)] (u64 value) { return space.set_log_unmap(bool(value)); }); - if (m_memory->has_space(AS_OPCODES)) - m_symtable->add( - "logunmap", - [&space = m_memory->space(AS_OPCODES)] () { return space.log_unmap(); }, - [&space = m_memory->space(AS_OPCODES)] (u64 value) { return space.set_log_unmap(bool(value)); }); + // add entries to enable/disable unmap reporting for each space + if (m_memory != nullptr) + { + if (m_memory->has_space(AS_PROGRAM)) + m_symtable->add( + "logunmap", + [&space = m_memory->space(AS_PROGRAM)] () { return space.log_unmap(); }, + [&space = m_memory->space(AS_PROGRAM)] (u64 value) { return space.set_log_unmap(bool(value)); }); + if (m_memory->has_space(AS_DATA)) + m_symtable->add( + "logunmap", + [&space = m_memory->space(AS_DATA)] () { return space.log_unmap(); }, + [&space = m_memory->space(AS_DATA)] (u64 value) { return space.set_log_unmap(bool(value)); }); + if (m_memory->has_space(AS_IO)) + m_symtable->add( + "logunmap", + [&space = m_memory->space(AS_IO)] () { return space.log_unmap(); }, + [&space = m_memory->space(AS_IO)] (u64 value) { return space.set_log_unmap(bool(value)); }); + if (m_memory->has_space(AS_OPCODES)) + m_symtable->add( + "logunmap", + [&space = m_memory->space(AS_OPCODES)] () { return space.log_unmap(); }, + [&space = m_memory->space(AS_OPCODES)] (u64 value) { return space.set_log_unmap(bool(value)); }); + } } + // Use own table for CPU and the global for others + symbol_table *symtable = m_symtable != nullptr ? m_symtable.get() : &device.machine().debugger().cpu().global_symtable(); + // add all registers into it for (const auto &entry : m_state->state_entries()) { @@ -580,7 +585,7 @@ device_debug::device_debug(device_t &device) { using namespace std::placeholders; std::string tempstr(strmakelower(entry->symbol())); - m_symtable->add( + symtable->add( tempstr.c_str(), std::bind(&device_state_entry::value, entry.get()), entry->writeable() ? std::bind(&device_state_entry::set_value, entry.get(), _1) : symbol_table::setter_func(nullptr), diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp index 89637df4f0385..767a0adb46882 100644 --- a/src/emu/debug/express.cpp +++ b/src/emu/debug/express.cpp @@ -372,6 +372,8 @@ symbol_table::symbol_table(running_machine &machine, table_type type, symbol_tab , m_memintf(dynamic_cast(device)) , m_memory_modified(nullptr) { + assert(type != table_type::CPU_STATE || device != nullptr); + assert(type != table_type::BUILTIN_GLOBALS || device == nullptr); } diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h index f5a1b685a648f..db648ea3e7834 100644 --- a/src/emu/debug/express.h +++ b/src/emu/debug/express.h @@ -178,7 +178,7 @@ class symbol_table { CPU_STATE, // CPU registers, etc. BUILTIN_GLOBALS, // Built-in MAME global symbols (e.g., beamx, beamy, frame, etc.) - // (also used for tables outside debugger: lua scripts, cheat engine) + // (also used for tables outside debugger: lua scripts, cheat engine) }; // construction/destruction diff --git a/src/mame/sinclair/specnext.cpp b/src/mame/sinclair/specnext.cpp index ab6e24269af3b..0cb3aa11a89ef 100644 --- a/src/mame/sinclair/specnext.cpp +++ b/src/mame/sinclair/specnext.cpp @@ -99,11 +99,12 @@ struct video_timings_info { u16 hdmi_ysync; }; -class specnext_state : public spectrum_128_state +class specnext_state : public spectrum_128_state, public device_state_interface { public: specnext_state(const machine_config &mconfig, device_type type, const char *tag) : spectrum_128_state(mconfig, type, tag) + , device_state_interface(mconfig, *this) , m_maincpu(*this, "maincpu") , m_io_expbus_view(*this, "io_expbus_view") , m_bank_boot_rom(*this, "bootrom") @@ -151,6 +152,7 @@ class specnext_state : public spectrum_128_state virtual void machine_start() override ATTR_COLD; virtual void device_post_load() override ATTR_COLD; virtual void machine_reset() override ATTR_COLD; + virtual void state_import(const device_state_entry &entry) override; void reset_hard(); virtual void video_start() override ATTR_COLD; virtual void spectrum_128_update_memory() override {} @@ -3467,6 +3469,22 @@ void specnext_state::machine_start() save_item(NAME(m_spi_miso_dat)); save_item(NAME(m_i2c_scl_data)); save_item(NAME(m_i2c_sda_data)); + + state_add(0, "mmu0", m_mmu[0]).callimport(); + state_add(1, "mmu1", m_mmu[1]).callimport(); + state_add(2, "mmu2", m_mmu[2]).callimport(); + state_add(3, "mmu3", m_mmu[3]).callimport(); + state_add(4, "mmu4", m_mmu[4]).callimport(); + state_add(5, "mmu5", m_mmu[5]).callimport(); + state_add(6, "mmu6", m_mmu[6]).callimport(); + state_add(7, "mmu7", m_mmu[7]).callimport(); +} + +void specnext_state::state_import(const device_state_entry &entry) +{ + if (entry.index() < 8) { + bank_update(entry.index()); + } } void specnext_state::device_post_load()