From cb8a6b8e169d1d3fdbb006266c0951ee1bd09830 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Mon, 12 Aug 2019 01:26:04 +0200 Subject: gdbstub: add z80 and m6502 z80 was tested with pacman and m6502 was tested with apple2e. Side-effects must be disabled before reading memory, otherwise apple2e starts failing after the first read to 0xc080. Since GDB doesn't support those processors, I made up the features name with "mame.". I also had to choose the registers to export in the target.xml file, and since I don't have any experience with these processors I don't know if I made the best choice. --- src/osd/modules/debugger/debuggdbstub.cpp | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/osd') diff --git a/src/osd/modules/debugger/debuggdbstub.cpp b/src/osd/modules/debugger/debuggdbstub.cpp index d345f4ec602..a800479edef 100644 --- a/src/osd/modules/debugger/debuggdbstub.cpp +++ b/src/osd/modules/debugger/debuggdbstub.cpp @@ -166,11 +166,49 @@ static const gdb_register_map gdb_register_map_ppc601 = } }; +//------------------------------------------------------------------------- +static const gdb_register_map gdb_register_map_z80 = +{ + "z80", + "mame.z80", + { + { "AF", "af", false, TYPE_INT }, + { "BC", "bc", false, TYPE_INT }, + { "DE", "de", false, TYPE_INT }, + { "HL", "hl", false, TYPE_INT }, + { "AF2", "af'", false, TYPE_INT }, + { "BC2", "bc'", false, TYPE_INT }, + { "DE2", "de'", false, TYPE_INT }, + { "HL2", "hl'", false, TYPE_INT }, + { "IX", "ix", false, TYPE_INT }, + { "IY", "iy", false, TYPE_INT }, + { "SP", "sp", true, TYPE_DATA_POINTER }, + { "PC", "pc", true, TYPE_CODE_POINTER }, + } +}; + +//------------------------------------------------------------------------- +static const gdb_register_map gdb_register_map_m6502 = +{ + "m6502", + "mame.m6502", + { + { "A", "a", false, TYPE_INT }, + { "X", "x", false, TYPE_INT }, + { "Y", "y", false, TYPE_INT }, + { "P", "p", false, TYPE_INT }, + { "PC", "pc", true, TYPE_CODE_POINTER }, + { "SP", "sp", true, TYPE_DATA_POINTER }, + } +}; + //------------------------------------------------------------------------- static const std::map gdb_register_maps = { { "i486", gdb_register_map_i486 }, { "arm7_le", gdb_register_map_arm7 }, { "ppc601", gdb_register_map_ppc601 }, + { "z80", gdb_register_map_z80 }, + { "m6502", gdb_register_map_m6502 }, }; //------------------------------------------------------------------------- @@ -416,6 +454,18 @@ void debug_gdbstub::wait_for_debugger(device_t &device, bool firststop) m_is_be = m_address_space->endianness() == ENDIANNESS_BIG; +#if 0 + for ( const auto &entry: m_state->state_entries() ) + { + const char *symbol = entry->symbol(); + uint8_t datasize = entry->datasize(); + uint64_t datamask = entry->datamask(); + int index = entry->index(); + const std::string &format_string = entry->format_string(); + osd_printf_info("[%3d] datasize %d mask %016" PRIx64 " [%s] [%s]\n", index, datasize, datamask, symbol, format_string.c_str()); + } +#endif + const gdb_register_map ®ister_map = it->second; m_gdb_arch = register_map.arch; m_gdb_feature = register_map.feature; @@ -632,6 +682,9 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_m(const char *buf) if ( !m_memory->translate(m_address_space->spacenum(), TRANSLATE_READ_DEBUG, offset) ) return REPLY_ENN; + // Disable side effects while reading memory. + auto dis = m_machine->disable_side_effects(); + std::string reply; reply.reserve(length * 2); for ( int i = 0; i < length; i++ ) -- cgit v1.2.3