Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 31 additions & 26 deletions src/emu/debug/debugcpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<symbol_table>(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)
Expand Down Expand Up @@ -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<symbol_table>(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())
{
Expand All @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions src/emu/debug/express.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ symbol_table::symbol_table(running_machine &machine, table_type type, symbol_tab
, m_memintf(dynamic_cast<device_memory_interface *>(device))
, m_memory_modified(nullptr)
{
assert(type != table_type::CPU_STATE || device != nullptr);
assert(type != table_type::BUILTIN_GLOBALS || device == nullptr);
}


Expand Down
2 changes: 1 addition & 1 deletion src/emu/debug/express.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion src/mame/sinclair/specnext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {}
Expand Down Expand Up @@ -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()
Expand Down
Loading