Merge pull request #987 from ajrhacker/debugpassthru

Eliminate some unnecessary pass-through methods from debugcpu (nw)
This commit is contained in:
Miodrag Milanović 2016-06-23 07:53:01 +02:00 committed by GitHub
commit f55646ea6f
3 changed files with 19 additions and 20 deletions

View File

@ -2338,9 +2338,14 @@ void debugger_commands::execute_dasm(int ref, int params, const char *param[])
decrypted_space = space; decrypted_space = space;
/* determine the width of the bytes */ /* determine the width of the bytes */
cpu_device *cpudevice = downcast<cpu_device *>(&space->device()); device_disasm_interface *dasmintf;
minbytes = cpudevice->min_opcode_bytes(); if (!space->device().interface(dasmintf))
maxbytes = cpudevice->max_opcode_bytes(); {
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; byteswidth = 0;
if (bytes) if (bytes)
{ {
@ -2538,7 +2543,8 @@ void debugger_commands::execute_history(int ref, int params, const char *param[]
device_debug *debug = space->device().debug(); device_debug *debug = space->device().debug();
/* loop over lines */ /* 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++) for (int index = 0; index < (int) count; index++)
{ {
offs_t pc = debug->history_pc(-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 // Insert current pc
if (m_cpu.get_visible_cpu() == cpu) 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); cpu->debug()->set_track_pc_visited(pc);
} }
m_console.printf("PC tracking enabled\n"); m_console.printf("PC tracking enabled\n");

View File

@ -1632,7 +1632,6 @@ device_debug::device_debug(device_t &device)
, m_symtable(&device, device.machine().debugger().cpu().get_global_symtable()) , m_symtable(&device, device.machine().debugger().cpu().get_global_symtable())
, m_instrhook(nullptr) , m_instrhook(nullptr)
, m_dasm_override(nullptr) , m_dasm_override(nullptr)
, m_opwidth(0)
, m_stepaddr(0) , m_stepaddr(0)
, m_stepsleft(0) , m_stepsleft(0)
, m_stopaddr(0) , m_stopaddr(0)
@ -1698,7 +1697,6 @@ device_debug::device_debug(device_t &device)
if (m_exec != nullptr) if (m_exec != nullptr)
{ {
m_flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; m_flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY;
m_opwidth = min_opcode_bytes();
// if no curpc, add one // if no curpc, add one
if (m_state != nullptr && m_symtable.find("curpc") == nullptr) 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 // 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) 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 // no longer in debugger code
debugcpu.set_within_instruction(false); 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); result = m_disasm->disassemble(buffer, pc, oprom, opram, 0);
// make sure we get good results // make sure we get good results
assert((result & DASMFLAG_LENGTHMASK) != 0); assert((result & DASMFLAG_LENGTHMASK) != 0 || m_disasm == nullptr);
#ifdef MAME_DEBUG #ifdef MAME_DEBUG
if (m_memory != nullptr && m_disasm != nullptr) 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 // fetch the bytes up to the maximum
UINT8 opbuf[64], argbuf[64]; 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++) for (int numbytes = 0; numbytes < maxbytes; numbytes++)
{ {
opbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(decrypted_space, pcbyte + numbytes, 1); 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" "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; std::string buffer;
if (type & WATCHPOINT_WRITE) 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) 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 // see if we have a match in our list
unsigned int hotindex; 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 // fetch the bytes up to the maximum
UINT8 opbuf[64], argbuf[64]; UINT8 opbuf[64], argbuf[64];
int maxbytes = max_opcode_bytes(); int maxbytes = m_disasm->max_opcode_bytes();
for (int numbytes = 0; numbytes < maxbytes; numbytes++) for (int numbytes = 0; numbytes < maxbytes; numbytes++)
{ {
opbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(decrypted_space, pcbyte + numbytes, 1); 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) UINT64 device_debug::get_current_pc(symbol_table &table, void *ref)
{ {
device_t *device = reinterpret_cast<device_t *>(table.globalref()); device_t *device = reinterpret_cast<device_t *>(table.globalref());
return device->debug()->pc(); return device->safe_pc();
} }

View File

@ -172,13 +172,9 @@ public:
symbol_table &symtable() { return m_symtable; } symbol_table &symtable() { return m_symtable; }
// commonly-used pass-throughs // commonly-used pass-throughs
offs_t pc() const { return (m_state != nullptr) ? m_state->pc() : 0; } int logaddrchars() const { return (m_memory != nullptr && m_memory->has_space(AS_PROGRAM)) ? m_memory->space(AS_PROGRAM).logaddrchars() : 8; }
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; }
device_t& device() const { return m_device; } device_t& device() const { return m_device; }
// hooks used by the rest of the system // hooks used by the rest of the system
void start_hook(const attotime &endtime); void start_hook(const attotime &endtime);
void stop_hook(); void stop_hook();
@ -322,7 +318,6 @@ private:
// disassembly // disassembly
dasm_override_func m_dasm_override; // pointer to provided override function dasm_override_func m_dasm_override; // pointer to provided override function
UINT8 m_opwidth; // width of an opcode
// stepping information // stepping information
offs_t m_stepaddr; // step target address for DEBUG_FLAG_STEPPING_OVER offs_t m_stepaddr; // step target address for DEBUG_FLAG_STEPPING_OVER