From d6f9e3bc1ce1de91612dbec0db5e4fbbbcef4727 Mon Sep 17 00:00:00 2001 From: AJR Date: Wed, 22 Jun 2016 16:52:55 -0400 Subject: [PATCH] Eliminate some unnecessary pass-through methods from debugcpu (nw) --- src/emu/debug/debugcmd.cpp | 16 +++++++++++----- src/emu/debug/debugcpu.cpp | 16 +++++++--------- src/emu/debug/debugcpu.h | 7 +------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 97eeb525fe1..72865e06680 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -2338,9 +2338,14 @@ void debugger_commands::execute_dasm(int ref, int params, const char *param[]) decrypted_space = space; /* determine the width of the bytes */ - cpu_device *cpudevice = downcast(&space->device()); - minbytes = cpudevice->min_opcode_bytes(); - maxbytes = cpudevice->max_opcode_bytes(); + device_disasm_interface *dasmintf; + if (!space->device().interface(dasmintf)) + { + m_console.printf("No disassembler available for %s\n", space->device().name()); + return; + } + minbytes = dasmintf->min_opcode_bytes(); + maxbytes = dasmintf->max_opcode_bytes(); byteswidth = 0; if (bytes) { @@ -2538,7 +2543,8 @@ void debugger_commands::execute_history(int ref, int params, const char *param[] device_debug *debug = space->device().debug(); /* loop over lines */ - int maxbytes = debug->max_opcode_bytes(); + device_disasm_interface *dasmintf; + int maxbytes = space->device().interface(dasmintf) ? dasmintf->max_opcode_bytes() : 1; for (int index = 0; index < (int) count; index++) { offs_t pc = debug->history_pc(-index); @@ -2587,7 +2593,7 @@ void debugger_commands::execute_trackpc(int ref, int params, const char *param[] // Insert current pc if (m_cpu.get_visible_cpu() == cpu) { - const offs_t pc = cpu->debug()->pc(); + const offs_t pc = cpu->safe_pc(); cpu->debug()->set_track_pc_visited(pc); } m_console.printf("PC tracking enabled\n"); diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index d9a63868899..021d745d0ec 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1632,7 +1632,6 @@ device_debug::device_debug(device_t &device) , m_symtable(&device, device.machine().debugger().cpu().get_global_symtable()) , m_instrhook(nullptr) , m_dasm_override(nullptr) - , m_opwidth(0) , m_stepaddr(0) , m_stepsleft(0) , m_stopaddr(0) @@ -1698,7 +1697,6 @@ device_debug::device_debug(device_t &device) if (m_exec != nullptr) { m_flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; - m_opwidth = min_opcode_bytes(); // if no curpc, add one if (m_state != nullptr && m_symtable.find("curpc") == nullptr) @@ -1920,7 +1918,7 @@ void device_debug::instruction_hook(offs_t curpc) // handle step out/over on the instruction we are about to execute if ((m_flags & (DEBUG_FLAG_STEPPING_OVER | DEBUG_FLAG_STEPPING_OUT)) != 0 && m_stepaddr == ~0) - prepare_for_step_overout(pc()); + prepare_for_step_overout(m_device.safe_pc()); // no longer in debugger code debugcpu.set_within_instruction(false); @@ -1997,7 +1995,7 @@ offs_t device_debug::disassemble(char *buffer, offs_t pc, const UINT8 *oprom, co result = m_disasm->disassemble(buffer, pc, oprom, opram, 0); // make sure we get good results - assert((result & DASMFLAG_LENGTHMASK) != 0); + assert((result & DASMFLAG_LENGTHMASK) != 0 || m_disasm == nullptr); #ifdef MAME_DEBUG if (m_memory != nullptr && m_disasm != nullptr) { @@ -2653,7 +2651,7 @@ UINT32 device_debug::compute_opcode_crc32(offs_t pc) const // fetch the bytes up to the maximum UINT8 opbuf[64], argbuf[64]; - int maxbytes = max_opcode_bytes(); + int maxbytes = (m_disasm != nullptr) ? m_disasm->max_opcode_bytes() : 1; for (int numbytes = 0; numbytes < maxbytes; numbytes++) { opbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(decrypted_space, pcbyte + numbytes, 1); @@ -2966,7 +2964,7 @@ void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t addre { "0bytes", "byte", "word", "3bytes", "dword", "5bytes", "6bytes", "7bytes", "qword" }; - offs_t pc = space.device().debug()->pc(); + offs_t pc = space.device().safe_pc(); std::string buffer; if (type & WATCHPOINT_WRITE) @@ -2996,7 +2994,7 @@ void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t addre void device_debug::hotspot_check(address_space &space, offs_t address) { - offs_t curpc = pc(); + offs_t curpc = m_device.safe_pc(); // see if we have a match in our list unsigned int hotindex; @@ -3051,7 +3049,7 @@ UINT32 device_debug::dasm_wrapped(std::string &buffer, offs_t pc) // fetch the bytes up to the maximum UINT8 opbuf[64], argbuf[64]; - int maxbytes = max_opcode_bytes(); + int maxbytes = m_disasm->max_opcode_bytes(); for (int numbytes = 0; numbytes < maxbytes; numbytes++) { opbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(decrypted_space, pcbyte + numbytes, 1); @@ -3075,7 +3073,7 @@ UINT32 device_debug::dasm_wrapped(std::string &buffer, offs_t pc) UINT64 device_debug::get_current_pc(symbol_table &table, void *ref) { device_t *device = reinterpret_cast(table.globalref()); - return device->debug()->pc(); + return device->safe_pc(); } diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index af8cb57a2e4..757fc57649a 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -172,13 +172,9 @@ public: symbol_table &symtable() { return m_symtable; } // commonly-used pass-throughs - offs_t pc() const { return (m_state != nullptr) ? m_state->pc() : 0; } - int logaddrchars(address_spacenum spacenum = AS_0) const { return (m_memory != nullptr && m_memory->has_space(spacenum)) ? m_memory->space(spacenum).logaddrchars() : 8; } - int min_opcode_bytes() const { return (m_disasm != nullptr) ? m_disasm->max_opcode_bytes() : 1; } - int max_opcode_bytes() const { return (m_disasm != nullptr) ? m_disasm->max_opcode_bytes() : 1; } + int logaddrchars() const { return (m_memory != nullptr && m_memory->has_space(AS_PROGRAM)) ? m_memory->space(AS_PROGRAM).logaddrchars() : 8; } device_t& device() const { return m_device; } - // hooks used by the rest of the system void start_hook(const attotime &endtime); void stop_hook(); @@ -322,7 +318,6 @@ private: // disassembly dasm_override_func m_dasm_override; // pointer to provided override function - UINT8 m_opwidth; // width of an opcode // stepping information offs_t m_stepaddr; // step target address for DEBUG_FLAG_STEPPING_OVER