diff options
193 files changed, 1676 insertions, 1857 deletions
diff --git a/.gitattributes b/.gitattributes index 5ad20acde1e..c97ac8afc1e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -509,6 +509,7 @@ src/emu/debug/express.c svneol=native#text/plain src/emu/debug/express.h svneol=native#text/plain src/emu/debug/textbuf.c svneol=native#text/plain src/emu/debug/textbuf.h svneol=native#text/plain +src/emu/debugger.c svneol=native#text/plain src/emu/debugger.h svneol=native#text/plain src/emu/deprecat.h svneol=native#text/plain src/emu/devconv.h svneol=native#text/plain @@ -97,9 +97,6 @@ endif # for details #------------------------------------------------- -# uncomment next line to enable the debugger -# DEBUGGER = 1 - # uncomment next line to build a debug version # DEBUG = 1 @@ -205,8 +202,8 @@ RM = @rm -f # form the name of the executable #------------------------------------------------- -# debugger builds just get the 'd' suffix and nothing more -ifdef DEBUGGER +# debug builds just get the 'd' suffix and nothing more +ifdef DEBUG DEBUGSUFFIX = d endif @@ -265,11 +262,6 @@ ifdef PTR64 DEFS += -DPTR64 endif -# define ENABLE_DEBUGGER if we are a debugger-enabled build -ifdef DEBUGGER -DEFS += -DENABLE_DEBUGGER -endif - # define MAME_DEBUG if we are a debugging build ifdef DEBUG DEFS += -DMAME_DEBUG diff --git a/src/emu/cpu/adsp2100/adsp2100.c b/src/emu/cpu/adsp2100/adsp2100.c index 45b06b5380a..a07fb9c3f2b 100644 --- a/src/emu/cpu/adsp2100/adsp2100.c +++ b/src/emu/cpu/adsp2100/adsp2100.c @@ -950,7 +950,7 @@ static int adsp2100_execute(int cycles) /* debugging */ adsp2100.ppc = adsp2100.pc; /* copy PC to previous PC */ - CALL_DEBUGGER(adsp2100.pc); + debugger_instruction_hook(Machine, adsp2100.pc); #if TRACK_HOTSPOTS pcbucket[adsp2100.pc & 0x3fff]++; @@ -1690,9 +1690,7 @@ static int adsp2100_execute(int cycles) DEBUGGER DEFINITIONS ***************************************************************************/ -#ifdef ENABLE_DEBUGGER extern offs_t adsp2100_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ @@ -1947,9 +1945,7 @@ static void adsp21xx_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = adsp2100_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = adsp2100_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = adsp2100_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &adsp2100_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/alph8201/alph8201.c b/src/emu/cpu/alph8201/alph8201.c index 498618f0bb8..532cdc2f61f 100644 --- a/src/emu/cpu/alph8201/alph8201.c +++ b/src/emu/cpu/alph8201/alph8201.c @@ -285,7 +285,7 @@ INLINE void M_UNDEFINED(void) mame_printf_debug("ALPHA8201: PC = %03x, Unimplemented opcode = %02x\n", PC-1, M_RDMEM(PC-1)); #endif #if BREAK_ON_UNKNOWN_OPCODE - DEBUGGER_BREAK; + debugger_break(Machine); #endif } @@ -298,7 +298,7 @@ INLINE void M_UNDEFINED2(void) mame_printf_debug("ALPHA8201: PC = %03x, Unimplemented opcode = %02x,%02x\n", PC-2, op,imm); #endif #if BREAK_ON_UNKNOWN_OPCODE - DEBUGGER_BREAK; + debugger_break(Machine); #endif } @@ -313,7 +313,7 @@ static void need_verify(const char *s) mame_printf_debug("ALPHA8201: PC = %03x, unknown opcode = %02x is '%s' ??\n",PC-1, op,s); #endif #if BREAK_ON_UNCERTAIN_OPCODE - DEBUGGER_BREAK; + debugger_break(Machine); #endif } @@ -327,7 +327,7 @@ static void need_verify2(const char *s) mame_printf_debug("ALPHA8201: PC = %03x, unknown opcode = %02x %02x is '%s' ??\n",PC-2, op1, op2, s); #endif #if BREAK_ON_UNCERTAIN_OPCODE - DEBUGGER_BREAK; + debugger_break(Machine); #endif } #endif @@ -790,7 +790,7 @@ mame_printf_debug("ALPHA8201 START ENTRY=%02X PC=%03X\n",pcptr,PC); /* run */ R.PREVPC = PC; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); opcode =M_RDOP(PC); #if TRACE_PC mame_printf_debug("ALPHA8201: PC = %03x, opcode = %02x\n", PC, opcode); @@ -954,9 +954,7 @@ static void alpha8xxx_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = ALPHA8201_reset; break; case CPUINFO_PTR_EXIT: info->exit = ALPHA8201_exit; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = ALPHA8201_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &ALPHA8201_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/alph8201/alph8201.h b/src/emu/cpu/alph8201/alph8201.h index 05bfa8bad93..f2b50e291bc 100644 --- a/src/emu/cpu/alph8201/alph8201.h +++ b/src/emu/cpu/alph8201/alph8201.h @@ -65,8 +65,6 @@ extern void alpha8301_get_info(UINT32 state, cpuinfo *info); */ #define ALPHA8201_RDOP_ARG(A) ((unsigned)cpu_readop_arg(A)) -#ifdef ENABLE_DEBUGGER offs_t ALPHA8201_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _ALPHA8201_H */ diff --git a/src/emu/cpu/apexc/apexc.c b/src/emu/cpu/apexc/apexc.c index d9e31c2eca2..286341314ae 100644 --- a/src/emu/cpu/apexc/apexc.c +++ b/src/emu/cpu/apexc/apexc.c @@ -802,7 +802,7 @@ static int apexc_execute(int cycles) do { - CALL_DEBUGGER(effective_address(apexc.ml)); + debugger_instruction_hook(Machine, effective_address(apexc.ml)); if (apexc.running) execute(); @@ -898,10 +898,7 @@ void apexc_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = apexc_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = apexc_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; - -#ifdef ENABLE_DEBUGGER - case CPUINFO_PTR_DISASSEMBLE: info->disassemble = apexc_dasm; break; -#endif /* ENABLE_DEBUGGER */ + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = apexc_dasm; break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &apexc_ICount; break; case CPUINFO_STR_NAME: strcpy(info->s = cpuintrf_temp_str(), "APEXC"); break; diff --git a/src/emu/cpu/apexc/apexc.h b/src/emu/cpu/apexc/apexc.h index 54a8326c194..073dd398348 100644 --- a/src/emu/cpu/apexc/apexc.h +++ b/src/emu/cpu/apexc/apexc.h @@ -28,9 +28,7 @@ without danger */ #define apexc_writemem_masked(address, data, mask) cpu_writemem13_32masked((address), (data), (mask)) #endif -#ifdef ENABLE_DEBUGGER unsigned apexc_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ #define apexc_readop(address) apexc_readmem(address) diff --git a/src/emu/cpu/arm/arm.c b/src/emu/cpu/arm/arm.c index 69c0106ef16..4be8b399915 100644 --- a/src/emu/cpu/arm/arm.c +++ b/src/emu/cpu/arm/arm.c @@ -323,7 +323,7 @@ static int arm_execute( int cycles ) arm_icount = cycles; do { - CALL_DEBUGGER(R15); + debugger_instruction_hook(Machine, R15); /* load instruction */ pc = R15; @@ -502,13 +502,11 @@ static void set_irq_line(int irqline, int state) arm_check_irq_state(); } -#ifdef ENABLE_DEBUGGER static offs_t arm_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { UINT32 opcode = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); return 4 | arm_disasm(buffer, pc, opcode); } -#endif /* ENABLE_DEBUGGER */ static void arm_init(int index, int clock, const void *config, int (*irqcallback)(int)) { @@ -1531,9 +1529,7 @@ void arm_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = arm_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = arm_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = arm_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &arm_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/arm/arm.h b/src/emu/cpu/arm/arm.h index 2f752720264..8504dc6597c 100644 --- a/src/emu/cpu/arm/arm.h +++ b/src/emu/cpu/arm/arm.h @@ -16,9 +16,7 @@ extern void arm_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER -extern UINT32 arm_disasm( char *pBuf, UINT32 pc, UINT32 opcode ); -#endif +extern UINT32 arm_disasm(char *pBuf, UINT32 pc, UINT32 opcode); enum { diff --git a/src/emu/cpu/arm7/arm7.c b/src/emu/cpu/arm7/arm7.c index e22680cabf3..042e10d5077 100644 --- a/src/emu/cpu/arm7/arm7.c +++ b/src/emu/cpu/arm7/arm7.c @@ -48,12 +48,10 @@ static READ32_HANDLER(test_rt_r_callback); static WRITE32_HANDLER(test_rt_w_callback); static void test_dt_r_callback(UINT32 insn, UINT32 *prn, UINT32 (*read32)(UINT32 addr)); static void test_dt_w_callback(UINT32 insn, UINT32 *prn, void (*write32)(UINT32 addr, UINT32 data)); -#ifdef ENABLE_DEBUGGER static char *Spec_RT(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); static char *Spec_DT(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); static char *Spec_DO(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); #endif -#endif /* Macros that can be re-defined for custom cpu implementations - The core expects these to be defined */ /* In this case, we are using the default arm7 handlers (supplied by the core) @@ -101,13 +99,11 @@ static void arm7_init(int index, int clock, const void *config, int (*irqcallbac arm7_coproc_rt_w_callback = test_rt_w_callback; arm7_coproc_dt_r_callback = test_dt_r_callback; arm7_coproc_dt_w_callback = test_dt_w_callback; -#ifdef ENABLE_DEBUGGER // setup dasm callbacks - direct method example arm7_dasm_cop_dt_callback = Spec_DT; arm7_dasm_cop_rt_callback = Spec_RT; arm7_dasm_cop_do_callback = Spec_DO; #endif -#endif } static void arm7_reset(void) @@ -150,7 +146,6 @@ static void arm7_set_context(void *src) } } -#ifdef ENABLE_DEBUGGER static offs_t arm7_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { if (T_IS_SET(GET_CPSR)) @@ -162,7 +157,6 @@ static offs_t arm7_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 return arm7_disasm(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)) | 4; } } -#endif /* ENABLE_DEBUGGER */ /************************************************************************** @@ -340,9 +334,7 @@ void arm7_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = arm7_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = arm7_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = arm7_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &ARM7_ICOUNT; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -442,7 +434,6 @@ static void test_dt_w_callback(UINT32 insn, UINT32 *prn, void (*write32)(UINT32 } /* Custom Co-proc DASM handlers */ -#ifdef ENABLE_DEBUGGER static char *Spec_RT(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0) { pBuf += sprintf(pBuf, "SPECRT"); @@ -459,4 +450,3 @@ static char *Spec_DO(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf return pBuf; } #endif -#endif diff --git a/src/emu/cpu/arm7/arm7core.c b/src/emu/cpu/arm7/arm7core.c index 46ba193b092..40d3b867a4f 100644 --- a/src/emu/cpu/arm7/arm7core.c +++ b/src/emu/cpu/arm7/arm7core.c @@ -125,12 +125,11 @@ WRITE32_HANDLER((*arm7_coproc_rt_w_callback)); // holder for the co processor R void (*arm7_coproc_dt_r_callback)(UINT32 insn, UINT32 *prn, UINT32 (*read32)(UINT32 addr)); void (*arm7_coproc_dt_w_callback)(UINT32 insn, UINT32 *prn, void (*write32)(UINT32 addr, UINT32 data)); -#ifdef ENABLE_DEBUGGER // custom dasm callback handlers for co-processor instructions char *(*arm7_dasm_cop_dt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); char *(*arm7_dasm_cop_rt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); char *(*arm7_dasm_cop_do_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); -#endif + /*************************************************************************** * Default Memory Handlers diff --git a/src/emu/cpu/arm7/arm7core.h b/src/emu/cpu/arm7/arm7core.h index f3668ec8889..78738d04dba 100644 --- a/src/emu/cpu/arm7/arm7core.h +++ b/src/emu/cpu/arm7/arm7core.h @@ -398,13 +398,11 @@ extern WRITE32_HANDLER((*arm7_coproc_rt_w_callback)); extern void (*arm7_coproc_dt_r_callback)(UINT32 insn, UINT32* prn, UINT32 (*read32)(UINT32 addr)); extern void (*arm7_coproc_dt_w_callback)(UINT32 insn, UINT32* prn, void (*write32)(UINT32 addr, UINT32 data)); -#ifdef ENABLE_DEBUGGER extern UINT32 arm7_disasm(char *pBuf, UINT32 pc, UINT32 opcode); extern UINT32 thumb_disasm(char *pBuf, UINT32 pc, UINT16 opcode); extern char *(*arm7_dasm_cop_dt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); extern char *(*arm7_dasm_cop_rt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); extern char *(*arm7_dasm_cop_do_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0); -#endif #endif /* ARM7CORE_H */ diff --git a/src/emu/cpu/arm7/arm7exec.c b/src/emu/cpu/arm7/arm7exec.c index 81174cf6ab3..4cf9a3e1efc 100644 --- a/src/emu/cpu/arm7/arm7exec.c +++ b/src/emu/cpu/arm7/arm7exec.c @@ -47,7 +47,7 @@ ARM7_ICOUNT = cycles; do { - CALL_DEBUGGER(R15); + debugger_instruction_hook(Machine, R15); /* handle Thumb instructions if active */ if (T_IS_SET(GET_CPSR)) diff --git a/src/emu/cpu/asap/asap.c b/src/emu/cpu/asap/asap.c index 54eb6c56831..eb2e8cdbe25 100644 --- a/src/emu/cpu/asap/asap.c +++ b/src/emu/cpu/asap/asap.c @@ -508,7 +508,17 @@ INLINE void fetch_instruction(void) { /* debugging */ asap.ppc = asap.pc; - CALL_DEBUGGER(asap.pc); + + /* instruction fetch */ + asap.op.d = ROPCODE(asap.pc); + asap.pc += 4; +} + +INLINE void fetch_instruction_debug(void) +{ + /* debugging */ + asap.ppc = asap.pc; + debugger_instruction_hook(Machine, asap.pc); /* instruction fetch */ asap.op.d = ROPCODE(asap.pc); @@ -530,27 +540,54 @@ static int asap_execute(int cycles) UPDATEPC(); /* core execution loop */ - do + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) == 0) { - /* fetch and execute the next instruction */ - fetch_instruction(); - execute_instruction(); + do + { + /* fetch and execute the next instruction */ + fetch_instruction(); + execute_instruction(); - /* fetch and execute the next instruction */ - fetch_instruction(); - execute_instruction(); + /* fetch and execute the next instruction */ + fetch_instruction(); + execute_instruction(); - /* fetch and execute the next instruction */ - fetch_instruction(); - execute_instruction(); + /* fetch and execute the next instruction */ + fetch_instruction(); + execute_instruction(); - /* fetch and execute the next instruction */ - fetch_instruction(); - execute_instruction(); + /* fetch and execute the next instruction */ + fetch_instruction(); + execute_instruction(); + + asap_icount -= 4; + + } while (asap_icount > 0); + } + else + { + do + { + /* fetch and execute the next instruction */ + fetch_instruction_debug(); + execute_instruction(); + + /* fetch and execute the next instruction */ + fetch_instruction_debug(); + execute_instruction(); - asap_icount -= 4; + /* fetch and execute the next instruction */ + fetch_instruction_debug(); + execute_instruction(); - } while (asap_icount > 0); + /* fetch and execute the next instruction */ + fetch_instruction_debug(); + execute_instruction(); + + asap_icount -= 4; + + } while (asap_icount > 0); + } /* eat any new interrupt cycles */ asap_icount -= asap.interrupt_cycles; @@ -564,9 +601,7 @@ static int asap_execute(int cycles) DISASSEMBLY HOOK ***************************************************************************/ -#ifdef ENABLE_DEBUGGER extern offs_t asap_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ @@ -1806,9 +1841,7 @@ void asap_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = asap_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = asap_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = asap_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &asap_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/ccpu/ccpu.c b/src/emu/cpu/ccpu/ccpu.c index 0af94355ba1..f6826d6f1bf 100644 --- a/src/emu/cpu/ccpu/ccpu.c +++ b/src/emu/cpu/ccpu/ccpu.c @@ -212,7 +212,7 @@ static int ccpu_execute(int cycles) ccpu.nextmiflag = ccpu.nextnextmiflag; /* fetch the opcode */ - CALL_DEBUGGER(ccpu.PC); + debugger_instruction_hook(Machine, ccpu.PC); opcode = READOP(ccpu.PC++); switch (opcode) @@ -786,9 +786,7 @@ void ccpu_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = NULL; break; case CPUINFO_PTR_EXECUTE: info->execute = ccpu_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = ccpu_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &ccpu_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/ccpu/ccpu.h b/src/emu/cpu/ccpu/ccpu.h index 790e984663c..a1075c106c7 100644 --- a/src/emu/cpu/ccpu/ccpu.h +++ b/src/emu/cpu/ccpu/ccpu.h @@ -53,8 +53,6 @@ struct CCPUConfig void ccpu_get_info(UINT32 state, cpuinfo *info); void ccpu_wdt_timer_trigger(void); -#ifdef ENABLE_DEBUGGER offs_t ccpu_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/cdp1802/cdp1802.c b/src/emu/cpu/cdp1802/cdp1802.c index ff441aea346..645a734e2db 100644 --- a/src/emu/cpu/cdp1802/cdp1802.c +++ b/src/emu/cpu/cdp1802/cdp1802.c @@ -232,7 +232,7 @@ static void cdp1802_run(running_machine *machine) cdp1802_ICount -= CDP1802_CYCLES_RESET; - CALL_DEBUGGER(cdp1802.r[cdp1802.p]); + debugger_instruction_hook(Machine, cdp1802.r[cdp1802.p]); break; @@ -257,7 +257,7 @@ static void cdp1802_run(running_machine *machine) cdp1802.state = CDP1802_STATE_0_FETCH; } - CALL_DEBUGGER(cdp1802.r[cdp1802.p]); + debugger_instruction_hook(Machine, cdp1802.r[cdp1802.p]); break; @@ -734,7 +734,7 @@ static void cdp1802_run(running_machine *machine) cdp1802.state = CDP1802_STATE_0_FETCH; } - CALL_DEBUGGER(cdp1802.r[cdp1802.p]); + debugger_instruction_hook(Machine, cdp1802.r[cdp1802.p]); break; @@ -822,7 +822,7 @@ static void cdp1802_run(running_machine *machine) cdp1802.state = CDP1802_STATE_0_FETCH; } - CALL_DEBUGGER(cdp1802.r[cdp1802.p]); + debugger_instruction_hook(Machine, cdp1802.r[cdp1802.p]); break; } @@ -1025,9 +1025,7 @@ void cdp1802_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = cdp1802_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = cdp1802_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = cdp1802_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cdp1802_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/cdp1802/cdp1802.h b/src/emu/cpu/cdp1802/cdp1802.h index 0b4d49b525f..6e2fbd1d065 100644 --- a/src/emu/cpu/cdp1802/cdp1802.h +++ b/src/emu/cpu/cdp1802/cdp1802.h @@ -110,8 +110,6 @@ struct _cdp1802_interface }; #define CDP1802_INTERFACE(name) const cdp1802_interface (name) = -#ifdef ENABLE_DEBUGGER offs_t cdp1802_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/cop400/cop400.h b/src/emu/cpu/cop400/cop400.h index a12dbd3bde2..3f6172136a6 100644 --- a/src/emu/cpu/cop400/cop400.h +++ b/src/emu/cpu/cop400/cop400.h @@ -97,9 +97,7 @@ extern void cop426_get_info(UINT32 state, cpuinfo *info); extern void cop444_get_info(UINT32 state, cpuinfo *info); extern void cop445_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER offs_t cop410_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t cop420_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ #endif /* __COP400__ */ diff --git a/src/emu/cpu/cop400/cop410.c b/src/emu/cpu/cop400/cop410.c index 2722842f144..9e2676ff26c 100644 --- a/src/emu/cpu/cop400/cop410.c +++ b/src/emu/cpu/cop400/cop410.c @@ -313,7 +313,7 @@ static int cop410_execute(int cycles) { prevPC = PC; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); if (R.intf->cko == COP400_CKO_HALT_IO_PORT) { @@ -469,9 +469,7 @@ void cop410_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = cop410_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = cop410_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = cop410_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cop410_ICount; break; /* case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: diff --git a/src/emu/cpu/cop400/cop420.c b/src/emu/cpu/cop400/cop420.c index b7aaff61085..8ae93af0633 100644 --- a/src/emu/cpu/cop400/cop420.c +++ b/src/emu/cpu/cop400/cop420.c @@ -452,7 +452,7 @@ static int cop420_execute(int cycles) { prevPC = PC; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); opcode = ROM(PC); @@ -642,9 +642,7 @@ void cop420_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = cop420_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = cop420_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = cop420_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cop420_ICount; break; /* case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: diff --git a/src/emu/cpu/cp1610/cp1610.c b/src/emu/cpu/cp1610/cp1610.c index 085f0832200..ec7780b634f 100644 --- a/src/emu/cpu/cp1610/cp1610.c +++ b/src/emu/cpu/cp1610/cp1610.c @@ -2166,7 +2166,7 @@ static int cp1610_execute(int cycles) do { - CALL_DEBUGGER(cp1610.r[7]); + debugger_instruction_hook(Machine, cp1610.r[7]); cp1610.mask_interrupts = 0; @@ -3491,9 +3491,7 @@ void cp1610_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXECUTE: info->execute = cp1610_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = cp1610_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cp1610_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/cp1610/cp1610.h b/src/emu/cpu/cp1610/cp1610.h index 2bee8945c7a..0a84fc02ebb 100644 --- a/src/emu/cpu/cp1610/cp1610.h +++ b/src/emu/cpu/cp1610/cp1610.h @@ -35,9 +35,7 @@ enum { void cp1610_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER unsigned cp1610_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ // Temporary #define cp1610_readop(A) program_read_word_16be((A)<<1) diff --git a/src/emu/cpu/drcbec.c b/src/emu/cpu/drcbec.c index 129553264fd..b5254d06c5d 100644 --- a/src/emu/cpu/drcbec.c +++ b/src/emu/cpu/drcbec.c @@ -596,7 +596,7 @@ static int drcbec_execute(drcbe_state *drcbe, drcuml_codehandle *entry) break; case MAKE_OPCODE_SHORT(DRCUML_OP_DEBUG, 4, 0): /* DEBUG pc */ - CALL_DEBUGGER(PARAM0); + debugger_instruction_hook(Machine, PARAM0); break; case MAKE_OPCODE_SHORT(DRCUML_OP_HASHJMP, 4, 0): /* HASHJMP mode,pc,handle */ diff --git a/src/emu/cpu/drcbex64.c b/src/emu/cpu/drcbex64.c index 1d24a46ab50..ddaccadc70f 100644 --- a/src/emu/cpu/drcbex64.c +++ b/src/emu/cpu/drcbex64.c @@ -273,7 +273,7 @@ struct _drcbe_state x86code * exit; /* exit point */ x86code * nocode; /* nocode handler */ - x86code * mame_debug_hook; /* debugger callback */ + x86code * debug_cpu_instruction_hook;/* debugger callback */ x86code * debug_log_hashjmp; /* hashjmp debugging */ x86code * drcmap_get_value; /* map lookup helper */ data_accessors accessors[ADDRESS_SPACES];/* memory accessors */ @@ -713,9 +713,7 @@ static drcbe_state *drcbex64_alloc(drcuml_state *drcuml, drccache *cache, UINT32 drcbe->absmask64[0] = drcbe->absmask64[1] = U64(0x7fffffffffffffff); /* get pointers to C functions we need to call */ -#ifdef ENABLE_DEBUGGER - drcbe->mame_debug_hook = (x86code *)mame_debug_hook; -#endif + drcbe->debug_cpu_instruction_hook = (x86code *)debug_cpu_instruction_hook; #if LOG_HASHJMPS drcbe->debug_log_hashjmp = (x86code *)debug_log_hashjmp; #endif @@ -3083,24 +3081,32 @@ static x86code *op_nop(drcbe_state *drcbe, x86code *dst, const drcuml_instructio static x86code *op_debug(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) { + emit_link skip = { 0 }; + /* validate instruction */ assert(inst->size == 4); assert_no_condition(inst); assert_no_flags(inst); -#ifdef ENABLE_DEBUGGER - if (Machine->debug_mode) + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { drcuml_parameter pcp; /* normalize parameters */ param_normalize_1(drcbe, inst, &pcp, PTYPE_MRI); + /* test and branch */ + emit_mov_r64_imm(&dst, REG_PARAM1, (FPTR)Machine); // mov param1,pcp + emit_test_m32_imm(&dst, MBD(REG_PARAM1, offsetof(running_machine, debug_flags)), DEBUG_FLAG_CALL_HOOK); + // test [Machine->debug_flags],DEBUG_FLAG_CALL_HOOK + emit_jcc_short_link(&dst, COND_Z, &skip); // jz skip + /* push the parameter */ - emit_mov_r32_p32(drcbe, &dst, REG_PARAM1, &pcp); // mov param1,pcp - emit_smart_call_m64(drcbe, &dst, &drcbe->mame_debug_hook); // call mame_debug_hook + emit_mov_r32_p32(drcbe, &dst, REG_PARAM2, &pcp); // mov param1,pcp + emit_smart_call_m64(drcbe, &dst, &drcbe->debug_cpu_instruction_hook); // call debug_cpu_instruction_hook + + resolve_link(&dst, &skip); // skip: } -#endif return dst; } diff --git a/src/emu/cpu/drcbex86.c b/src/emu/cpu/drcbex86.c index b6a9d40ee52..9d22d02d638 100644 --- a/src/emu/cpu/drcbex86.c +++ b/src/emu/cpu/drcbex86.c @@ -3207,24 +3207,31 @@ static x86code *op_nop(drcbe_state *drcbe, x86code *dst, const drcuml_instructio static x86code *op_debug(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) { + emit_link skip = { 0 }; + /* validate instruction */ assert(inst->size == 4); assert_no_condition(inst); assert_no_flags(inst); -#ifdef ENABLE_DEBUGGER - if (Machine->debug_mode) + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { drcuml_parameter pcp; - + /* normalize parameters */ param_normalize_1(drcbe, inst, &pcp, PTYPE_MRI); + /* test and branch */ + emit_test_m32_imm(&dst, MABS(&Machine->debug_flags), DEBUG_FLAG_CALL_HOOK); // test [Machine->debug_flags],DEBUG_FLAG_CALL_HOOK + emit_jcc_short_link(&dst, COND_Z, &skip); // jz skip + /* push the parameter */ - emit_mov_m32_p32(drcbe, &dst, MBD(REG_ESP, 0), &pcp); // mov [esp],pcp - emit_call(&dst, (x86code *)mame_debug_hook); // call mame_debug_hook + emit_mov_m32_p32(drcbe, &dst, MBD(REG_ESP, 4), &pcp); // mov [esp+4],pcp + emit_mov_m32_imm(&dst, MBD(REG_ESP, 0), (FPTR)Machine); // mov [esp],Machine + emit_call(&dst, (x86code *)debug_cpu_instruction_hook); // call debug_cpu_instruction_hook + + resolve_link(&dst, &skip); // skip: } -#endif return dst; } diff --git a/src/emu/cpu/ds5002fp/ds5002fp.c b/src/emu/cpu/ds5002fp/ds5002fp.c index 9d0a5ac30fa..0bc37003517 100644 --- a/src/emu/cpu/ds5002fp/ds5002fp.c +++ b/src/emu/cpu/ds5002fp/ds5002fp.c @@ -706,7 +706,7 @@ int ds5002fp_execute(int cycles) PPC = PC; //Call Debugger - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); //remove after testing if(PC != PPC) op = cpu_readop(PC); @@ -2184,9 +2184,7 @@ INLINE void do_add_flags(UINT8 a, UINT8 data, UINT8 c) SET_AC(ac); SET_OV(ov); -#ifdef ENABLE_DEBUGGER // mame_printf_debug("add: result=%x, c=%x, ac=%x, ov=%x\n",a+data+c,cy,ac,ov); -#endif } INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c) @@ -2202,9 +2200,7 @@ INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c) SET_AC(ac); SET_OV(ov); -#ifdef ENABLE_DEBUGGER // mame_printf_debug("sub: a=%x, d=%x, c=%x, result=%x, cy=%x, ac=%x, ov=%x\n",a,data,c,a-data-c,cy,ac,ov); -#endif } INLINE void update_timer(int cyc) @@ -2539,14 +2535,12 @@ void ds5002fp_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_SET_INFO: info->setinfo = ds5002fp_set_info; break; case CPUINFO_PTR_GET_CONTEXT: info->getcontext = ds5002fp_get_context; break; case CPUINFO_PTR_SET_CONTEXT: info->setcontext = ds5002fp_set_context; break; - case CPUINFO_PTR_INIT: info->init = ds5002fp_init; break; + case CPUINFO_PTR_INIT: info->init = ds5002fp_init; break; case CPUINFO_PTR_RESET: info->reset = ds5002fp_reset; break; - case CPUINFO_PTR_EXIT: info->exit = ds5002fp_exit; break; + case CPUINFO_PTR_EXIT: info->exit = ds5002fp_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = ds5002fp_execute; break; - case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER + case CPUINFO_PTR_BURN: info->burn = NULL; break; case CPUINFO_PTR_DISASSEMBLE: info->disassemble = ds5002fp_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &ds5002fp_icount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = NULL; break; diff --git a/src/emu/cpu/ds5002fp/ds5002fp.h b/src/emu/cpu/ds5002fp/ds5002fp.h index 8559432efca..d108d381f42 100644 --- a/src/emu/cpu/ds5002fp/ds5002fp.h +++ b/src/emu/cpu/ds5002fp/ds5002fp.h @@ -132,9 +132,7 @@ extern void ds5002fp_set_serial_tx_callback(void (*callback)(int data)); extern void ds5002fp_set_serial_rx_callback(int (*callback)(void)); extern void ds5002fp_set_ebram_iaddr_callback(READ32_HANDLER((*callback))); -#ifdef ENABLE_DEBUGGER extern offs_t ds5002fp_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ void ds5002fp_get_info(UINT32 state, cpuinfo *info); diff --git a/src/emu/cpu/dsp32/dsp32.c b/src/emu/cpu/dsp32/dsp32.c index be7636431ba..943ca675b48 100644 --- a/src/emu/cpu/dsp32/dsp32.c +++ b/src/emu/cpu/dsp32/dsp32.c @@ -436,13 +436,11 @@ static int dsp32c_execute(int cycles) DISASSEMBLY HOOK ***************************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t dsp32c_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { extern unsigned dasm_dsp32(char *, unsigned, UINT32); return dasm_dsp32(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)); } -#endif /* ENABLE_DEBUGGER */ @@ -876,9 +874,7 @@ void dsp32c_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = dsp32c_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = dsp32c_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = dsp32c_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &dsp32_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/dsp32/dsp32ops.c b/src/emu/cpu/dsp32/dsp32ops.c index e23b453eab4..8932ff9bb8d 100644 --- a/src/emu/cpu/dsp32/dsp32ops.c +++ b/src/emu/cpu/dsp32/dsp32ops.c @@ -130,7 +130,7 @@ static void unimplemented(void) INLINE void execute_one(void) { PROCESS_DEFERRED_MEMORY(); - CALL_DEBUGGER(dsp32.PC); + debugger_instruction_hook(Machine, dsp32.PC); OP = ROPCODE(dsp32.PC); dsp32_icount -= 4; /* 4 clocks per cycle */ dsp32.PC += 4; @@ -363,7 +363,7 @@ INLINE void dau_set_val_flags(int aidx, double res) else if (absres > 3.40282e38) { dsp32.VUflags = VFLAGBIT; -// DEBUGGER_BREAK; +// debugger_break(Machine); // fprintf(stderr, "Result = %g\n", absres); res = (res < 0) ? -3.40282e38 : 3.40282e38; } @@ -408,7 +408,7 @@ INLINE UINT32 double_to_dsp(double val) return 0x00000000; else if (exponent > 255) { -// DEBUGGER_BREAK; +// debugger_break(Machine); // fprintf(stderr, "Exponent = %d\n", exponent); return ((INT32)id.i[BYTE_XOR_BE(0)] >= 0) ? 0x7fffffff : 0x800000ff; } diff --git a/src/emu/cpu/dsp56k/dsp56k.c b/src/emu/cpu/dsp56k/dsp56k.c index d73bced71b4..5a7f049b0d4 100644 --- a/src/emu/cpu/dsp56k/dsp56k.c +++ b/src/emu/cpu/dsp56k/dsp56k.c @@ -1236,9 +1236,7 @@ void dsp56k_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = dsp56k_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = dsp56k_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = dsp56k_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &dsp56k_icount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map16 = address_map_dsp56156_x_data_memory; break; diff --git a/src/emu/cpu/dsp56k/dsp56ops.c b/src/emu/cpu/dsp56k/dsp56ops.c index c0ccc59dc4b..e1b657aca2c 100644 --- a/src/emu/cpu/dsp56k/dsp56ops.c +++ b/src/emu/cpu/dsp56k/dsp56ops.c @@ -117,7 +117,7 @@ static void execute_one(void) { unsigned size = 666 ; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); OP = ROPCODE(PC<<1); if (BITS(OP,0x8000)) // First, the parallel data move instructions diff --git a/src/emu/cpu/e132xs/e132xs.c b/src/emu/cpu/e132xs/e132xs.c index fc460f3ca28..b5d882a2956 100644 --- a/src/emu/cpu/e132xs/e132xs.c +++ b/src/emu/cpu/e132xs/e132xs.c @@ -1774,12 +1774,10 @@ static void hyperstone_set_context(void *regs) hyperstone = *(hyperstone_regs *)regs; } -#ifdef ENABLE_DEBUGGER static offs_t hyperstone_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return dasm_hyperstone( buffer, pc, oprom, GET_H, GET_FP ); } -#endif /* ENABLE_DEBUGGER */ /* Opcodes */ @@ -4762,7 +4760,7 @@ static int hyperstone_execute(int cycles) UINT16 opcode; PPC = PC; /* copy PC to previous PC */ - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); opcode = READ_OP(PC); PC += 2; @@ -5084,9 +5082,7 @@ static void hyperstone_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = hyperstone_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = hyperstone_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = hyperstone_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &hyperstone_ICount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map16 = NULL; break; diff --git a/src/emu/cpu/e132xs/e132xs.h b/src/emu/cpu/e132xs/e132xs.h index 349e3532519..f3229892a30 100644 --- a/src/emu/cpu/e132xs/e132xs.h +++ b/src/emu/cpu/e132xs/e132xs.h @@ -77,9 +77,7 @@ void gms30c2216_get_info(UINT32 state, cpuinfo *info); void gms30c2232_get_info(UINT32 state, cpuinfo *info); #endif -#ifdef ENABLE_DEBUGGER extern unsigned dasm_hyperstone(char *buffer, unsigned pc, const UINT8 *oprom, unsigned h_flag, int private_fp); -#endif extern int hyp_type_16bit; diff --git a/src/emu/cpu/f8/f8.c b/src/emu/cpu/f8/f8.c index 229779d10ff..67a76c73b91 100644 --- a/src/emu/cpu/f8/f8.c +++ b/src/emu/cpu/f8/f8.c @@ -1575,7 +1575,7 @@ static int f8_execute(int cycles) do { UINT8 op=f8.dbus; - CALL_DEBUGGER((f8.pc0 - 1) & 0xffff); + debugger_instruction_hook(Machine, (f8.pc0 - 1) & 0xffff); switch( op ) { @@ -1890,9 +1890,7 @@ static void f8_set_context (void *src) f8 = *(f8_Regs *) src; } -#ifdef ENABLE_DEBUGGER unsigned f8_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ static void f8_init (int index, int clock, const void *config, int (*irqcallback)(int)) { @@ -2115,9 +2113,7 @@ void f8_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXECUTE: info->execute = f8_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER - case CPUINFO_PTR_DISASSEMBLE: info->disassemble = f8_dasm; break; -#endif /* ENABLE_DEBUGGER */ + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = f8_dasm; break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &f8_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/g65816/g65816.c b/src/emu/cpu/g65816/g65816.c index 18024f3c866..eaecaa70942 100644 --- a/src/emu/cpu/g65816/g65816.c +++ b/src/emu/cpu/g65816/g65816.c @@ -310,14 +310,12 @@ static void g65816_set_irq_callback(int (*callback)(int)) /* Disassemble an instruction */ -#ifdef ENABLE_DEBUGGER #include "g65816ds.h" static offs_t g65816_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return g65816_disassemble(buffer, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, FLAG_M, FLAG_X); } -#endif /* ENABLE_DEBUGGER */ @@ -430,9 +428,7 @@ void g65816_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = g65816_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = g65816_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = g65816_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &g65816_ICount; break; case CPUINFO_PTR_G65816_READVECTOR_CALLBACK: info->f = (genf *) READ_VECTOR; break; diff --git a/src/emu/cpu/g65816/g65816.h b/src/emu/cpu/g65816/g65816.h index 2b0fd6b8ca5..aab39bb9cd7 100644 --- a/src/emu/cpu/g65816/g65816.h +++ b/src/emu/cpu/g65816/g65816.h @@ -89,7 +89,7 @@ enum void g65816_get_info(UINT32 state, cpuinfo *info); #undef G65816_CALL_DEBUGGER -#define G65816_CALL_DEBUGGER CALL_DEBUGGER +#define G65816_CALL_DEBUGGER(x) debugger_instruction_hook(Machine, x) #define g65816_read_8(addr) program_read_byte_8be(addr) #define g65816_write_8(addr,data) program_write_byte_8be(addr,data) diff --git a/src/emu/cpu/h6280/h6280.c b/src/emu/cpu/h6280/h6280.c index 2c898b4f661..3b98ec3b1ec 100644 --- a/src/emu/cpu/h6280/h6280.c +++ b/src/emu/cpu/h6280/h6280.c @@ -244,7 +244,7 @@ static int h6280_execute(int cycles) CHANGE_PC; h6280.ppc = h6280.pc; - CALL_DEBUGGER(PCW); + debugger_instruction_hook(Machine, PCW); /* Execute 1 instruction */ in=RDOP(); @@ -426,7 +426,6 @@ static void h6280_set_info(UINT32 state, cpuinfo *info) case CPUINFO_INT_REGISTER + H6280_IRQ1_STATE: set_irq_line( 0, info->i ); break; case CPUINFO_INT_REGISTER + H6280_IRQ2_STATE: set_irq_line( 1, info->i ); break; case CPUINFO_INT_REGISTER + H6280_IRQT_STATE: set_irq_line( 2, info->i ); break; -#ifdef ENABLE_DEBUGGER case CPUINFO_INT_REGISTER + H6280_M1: h6280.mmr[0] = info->i; break; case CPUINFO_INT_REGISTER + H6280_M2: h6280.mmr[1] = info->i; break; case CPUINFO_INT_REGISTER + H6280_M3: h6280.mmr[2] = info->i; break; @@ -435,7 +434,6 @@ static void h6280_set_info(UINT32 state, cpuinfo *info) case CPUINFO_INT_REGISTER + H6280_M6: h6280.mmr[5] = info->i; break; case CPUINFO_INT_REGISTER + H6280_M7: h6280.mmr[6] = info->i; break; case CPUINFO_INT_REGISTER + H6280_M8: h6280.mmr[7] = info->i; break; -#endif } } @@ -493,7 +491,6 @@ void h6280_get_info(UINT32 state, cpuinfo *info) case CPUINFO_INT_REGISTER + H6280_IRQ1_STATE: info->i = h6280.irq_state[0]; break; case CPUINFO_INT_REGISTER + H6280_IRQ2_STATE: info->i = h6280.irq_state[1]; break; case CPUINFO_INT_REGISTER + H6280_IRQT_STATE: info->i = h6280.irq_state[2]; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_INT_REGISTER + H6280_M1: info->i = h6280.mmr[0]; break; case CPUINFO_INT_REGISTER + H6280_M2: info->i = h6280.mmr[1]; break; case CPUINFO_INT_REGISTER + H6280_M3: info->i = h6280.mmr[2]; break; @@ -502,7 +499,6 @@ void h6280_get_info(UINT32 state, cpuinfo *info) case CPUINFO_INT_REGISTER + H6280_M6: info->i = h6280.mmr[5]; break; case CPUINFO_INT_REGISTER + H6280_M7: info->i = h6280.mmr[6]; break; case CPUINFO_INT_REGISTER + H6280_M8: info->i = h6280.mmr[7]; break; -#endif /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_SET_INFO: info->setinfo = h6280_set_info; break; @@ -513,9 +509,7 @@ void h6280_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = h6280_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = h6280_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = h6280_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &h6280_ICount; break; case CPUINFO_PTR_TRANSLATE: info->translate = h6280_translate; break; @@ -550,7 +544,6 @@ void h6280_get_info(UINT32 state, cpuinfo *info) case CPUINFO_STR_REGISTER + H6280_IRQ1_STATE: sprintf(info->s, "IRQ1:%X", h6280.irq_state[0]); break; case CPUINFO_STR_REGISTER + H6280_IRQ2_STATE: sprintf(info->s, "IRQ2:%X", h6280.irq_state[1]); break; case CPUINFO_STR_REGISTER + H6280_IRQT_STATE: sprintf(info->s, "IRQT:%X", h6280.irq_state[2]); break; -#ifdef ENABLE_DEBUGGER case CPUINFO_STR_REGISTER + H6280_M1: sprintf(info->s, "M1:%02X", h6280.mmr[0]); break; case CPUINFO_STR_REGISTER + H6280_M2: sprintf(info->s, "M2:%02X", h6280.mmr[1]); break; case CPUINFO_STR_REGISTER + H6280_M3: sprintf(info->s, "M3:%02X", h6280.mmr[2]); break; @@ -559,6 +552,5 @@ void h6280_get_info(UINT32 state, cpuinfo *info) case CPUINFO_STR_REGISTER + H6280_M6: sprintf(info->s, "M6:%02X", h6280.mmr[5]); break; case CPUINFO_STR_REGISTER + H6280_M7: sprintf(info->s, "M7:%02X", h6280.mmr[6]); break; case CPUINFO_STR_REGISTER + H6280_M8: sprintf(info->s, "M8:%02X", h6280.mmr[7]); break; -#endif } } diff --git a/src/emu/cpu/h6280/h6280.h b/src/emu/cpu/h6280/h6280.h index 84839562b1b..3a06480d278 100644 --- a/src/emu/cpu/h6280/h6280.h +++ b/src/emu/cpu/h6280/h6280.h @@ -18,12 +18,9 @@ enum { H6280_PC=1, H6280_S, H6280_P, H6280_A, H6280_X, H6280_Y, H6280_IRQ_MASK, H6280_TIMER_STATE, - H6280_NMI_STATE, H6280_IRQ1_STATE, H6280_IRQ2_STATE, H6280_IRQT_STATE -#ifdef ENABLE_DEBUGGER - , + H6280_NMI_STATE, H6280_IRQ1_STATE, H6280_IRQ2_STATE, H6280_IRQT_STATE, H6280_M1, H6280_M2, H6280_M3, H6280_M4, H6280_M5, H6280_M6, H6280_M7, H6280_M8 -#endif }; #define LAZY_FLAGS 0 @@ -47,8 +44,6 @@ WRITE8_HANDLER( H6280_timer_w ); UINT8 h6280io_get_buffer(void); void h6280io_set_buffer(UINT8); -#ifdef ENABLE_DEBUGGER offs_t h6280_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _H6280_H */ diff --git a/src/emu/cpu/h83002/h83002.c b/src/emu/cpu/h83002/h83002.c index 315e034174a..1394ed6ee0a 100644 --- a/src/emu/cpu/h83002/h83002.c +++ b/src/emu/cpu/h83002/h83002.c @@ -181,9 +181,7 @@ static UINT32 h8_divxs16(INT16 src, INT32 dst); /* implementation */ -#ifdef ENABLE_DEBUGGER extern offs_t h8_disasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ void h8_3002_InterruptRequest(UINT8 source) { @@ -479,7 +477,7 @@ static int h8_execute(int cycles) { h8.ppc = h8.pc; - CALL_DEBUGGER(h8.pc); + debugger_instruction_hook(Machine, h8.pc); opcode = cpu_readop16(h8.pc); // mame_printf_debug("[%06x]: %04x => %x\n", h8.pc, opcode, (opcode>>12)&0xf); @@ -4081,9 +4079,7 @@ void h8_3002_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = 0; break; case CPUINFO_PTR_EXECUTE: info->execute = h8_execute; break; case CPUINFO_PTR_BURN: info->burn = 0; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = h8_disasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &h8_cyccnt; break; case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(h83002_state); break; case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 2; break; diff --git a/src/emu/cpu/hd6309/hd6309.c b/src/emu/cpu/hd6309/hd6309.c index 9183d6a1151..b8d9c4237d1 100644 --- a/src/emu/cpu/hd6309/hd6309.c +++ b/src/emu/cpu/hd6309/hd6309.c @@ -118,9 +118,7 @@ #define false 0 #endif -#ifdef ENABLE_DEBUGGER extern offs_t hd6309_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /*#define BIG_SWITCH*/ @@ -629,7 +627,7 @@ static int hd6309_execute(int cycles) /* NS 970908 */ if (hd6309.int_state & (HD6309_CWAI | HD6309_SYNC)) { - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); hd6309_ICount = 0; } else @@ -638,7 +636,7 @@ static int hd6309_execute(int cycles) /* NS 970908 */ { pPPC = pPC; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); hd6309.ireg = ROP(PCD); PC++; @@ -1296,9 +1294,7 @@ void hd6309_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = hd6309_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = hd6309_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = hd6309_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &hd6309_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/i386/i386.c b/src/emu/cpu/i386/i386.c index 6182137d941..956d4954d09 100644 --- a/src/emu/cpu/i386/i386.c +++ b/src/emu/cpu/i386/i386.c @@ -15,9 +15,7 @@ #include "i386.h" #include "i386intf.h" -#ifdef ENABLE_DEBUGGER #include "debug/debugcpu.h" -#endif int i386_parity_table[256]; MODRM_TABLE i386_MODRM_table[256]; @@ -443,8 +441,6 @@ static void I386OP(decode_two_byte)(void) /*************************************************************************/ -#ifdef ENABLE_DEBUGGER - static UINT64 i386_debug_segbase(UINT32 ref, UINT32 params, UINT64 *param) { UINT32 result; @@ -485,8 +481,6 @@ static void i386_debug_setup(void) symtable_add_function(global_symtable, "seglimit", 0, 1, 1, i386_debug_seglimit); } -#endif /* defined(ENABLE_DEBUGGER) */ - /*************************************************************************/ static STATE_POSTLOAD( i386_postload ) @@ -717,7 +711,7 @@ static int i386_execute(int num_cycles) I.segment_prefix = 0; I.prev_eip = I.eip; - CALL_DEBUGGER(I.pc); + debugger_instruction_hook(Machine, I.pc); i386_check_irq_line(); I386OP(decode_opcode)(); @@ -741,12 +735,10 @@ static int translate_address_cb(int space, int intention, offs_t *addr) return result; } -#ifdef ENABLE_DEBUGGER static offs_t i386_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return i386_dasm_one(buffer, pc, oprom, I.sreg[CS].d ? 32 : 16); } -#endif /* ENABLE_DEBUGGER */ static void i386_set_info(UINT32 state, cpuinfo *info) { @@ -969,10 +961,8 @@ void i386_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_BURN: info->burn = NULL; break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &I.cycles; break; case CPUINFO_PTR_TRANSLATE: info->translate = translate_address_cb; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i386_dasm; break; case CPUINFO_PTR_DEBUG_SETUP_COMMANDS: info->setup_commands = i386_debug_setup; break; -#endif /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "I386"); break; diff --git a/src/emu/cpu/i386/i386.h b/src/emu/cpu/i386/i386.h index 3f977385369..9fd26383c6f 100644 --- a/src/emu/cpu/i386/i386.h +++ b/src/emu/cpu/i386/i386.h @@ -10,9 +10,7 @@ #define INPUT_LINE_A20 1 -#ifdef ENABLE_DEBUGGER extern int i386_dasm_one(char *buffer, UINT32 pc, const UINT8 *oprom, int mode); -#endif typedef enum { ES, CS, SS, DS, FS, GS } SREGS; diff --git a/src/emu/cpu/i8039/i8039.c b/src/emu/cpu/i8039/i8039.c index 566baa41cda..baeaf0e7f67 100644 --- a/src/emu/cpu/i8039/i8039.c +++ b/src/emu/cpu/i8039/i8039.c @@ -761,7 +761,7 @@ static int i8039_execute(int cycles) { R.PREVPC = R.PC; - CALL_DEBUGGER(R.PC.w.l); + debugger_instruction_hook(Machine, R.PC.w.l); opcode=M_RDOP(R.PC.w.l); @@ -956,9 +956,7 @@ void i8039_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = i8039_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = i8039_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i8039_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &i8039_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/i8039/i8039.h b/src/emu/cpu/i8039/i8039.h index da2388931f4..4508e3a3c35 100644 --- a/src/emu/cpu/i8039/i8039.h +++ b/src/emu/cpu/i8039/i8039.h @@ -241,8 +241,6 @@ extern void m58715_get_info(UINT32 state, cpuinfo *info); */ #define I8039_RDOP_ARG(A) ((unsigned)cpu_readop_arg(A)) -#ifdef ENABLE_DEBUGGER offs_t i8039_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _I8039_H */ diff --git a/src/emu/cpu/i8051/i8051.c b/src/emu/cpu/i8051/i8051.c index 0876ea0c459..24650eac7bb 100644 --- a/src/emu/cpu/i8051/i8051.c +++ b/src/emu/cpu/i8051/i8051.c @@ -600,7 +600,7 @@ int i8051_execute(int cycles) PPC = PC; //Call Debugger - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); //remove after testing if(PC != PPC) op = cpu_readop(PC); @@ -1948,9 +1948,7 @@ INLINE void do_add_flags(UINT8 a, UINT8 data, UINT8 c) SET_AC(ac); SET_OV(ov); -#ifdef ENABLE_DEBUGGER // mame_printf_debug("add: result=%x, c=%x, ac=%x, ov=%x\n",a+data+c,cy,ac,ov); -#endif } INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c) @@ -1966,9 +1964,7 @@ INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c) SET_AC(ac); SET_OV(ov); -#ifdef ENABLE_DEBUGGER // mame_printf_debug("sub: a=%x, d=%x, c=%x, result=%x, cy=%x, ac=%x, ov=%x\n",a,data,c,a-data-c,cy,ac,ov); -#endif } INLINE void update_timer(int cyc) @@ -2477,9 +2473,7 @@ void i8051_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = i8051_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = i8051_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i8051_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &i8051_icount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = NULL; break; diff --git a/src/emu/cpu/i8051/i8051.h b/src/emu/cpu/i8051/i8051.h index a386306abc8..a3832b2ff47 100644 --- a/src/emu/cpu/i8051/i8051.h +++ b/src/emu/cpu/i8051/i8051.h @@ -114,9 +114,7 @@ extern void i8051_set_serial_tx_callback(void (*callback)(int data)); extern void i8051_set_serial_rx_callback(int (*callback)(void)); extern void i8051_set_eram_iaddr_callback(READ32_HANDLER((*callback))); -#ifdef ENABLE_DEBUGGER extern offs_t i8051_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ /**************************************************************************** * 8752 Section diff --git a/src/emu/cpu/i8085/i8085.c b/src/emu/cpu/i8085/i8085.c index ba63205d2a8..1f2b11a7090 100644 --- a/src/emu/cpu/i8085/i8085.c +++ b/src/emu/cpu/i8085/i8085.c @@ -1298,7 +1298,7 @@ static int i8085_execute(int cycles) i8085_ICount = cycles; do { - CALL_DEBUGGER(I.PC.d); + debugger_instruction_hook(Machine, I.PC.d); /* interrupts enabled or TRAP pending ? */ if ( (I.IM & IM_IEN) || (I.IREQ & IM_TRAP) ) { @@ -1728,9 +1728,7 @@ void i8085_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = i8085_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = i8085_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i8085_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &i8085_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/i8085/i8085.h b/src/emu/cpu/i8085/i8085.h index 4e94cfef638..02a7a9f909e 100644 --- a/src/emu/cpu/i8085/i8085.h +++ b/src/emu/cpu/i8085/i8085.h @@ -51,8 +51,6 @@ void i8085_get_info(UINT32 state, cpuinfo *info); void i8080_get_info(UINT32 state, cpuinfo *info); #endif -#ifdef ENABLE_DEBUGGER offs_t i8085_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/i86/i286.c b/src/emu/cpu/i86/i286.c index 445bb558b06..a79f50702fa 100644 --- a/src/emu/cpu/i86/i286.c +++ b/src/emu/cpu/i86/i286.c @@ -225,7 +225,7 @@ static int i80286_execute(int num_cycles) while(i80286_ICount>0) { LOG(("[%04x:%04x]=%02x\tF:%04x\tAX=%04x\tBX=%04x\tCX=%04x\tDX=%04x %d%d%d%d%d%d%d%d%d\n",I.sregs[CS],I.pc - I.base[CS],ReadByte(I.pc),I.flags,I.regs.w[AX],I.regs.w[BX],I.regs.w[CX],I.regs.w[DX], I.AuxVal?1:0, I.OverVal?1:0, I.SignVal?1:0, I.ZeroVal?1:0, I.CarryVal?1:0, I.ParityVal?1:0,I.TF, I.IF, I.DirVal<0?1:0)); - CALL_DEBUGGER(I.pc); + debugger_instruction_hook(Machine, I.pc); seg_prefix=FALSE; I.prevpc = I.pc; @@ -242,12 +242,10 @@ static int i80286_execute(int num_cycles) extern int i386_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom, int mode); -#ifdef ENABLE_DEBUGGER static offs_t i80286_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return i386_dasm_one(buffer, pc, oprom, 16); } -#endif /* ENABLE_DEBUGGER */ static void i80286_init(int index, int clock, const void *config, int (*irqcallback)(int)) { @@ -445,9 +443,7 @@ void i80286_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = NULL; break; case CPUINFO_PTR_EXECUTE: info->execute = i80286_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i80286_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &i80286_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/i86/i86.c b/src/emu/cpu/i86/i86.c index add38604b7a..2b992c5d4c4 100644 --- a/src/emu/cpu/i86/i86.c +++ b/src/emu/cpu/i86/i86.c @@ -244,7 +244,7 @@ static int i8086_execute(int num_cycles) LOG(("[%04x:%04x]=%02x\tF:%04x\tAX=%04x\tBX=%04x\tCX=%04x\tDX=%04x %d%d%d%d%d%d%d%d%d\n", I.sregs[CS], I.pc - I.base[CS], ReadByte(I.pc), I.flags, I.regs.w[AX], I.regs.w[BX], I.regs.w[CX], I.regs.w[DX], I.AuxVal ? 1 : 0, I.OverVal ? 1 : 0, I.SignVal ? 1 : 0, I.ZeroVal ? 1 : 0, I.CarryVal ? 1 : 0, I.ParityVal ? 1 : 0, I.TF, I.IF, I.DirVal < 0 ? 1 : 0)); - CALL_DEBUGGER(I.pc); + debugger_instruction_hook(Machine, I.pc); seg_prefix = FALSE; I.prevpc = I.pc; @@ -259,12 +259,10 @@ static int i8086_execute(int num_cycles) } -#ifdef ENABLE_DEBUGGER static offs_t i8086_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return i386_dasm_one(buffer, pc, oprom, 16); } -#endif /* ENABLE_DEBUGGER */ #if (HAS_I80186 || HAS_I80188) @@ -299,7 +297,7 @@ static int i80186_execute(int num_cycles) { LOG(("[%04x:%04x]=%02x\tAX=%04x\tBX=%04x\tCX=%04x\tDX=%04x\n", I.sregs[CS], I.pc, ReadByte(I.pc), I.regs.w[AX], I.regs.w[BX], I.regs.w[CX], I.regs.w[DX])); - CALL_DEBUGGER(I.pc); + debugger_instruction_hook(Machine, I.pc); seg_prefix = FALSE; I.prevpc = I.pc; @@ -436,9 +434,7 @@ void i8086_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = i8086_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = i8086_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i8086_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &i8086_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/i86/instr86.c b/src/emu/cpu/i86/instr86.c index 0ede0be802f..a11617131d6 100644 --- a/src/emu/cpu/i86/instr86.c +++ b/src/emu/cpu/i86/instr86.c @@ -3128,7 +3128,7 @@ static void PREFIX86(_invalid)(void) i80286_trap2(ILLEGAL_INSTRUCTION); #else /* makes the cpu loops forever until user resets it */ - /*{ DEBUGGER_BREAK; } */ + /*{ debugger_break(Machine); } */ logerror("illegal instruction %.2x at %.5x\n",PEEKBYTE(I.pc), I.pc); I.pc--; ICOUNT -= 10; diff --git a/src/emu/cpu/i8x41/i8x41.c b/src/emu/cpu/i8x41/i8x41.c index fe9af9f6f09..f4740359027 100644 --- a/src/emu/cpu/i8x41/i8x41.c +++ b/src/emu/cpu/i8x41/i8x41.c @@ -1402,7 +1402,7 @@ static int i8x41_execute(int cycles) PPC = PC; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); PC += 1; i8x41_ICount -= i8x41_cycles[op]; @@ -2283,9 +2283,7 @@ void i8x41_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = i8x41_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = i8x41_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i8x41_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &i8x41_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/i8x41/i8x41.h b/src/emu/cpu/i8x41/i8x41.h index 4c12f349e95..41830aa7266 100644 --- a/src/emu/cpu/i8x41/i8x41.h +++ b/src/emu/cpu/i8x41/i8x41.h @@ -91,8 +91,6 @@ enum { extern void i8x41_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern offs_t i8x41_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _I8X41_H */ diff --git a/src/emu/cpu/i960/i960.c b/src/emu/cpu/i960/i960.c index 267a096bf9a..5283f30516f 100644 --- a/src/emu/cpu/i960/i960.c +++ b/src/emu/cpu/i960/i960.c @@ -618,7 +618,7 @@ static int i960_execute(int cycles) check_irqs(); while(i960_icount >= 0) { i960.PIP = i960.IP; - CALL_DEBUGGER(i960.IP); + debugger_instruction_hook(Machine, i960.IP); i960.bursting = 0; @@ -2067,7 +2067,6 @@ static void i960_init(int index, int clock, const void *config, int (*irqcallbac state_save_register_item_array("i960", index, i960.rcache_frame_addr); } -#ifdef ENABLE_DEBUGGER static offs_t i960_disasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { disassemble_t dis; @@ -2080,7 +2079,6 @@ static offs_t i960_disasm(char *buffer, offs_t pc, const UINT8 *oprom, const UIN return dis.IPinc | dis.disflags | DASMFLAG_SUPPORTED; } -#endif /* ENABLE_DEBUGGER */ static void i960_reset(void) { @@ -2118,9 +2116,7 @@ void i960_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = 0; break; case CPUINFO_PTR_EXECUTE: info->execute = i960_execute; break; case CPUINFO_PTR_BURN: info->burn = 0; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i960_disasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &i960_icount; break; case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(i960_state); break; case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 4; break; diff --git a/src/emu/cpu/jaguar/jaguar.c b/src/emu/cpu/jaguar/jaguar.c index e525a996aaf..58618215a83 100644 --- a/src/emu/cpu/jaguar/jaguar.c +++ b/src/emu/cpu/jaguar/jaguar.c @@ -522,7 +522,7 @@ static int jaguargpu_execute(int cycles) /* debugging */ //if (jaguar.PC < 0xf03000 || jaguar.PC > 0xf04000) { fatalerror("GPU: jaguar.PC = %06X (ppc = %06X)", jaguar.PC, jaguar.ppc); } jaguar.ppc = jaguar.PC; - CALL_DEBUGGER(jaguar.PC); + debugger_instruction_hook(Machine, jaguar.PC); /* instruction fetch */ jaguar.op = ROPCODE(jaguar.PC); @@ -568,7 +568,7 @@ static int jaguardsp_execute(int cycles) /* debugging */ //if (jaguar.PC < 0xf1b000 || jaguar.PC > 0xf1d000) { fatalerror(stderr, "DSP: jaguar.PC = %06X", jaguar.PC); } jaguar.ppc = jaguar.PC; - CALL_DEBUGGER(jaguar.PC); + debugger_instruction_hook(Machine, jaguar.PC); /* instruction fetch */ jaguar.op = ROPCODE(jaguar.PC); @@ -595,7 +595,6 @@ static int jaguardsp_execute(int cycles) DISASSEMBLY HOOK ***************************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t jaguargpu_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { extern unsigned dasmjag(int, char *, unsigned, const UINT8 *); @@ -607,7 +606,6 @@ static offs_t jaguardsp_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const extern unsigned dasmjag(int, char *, unsigned, const UINT8 *); return dasmjag(JAGUAR_VARIANT_DSP, buffer, pc, oprom); } -#endif /* ENABLE_DEBUGGER */ @@ -806,7 +804,7 @@ void jr_cc_n(void) { INT32 r1 = (INT8)((jaguar.op >> 2) & 0xf8) >> 2; UINT32 newpc = jaguar.PC + r1; - CALL_DEBUGGER(jaguar.PC); + debugger_instruction_hook(Machine, jaguar.PC); jaguar.op = ROPCODE(jaguar.PC); jaguar.PC = newpc; (*jaguar.table[jaguar.op >> 10])(); @@ -823,7 +821,7 @@ void jump_cc_rn(void) /* special kludge for risky code in the cojag DSP interrupt handlers */ UINT32 newpc = (jaguar_icount == bankswitch_icount) ? jaguar.a[reg] : jaguar.r[reg]; - CALL_DEBUGGER(jaguar.PC); + debugger_instruction_hook(Machine, jaguar.PC); jaguar.op = ROPCODE(jaguar.PC); jaguar.PC = newpc; (*jaguar.table[jaguar.op >> 10])(); @@ -1659,9 +1657,7 @@ void jaguargpu_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = jaguar_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = jaguargpu_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = jaguargpu_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &jaguar_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -1754,9 +1750,7 @@ void jaguardsp_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_INIT: info->init = jaguardsp_init; break; case CPUINFO_PTR_RESET: info->reset = jaguardsp_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = jaguardsp_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = jaguardsp_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "Jaguar DSP"); break; diff --git a/src/emu/cpu/konami/konami.c b/src/emu/cpu/konami/konami.c index b4460fa5054..b3adc589a39 100644 --- a/src/emu/cpu/konami/konami.c +++ b/src/emu/cpu/konami/konami.c @@ -501,7 +501,7 @@ static int konami_execute(int cycles) { pPPC = pPC; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); konami.ireg = ROP(PCD); PC++; @@ -609,9 +609,7 @@ void konami_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = konami_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = konami_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = konami_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &konami_ICount; break; case CPUINFO_PTR_KONAMI_SETLINES_CALLBACK: info->f = (genf *)konami.setlines_callback; break; diff --git a/src/emu/cpu/konami/konami.h b/src/emu/cpu/konami/konami.h index 2aa2584fbb0..75fc6f3d24f 100644 --- a/src/emu/cpu/konami/konami.h +++ b/src/emu/cpu/konami/konami.h @@ -51,8 +51,6 @@ void konami_get_info(UINT32 state, cpuinfo *info); # define TRUE (!FALSE) #endif -#ifdef ENABLE_DEBUGGER offs_t konami_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _KONAMI_H */ diff --git a/src/emu/cpu/lh5801/lh5801.c b/src/emu/cpu/lh5801/lh5801.c index 3654e4b8a2a..bb2f9d509bd 100644 --- a/src/emu/cpu/lh5801/lh5801.c +++ b/src/emu/cpu/lh5801/lh5801.c @@ -131,7 +131,7 @@ static int lh5801_execute(int cycles) { lh5801.oldpc = P; - CALL_DEBUGGER(P); + debugger_instruction_hook(Machine, P); lh5801_instruction(); } while (lh5801_icount > 0); @@ -234,9 +234,7 @@ void lh5801_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = NULL; break; case CPUINFO_PTR_EXECUTE: info->execute = lh5801_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = lh5801_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &lh5801_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/lr35902/lr35902.c b/src/emu/cpu/lr35902/lr35902.c index a8d557498f4..1b131b12031 100644 --- a/src/emu/cpu/lr35902/lr35902.c +++ b/src/emu/cpu/lr35902/lr35902.c @@ -306,7 +306,7 @@ static int lr35902_execute (int cycles) } else { /* Fetch and count cycles */ lr35902_ProcessInterrupts (); - CALL_DEBUGGER(Regs.w.PC); + debugger_instruction_hook(Machine, Regs.w.PC); if ( Regs.w.enable & HALTED ) { CYCLES_PASSED( Cycles[0x76] ); Regs.w.execution_state = 1; @@ -464,10 +464,7 @@ void lr35902_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = lr35902_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = lr35902_execute; break; case CPUINFO_PTR_BURN: info->burn = lr35902_burn; break; - -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = lr35902_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &lr35902_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/lr35902/lr35902.h b/src/emu/cpu/lr35902/lr35902.h index b3c1c08dd3b..41774ec1404 100644 --- a/src/emu/cpu/lr35902/lr35902.h +++ b/src/emu/cpu/lr35902/lr35902.h @@ -25,8 +25,6 @@ enum { /****************************************************************************/ extern void lr35902_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned lr35902_dasm( char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram ); -#endif /* ENABLE_DEBUGGER */ #endif diff --git a/src/emu/cpu/m37710/m37710.c b/src/emu/cpu/m37710/m37710.c index 24389699816..0fa07e0e2b3 100644 --- a/src/emu/cpu/m37710/m37710.c +++ b/src/emu/cpu/m37710/m37710.c @@ -1033,14 +1033,12 @@ void m37710_set_irq_callback(int (*callback)(int)) #endif /* Disassemble an instruction */ -#ifdef ENABLE_DEBUGGER #include "m7700ds.h" static offs_t m37710_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return m7700_disassemble(buffer, (pc&0xffff), pc>>16, oprom, FLAG_M, FLAG_X); } -#endif /* ENABLE_DEBUGGER */ static STATE_POSTLOAD( m37710_restore_state ) { @@ -1225,9 +1223,7 @@ void m37710_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m37710_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m37710_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m37710_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m37710_ICount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map16 = address_map_m37710_internal_map; break; diff --git a/src/emu/cpu/m37710/m37710.h b/src/emu/cpu/m37710/m37710.h index b513e07b70d..5e108c9af10 100644 --- a/src/emu/cpu/m37710/m37710.h +++ b/src/emu/cpu/m37710/m37710.h @@ -104,7 +104,7 @@ void m37710_state_load(void *file); #undef M37710_CALL_DEBUGGER -#define M37710_CALL_DEBUGGER CALL_DEBUGGER +#define M37710_CALL_DEBUGGER(x) debugger_instruction_hook(Machine, x) #define m37710_read_8(addr) program_read_byte_16le(addr) #define m37710_write_8(addr,data) program_write_byte_16le(addr,data) #define m37710_read_8_immediate(A) program_read_byte_16le(A) diff --git a/src/emu/cpu/m6502/m4510.c b/src/emu/cpu/m6502/m4510.c index 42d77a4f874..92285fe03b3 100644 --- a/src/emu/cpu/m6502/m4510.c +++ b/src/emu/cpu/m6502/m4510.c @@ -263,7 +263,7 @@ static int m4510_execute(int cycles) UINT8 op; PPC = PCD; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); /* if an irq is pending, take it now */ if( m4510.pending_irq ) @@ -493,9 +493,7 @@ void m4510_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m4510_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m4510_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m4510_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m4510_ICount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP: info->internal_map8 = address_map_m4510_mem; break; case CPUINFO_PTR_TRANSLATE: info->translate = m4510_translate; break; diff --git a/src/emu/cpu/m6502/m4510.h b/src/emu/cpu/m6502/m4510.h index aa3c2a8e1b7..5f772bb5e39 100644 --- a/src/emu/cpu/m6502/m4510.h +++ b/src/emu/cpu/m6502/m4510.h @@ -39,9 +39,7 @@ enum { void m4510_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned m4510_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ #endif diff --git a/src/emu/cpu/m6502/m6502.c b/src/emu/cpu/m6502/m6502.c index a2711726824..8317e785f2e 100644 --- a/src/emu/cpu/m6502/m6502.c +++ b/src/emu/cpu/m6502/m6502.c @@ -230,7 +230,7 @@ static int m6502_execute(int cycles) UINT8 op; PPC = PCD; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); /* if an irq is pending, take it now */ if( m6502.pending_irq ) @@ -449,7 +449,7 @@ static int m65c02_execute(int cycles) UINT8 op; PPC = PCD; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); op = RDOP(); (*m6502.insn[op])(); @@ -620,7 +620,7 @@ static int deco16_execute(int cycles) UINT8 op; PPC = PCD; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); op = RDOP(); (*m6502.insn[op])(); @@ -747,9 +747,7 @@ void m6502_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m6502_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m6502_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6502_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m6502_ICount; break; case CPUINFO_PTR_M6502_READINDEXED_CALLBACK: info->f = (genf *) m6502.rdmem_id; break; case CPUINFO_PTR_M6502_WRITEINDEXED_CALLBACK: info->f = (genf *) m6502.wrmem_id; break; @@ -831,9 +829,7 @@ void m6510_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_SET_INFO: info->setinfo = m6510_set_info; break; case CPUINFO_PTR_INIT: info->init = m6510_init; break; case CPUINFO_PTR_RESET: info->reset = m6510_reset; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6510_dasm; break; -#endif case CPUINFO_PTR_INTERNAL_MEMORY_MAP: info->internal_map8 = address_map_m6510_mem; break; case CPUINFO_PTR_M6510_PORTREAD: info->f = (genf *) m6502.port_read; break; case CPUINFO_PTR_M6510_PORTWRITE: info->f = (genf *) m6502.port_write; break; @@ -929,9 +925,7 @@ void m65c02_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_INIT: info->init = m65c02_init; break; case CPUINFO_PTR_RESET: info->reset = m65c02_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = m65c02_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m65c02_dasm; break; -#endif /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "M65C02"); break; @@ -953,9 +947,7 @@ void m65sc02_get_info(UINT32 state, cpuinfo *info) { /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = m65sc02_init; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m65sc02_dasm; break; -#endif /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "M65SC02"); break; @@ -1001,9 +993,7 @@ void deco16_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_INIT: info->init = deco16_init; break; case CPUINFO_PTR_RESET: info->reset = deco16_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = deco16_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = deco16_dasm; break; -#endif /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "DECO CPU16"); break; diff --git a/src/emu/cpu/m6502/m6502.h b/src/emu/cpu/m6502/m6502.h index 262c8c29ac1..dfc29c8616f 100644 --- a/src/emu/cpu/m6502/m6502.h +++ b/src/emu/cpu/m6502/m6502.h @@ -71,9 +71,7 @@ enum extern void m6502_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned m6502_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /**************************************************************************** * The 6510 @@ -94,9 +92,7 @@ extern unsigned m6502_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UI extern void m6510_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned m6510_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif @@ -201,9 +197,7 @@ extern void n2a03_irq(void); extern void m65c02_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned m65c02_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif @@ -226,10 +220,8 @@ extern unsigned m65c02_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const U extern void m65sc02_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned m65sc02_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); #endif -#endif /**************************************************************************** * The DECO CPU16 @@ -251,9 +243,7 @@ extern unsigned m65sc02_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const extern void deco16_get_info(UINT32 state, cpuinfo *info); #endif -#ifdef ENABLE_DEBUGGER extern unsigned deco16_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _M6502_H */ diff --git a/src/emu/cpu/m6502/m6509.c b/src/emu/cpu/m6502/m6509.c index fc4e026d54a..39493549326 100644 --- a/src/emu/cpu/m6502/m6509.c +++ b/src/emu/cpu/m6502/m6509.c @@ -204,7 +204,7 @@ static int m6509_execute(int cycles) UINT8 op; PPC = PCD; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); /* if an irq is pending, take it now */ if( m6509.pending_irq ) @@ -372,9 +372,7 @@ void m6509_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m6509_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m6509_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6502_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m6502_ICount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP: info->internal_map8 = address_map_m6509_mem; break; case CPUINFO_PTR_M6502_READINDEXED_CALLBACK: info->f = (genf *) m6509.rdmem_id; break; diff --git a/src/emu/cpu/m6502/m65ce02.c b/src/emu/cpu/m6502/m65ce02.c index c8a0bf00d45..5630cface38 100644 --- a/src/emu/cpu/m6502/m65ce02.c +++ b/src/emu/cpu/m6502/m65ce02.c @@ -168,7 +168,7 @@ static int m65ce02_execute(int cycles) UINT8 op; PPC = PCD; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); /* if an irq is pending, take it now */ if( m65ce02.pending_irq ) @@ -323,9 +323,7 @@ void m65ce02_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m65ce02_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m65ce02_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m65ce02_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m65ce02_ICount; break; case CPUINFO_PTR_M6502_READINDEXED_CALLBACK: info->f = (genf *) m65ce02.rdmem_id; break; case CPUINFO_PTR_M6502_WRITEINDEXED_CALLBACK: info->f = (genf *) m65ce02.wrmem_id; break; diff --git a/src/emu/cpu/m6502/m65ce02.h b/src/emu/cpu/m6502/m65ce02.h index d31d3b0c48c..77463462b1d 100644 --- a/src/emu/cpu/m6502/m65ce02.h +++ b/src/emu/cpu/m6502/m65ce02.h @@ -34,9 +34,7 @@ enum { void m65ce02_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned m65ce02_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _M65CE02_H */ diff --git a/src/emu/cpu/m6800/m6800.c b/src/emu/cpu/m6800/m6800.c index f6368db6516..2eaf4ce1579 100644 --- a/src/emu/cpu/m6800/m6800.c +++ b/src/emu/cpu/m6800/m6800.c @@ -264,7 +264,7 @@ enum #define ONE_MORE_INSN() { \ UINT8 ireg; \ pPPC = pPC; \ - CALL_DEBUGGER(PCD); \ + debugger_instruction_hook(Machine, PCD); \ ireg=M_RDOP(PCD); \ PC++; \ (*m6800.insn[ireg])(); \ @@ -987,7 +987,7 @@ static int m6800_execute(int cycles) else { pPPC = pPC; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); ireg=M_RDOP(PCD); PC++; @@ -1334,7 +1334,7 @@ static int m6803_execute(int cycles) else { pPPC = pPC; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); ireg=M_RDOP(PCD); PC++; @@ -1674,7 +1674,7 @@ static int hd63701_execute(int cycles) else { pPPC = pPC; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); ireg=M_RDOP(PCD); PC++; @@ -2006,7 +2006,7 @@ static int nsc8105_execute(int cycles) else { pPPC = pPC; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); ireg=M_RDOP(PCD); PC++; @@ -2652,9 +2652,7 @@ void m6800_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m6800_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m6800_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6800_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m6800_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -2704,9 +2702,7 @@ void m6801_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = m6801_init; break; case CPUINFO_PTR_EXECUTE: info->execute = m6803_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6801_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "M6801"); break; @@ -2731,9 +2727,7 @@ void m6802_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = m6802_init; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6802_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "M6802"); break; @@ -2761,9 +2755,7 @@ void m6803_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = m6803_init; break; case CPUINFO_PTR_EXECUTE: info->execute = m6803_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6803_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_m6803_mem; break; @@ -2790,9 +2782,7 @@ void m6808_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = m6808_init; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6808_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "M6808"); break; @@ -2820,9 +2810,7 @@ void hd63701_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = hd63701_init; break; case CPUINFO_PTR_EXECUTE: info->execute = hd63701_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = hd63701_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "HD63701"); break; @@ -2848,9 +2836,7 @@ void nsc8105_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = nsc8105_init; break; case CPUINFO_PTR_EXECUTE: info->execute = nsc8105_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = nsc8105_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "NSC8105"); break; diff --git a/src/emu/cpu/m6800/m6800.h b/src/emu/cpu/m6800/m6800.h index 4b5c5cdb898..74e7fd56bea 100644 --- a/src/emu/cpu/m6800/m6800.h +++ b/src/emu/cpu/m6800/m6800.h @@ -210,7 +210,6 @@ extern void nsc8105_get_info(UINT32 state, cpuinfo *info); # define TRUE (!FALSE) #endif -#ifdef ENABLE_DEBUGGER offs_t m6800_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t m6801_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t m6802_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); @@ -218,6 +217,5 @@ offs_t m6803_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opra offs_t m6808_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t hd63701_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t nsc8105_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _M6800_H */ diff --git a/src/emu/cpu/m68000/m68kmame.c b/src/emu/cpu/m68000/m68kmame.c index 43fd57adb6b..bf973fc8c66 100644 --- a/src/emu/cpu/m68000/m68kmame.c +++ b/src/emu/cpu/m68000/m68kmame.c @@ -197,13 +197,11 @@ static void m68000_set_context(void *src) m68k_set_context(src); } -#ifdef ENABLE_DEBUGGER static offs_t m68000_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { M68K_SET_PC_CALLBACK(pc); return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68000); } -#endif /* ENABLE_DEBUGGER */ /**************************************************************************** * M68008 section @@ -246,13 +244,11 @@ static void m68008_set_context(void *src) m68k_set_context(src); } -#ifdef ENABLE_DEBUGGER static offs_t m68008_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { M68K_SET_PC_CALLBACK(pc); return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68008); } -#endif /* ENABLE_DEBUGGER */ #endif /* HAS_M68008 */ @@ -270,13 +266,11 @@ static void m68010_init(int index, int clock, const void *config, int (*irqcallb m68k_set_int_ack_callback(irqcallback); } -#ifdef ENABLE_DEBUGGER static offs_t m68010_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { M68K_SET_PC_CALLBACK(pc); return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68010); } -#endif /* ENABLE_DEBUGGER */ #endif /* HAS_M68010 */ @@ -320,13 +314,11 @@ static void m68020_set_context(void *src) m68k_set_context(src); } -#ifdef ENABLE_DEBUGGER static offs_t m68020_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { M68K_SET_PC_CALLBACK(pc); return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68020); } -#endif /* ENABLE_DEBUGGER */ /**************************************************************************** @@ -343,13 +335,11 @@ static void m68ec020_init(int index, int clock, const void *config, int (*irqcal m68k_set_int_ack_callback(irqcallback); } -#ifdef ENABLE_DEBUGGER static offs_t m68ec020_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { M68K_SET_PC_CALLBACK(pc); return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68EC020); } -#endif /* ENABLE_DEBUGGER */ #endif /* HAS_M68EC020 */ @@ -394,13 +384,11 @@ static void m68040_set_context(void *src) m68k_set_context(src); } -#ifdef ENABLE_DEBUGGER static offs_t m68040_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { M68K_SET_PC_CALLBACK(pc); return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68040); } -#endif /* ENABLE_DEBUGGER */ #endif /* HAS_M68040 */ @@ -533,9 +521,7 @@ void m68000_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m68000_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m68000_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m68000_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m68k_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -713,9 +699,7 @@ void m68008_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m68008_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m68008_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m68008_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m68k_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -804,9 +788,8 @@ void m68010_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_SET_INFO: info->setinfo = m68010_set_info; break; case CPUINFO_PTR_INIT: info->init = m68010_init; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m68010_dasm; break; -#endif /* ENABLE_DEBUGGER */ + /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "68010"); break; case CPUINFO_STR_REGISTER + M68K_SFC: sprintf(info->s, "SFC:%X", m68k_get_reg(NULL, M68K_REG_SFC)); break; @@ -954,9 +937,7 @@ void m68020_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m68020_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m68020_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m68020_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m68k_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -1047,9 +1028,7 @@ void m68ec020_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_SET_INFO: info->setinfo = m68ec020_set_info; break; case CPUINFO_PTR_INIT: info->init = m68ec020_init; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m68ec020_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "68EC020"); break; @@ -1196,9 +1175,7 @@ void m68040_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m68040_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m68040_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m68040_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m68k_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/m68000/m68kmame.h b/src/emu/cpu/m68000/m68kmame.h index 29915aed12c..83dd8d40de0 100644 --- a/src/emu/cpu/m68000/m68kmame.h +++ b/src/emu/cpu/m68000/m68kmame.h @@ -40,7 +40,7 @@ #define M68K_SET_PC_CALLBACK(A) change_pc(A) #define M68K_INSTRUCTION_HOOK OPT_SPECIFY_HANDLER -#define M68K_INSTRUCTION_CALLBACK(A) CALL_DEBUGGER(A) +#define M68K_INSTRUCTION_CALLBACK(A) debugger_instruction_hook(Machine, A) #define M68K_EMULATE_PREFETCH OPT_ON diff --git a/src/emu/cpu/m6805/m6805.c b/src/emu/cpu/m6805/m6805.c index 822e5a078ff..0a69b51e288 100644 --- a/src/emu/cpu/m6805/m6805.c +++ b/src/emu/cpu/m6805/m6805.c @@ -522,7 +522,7 @@ static int m6805_execute(int cycles) } } - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); ireg=M_RDOP(PC++); @@ -939,9 +939,7 @@ void m6805_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m6805_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m6805_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6805_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m6805_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/m6805/m6805.h b/src/emu/cpu/m6805/m6805.h index 1aa779e8580..154fb060283 100644 --- a/src/emu/cpu/m6805/m6805.h +++ b/src/emu/cpu/m6805/m6805.h @@ -82,8 +82,6 @@ extern void hd63705_get_info(UINT32 state, cpuinfo *info); /****************************************************************************/ #define M6805_RDOP_ARG(Addr) ((unsigned)cpu_readop_arg(Addr)) -#ifdef ENABLE_DEBUGGER offs_t m6805_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _M6805_H */ diff --git a/src/emu/cpu/m6809/m6809.c b/src/emu/cpu/m6809/m6809.c index 53a64b0b8e7..0024874b0ba 100644 --- a/src/emu/cpu/m6809/m6809.c +++ b/src/emu/cpu/m6809/m6809.c @@ -82,9 +82,7 @@ #define LOG(x) do { if (VERBOSE) logerror x; } while (0) -#ifdef ENABLE_DEBUGGER extern offs_t m6809_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif INLINE void fetch_effective_address( void ); @@ -517,7 +515,7 @@ static int m6809_execute(int cycles) /* NS 970908 */ if (m6809.int_state & (M6809_CWAI | M6809_SYNC)) { - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); m6809_ICount = 0; } else @@ -526,7 +524,7 @@ static int m6809_execute(int cycles) /* NS 970908 */ { pPPC = pPC; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); m6809.ireg = ROP(PCD); PC++; @@ -1173,9 +1171,7 @@ void m6809_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = m6809_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = m6809_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = m6809_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m6809_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/mb86233/mb86233.c b/src/emu/cpu/mb86233/mb86233.c index 3c8704f7f5c..b6eecbf915a 100644 --- a/src/emu/cpu/mb86233/mb86233.c +++ b/src/emu/cpu/mb86233/mb86233.c @@ -906,7 +906,7 @@ static int mb86233_execute(int cycles) UINT32 val; UINT32 opcode; - CALL_DEBUGGER(GETPC()); + debugger_instruction_hook(Machine, GETPC()); opcode = ROPCODE(GETPC()); @@ -1522,7 +1522,6 @@ static int mb86233_execute(int cycles) DISASSEMBLY HOOK ***************************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t mb86233_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { extern UINT32 dasm_mb86233(char *, UINT32); @@ -1531,7 +1530,7 @@ static offs_t mb86233_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UI op = LITTLE_ENDIANIZE_INT32(op); return dasm_mb86233(buffer, op); } -#endif /* ENABLE_DEBUGGER */ + /*************************************************************************** Information Setters @@ -1642,9 +1641,7 @@ void mb86233_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = NULL; break; case CPUINFO_PTR_EXECUTE: info->execute = mb86233_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = mb86233_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &mb86233_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/mb88xx/mb88xx.c b/src/emu/cpu/mb88xx/mb88xx.c index 534eae48f62..66935c4351c 100644 --- a/src/emu/cpu/mb88xx/mb88xx.c +++ b/src/emu/cpu/mb88xx/mb88xx.c @@ -236,7 +236,7 @@ static int mb88_execute(int cycles) UINT8 opcode, arg, oc; /* fetch the opcode */ - CALL_DEBUGGER(GETPC()); + debugger_instruction_hook(Machine, GETPC()); opcode = READOP(GETPC()); /* increment the PC */ @@ -850,9 +850,7 @@ void mb88_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = NULL; break; case CPUINFO_PTR_EXECUTE: info->execute = mb88_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = mb88_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &mb88_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/mb88xx/mb88xx.h b/src/emu/cpu/mb88xx/mb88xx.h index 6052926739e..e80c12e443f 100644 --- a/src/emu/cpu/mb88xx/mb88xx.h +++ b/src/emu/cpu/mb88xx/mb88xx.h @@ -71,8 +71,6 @@ void mb8842_get_info(UINT32 state, cpuinfo *info); void mb8843_get_info(UINT32 state, cpuinfo *info); void mb8844_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER offs_t mb88_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/mc68hc11/mc68hc11.c b/src/emu/cpu/mc68hc11/mc68hc11.c index b339ef9e115..c5eae242e94 100644 --- a/src/emu/cpu/mc68hc11/mc68hc11.c +++ b/src/emu/cpu/mc68hc11/mc68hc11.c @@ -384,7 +384,7 @@ static int hc11_execute(int cycles) UINT8 op; hc11.ppc = hc11.pc; - CALL_DEBUGGER(hc11.pc); + debugger_instruction_hook(Machine, hc11.pc); op = FETCH(); hc11_optable[op](); @@ -457,9 +457,7 @@ void mc68hc11_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = hc11_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = hc11_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = hc11_disasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &hc11.icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/mc68hc11/mc68hc11.h b/src/emu/cpu/mc68hc11/mc68hc11.h index 25bacc941f2..29eb6b990c3 100644 --- a/src/emu/cpu/mc68hc11/mc68hc11.h +++ b/src/emu/cpu/mc68hc11/mc68hc11.h @@ -3,9 +3,7 @@ #include "cpuintrf.h" -#ifdef ENABLE_DEBUGGER offs_t hc11_disasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif void mc68hc11_get_info(UINT32 state, cpuinfo *info); diff --git a/src/emu/cpu/minx/minx.c b/src/emu/cpu/minx/minx.c index 39a5a3a193f..cb92fb3f403 100644 --- a/src/emu/cpu/minx/minx.c +++ b/src/emu/cpu/minx/minx.c @@ -165,7 +165,7 @@ static int minx_execute( int cycles ) do { - CALL_DEBUGGER(GET_MINX_PC); + debugger_instruction_hook(Machine, GET_MINX_PC); oldpc = GET_MINX_PC; if ( regs.interrupt_pending ) @@ -354,9 +354,7 @@ void minx_get_info( UINT32 state, cpuinfo *info ) case CPUINFO_PTR_EXIT: info->exit = minx_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = minx_execute; break; case CPUINFO_PTR_BURN: info->burn = minx_burn; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = minx_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &minx_icount; break; case CPUINFO_STR_NAME: strcpy( info->s = cpuintrf_temp_str(), "Minx" ); break; case CPUINFO_STR_CORE_FAMILY: strcpy( info->s = cpuintrf_temp_str(), "Nintendo Minx" ); break; diff --git a/src/emu/cpu/minx/minx.h b/src/emu/cpu/minx/minx.h index 3b719bf37d5..0824a21bfb4 100644 --- a/src/emu/cpu/minx/minx.h +++ b/src/emu/cpu/minx/minx.h @@ -10,9 +10,7 @@ enum { MINX_XI, MINX_YI, }; -#ifdef ENABLE_DEBUGGER extern unsigned minx_dasm( char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram ); -#endif #endif diff --git a/src/emu/cpu/mips/mips3.c b/src/emu/cpu/mips/mips3.c index ed12d7f8d7a..5b1cc411a8e 100644 --- a/src/emu/cpu/mips/mips3.c +++ b/src/emu/cpu/mips/mips3.c @@ -166,7 +166,7 @@ INLINE void generate_exception(int exception, int backup) if (exception != 0) { fprintf(stderr, "Exception: PC=%08X, PPC=%08X\n", mips3.core.pc, mips3.ppc); - DEBUGGER_BREAK; + debugger_break(Machine); } */ @@ -297,13 +297,11 @@ static int mips3_translate(int space, int intention, offs_t *address) } -#ifdef ENABLE_DEBUGGER offs_t mips3_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { /* common disassemble */ return mips3com_dasm(&mips3.core, buffer, pc, oprom, opram); } -#endif /* ENABLE_DEBUGGER */ @@ -1679,7 +1677,7 @@ int mips3_execute(int cycles) /* debugging */ mips3.ppc = mips3.core.pc; - CALL_DEBUGGER(mips3.core.pc); + debugger_instruction_hook(Machine, mips3.core.pc); /* instruction fetch */ op = ROPCODE(mips3.pcbase | (mips3.core.pc & 0xfff)); @@ -2136,9 +2134,7 @@ void mips3_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_INIT: /* provided per-CPU */ break; case CPUINFO_PTR_RESET: info->reset = mips3_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = mips3_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = mips3_dasm; break; -#endif case CPUINFO_PTR_TRANSLATE: info->translate = mips3_translate; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/mips/mips3com.c b/src/emu/cpu/mips/mips3com.c index 81ddfaa8a34..df9f5ba85b4 100644 --- a/src/emu/cpu/mips/mips3com.c +++ b/src/emu/cpu/mips/mips3com.c @@ -164,7 +164,6 @@ void mips3com_reset(mips3_state *mips) CPU -------------------------------------------------*/ -#ifdef ENABLE_DEBUGGER offs_t mips3com_dasm(mips3_state *mips, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { extern unsigned dasmmips3(char *, unsigned, UINT32); @@ -175,8 +174,6 @@ offs_t mips3com_dasm(mips3_state *mips, char *buffer, offs_t pc, const UINT8 *op op = LITTLE_ENDIANIZE_INT32(op); return dasmmips3(buffer, pc, op); } -#endif /* ENABLE_DEBUGGER */ - /*------------------------------------------------- diff --git a/src/emu/cpu/mips/mips3com.h b/src/emu/cpu/mips/mips3com.h index 67de9a615d9..952158080ea 100644 --- a/src/emu/cpu/mips/mips3com.h +++ b/src/emu/cpu/mips/mips3com.h @@ -223,9 +223,7 @@ void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, int in void mips3com_exit(mips3_state *mips); void mips3com_reset(mips3_state *mips); -#ifdef ENABLE_DEBUGGER offs_t mips3com_dasm(mips3_state *mips, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif void mips3com_update_cycle_counting(mips3_state *mips); void mips3com_map_tlb_entry(mips3_state *mips, int tlbindex); diff --git a/src/emu/cpu/mips/mips3drc.c b/src/emu/cpu/mips/mips3drc.c index 8930d25d01d..7edeb7641b6 100644 --- a/src/emu/cpu/mips/mips3drc.c +++ b/src/emu/cpu/mips/mips3drc.c @@ -573,13 +573,10 @@ static int mips3_translate(int space, int intention, offs_t *address) mips3_dasm - disassemble an instruction -------------------------------------------------*/ -#ifdef ENABLE_DEBUGGER static offs_t mips3_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return mips3com_dasm(mips3, buffer, pc, oprom, opram); } -#endif /* ENABLE_DEBUGGER */ - /*------------------------------------------------- @@ -634,9 +631,7 @@ static void mips3_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = mips3_reset; break; case CPUINFO_PTR_EXIT: info->exit = mips3_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = mips3_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = mips3_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_TRANSLATE: info->translate = mips3_translate; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -1229,99 +1224,100 @@ static void static_generate_memory_accessor(drcuml_state *drcuml, int mode, int UML_JMPc(block, IF_Z, tlbmiss = label++); // jmp tlbmiss,z UML_ROLINS(block, IREG(0), IREG(3), IMM(0), IMM(0xfffff000)); // rolins i0,i3,0,0xfffff000 - for (ramnum = 0; ramnum < MIPS3_MAX_FASTRAM; ramnum++) - if (!Machine->debug_mode && mips3->impstate->fastram[ramnum].base != NULL && (!iswrite || !mips3->impstate->fastram[ramnum].readonly)) - { - void *fastbase = (UINT8 *)mips3->impstate->fastram[ramnum].base - mips3->impstate->fastram[ramnum].start; - UINT32 skip = label++; - if (mips3->impstate->fastram[ramnum].end != 0xffffffff) - { - UML_CMP(block, IREG(0), IMM(mips3->impstate->fastram[ramnum].end)); // cmp i0,end - UML_JMPc(block, IF_A, skip); // ja skip - } - if (mips3->impstate->fastram[ramnum].start != 0x00000000) - { - UML_CMP(block, IREG(0), IMM(mips3->impstate->fastram[ramnum].start));// cmp i0,fastram_start - UML_JMPc(block, IF_B, skip); // jb skip - } - - if (!iswrite) - { - if (size == 1) - { - UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0))); - // xor i0,i0,bytexor - UML_LOAD(block, IREG(0), fastbase, IREG(0), BYTE); // load i0,fastbase,i0,byte - } - else if (size == 2) - { - UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 - UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); - // xor i0,i0,bytexor - UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD); // load i0,fastbase,i0,word - } - else if (size == 4) - { - UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 - UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD); // load i0,fastbase,i0,dword - } - else if (size == 8) - { - UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 - UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD); // dload i0,fastbase,i0,qword - UML_DROR(block, IREG(0), IREG(0), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)))); - // dror i0,i0,32*bytexor - } - UML_RET(block); // ret - } - else + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) == 0) + for (ramnum = 0; ramnum < MIPS3_MAX_FASTRAM; ramnum++) + if (mips3->impstate->fastram[ramnum].base != NULL && (!iswrite || !mips3->impstate->fastram[ramnum].readonly)) { - if (size == 1) + void *fastbase = (UINT8 *)mips3->impstate->fastram[ramnum].base - mips3->impstate->fastram[ramnum].start; + UINT32 skip = label++; + if (mips3->impstate->fastram[ramnum].end != 0xffffffff) { - UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0))); - // xor i0,i0,bytexor - UML_STORE(block, fastbase, IREG(0), IREG(1), BYTE); // store fastbase,i0,i1,byte + UML_CMP(block, IREG(0), IMM(mips3->impstate->fastram[ramnum].end)); // cmp i0,end + UML_JMPc(block, IF_A, skip); // ja skip } - else if (size == 2) + if (mips3->impstate->fastram[ramnum].start != 0x00000000) { - UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 - UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); - // xor i0,i0,bytexor - UML_STORE(block, fastbase, IREG(0), IREG(1), WORD); // store fastbase,i0,i1,word + UML_CMP(block, IREG(0), IMM(mips3->impstate->fastram[ramnum].start));// cmp i0,fastram_start + UML_JMPc(block, IF_B, skip); // jb skip } - else if (size == 4) + + if (!iswrite) { - UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 - if (ismasked) + if (size == 1) + { + UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0))); + // xor i0,i0,bytexor + UML_LOAD(block, IREG(0), fastbase, IREG(0), BYTE); // load i0,fastbase,i0,byte + } + else if (size == 2) + { + UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 + UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); + // xor i0,i0,bytexor + UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD); // load i0,fastbase,i0,word + } + else if (size == 4) + { + UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 + UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD); // load i0,fastbase,i0,dword + } + else if (size == 8) { - UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD); // load i3,fastbase,i0,dword - UML_ROLINS(block, IREG(3), IREG(1), IMM(0), IREG(2)); // rolins i3,i1,0,i2 - UML_STORE(block, fastbase, IREG(0), IREG(3), DWORD); // store fastbase,i0,i3,dword + UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 + UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD); // dload i0,fastbase,i0,qword + UML_DROR(block, IREG(0), IREG(0), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)))); + // dror i0,i0,32*bytexor } - else - UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD); // store fastbase,i0,i1,dword + UML_RET(block); // ret } - else if (size == 8) + else { - UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 - UML_DROR(block, IREG(1), IREG(1), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)))); - // dror i1,i1,32*bytexor - if (ismasked) + if (size == 1) + { + UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE4_XOR_BE(0) : BYTE4_XOR_LE(0))); + // xor i0,i0,bytexor + UML_STORE(block, fastbase, IREG(0), IREG(1), BYTE); // store fastbase,i0,i1,byte + } + else if (size == 2) { - UML_DROR(block, IREG(2), IREG(2), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)))); - // dror i2,i2,32*bytexor - UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD); // dload i3,fastbase,i0,qword - UML_DROLINS(block, IREG(3), IREG(1), IMM(0), IREG(2)); // drolins i3,i1,0,i2 - UML_DSTORE(block, fastbase, IREG(0), IREG(3), QWORD); // dstore fastbase,i0,i3,qword + UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 + UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))); + // xor i0,i0,bytexor + UML_STORE(block, fastbase, IREG(0), IREG(1), WORD); // store fastbase,i0,i1,word } - else - UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD); // dstore fastbase,i0,i1,qword + else if (size == 4) + { + UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 + if (ismasked) + { + UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD); // load i3,fastbase,i0,dword + UML_ROLINS(block, IREG(3), IREG(1), IMM(0), IREG(2)); // rolins i3,i1,0,i2 + UML_STORE(block, fastbase, IREG(0), IREG(3), DWORD); // store fastbase,i0,i3,dword + } + else + UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD); // store fastbase,i0,i1,dword + } + else if (size == 8) + { + UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 + UML_DROR(block, IREG(1), IREG(1), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)))); + // dror i1,i1,32*bytexor + if (ismasked) + { + UML_DROR(block, IREG(2), IREG(2), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)))); + // dror i2,i2,32*bytexor + UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD); // dload i3,fastbase,i0,qword + UML_DROLINS(block, IREG(3), IREG(1), IMM(0), IREG(2)); // drolins i3,i1,0,i2 + UML_DSTORE(block, fastbase, IREG(0), IREG(3), QWORD); // dstore fastbase,i0,i3,qword + } + else + UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD); // dstore fastbase,i0,i1,qword + } + UML_RET(block); // ret } - UML_RET(block); // ret - } - UML_LABEL(block, skip); // skip: - } + UML_LABEL(block, skip); // skip: + } switch (size) { @@ -1556,7 +1552,7 @@ static void generate_sequence_instruction(drcuml_block *block, compiler_state *c UML_CALLC(block, cfunc_printf_probe, desc->pc); // callc cfunc_printf_probe,desc->pc /* if we are debugging, call the debugger */ - if (Machine->debug_mode) + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { UML_MOV(block, MEM(&mips3->pc), IMM(desc->pc)); // mov [pc],desc->pc save_fast_iregs(block); @@ -3926,14 +3922,3 @@ void rm7000le_get_info(UINT32 state, cpuinfo *info) } } #endif - - - -/*************************************************************************** - DISASSEMBLERS -***************************************************************************/ - -#if !defined(ENABLE_DEBUGGER) && (LOG_UML || LOG_NATIVE) -#include "mips3dsm.c" -#endif - diff --git a/src/emu/cpu/mips/psx.c b/src/emu/cpu/mips/psx.c index 14313395a3d..2b2e1bacde2 100644 --- a/src/emu/cpu/mips/psx.c +++ b/src/emu/cpu/mips/psx.c @@ -256,8 +256,8 @@ static void mips_load_bad_address( UINT32 address ); static void mips_stop( void ) { - DEBUGGER_BREAK; - CALL_DEBUGGER( mipscpu.pc ); + debugger_break(Machine); + debugger_instruction_hook(Machine, mipscpu.pc ); } #if LOG_BIOSCALL @@ -1803,7 +1803,7 @@ static int mips_execute( int cycles ) log_bioscall(); #endif - CALL_DEBUGGER( mipscpu.pc ); + debugger_instruction_hook(Machine, mipscpu.pc ); mipscpu.op = cpu_readop32( mipscpu.pc ); switch( INS_OP( mipscpu.op ) ) @@ -2913,12 +2913,10 @@ ADDRESS_MAP_END * Return a formatted string for a register ****************************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t mips_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return DasmMIPS( buffer, pc, opram ); } -#endif /* ENABLE_DEBUGGER */ static UINT32 getcp1dr( int reg ) @@ -4178,9 +4176,7 @@ static void mips_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = mips_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = mips_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = mips_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &mips_ICount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map32 = address_map_psxcpu_internal_map; break; diff --git a/src/emu/cpu/mips/psx.h b/src/emu/cpu/mips/psx.h index ade57b88676..2a92949f75e 100644 --- a/src/emu/cpu/mips/psx.h +++ b/src/emu/cpu/mips/psx.h @@ -203,9 +203,7 @@ enum #define CF_TLBP ( 8 ) #define CF_RFE ( 16 ) -#ifdef ENABLE_DEBUGGER extern unsigned DasmMIPS( char *buffer, UINT32 pc, const UINT8 *opram ); -#endif #if (HAS_PSXCPU) extern void psxcpu_get_info(UINT32 state, cpuinfo *info); diff --git a/src/emu/cpu/mips/r3000.c b/src/emu/cpu/mips/r3000.c index 57f795e974e..ea2f950ddc6 100644 --- a/src/emu/cpu/mips/r3000.c +++ b/src/emu/cpu/mips/r3000.c @@ -750,7 +750,7 @@ static int r3000_execute(int cycles) /* debugging */ r3000.ppc = r3000.pc; - CALL_DEBUGGER(r3000.pc); + debugger_instruction_hook(Machine, r3000.pc); /* instruction fetch */ op = ROPCODE(r3000.pc); @@ -932,7 +932,6 @@ static int r3000_execute(int cycles) DISASSEMBLY HOOK ***************************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t r3000_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { extern unsigned dasmr3k(char *, unsigned, UINT32); @@ -944,7 +943,6 @@ static offs_t r3000_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT return dasmr3k(buffer, pc, op); } -#endif /* ENABLE_DEBUGGER */ @@ -1287,9 +1285,7 @@ static void r3000_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = r3000_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = r3000_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = r3000_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &r3000_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/nec/nec.c b/src/emu/cpu/nec/nec.c index ffb00ba993c..ab32e2eeb77 100644 --- a/src/emu/cpu/nec/nec.c +++ b/src/emu/cpu/nec/nec.c @@ -1039,12 +1039,10 @@ static void set_poll_line(int state) I.poll_state = state; } -#ifdef ENABLE_DEBUGGER static offs_t nec_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return necv_dasm_one(buffer, pc, oprom, I.config); } -#endif /* ENABLE_DEBUGGER */ static void nec_init(int index, int clock, const void *_config, int (*irqcallback)(int), int type) { @@ -1194,7 +1192,7 @@ static int v20_execute(int cycles) if (I.no_interrupt) I.no_interrupt--; - CALL_DEBUGGER((I.sregs[PS]<<4) + I.ip); + debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip); nec_instruction[fetchop()](); } return cycles - nec_ICount; @@ -1225,7 +1223,7 @@ static int v30_execute(int cycles) { if (I.no_interrupt) I.no_interrupt--; - CALL_DEBUGGER((I.sregs[PS]<<4) + I.ip); + debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip); nec_instruction[fetchop()](); } return cycles - nec_ICount; @@ -1257,7 +1255,7 @@ static int v33_execute(int cycles) if (I.no_interrupt) I.no_interrupt--; - CALL_DEBUGGER((I.sregs[PS]<<4) + I.ip); + debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip); nec_instruction[fetchop()](); } @@ -1390,9 +1388,7 @@ static void nec_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = nec_exit; break; case CPUINFO_PTR_EXECUTE: /* set per-CPU */ break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = nec_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &nec_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/pdp1/pdp1.c b/src/emu/cpu/pdp1/pdp1.c index 057aec375f0..3c397945a1c 100644 --- a/src/emu/cpu/pdp1/pdp1.c +++ b/src/emu/cpu/pdp1/pdp1.c @@ -626,7 +626,7 @@ static int pdp1_execute(int cycles) do { - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); /* ioh should be cleared at the end of the instruction cycle, and ios at the @@ -1025,9 +1025,7 @@ void pdp1_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXECUTE: info->execute = pdp1_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = pdp1_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &pdp1_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/pdp1/pdp1.h b/src/emu/cpu/pdp1/pdp1.h index ea14ef2e18a..f5a74cfaa94 100644 --- a/src/emu/cpu/pdp1/pdp1.h +++ b/src/emu/cpu/pdp1/pdp1.h @@ -74,8 +74,6 @@ void pdp1_get_info(UINT32 state, cpuinfo *info); #define IOT 035 #define OPR 037 -#ifdef ENABLE_DEBUGGER unsigned pdp1_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ #endif /* _PDP1_H */ diff --git a/src/emu/cpu/pdp1/tx0.c b/src/emu/cpu/pdp1/tx0.c index 7977b3c7d6a..6b3eb55dfbd 100644 --- a/src/emu/cpu/pdp1/tx0.c +++ b/src/emu/cpu/pdp1/tx0.c @@ -182,7 +182,7 @@ static int tx0_execute_64kw(int cycles) do { - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); if (tx0.ioh && tx0.ios) @@ -290,7 +290,7 @@ static int tx0_execute_8kw(int cycles) do { - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); if (tx0.ioh && tx0.ios) @@ -516,10 +516,7 @@ void tx0_64kw_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = tx0_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = tx0_execute_64kw; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; - -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tx0_dasm_64kw; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tx0_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -645,10 +642,7 @@ void tx0_8kw_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = tx0_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = tx0_execute_8kw; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; - -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tx0_dasm_8kw; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tx0_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/pdp1/tx0.h b/src/emu/cpu/pdp1/tx0.h index 2854e8605e0..f883c3cfb19 100644 --- a/src/emu/cpu/pdp1/tx0.h +++ b/src/emu/cpu/pdp1/tx0.h @@ -44,7 +44,5 @@ void tx0_8kw_get_info(UINT32 state, cpuinfo *info); #define READ_TX0_18BIT(A) ((signed)program_read_dword_32be((A)<<2)) #define WRITE_TX0_18BIT(A,V) (program_write_dword_32be((A)<<2,(V))) -#ifdef ENABLE_DEBUGGER unsigned tx0_dasm_64kw(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); unsigned tx0_dasm_8kw(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ diff --git a/src/emu/cpu/pic16c5x/16c5xdsm.c b/src/emu/cpu/pic16c5x/16c5xdsm.c index a0246d31c11..87e13a51b71 100644 --- a/src/emu/cpu/pic16c5x/16c5xdsm.c +++ b/src/emu/cpu/pic16c5x/16c5xdsm.c @@ -26,23 +26,12 @@ #include <string.h> #include <ctype.h> -#ifdef ENABLE_DEBUGGER /* Compile interface to MAME */ #include "cpuintrf.h" static const UINT8 *rombase; static const UINT8 *rambase; static offs_t pcbase; #define READOP16(A) (rombase[(A) - pcbase] | (rombase[(A) + 1 - pcbase] << 8)) #define READARG16(A) (rambase[(A) - pcbase] | (rambase[(A) + 1 - pcbase] << 8)) -#else /* Compile interface for standalone */ -extern unsigned char *Buffer; -#ifdef MSB_FIRST -#define READOP16(A) ( ((Buffer[A]<<8) | Buffer[A+1]) ) -#define READARG16(A) ( ((Buffer[A]<<8) | Buffer[A+1]) ) -#else -#define READOP16(A) ( ((Buffer[A+1]<<8) | Buffer[A]) ) -#define READARG16(A) ( ((Buffer[A+1]<<8) | Buffer[A]) ) -#endif -#endif diff --git a/src/emu/cpu/pic16c5x/pic16c5x.c b/src/emu/cpu/pic16c5x/pic16c5x.c index 0a3cd253e80..317da258526 100644 --- a/src/emu/cpu/pic16c5x/pic16c5x.c +++ b/src/emu/cpu/pic16c5x/pic16c5x.c @@ -840,7 +840,7 @@ static int pic16C5x_execute(int cycles) if (PD == 0) /* Sleep Mode */ { inst_cycles = (1*CLK); - CALL_DEBUGGER(R.PC); + debugger_instruction_hook(Machine, R.PC); if (WDTE) { pic16C5x_update_watchdog(1*CLK); } @@ -849,7 +849,7 @@ static int pic16C5x_execute(int cycles) { R.PREVPC = R.PC; - CALL_DEBUGGER(R.PC); + debugger_instruction_hook(Machine, R.PC); R.opcode.d = M_RDOP(R.PC); R.PC++; @@ -1012,9 +1012,7 @@ static void pic16C5x_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = pic16C5x_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = pic16C5x_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = pic16C5x_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &pic16C5x_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/pic16c5x/pic16c5x.h b/src/emu/cpu/pic16c5x/pic16c5x.h index 5bc1ccf7392..7be0cce7428 100644 --- a/src/emu/cpu/pic16c5x/pic16c5x.h +++ b/src/emu/cpu/pic16c5x/pic16c5x.h @@ -126,10 +126,8 @@ void pic16C58_get_info(UINT32 state, cpuinfo *info); #if (HAS_PIC16C54) || (HAS_PIC16C55) || (HAS_PIC16C56) || (HAS_PIC16C57) || (HAS_PIC16C58) -#ifdef ENABLE_DEBUGGER offs_t pic16C5x_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); #endif -#endif #endif /* _PIC16C5X_H */ diff --git a/src/emu/cpu/powerpc/ppc.c b/src/emu/cpu/powerpc/ppc.c index 80b4a3087a4..66d2cceae9c 100644 --- a/src/emu/cpu/powerpc/ppc.c +++ b/src/emu/cpu/powerpc/ppc.c @@ -1883,9 +1883,7 @@ static void ppc_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_GET_CONTEXT: info->getcontext = ppc_get_context; break; case CPUINFO_PTR_SET_CONTEXT: info->setcontext = ppc_set_context; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = ppc_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &ppc_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/powerpc/ppc403.c b/src/emu/cpu/powerpc/ppc403.c index 85183e65b94..620a62f3c11 100644 --- a/src/emu/cpu/powerpc/ppc403.c +++ b/src/emu/cpu/powerpc/ppc403.c @@ -177,7 +177,7 @@ static int ppc403_execute(int cycles) { UINT32 opcode; - CALL_DEBUGGER(ppc.pc); + debugger_instruction_hook(Machine, ppc.pc); ppc.pc = ppc.npc; ppc.npc += 4; opcode = ROPCODE(ppc.pc); diff --git a/src/emu/cpu/powerpc/ppc602.c b/src/emu/cpu/powerpc/ppc602.c index ff4fa4d8a34..5e623b0f88f 100644 --- a/src/emu/cpu/powerpc/ppc602.c +++ b/src/emu/cpu/powerpc/ppc602.c @@ -252,7 +252,7 @@ static int ppc602_execute(int cycles) while( ppc_icount > 0 ) { ppc.pc = ppc.npc; - CALL_DEBUGGER(ppc.pc); + debugger_instruction_hook(Machine, ppc.pc); if (MSR & MSR_IR) opcode = ppc_readop_translated(ppc.pc); diff --git a/src/emu/cpu/powerpc/ppc603.c b/src/emu/cpu/powerpc/ppc603.c index ab97be5112c..5985ce934ea 100644 --- a/src/emu/cpu/powerpc/ppc603.c +++ b/src/emu/cpu/powerpc/ppc603.c @@ -260,7 +260,7 @@ static int ppc603_execute(int cycles) while( ppc_icount > 0 ) { ppc.pc = ppc.npc; - CALL_DEBUGGER(ppc.pc); + debugger_instruction_hook(Machine, ppc.pc); if (MSR & MSR_IR) opcode = ppc_readop_translated(ppc.pc); diff --git a/src/emu/cpu/powerpc/ppc_mem.c b/src/emu/cpu/powerpc/ppc_mem.c index c96002751ab..f04b3d73e7b 100644 --- a/src/emu/cpu/powerpc/ppc_mem.c +++ b/src/emu/cpu/powerpc/ppc_mem.c @@ -371,14 +371,12 @@ static UINT32 ppc_readop_translated(offs_t address) /***********************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t ppc_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { UINT32 op; op = BIG_ENDIANIZE_INT32(*((UINT32 *) oprom)); return ppc_dasm_one(buffer, pc, op); } -#endif /* ENABLE_DEBUGGER */ /***********************************************************************/ diff --git a/src/emu/cpu/powerpc/ppccom.c b/src/emu/cpu/powerpc/ppccom.c index 3f72d03a1e5..10fdb9391b5 100644 --- a/src/emu/cpu/powerpc/ppccom.c +++ b/src/emu/cpu/powerpc/ppccom.c @@ -312,7 +312,6 @@ void ppccom_reset(powerpc_state *ppc) CPU -------------------------------------------------*/ -#ifdef ENABLE_DEBUGGER offs_t ppccom_dasm(powerpc_state *ppc, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { extern offs_t ppc_dasm_one(char *buffer, UINT32 pc, UINT32 op); @@ -320,7 +319,6 @@ offs_t ppccom_dasm(powerpc_state *ppc, char *buffer, offs_t pc, const UINT8 *opr op = BIG_ENDIANIZE_INT32(op); return ppc_dasm_one(buffer, pc, op); } -#endif /* ENABLE_DEBUGGER */ diff --git a/src/emu/cpu/powerpc/ppccom.h b/src/emu/cpu/powerpc/ppccom.h index 232bca5bc57..c7dc1ca36a1 100644 --- a/src/emu/cpu/powerpc/ppccom.h +++ b/src/emu/cpu/powerpc/ppccom.h @@ -572,9 +572,7 @@ void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_di void ppccom_exit(powerpc_state *ppc); void ppccom_reset(powerpc_state *ppc); -#ifdef ENABLE_DEBUGGER offs_t ppccom_dasm(powerpc_state *ppc, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif void ppccom_update_cycle_counting(powerpc_state *ppc); int ppccom_translate_address(powerpc_state *ppc, int space, int intention, offs_t *address); diff --git a/src/emu/cpu/powerpc/ppcdrc.c b/src/emu/cpu/powerpc/ppcdrc.c index 7909eeeca7c..b7c939dbe33 100644 --- a/src/emu/cpu/powerpc/ppcdrc.c +++ b/src/emu/cpu/powerpc/ppcdrc.c @@ -770,12 +770,10 @@ static int ppcdrc_translate(int space, int intention, offs_t *address) ppcdrc_dasm - disassemble an instruction -------------------------------------------------*/ -#ifdef ENABLE_DEBUGGER static offs_t ppcdrc_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return ppccom_dasm(ppc, buffer, pc, oprom, opram); } -#endif /* ENABLE_DEBUGGER */ /*------------------------------------------------- @@ -830,9 +828,7 @@ static void ppcdrc_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = ppcdrc_reset; break; case CPUINFO_PTR_EXIT: info->exit = ppcdrc_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc_execute; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = ppcdrc_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_TRANSLATE: info->translate = ppcdrc_translate; break; case CPUINFO_PTR_CONTEXT: info->p = ppc; break; @@ -1511,94 +1507,95 @@ static void static_generate_memory_accessor(drcuml_state *drcuml, int mode, int UML_AND(block, IREG(0), IREG(0), IMM(0x7fffffff)); // and i0,i0,0x7fffffff UML_XOR(block, IREG(0), IREG(0), IMM((mode & MODE_LITTLE_ENDIAN) ? (8 - size) : 0)); // xor i0,i0,8-size - for (ramnum = 0; ramnum < PPC_MAX_FASTRAM; ramnum++) - if (!Machine->debug_mode && ppc->impstate->fastram[ramnum].base != NULL && (!iswrite || !ppc->impstate->fastram[ramnum].readonly)) - { - void *fastbase = (UINT8 *)ppc->impstate->fastram[ramnum].base - ppc->impstate->fastram[ramnum].start; - UINT32 skip = label++; - - if (ppc->impstate->fastram[ramnum].end != 0xffffffff) + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + for (ramnum = 0; ramnum < PPC_MAX_FASTRAM; ramnum++) + if (ppc->impstate->fastram[ramnum].base != NULL && (!iswrite || !ppc->impstate->fastram[ramnum].readonly)) { - UML_CMP(block, IREG(0), IMM(ppc->impstate->fastram[ramnum].end)); // cmp i0,end - UML_JMPc(block, IF_A, skip); // ja skip - } - if (ppc->impstate->fastram[ramnum].start != 0x00000000) - { - UML_CMP(block, IREG(0), IMM(ppc->impstate->fastram[ramnum].start)); // cmp i0,fastram_start - UML_JMPc(block, IF_B, skip); // jb skip - } + void *fastbase = (UINT8 *)ppc->impstate->fastram[ramnum].base - ppc->impstate->fastram[ramnum].start; + UINT32 skip = label++; - if (!iswrite) - { - if (size == 1) - { - UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 0)); // xor i0,i0,fastxor >> 0 - UML_LOAD(block, IREG(0), fastbase, IREG(0), BYTE); // load i0,fastbase,i0,byte - } - else if (size == 2) - { - UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 - UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 1)); // xor i0,i0,fastxor >> 1 - UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD); // load i0,fastbase,i0,word - } - else if (size == 4) - { - UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 - UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 2)); // xor i0,i0,fastxor >> 2 - UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD); // load i0,fastbase,i0,dword - } - else if (size == 8) - { - UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 - UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD); // dload i0,fastbase,i0,qword - } - UML_RET(block); // ret - } - else - { - if (size == 1) + if (ppc->impstate->fastram[ramnum].end != 0xffffffff) { - UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 0)); // xor i0,i0,fastxor >> 0 - UML_STORE(block, fastbase, IREG(0), IREG(1), BYTE); // store fastbase,i0,i1,byte + UML_CMP(block, IREG(0), IMM(ppc->impstate->fastram[ramnum].end)); // cmp i0,end + UML_JMPc(block, IF_A, skip); // ja skip } - else if (size == 2) + if (ppc->impstate->fastram[ramnum].start != 0x00000000) { - UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 - UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 1)); // xor i0,i0,fastxor >> 1 - UML_STORE(block, fastbase, IREG(0), IREG(1), WORD); // store fastbase,i0,i1,word + UML_CMP(block, IREG(0), IMM(ppc->impstate->fastram[ramnum].start)); // cmp i0,fastram_start + UML_JMPc(block, IF_B, skip); // jb skip } - else if (size == 4) + + if (!iswrite) { - UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 - UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 2)); // xor i0,i0,fastxor >> 2 - if (ismasked) + if (size == 1) + { + UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 0)); // xor i0,i0,fastxor >> 0 + UML_LOAD(block, IREG(0), fastbase, IREG(0), BYTE); // load i0,fastbase,i0,byte + } + else if (size == 2) + { + UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 + UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 1)); // xor i0,i0,fastxor >> 1 + UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD); // load i0,fastbase,i0,word + } + else if (size == 4) { - UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD); // load i3,fastbase,i0,dword - UML_AND(block, IREG(1), IREG(1), IREG(2)); // and i1,i1,i2 - UML_XOR(block, IREG(2), IREG(2), IMM(0xffffffff)); // xor i2,i2,0xfffffffff - UML_AND(block, IREG(3), IREG(3), IREG(2)); // and i3,i3,i2 - UML_OR(block, IREG(1), IREG(1), IREG(3)); // or i1,i1,i3 + UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 + UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 2)); // xor i0,i0,fastxor >> 2 + UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD); // load i0,fastbase,i0,dword } - UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD); // store fastbase,i0,i1,dword + else if (size == 8) + { + UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 + UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD); // dload i0,fastbase,i0,qword + } + UML_RET(block); // ret } - else if (size == 8) + else { - UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 - if (ismasked) + if (size == 1) + { + UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 0)); // xor i0,i0,fastxor >> 0 + UML_STORE(block, fastbase, IREG(0), IREG(1), BYTE); // store fastbase,i0,i1,byte + } + else if (size == 2) + { + UML_SHR(block, IREG(0), IREG(0), IMM(1)); // shr i0,i0,1 + UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 1)); // xor i0,i0,fastxor >> 1 + UML_STORE(block, fastbase, IREG(0), IREG(1), WORD); // store fastbase,i0,i1,word + } + else if (size == 4) + { + UML_SHR(block, IREG(0), IREG(0), IMM(2)); // shr i0,i0,2 + UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 2)); // xor i0,i0,fastxor >> 2 + if (ismasked) + { + UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD); // load i3,fastbase,i0,dword + UML_AND(block, IREG(1), IREG(1), IREG(2)); // and i1,i1,i2 + UML_XOR(block, IREG(2), IREG(2), IMM(0xffffffff)); // xor i2,i2,0xfffffffff + UML_AND(block, IREG(3), IREG(3), IREG(2)); // and i3,i3,i2 + UML_OR(block, IREG(1), IREG(1), IREG(3)); // or i1,i1,i3 + } + UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD); // store fastbase,i0,i1,dword + } + else if (size == 8) { - UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD); // dload i3,fastbase,i0,qword - UML_DAND(block, IREG(1), IREG(1), IREG(2)); // dand i1,i1,i2 - UML_DXOR(block, IREG(2), IREG(2), IMM(U64(0xffffffffffffffff))); // dxor i2,i2,0xfffffffffffffffff - UML_DAND(block, IREG(3), IREG(3), IREG(2)); // dand i3,i3,i2 - UML_DOR(block, IREG(1), IREG(1), IREG(3)); // dor i1,i1,i3 + UML_SHR(block, IREG(0), IREG(0), IMM(3)); // shr i0,i0,3 + if (ismasked) + { + UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD); // dload i3,fastbase,i0,qword + UML_DAND(block, IREG(1), IREG(1), IREG(2)); // dand i1,i1,i2 + UML_DXOR(block, IREG(2), IREG(2), IMM(U64(0xffffffffffffffff))); // dxor i2,i2,0xfffffffffffffffff + UML_DAND(block, IREG(3), IREG(3), IREG(2)); // dand i3,i3,i2 + UML_DOR(block, IREG(1), IREG(1), IREG(3)); // dor i1,i1,i3 + } + UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD); // dstore fastbase,i0,i1,qword } - UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD); // dstore fastbase,i0,i1,qword + UML_RET(block); // ret } - UML_RET(block); // ret - } - UML_LABEL(block, skip); // skip: - } + UML_LABEL(block, skip); // skip: + } switch (size) { @@ -2136,7 +2133,7 @@ static void generate_sequence_instruction(drcuml_block *block, compiler_state *c UML_CALLC(block, cfunc_printf_probe, desc->pc); // callc cfunc_printf_probe,desc->pc /* if we are debugging, call the debugger */ - if (Machine->debug_mode) + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) { UML_MOV(block, MEM(&ppc->pc), IMM(desc->pc)); // mov [pc],desc->pc save_fast_iregs(block); // <save fastregs> diff --git a/src/emu/cpu/rsp/rsp.c b/src/emu/cpu/rsp/rsp.c index 9569c22ca9d..718153c852f 100644 --- a/src/emu/cpu/rsp/rsp.c +++ b/src/emu/cpu/rsp/rsp.c @@ -262,11 +262,12 @@ static void set_cop0_reg(int reg, UINT32 data) static void unimplemented_opcode(UINT32 op) { -#ifdef ENABLE_DEBUGGER - char string[200]; - rsp_dasm_one(string, rsp.ppc, op); - mame_printf_debug("%08X: %s\n", rsp.ppc, string); -#endif + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + { + char string[200]; + rsp_dasm_one(string, rsp.ppc, op); + mame_printf_debug("%08X: %s\n", rsp.ppc, string); + } #if SAVE_DISASM { @@ -2596,7 +2597,7 @@ static int rsp_execute(int cycles) while (rsp_icount > 0) { rsp.ppc = rsp.pc; - CALL_DEBUGGER(rsp.pc); + debugger_instruction_hook(Machine, rsp.pc); op = ROPCODE(rsp.pc); if (rsp.nextpc != ~0) @@ -2875,13 +2876,11 @@ static void rsp_set_context(void *src) /*****************************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t rsp_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { UINT32 op = LITTLE_ENDIANIZE_INT32(*(UINT32 *)opram); return rsp_dasm_one(buffer, pc, op); } -#endif /* ENABLE_DEBUGGER */ /*****************************************************************************/ @@ -3010,9 +3009,7 @@ void rsp_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = rsp_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = rsp_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = rsp_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &rsp_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/rsp/rsp.h b/src/emu/cpu/rsp/rsp.h index 22bee7d679f..2ee22b4f912 100644 --- a/src/emu/cpu/rsp/rsp.h +++ b/src/emu/cpu/rsp/rsp.h @@ -69,8 +69,6 @@ enum void rsp_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern offs_t rsp_dasm_one(char *buffer, offs_t pc, UINT32 op); -#endif #endif diff --git a/src/emu/cpu/s2650/s2650.c b/src/emu/cpu/s2650/s2650.c index e31ae2c2bad..204e0d8fc09 100644 --- a/src/emu/cpu/s2650/s2650.c +++ b/src/emu/cpu/s2650/s2650.c @@ -864,7 +864,7 @@ static int s2650_execute(int cycles) { S.ppc = S.page + S.iar; - CALL_DEBUGGER(S.page + S.iar); + debugger_instruction_hook(Machine, S.page + S.iar); S.ir = ROP(); S.r = S.ir & 3; /* register / value */ @@ -1568,9 +1568,7 @@ void s2650_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = s2650_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = s2650_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = s2650_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &s2650_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/s2650/s2650.h b/src/emu/cpu/s2650/s2650.h index e477ada8a69..51c4a78e998 100644 --- a/src/emu/cpu/s2650/s2650.h +++ b/src/emu/cpu/s2650/s2650.h @@ -23,8 +23,6 @@ enum { extern void s2650_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern offs_t s2650_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/saturn/saturn.c b/src/emu/cpu/saturn/saturn.c index e66acc1aa96..820cd010c2d 100644 --- a/src/emu/cpu/saturn/saturn.c +++ b/src/emu/cpu/saturn/saturn.c @@ -177,7 +177,7 @@ static int saturn_execute(int cycles) { saturn.oldpc = saturn.pc; - CALL_DEBUGGER(saturn.pc); + debugger_instruction_hook(Machine, saturn.pc); if ( saturn.sleeping ) { @@ -370,9 +370,7 @@ void saturn_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = saturn_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = saturn_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = saturn_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &saturn_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/saturn/saturn.h b/src/emu/cpu/saturn/saturn.h index e302f5b7a66..55910276cd8 100644 --- a/src/emu/cpu/saturn/saturn.h +++ b/src/emu/cpu/saturn/saturn.h @@ -82,9 +82,7 @@ enum { #define SATURN_NMI_LINE 1 #define SATURN_WAKEUP_LINE 2 -#ifdef ENABLE_DEBUGGER unsigned saturn_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ void saturn_get_info(UINT32 state, cpuinfo *info); diff --git a/src/emu/cpu/sc61860/sc61860.c b/src/emu/cpu/sc61860/sc61860.c index 52f665e86b5..895cb092d87 100644 --- a/src/emu/cpu/sc61860/sc61860.c +++ b/src/emu/cpu/sc61860/sc61860.c @@ -116,7 +116,7 @@ static int sc61860_execute(int cycles) { sc61860.oldpc = sc61860.pc; - CALL_DEBUGGER(sc61860.pc); + debugger_instruction_hook(Machine, sc61860.pc); sc61860_instruction(); @@ -202,21 +202,19 @@ void sc61860_get_info(UINT32 state, cpuinfo *info) case CPUINFO_INT_REGISTER + SC61860_DP: info->i = sc61860.dp; break; case CPUINFO_INT_REGISTER + SC61860_P: info->i = sc61860.p; break; case CPUINFO_INT_REGISTER + SC61860_Q: info->i = sc61860.q; break; - case CPUINFO_INT_REGISTER + SC61860_CARRY: info->i = sc61860.carry; break; - case CPUINFO_INT_REGISTER + SC61860_ZERO: info->i = sc61860.zero; break; + case CPUINFO_INT_REGISTER + SC61860_CARRY: info->i = sc61860.carry; break; + case CPUINFO_INT_REGISTER + SC61860_ZERO: info->i = sc61860.zero; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_SET_INFO: info->setinfo = sc61860_set_info; break; case CPUINFO_PTR_GET_CONTEXT: info->getcontext = sc61860_get_context; break; case CPUINFO_PTR_SET_CONTEXT: info->setcontext = sc61860_set_context; break; - case CPUINFO_PTR_INIT: info->init = sc61860_init; break; + case CPUINFO_PTR_INIT: info->init = sc61860_init; break; case CPUINFO_PTR_RESET: info->reset = sc61860_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = sc61860_execute; break; - case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER - case CPUINFO_PTR_DISASSEMBLE: info->disassemble = sc61860_dasm; break; -#endif /* ENABLE_DEBUGGER */ - case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &sc61860_ICount; break; + case CPUINFO_PTR_BURN: info->burn = NULL; break; + case CPUINFO_PTR_DISASSEMBLE: info->disassemble = sc61860_dasm; break; + case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &sc61860_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s = cpuintrf_temp_str(), "SC61860"); break; diff --git a/src/emu/cpu/sc61860/sc61860.h b/src/emu/cpu/sc61860/sc61860.h index c6ff7973adc..3b881861d26 100644 --- a/src/emu/cpu/sc61860/sc61860.h +++ b/src/emu/cpu/sc61860/sc61860.h @@ -46,9 +46,7 @@ typedef struct { void (*outc)(int); } SC61860_CONFIG; -#ifdef ENABLE_DEBUGGER unsigned sc61860_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ /* this is though for power on/off of the sharps */ UINT8 *sc61860_internal_ram(void); diff --git a/src/emu/cpu/se3208/se3208.c b/src/emu/cpu/se3208/se3208.c index 9e81fce8e8f..63201c69c34 100644 --- a/src/emu/cpu/se3208/se3208.c +++ b/src/emu/cpu/se3208/se3208.c @@ -1769,7 +1769,7 @@ static int SE3208_Run(int cycles) { UINT16 Opcode=cpu_readop16(WORD_XOR_LE(Context.PC)); - CALL_DEBUGGER(Context.PC); + debugger_instruction_hook(Machine, Context.PC); OpTable[Opcode](Opcode); Context.PPC=Context.PC; @@ -1906,9 +1906,7 @@ void SE3208_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = SE3208_Exit; break; case CPUINFO_PTR_EXECUTE: info->execute = SE3208_Run; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = SE3208_Dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &SE3208_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/se3208/se3208.h b/src/emu/cpu/se3208/se3208.h index f25d563be20..e93e0868246 100644 --- a/src/emu/cpu/se3208/se3208.h +++ b/src/emu/cpu/se3208/se3208.h @@ -9,6 +9,4 @@ enum { extern void SE3208_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER offs_t SE3208_Dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif diff --git a/src/emu/cpu/sh2/sh2.c b/src/emu/cpu/sh2/sh2.c index 52d9db39e3a..e75c3ea7295 100644 --- a/src/emu/cpu/sh2/sh2.c +++ b/src/emu/cpu/sh2/sh2.c @@ -2342,7 +2342,7 @@ static int sh2_execute(int cycles) else opcode = cpu_readop16(WORD_XOR_BE((UINT32)(sh2.pc & AM))); - CALL_DEBUGGER(sh2.pc); + debugger_instruction_hook(Machine, sh2.pc); sh2.delay = 0; sh2.pc += 2; @@ -2921,12 +2921,10 @@ static void set_irq_line(int irqline, int state) } } -#ifdef ENABLE_DEBUGGER static offs_t sh2_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return DasmSH2( buffer, pc, (oprom[0] << 8) | oprom[1] ); } -#endif /* ENABLE_DEBUGGER */ static void sh2_init(int index, int clock, const void *config, int (*irqcallback)(int)) { @@ -3129,9 +3127,7 @@ void sh2_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = sh2_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = sh2_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = sh2_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &sh2_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/sh2/sh2.h b/src/emu/cpu/sh2/sh2.h index 6f52dcaea52..d893271bb2d 100644 --- a/src/emu/cpu/sh2/sh2.h +++ b/src/emu/cpu/sh2/sh2.h @@ -75,9 +75,7 @@ extern void sh2_get_info(UINT32 state, cpuinfo *info); WRITE32_HANDLER( sh2_internal_w ); READ32_HANDLER( sh2_internal_r ); -#ifdef ENABLE_DEBUGGER extern unsigned DasmSH2( char *dst, unsigned pc, UINT16 opcode ); -#endif #endif /* _SH2_H */ diff --git a/src/emu/cpu/sh4/sh4.c b/src/emu/cpu/sh4/sh4.c index 9edbc008fb9..018ccdb23fc 100644 --- a/src/emu/cpu/sh4/sh4.c +++ b/src/emu/cpu/sh4/sh4.c @@ -392,7 +392,6 @@ UINT32 z; } #endif -#ifdef ENABLE_DEBUGGER static void sh4_syncronize_register_bank(int to) { int s; @@ -402,7 +401,6 @@ int s; sh4.rbnk[to][s] = sh4.r[s]; } } -#endif static void sh4_default_exception_priorities(void) // setup default priorities for exceptions { @@ -504,9 +502,8 @@ INLINE void sh4_exception(const char *message, int exception) // handle exceptio sh4.sgr = sh4.r[15]; sh4.sr |= MD; -#ifdef ENABLE_DEBUGGER - sh4_syncronize_register_bank((sh4.sr & sRB) >> 29); -#endif + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + sh4_syncronize_register_bank((sh4.sr & sRB) >> 29); if (!(sh4.sr & sRB)) sh4_change_register_bank(1); sh4.sr |= sRB; @@ -1171,9 +1168,8 @@ INLINE void JSR(UINT32 m) /* LDC Rm,SR */ INLINE void LDCSR(UINT32 m) { -#ifdef ENABLE_DEBUGGER - sh4_syncronize_register_bank((sh4.sr & sRB) >> 29); -#endif + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + sh4_syncronize_register_bank((sh4.sr & sRB) >> 29); if ((sh4.r[m] & sRB) != (sh4.sr & sRB)) sh4_change_register_bank(sh4.r[m] & sRB ? 1 : 0); sh4.sr = sh4.r[m] & FLAGS; @@ -1200,9 +1196,8 @@ UINT32 old; old = sh4.sr; sh4.ea = sh4.r[m]; sh4.sr = RL( sh4.ea ) & FLAGS; -#ifdef ENABLE_DEBUGGER - sh4_syncronize_register_bank((old & sRB) >> 29); -#endif + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + sh4_syncronize_register_bank((old & sRB) >> 29); if ((old & sRB) != (sh4.sr & sRB)) sh4_change_register_bank(sh4.sr & sRB ? 1 : 0); sh4.r[m] += 4; @@ -1787,9 +1782,8 @@ INLINE void RTE(void) { sh4.delay = sh4.pc; sh4.pc = sh4.ea = sh4.spc; -#ifdef ENABLE_DEBUGGER - sh4_syncronize_register_bank((sh4.sr & sRB) >> 29); -#endif + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + sh4_syncronize_register_bank((sh4.sr & sRB) >> 29); if ((sh4.ssr & sRB) != (sh4.sr & sRB)) sh4_change_register_bank(sh4.ssr & sRB ? 1 : 0); sh4.sr = sh4.ssr; @@ -3514,11 +3508,9 @@ INLINE void op1111(UINT16 opcode) case 0x800: FRCHG(); break; -#ifdef ENABLE_DEBUGGER default: - mame_debug_break(); + debugger_break(Machine); break; -#endif } } else { FTRV(Rn); @@ -3527,21 +3519,17 @@ INLINE void op1111(UINT16 opcode) FSSCA(Rn); } break; -#ifdef ENABLE_DEBUGGER default: - mame_debug_break(); + debugger_break(Machine); break; -#endif } break; case 14: FMAC(Rm,Rn); break; -#ifdef ENABLE_DEBUGGER default: - mame_debug_break(); + debugger_break(Machine); break; -#endif } } @@ -3646,7 +3634,7 @@ static int sh4_execute(int cycles) else opcode = cpu_readop16(WORD2_XOR_LE((UINT32)(sh4.pc & AM))); - CALL_DEBUGGER(sh4.pc); + debugger_instruction_hook(Machine, sh4.pc); sh4.delay = 0; sh4.pc += 2; @@ -4658,12 +4646,10 @@ static void sh4_parse_configuration(const struct sh4_config *conf) } } -#ifdef ENABLE_DEBUGGER static offs_t sh4_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return DasmSH4( buffer, pc, (oprom[1] << 8) | oprom[0] ); } -#endif /* ENABLE_DEBUGGER */ static void sh4_init(int index, int clock, const void *config, int (*irqcallback)(int)) { @@ -5142,9 +5128,7 @@ void sh4_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = sh4_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = sh4_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = sh4_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &sh4_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/sh4/sh4.h b/src/emu/cpu/sh4/sh4.h index 9e89f8a8bb3..ab60ec85bbb 100644 --- a/src/emu/cpu/sh4/sh4.h +++ b/src/emu/cpu/sh4/sh4.h @@ -103,9 +103,7 @@ extern void sh4_get_info(UINT32 state, cpuinfo *info); WRITE32_HANDLER( sh4_internal_w ); READ32_HANDLER( sh4_internal_r ); -#ifdef ENABLE_DEBUGGER extern unsigned DasmSH4( char *dst, unsigned pc, UINT16 opcode ); -#endif #endif /* _SH4_H */ diff --git a/src/emu/cpu/sharc/sharc.c b/src/emu/cpu/sharc/sharc.c index 5c47389a604..ad1e801b511 100644 --- a/src/emu/cpu/sharc/sharc.c +++ b/src/emu/cpu/sharc/sharc.c @@ -6,9 +6,7 @@ #include "sharc.h" #include "debugger.h" -#ifdef ENABLE_DEBUGGER static offs_t sharc_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ static void sharc_dma_exec(int channel); static void check_interrupts(void); @@ -405,7 +403,6 @@ void sharc_external_dma_write(UINT32 address, UINT64 data) } } -#ifdef ENABLE_DEBUGGER static offs_t sharc_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { UINT64 op = 0; @@ -418,7 +415,6 @@ static offs_t sharc_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT flags = sharc_dasm_one(buffer, pc, op); return 1 | flags | DASMFLAG_SUPPORTED; } -#endif /* ENABLE_DEBUGGER */ static void sharc_init(int index, int clock, const void *config, int (*irqcallback)(int)) @@ -708,7 +704,7 @@ static int sharc_execute(int cycles) } sharc_icount = 0; - CALL_DEBUGGER(sharc.daddr); + debugger_instruction_hook(Machine, sharc.daddr); return cycles; } @@ -743,7 +739,7 @@ static int sharc_execute(int cycles) // fetch next instruction sharc.fetch_opcode = ROPCODE(sharc.faddr); - CALL_DEBUGGER(sharc.pc); + debugger_instruction_hook(Machine, sharc.pc); // handle looping if (sharc.pc == (sharc.laddr & 0xffffff)) @@ -1211,9 +1207,7 @@ static void sharc_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = sharc_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = sharc_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = sharc_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &sharc_icount; break; case CPUINFO_PTR_READ: info->read = sharc_debug_read; break; case CPUINFO_PTR_READOP: info->readop = sharc_debug_readop; break; diff --git a/src/emu/cpu/sharc/sharc.h b/src/emu/cpu/sharc/sharc.h index f9e9f7ca566..89b653d7367 100644 --- a/src/emu/cpu/sharc/sharc.h +++ b/src/emu/cpu/sharc/sharc.h @@ -28,8 +28,6 @@ extern void sharc_external_dma_write(UINT32 address, UINT64 data); void adsp21062_get_info(UINT32 state, cpuinfo *info); #endif -#ifdef ENABLE_DEBUGGER extern UINT32 sharc_dasm_one(char *buffer, offs_t pc, UINT64 opcode); -#endif #endif /* _SHARC_H */ diff --git a/src/emu/cpu/sharc/sharcops.c b/src/emu/cpu/sharc/sharcops.c index 1f648d62af3..0a7c5de4c25 100644 --- a/src/emu/cpu/sharc/sharcops.c +++ b/src/emu/cpu/sharc/sharcops.c @@ -2747,12 +2747,8 @@ static void sharcop_idle(void) static void sharcop_unimplemented(void) { -#ifdef ENABLE_DEBUGGER char dasm[1000]; sharc_dasm(dasm, sharc.pc, NULL, NULL); mame_printf_debug("SHARC: %08X: %s\n", sharc.pc, dasm); fatalerror("SHARC: Unimplemented opcode %04X%08X at %08X", (UINT16)(sharc.opcode >> 32), (UINT32)(sharc.opcode), sharc.pc); -#else - fatalerror("SHARC: Unimplemented opcode %04X%08X at %08X", (UINT16)(sharc.opcode >> 32), (UINT32)(sharc.opcode), sharc.pc); -#endif } diff --git a/src/emu/cpu/sm8500/sm8500.c b/src/emu/cpu/sm8500/sm8500.c index 5f4bf5fb236..f497b8d5c27 100644 --- a/src/emu/cpu/sm8500/sm8500.c +++ b/src/emu/cpu/sm8500/sm8500.c @@ -215,7 +215,7 @@ static int sm8500_execute( int cycles ) UINT32 d1,d2; UINT32 res; - CALL_DEBUGGER(regs.PC); + debugger_instruction_hook(Machine, regs.PC); oldpc = regs.PC; mycycles = 0; sm8500_process_interrupts(); @@ -496,9 +496,7 @@ void sm8500_get_info( UINT32 state, cpuinfo *info ) case CPUINFO_PTR_EXIT: info->exit = sm8500_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = sm8500_execute; break; case CPUINFO_PTR_BURN: info->burn = sm8500_burn; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = sm8500_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &sm8500_icount; break; case CPUINFO_STR_NAME: strcpy( info->s = cpuintrf_temp_str(), "sm8500" ); break; diff --git a/src/emu/cpu/sm8500/sm8500.h b/src/emu/cpu/sm8500/sm8500.h index 16744cbff44..66f360afd4e 100644 --- a/src/emu/cpu/sm8500/sm8500.h +++ b/src/emu/cpu/sm8500/sm8500.h @@ -49,9 +49,7 @@ INLINE void sm85cpu_mem_writeword( UINT32 address, UINT16 value ) sm85cpu_mem_writebyte( ( address + 1 ) & 0xffff, value & 0xff ); } -#ifdef ENABLE_DEBUGGER extern unsigned sm8500_dasm( char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram ); -#endif /* ENABLE_DEBUGGER */ #endif diff --git a/src/emu/cpu/spc700/spc700.c b/src/emu/cpu/spc700/spc700.c index 6f2d1312e72..e1a6318524a 100644 --- a/src/emu/cpu/spc700/spc700.c +++ b/src/emu/cpu/spc700/spc700.c @@ -1403,9 +1403,7 @@ void spc700_state_load(void *file) } -#ifdef ENABLE_DEBUGGER #include "spc700ds.h" -#endif //int dump_flag = 0; @@ -1416,7 +1414,7 @@ int spc700_execute(int clocks) while(CLOCKS > 0) { REG_PPC = REG_PC; - CALL_DEBUGGER(REG_PC); + debugger_instruction_hook(Machine, REG_PC); REG_PC++; #if 0 @@ -1796,9 +1794,7 @@ void spc700_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = spc700_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = spc700_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = spc700_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &spc700_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/ssp1601/ssp1601.c b/src/emu/cpu/ssp1601/ssp1601.c index 6546e76e22d..39a5ca20800 100644 --- a/src/emu/cpu/ssp1601/ssp1601.c +++ b/src/emu/cpu/ssp1601/ssp1601.c @@ -539,7 +539,7 @@ static int ssp1601_execute(int cycles) PPC = rPC; - CALL_DEBUGGER(rPC); + debugger_instruction_hook(Machine, rPC); op = FETCH(); @@ -756,12 +756,10 @@ static void ssp1601_set_context(void *regs) ssp1601 = *(ssp1601_regs *)regs; } -#ifdef ENABLE_DEBUGGER static offs_t ssp1601_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return dasm_ssp1601(buffer, pc, oprom); } -#endif /* ENABLE_DEBUGGER */ #if (HAS_SSP1601) @@ -867,9 +865,7 @@ void ssp1601_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = ssp1601_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = ssp1601_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = ssp1601_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &g_cycles; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map16 = NULL; break; diff --git a/src/emu/cpu/ssp1601/ssp1601.h b/src/emu/cpu/ssp1601/ssp1601.h index 3456e54700d..e8e96a62f84 100644 --- a/src/emu/cpu/ssp1601/ssp1601.h +++ b/src/emu/cpu/ssp1601/ssp1601.h @@ -17,8 +17,6 @@ enum { void ssp1601_get_info(UINT32 state, cpuinfo *info); #endif -#ifdef ENABLE_DEBUGGER extern unsigned dasm_ssp1601(char *buffer, unsigned pc, const UINT8 *oprom); -#endif #endif /* SSP1601_H */ diff --git a/src/emu/cpu/t11/t11.c b/src/emu/cpu/t11/t11.c index 5536360fb1d..7a24ae13a4a 100644 --- a/src/emu/cpu/t11/t11.c +++ b/src/emu/cpu/t11/t11.c @@ -397,7 +397,7 @@ static int t11_execute(int cycles) { t11.ppc = t11.reg[7]; /* copy PC to previous PC */ - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); t11.op = ROPCODE(); (*opcode_table[t11.op >> 3])(); @@ -502,9 +502,7 @@ void t11_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = t11_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = t11_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = t11_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &t11_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/t11/t11.h b/src/emu/cpu/t11/t11.h index 969e1c998d0..74e7b576c0b 100644 --- a/src/emu/cpu/t11/t11.h +++ b/src/emu/cpu/t11/t11.h @@ -43,8 +43,6 @@ extern void t11_get_info(UINT32 state, cpuinfo *info); #define T11_WRMEM(A,V) (program_write_byte_16le(A,V)) #define T11_WRMEM_WORD(A,V) (program_write_word_16le(A,V)) -#ifdef ENABLE_DEBUGGER offs_t t11_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _T11_H */ diff --git a/src/emu/cpu/tlcs90/tlcs90.c b/src/emu/cpu/tlcs90/tlcs90.c index 4a3e844bbc2..61e9a440826 100644 --- a/src/emu/cpu/tlcs90/tlcs90.c +++ b/src/emu/cpu/tlcs90/tlcs90.c @@ -1329,7 +1329,7 @@ static int t90_execute(int cycles) do { T90.prvpc.d = T90.pc.d; - CALL_DEBUGGER(T90.pc.d); + debugger_instruction_hook(Machine, T90.pc.d); check_interrupts(); @@ -2783,9 +2783,7 @@ void tmp90840_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = t90_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = t90_execute; break; case CPUINFO_PTR_BURN: info->burn = t90_burn; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = t90_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &t90_ICount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_tmp90840_mem; break; diff --git a/src/emu/cpu/tlcs90/tlcs90.h b/src/emu/cpu/tlcs90/tlcs90.h index fd9b3f8ad51..3b091acd88b 100644 --- a/src/emu/cpu/tlcs90/tlcs90.h +++ b/src/emu/cpu/tlcs90/tlcs90.h @@ -8,9 +8,7 @@ void tmp90841_get_info(UINT32, cpuinfo*); void tmp91640_get_info(UINT32, cpuinfo*); void tmp91641_get_info(UINT32, cpuinfo*); -#ifdef ENABLE_DEBUGGER unsigned t90_dasm(char *buffer, UINT32 oldpc, const UINT8 *oprom, const UINT8 *opram); -#endif #define T90_IOBASE 0xffc0 diff --git a/src/emu/cpu/tms32010/32010dsm.c b/src/emu/cpu/tms32010/32010dsm.c index c7d73071d8b..bf8224fff3d 100644 --- a/src/emu/cpu/tms32010/32010dsm.c +++ b/src/emu/cpu/tms32010/32010dsm.c @@ -29,20 +29,9 @@ #include <string.h> #include <ctype.h> -#ifdef ENABLE_DEBUGGER /* Compile interface to MAME */ #include "cpuintrf.h" #include "tms32010.h" #include "debugger.h" -#else /* Compile interface for standalone */ -extern unsigned char *Buffer; -#ifdef MSB_FIRST -#define READOP16(A) ( ((Buffer[A+1]<<8) | Buffer[A]) ) -#define READARG16(A) ( ((Buffer[A+1]<<8) | Buffer[A]) ) -#else -#define READOP16(A) ( ((Buffer[A]<<8) | Buffer[A+1]) ) -#define READARG16(A) ( ((Buffer[A]<<8) | Buffer[A+1]) ) -#endif -#endif diff --git a/src/emu/cpu/tms32010/tms32010.c b/src/emu/cpu/tms32010/tms32010.c index 308c3673333..ff446a982a2 100644 --- a/src/emu/cpu/tms32010/tms32010.c +++ b/src/emu/cpu/tms32010/tms32010.c @@ -789,7 +789,7 @@ static int tms32010_execute(int cycles) R.PREVPC = R.PC; - CALL_DEBUGGER(R.PC); + debugger_instruction_hook(Machine, R.PC); R.opcode.d = M_RDOP(R.PC); R.PC++; @@ -929,9 +929,7 @@ void tms32010_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = tms32010_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = tms32010_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms32010_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tms32010_icount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map16 = address_map_tms32010_ram; break; diff --git a/src/emu/cpu/tms32010/tms32010.h b/src/emu/cpu/tms32010/tms32010.h index 5ca14e6277c..a46cbbbd513 100644 --- a/src/emu/cpu/tms32010/tms32010.h +++ b/src/emu/cpu/tms32010/tms32010.h @@ -123,8 +123,6 @@ void tms32010_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER offs_t tms32010_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _TMS32010_H */ diff --git a/src/emu/cpu/tms32025/32025dsm.c b/src/emu/cpu/tms32025/32025dsm.c index 95bd0a8bddd..2ec30994328 100644 --- a/src/emu/cpu/tms32025/32025dsm.c +++ b/src/emu/cpu/tms32025/32025dsm.c @@ -33,7 +33,6 @@ #include <string.h> #include <ctype.h> -#ifdef ENABLE_DEBUGGER /* Compile interface to MAME */ #include "tms32025.h" #include "debugger.h" extern UINT16 *tms32025_pgmmap[0x200]; @@ -41,16 +40,6 @@ extern UINT16 *tms32025_pgmmap[0x200]; //#define READARG16(A) (cpu_readop_arg16((A) | (TMS32025_PGM_OFFSET << 1))) #define READOP16(A) ((tms32025_pgmmap[(A) >> 7]) ? (tms32025_pgmmap[(A) >> 7][(A) & 0x7f]) : cpu_readop16((A)<<1)) #define READARG16(A) ((tms32025_pgmmap[(A) >> 7]) ? (tms32025_pgmmap[(A) >> 7][(A) & 0x7f]) : cpu_readop16((A)<<1)) -#else /* Compile interface for standalone */ -extern unsigned char *Buffer; -#ifdef MSB_FIRST -#define READOP16(A) ( ((Buffer[A+1]<<8) | Buffer[A]) ) -#define READARG16(A) ( ((Buffer[A+1]<<8) | Buffer[A]) ) -#else -#define READOP16(A) ( ((Buffer[A]<<8) | Buffer[A+1]) ) -#define READARG16(A) ( ((Buffer[A]<<8) | Buffer[A+1]) ) -#endif -#endif diff --git a/src/emu/cpu/tms32025/tms32025.c b/src/emu/cpu/tms32025/tms32025.c index ca2322a0df3..6d5ae0f6ee5 100644 --- a/src/emu/cpu/tms32025/tms32025.c +++ b/src/emu/cpu/tms32025/tms32025.c @@ -1983,7 +1983,7 @@ static int tms32025_execute(int cycles) while (R.idle && tms32025_icount > 0) process_timer(tms32025_icount); - if (tms32025_icount <= 0) CALL_DEBUGGER(R.PC); + if (tms32025_icount <= 0) debugger_instruction_hook(Machine, R.PC); while (tms32025_icount > 0) @@ -1996,7 +1996,7 @@ static int tms32025_execute(int cycles) R.PREVPC = R.PC; - CALL_DEBUGGER(R.PC); + debugger_instruction_hook(Machine, R.PC); R.opcode.d = M_RDOP(R.PC); R.PC++; @@ -2021,7 +2021,7 @@ static int tms32025_execute(int cycles) if (R.init_load_addr == 2) { /* Repeat next instruction */ R.PREVPC = R.PC; - CALL_DEBUGGER(R.PC); + debugger_instruction_hook(Machine, R.PC); R.opcode.d = M_RDOP(R.PC); R.PC++; @@ -2386,9 +2386,7 @@ void tms32025_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = tms32025_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = tms32025_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms32025_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_READ: info->read = tms32025_read; break; case CPUINFO_PTR_WRITE: info->write = tms32025_write; break; case CPUINFO_PTR_READOP: info->readop = tms32025_readop; break; diff --git a/src/emu/cpu/tms32025/tms32025.h b/src/emu/cpu/tms32025/tms32025.h index 19d55fbe482..a5a9a728995 100644 --- a/src/emu/cpu/tms32025/tms32025.h +++ b/src/emu/cpu/tms32025/tms32025.h @@ -71,8 +71,6 @@ extern void tms32025_get_info(UINT32 state, cpuinfo *info); extern void tms32026_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER offs_t tms32025_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _TMS32025_H */ diff --git a/src/emu/cpu/tms32031/32031ops.c b/src/emu/cpu/tms32031/32031ops.c index 0f94a5493d3..f3edb348caf 100644 --- a/src/emu/cpu/tms32031/32031ops.c +++ b/src/emu/cpu/tms32031/32031ops.c @@ -85,10 +85,11 @@ static UINT32 defval; static void illegal(void) { -#ifdef ENABLE_DEBUGGER - logerror("Illegal op @ %06X: %08X (tbl=%03X)\n", tms32031.pc - 1, OP, OP >> 21); - DEBUGGER_BREAK; -#endif + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + { + logerror("Illegal op @ %06X: %08X (tbl=%03X)\n", tms32031.pc - 1, OP, OP >> 21); + debugger_break(Machine); + } } @@ -100,7 +101,7 @@ static void unimplemented(void) INLINE void execute_one(void) { - CALL_DEBUGGER(tms32031.pc); + debugger_instruction_hook(Machine, tms32031.pc); OP = ROPCODE(tms32031.pc); tms32031_icount -= 2; /* 2 clocks per cycle */ tms32031.pc++; diff --git a/src/emu/cpu/tms32031/tms32031.c b/src/emu/cpu/tms32031/tms32031.c index 78d08f22481..515e2279f94 100644 --- a/src/emu/cpu/tms32031/tms32031.c +++ b/src/emu/cpu/tms32031/tms32031.c @@ -518,33 +518,61 @@ static int tms32031_execute(int cycles) if (tms32031.is_idling) return tms32031_icount; - while (tms32031_icount > 0) + if ((Machine->debug_flags & DEBUG_FLAG_ENABLED) == 0) { -#ifdef ENABLE_DEBUGGER - if (IREG(TMR_SP) & 0xff000000) - DEBUGGER_BREAK; -#endif - if ((IREG(TMR_ST) & RMFLAG) && tms32031.pc == IREG(TMR_RE) + 1) + while (tms32031_icount > 0) { - if ((INT32)--IREG(TMR_RC) >= 0) - tms32031.pc = IREG(TMR_RS); - else + if ((IREG(TMR_ST) & RMFLAG) && tms32031.pc == IREG(TMR_RE) + 1) { - IREG(TMR_ST) &= ~RMFLAG; - if (tms32031.delayed) + if ((INT32)--IREG(TMR_RC) >= 0) + tms32031.pc = IREG(TMR_RS); + else { - tms32031.delayed = FALSE; - if (tms32031.irq_pending) + IREG(TMR_ST) &= ~RMFLAG; + if (tms32031.delayed) { - tms32031.irq_pending = FALSE; - check_irqs(); + tms32031.delayed = FALSE; + if (tms32031.irq_pending) + { + tms32031.irq_pending = FALSE; + check_irqs(); + } } } + continue; } - continue; + + execute_one(); } + } + else + { + while (tms32031_icount > 0) + { + if (IREG(TMR_SP) & 0xff000000) + debugger_break(Machine); + if ((IREG(TMR_ST) & RMFLAG) && tms32031.pc == IREG(TMR_RE) + 1) + { + if ((INT32)--IREG(TMR_RC) >= 0) + tms32031.pc = IREG(TMR_RS); + else + { + IREG(TMR_ST) &= ~RMFLAG; + if (tms32031.delayed) + { + tms32031.delayed = FALSE; + if (tms32031.irq_pending) + { + tms32031.irq_pending = FALSE; + check_irqs(); + } + } + } + continue; + } - execute_one(); + execute_one(); + } } tms32031_icount -= tms32031.interrupt_cycles; @@ -559,14 +587,12 @@ static int tms32031_execute(int cycles) DISASSEMBLY HOOK ***************************************************************************/ -#ifdef ENABLE_DEBUGGER static offs_t tms32031_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { UINT32 op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); extern unsigned dasm_tms32031(char *, unsigned, UINT32); return dasm_tms32031(buffer, pc, op); } -#endif /* ENABLE_DEBUGGER */ @@ -813,9 +839,7 @@ void tms32031_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = tms32031_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = tms32031_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms32031_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tms32031_icount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map32 = address_map_internal_32031; break; diff --git a/src/emu/cpu/tms32051/tms32051.c b/src/emu/cpu/tms32051/tms32051.c index 3f511c38618..10135b3e959 100644 --- a/src/emu/cpu/tms32051/tms32051.c +++ b/src/emu/cpu/tms32051/tms32051.c @@ -360,7 +360,7 @@ static int tms_execute(int num_cycles) } ppc = tms.pc; - CALL_DEBUGGER(tms.pc); + debugger_instruction_hook(Machine, tms.pc); tms.op = ROPCODE(); tms32051_opcode_table[tms.op >> 8](); @@ -627,9 +627,7 @@ static void tms_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = tms_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = tms_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms32051_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_READ: info->read = tms_debug_read; break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tms_icount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map16 = address_map_internal_pgm; break; diff --git a/src/emu/cpu/tms32051/tms32051.h b/src/emu/cpu/tms32051/tms32051.h index 172db88ef30..f3b2d60b609 100644 --- a/src/emu/cpu/tms32051/tms32051.h +++ b/src/emu/cpu/tms32051/tms32051.h @@ -5,8 +5,6 @@ void tms32051_get_info(UINT32 state, cpuinfo *info); #endif -#ifdef ENABLE_DEBUGGER offs_t tms32051_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _TMS32051_H */ diff --git a/src/emu/cpu/tms34010/34010ops.c b/src/emu/cpu/tms34010/34010ops.c index 29e4faa23f6..4ff1019ad74 100644 --- a/src/emu/cpu/tms34010/34010ops.c +++ b/src/emu/cpu/tms34010/34010ops.c @@ -98,7 +98,7 @@ static void unimpl(void) if (PC == 0 || opcode_table[cpu_readop16(TOBYTE(PC)) >> 4] == unimpl) { cpunum_set_input_line(state.screen->machine, cpu_getactivecpu(), INPUT_LINE_HALT, ASSERT_LINE); - DEBUGGER_BREAK; + debugger_break(state.screen->machine); } } diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c index 194ac066631..a37dfb3f08a 100644 --- a/src/emu/cpu/tms34010/tms34010.c +++ b/src/emu/cpu/tms34010/tms34010.c @@ -841,15 +841,27 @@ static int tms34010_execute(int cycles) /* check interrupts first */ executing_cpu = cpu_getactivecpu(); check_interrupt(); - do + if ((state.screen->machine->debug_flags & DEBUG_FLAG_ENABLED) == 0) { - #ifdef ENABLE_DEBUGGER - if (state.screen->machine->debug_mode) { state.st = GET_ST(); mame_debug_hook(PC); } - #endif - state.op = ROPCODE(); - (*opcode_table[state.op >> 4])(); - - } while (tms34010_ICount > 0); + do + { + state.op = ROPCODE(); + (*opcode_table[state.op >> 4])(); + } while (tms34010_ICount > 0); + } + else + { + do + { + if ((state.screen->machine->debug_flags & DEBUG_FLAG_CALL_HOOK) != 0) + { + state.st = GET_ST(); + debugger_instruction_hook(Machine, PC); + } + state.op = ROPCODE(); + (*opcode_table[state.op >> 4])(); + } while (tms34010_ICount > 0); + } executing_cpu = 0xff; return cycles - tms34010_ICount; @@ -1883,9 +1895,7 @@ void tms34010_get_info(UINT32 _state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = tms34010_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = tms34010_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms34010_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tms34010_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -1972,9 +1982,7 @@ void tms34020_get_info(UINT32 _state, cpuinfo *info) case CPUINFO_PTR_GET_CONTEXT: info->getcontext = tms34020_get_context; break; case CPUINFO_PTR_SET_CONTEXT: info->setcontext = tms34020_set_context; break; case CPUINFO_PTR_RESET: info->reset = tms34020_reset; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms34020_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "TMS34020"); break; diff --git a/src/emu/cpu/tms34010/tms34010.h b/src/emu/cpu/tms34010/tms34010.h index 92c56503ddf..d49d06419f9 100644 --- a/src/emu/cpu/tms34010/tms34010.h +++ b/src/emu/cpu/tms34010/tms34010.h @@ -122,9 +122,7 @@ READ16_HANDLER( tms34020_io_register_r ); #define TOWORD(bitaddr) ((offs_t)(bitaddr) >> 4) -#ifdef ENABLE_DEBUGGER offs_t tms34010_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t tms34020_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* _TMS34010_H */ diff --git a/src/emu/cpu/tms7000/tms7000.c b/src/emu/cpu/tms7000/tms7000.c index f091ed2f4cc..17633a501d8 100644 --- a/src/emu/cpu/tms7000/tms7000.c +++ b/src/emu/cpu/tms7000/tms7000.c @@ -333,9 +333,7 @@ void tms7000_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = tms7000_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = tms7000_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; /* Not supported */break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms7000_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tms7000_icount; break; case CPUINFO_PTR_INTERNAL_MEMORY_MAP: info->internal_map8 = address_map_tms7000_mem; break; @@ -473,7 +471,7 @@ static int tms7000_execute(int cycles) do { - CALL_DEBUGGER(pPC); + debugger_instruction_hook(Machine, pPC); if( tms7000.idle_state == 0 ) { @@ -512,7 +510,7 @@ static int tms7000_exl_execute(int cycles) do { - CALL_DEBUGGER(pPC); + debugger_instruction_hook(Machine, pPC); if( tms7000.idle_state == 0 ) { diff --git a/src/emu/cpu/tms7000/tms7000.h b/src/emu/cpu/tms7000/tms7000.h index 030ce982c1d..71d7306d90a 100644 --- a/src/emu/cpu/tms7000/tms7000.h +++ b/src/emu/cpu/tms7000/tms7000.h @@ -47,9 +47,7 @@ extern void tms7000_A6EC1( void ); /* External event counter */ extern void tms7000_get_info(UINT32 state, cpuinfo *info); extern void tms7000_exl_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned tms7000_dasm( char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram ); -#endif /* ENABLE_DEBUGGER */ #endif /* _TMS7000_H */ diff --git a/src/emu/cpu/tms9900/99xxcore.h b/src/emu/cpu/tms9900/99xxcore.h index 287a9075843..95e8be33963 100644 --- a/src/emu/cpu/tms9900/99xxcore.h +++ b/src/emu/cpu/tms9900/99xxcore.h @@ -1473,39 +1473,35 @@ static int tms99xx_execute(int cycles) } } - #ifdef ENABLE_DEBUGGER + if ((Machine->debug_flags & DEBUG_FLAG_CALL_HOOK) != 0) { - if (Machine->debug_mode) - { - #if 0 /* Trace */ - logerror("> PC %4.4x :%4.4x %4.4x : R=%4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x%4.4x %4.4x %4.4x %4.4x %4.4x %4.4x :T=%d\n",I.PC,I.STATUS,I.WP,I.FR[0],I.FR[1],I.FR[2],I.FR[3],I.FR[4],I.FR[5],I.FR[6],I.FR[7],I.FR[8],I.FR[9],I.FR[10],I.FR[11],I.FR[12],I.FR[13],I.FR[14],I.FR[15],TMS99XX_ICOUNT); - #if 0 /* useful with TI99/4a driver */ - #ifdef MESS - if (I.PC == 0x0078) + #if 0 /* Trace */ + logerror("> PC %4.4x :%4.4x %4.4x : R=%4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x%4.4x %4.4x %4.4x %4.4x %4.4x %4.4x :T=%d\n",I.PC,I.STATUS,I.WP,I.FR[0],I.FR[1],I.FR[2],I.FR[3],I.FR[4],I.FR[5],I.FR[6],I.FR[7],I.FR[8],I.FR[9],I.FR[10],I.FR[11],I.FR[12],I.FR[13],I.FR[14],I.FR[15],TMS99XX_ICOUNT); + #if 0 /* useful with TI99/4a driver */ + #ifdef MESS + if (I.PC == 0x0078) + { + extern struct { - extern struct - { - /* pointer to GROM data */ - UINT8 *data_ptr; - /* current address pointer for the active GROM in port (16 bits) */ - unsigned int addr; - /* GROM data buffer */ - UINT8 buf; - /* internal flip-flops that are set after the first access to the GROM - address so that next access is mapped to the LSB, and cleared after each - data access */ - char raddr_LSB, waddr_LSB; - } console_GROMs; - logerror("> GPL pointer %4.4X\n", console_GROMs.addr); - } - #endif - #endif + /* pointer to GROM data */ + UINT8 *data_ptr; + /* current address pointer for the active GROM in port (16 bits) */ + unsigned int addr; + /* GROM data buffer */ + UINT8 buf; + /* internal flip-flops that are set after the first access to the GROM + address so that next access is mapped to the LSB, and cleared after each + data access */ + char raddr_LSB, waddr_LSB; + } console_GROMs; + logerror("> GPL pointer %4.4X\n", console_GROMs.addr); + } #endif + #endif + #endif - mame_debug_hook(I.IR); - } + debugger_instruction_hook(Machine, I.IR); } - #endif if (I.IDLE) { /* IDLE instruction has halted execution */ @@ -1966,12 +1962,10 @@ static void field_interrupt(void) #endif -#ifdef ENABLE_DEBUGGER static unsigned tms99xx_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return Dasm9900(buffer, pc, TMS99XX_MODEL, oprom, opram); } -#endif /* ENABLE_DEBUGGER */ /*****************************************************************************/ @@ -4811,9 +4805,7 @@ void TMS99XX_GET_INFO(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = tms99xx_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = tms99xx_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = tms99xx_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &TMS99XX_ICOUNT; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/tms9900/tms9900.h b/src/emu/cpu/tms9900/tms9900.h index be5ec7c3d24..43aa7c4f5e2 100644 --- a/src/emu/cpu/tms9900/tms9900.h +++ b/src/emu/cpu/tms9900/tms9900.h @@ -214,9 +214,7 @@ typedef struct tms99110areset_param #endif -#ifdef ENABLE_DEBUGGER unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/upd7810/upd7810.c b/src/emu/cpu/upd7810/upd7810.c index 1238ecba47f..d2228499e0e 100644 --- a/src/emu/cpu/upd7810/upd7810.c +++ b/src/emu/cpu/upd7810/upd7810.c @@ -1702,7 +1702,7 @@ static int upd7810_execute (int cycles) { int cc = 0; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); PPC = PC; RDOP(OP); @@ -2000,9 +2000,7 @@ void upd7810_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = upd7810_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = upd7810_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = upd7810_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &upd7810_icount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -2088,9 +2086,7 @@ void upd7807_get_info(UINT32 state, cpuinfo *info) { /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_RESET: info->reset = upd7807_reset; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = upd7807_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "uPD7807"); break; @@ -2102,9 +2098,7 @@ void upd7807_get_info(UINT32 state, cpuinfo *info) void upd7801_get_info(UINT32 state, cpuinfo *info) { switch( state ) { case CPUINFO_PTR_RESET: info->reset = upd7801_reset; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = upd7801_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_STR_NAME: strcpy(info->s, "uPD7801"); break; @@ -2117,9 +2111,7 @@ void upd78c05_get_info(UINT32 state, cpuinfo *info ) { case CPUINFO_INT_CLOCK_DIVIDER: info->i = 4; break; case CPUINFO_PTR_RESET: info->reset = upd78c05_reset; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = upd78c05_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_STR_NAME: strcpy(info->s, "uPD78C05"); break; diff --git a/src/emu/cpu/upd7810/upd7810.h b/src/emu/cpu/upd7810/upd7810.h index 7e5c983c18b..98451276708 100644 --- a/src/emu/cpu/upd7810/upd7810.h +++ b/src/emu/cpu/upd7810/upd7810.h @@ -160,12 +160,10 @@ typedef struct { int (*irq_callback)(int irqline); } UPD7810; -#ifdef ENABLE_DEBUGGER offs_t upd7810_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t upd7807_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t upd7801_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t upd78c05_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/v30mz/v30mz.c b/src/emu/cpu/v30mz/v30mz.c index cefd990851d..f9fb4e5694a 100644 --- a/src/emu/cpu/v30mz/v30mz.c +++ b/src/emu/cpu/v30mz/v30mz.c @@ -916,12 +916,10 @@ static void set_irq_line(int irqline, int state) } } -#ifdef ENABLE_DEBUGGER static offs_t nec_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { return necv_dasm_one(buffer, pc, oprom); } -#endif /* ENABLE_DEBUGGER */ static void nec_init(int index, int clock, const void *config, int (*irqcallback)(int), int type) { @@ -969,7 +967,7 @@ static int v30mz_execute(int cycles) if (I.no_interrupt) I.no_interrupt--; - CALL_DEBUGGER((I.sregs[CS]<<4) + I.ip); + debugger_instruction_hook(Machine, (I.sregs[CS]<<4) + I.ip); nec_instruction[FETCHOP](); } @@ -1096,9 +1094,7 @@ void v30mz_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = nec_reset; break; case CPUINFO_PTR_EXIT: info->exit = nec_exit; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = nec_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &nec_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/v60/v60.c b/src/emu/cpu/v60/v60.c index 0e1f6f12b8e..b3a10ac8c12 100644 --- a/src/emu/cpu/v60/v60.c +++ b/src/emu/cpu/v60/v60.c @@ -425,7 +425,7 @@ static int v60_execute(int cycles) v60_try_irq(); while(v60_ICount >= 0) { v60.PPC = PC; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); v60_ICount -= 8; /* fix me -- this is just an average */ inc = OpCodeTable[OpRead8(PC)](); PC += inc; @@ -452,10 +452,8 @@ static void v60_set_context(void *src) } -#ifdef ENABLE_DEBUGGER offs_t v60_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); offs_t v70_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif /* ENABLE_DEBUGGER */ /************************************************************************** @@ -641,9 +639,7 @@ void v60_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = v60_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = v60_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = v60_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &v60_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ @@ -732,9 +728,7 @@ void v70_get_info(UINT32 state, cpuinfo *info) /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_PTR_INIT: info->init = v70_init; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = v70_dasm; break; -#endif /* ENABLE_DEBUGGER */ /* --- the following bits of info are returned as NULL-terminated strings --- */ case CPUINFO_STR_NAME: strcpy(info->s, "V70"); break; diff --git a/src/emu/cpu/v60/v60d.c b/src/emu/cpu/v60/v60d.c index 97804598569..e56150f6b95 100644 --- a/src/emu/cpu/v60/v60d.c +++ b/src/emu/cpu/v60/v60d.c @@ -1460,7 +1460,6 @@ static int (*const dasm_optable[256])(unsigned ipc, unsigned pc, char *out) = /* 0xFF */ dopCLRTLB }; -#ifdef ENABLE_DEBUGGER offs_t v60_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { rombase = oprom; @@ -1474,4 +1473,3 @@ offs_t v70_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) pcbase = pc; return dasm_optable[oprom[0]](pc, pc+1, buffer) | DASMFLAG_SUPPORTED; } -#endif diff --git a/src/emu/cpu/v810/v810.c b/src/emu/cpu/v810/v810.c index 6223d90f856..5752f999e6e 100644 --- a/src/emu/cpu/v810/v810.c +++ b/src/emu/cpu/v810/v810.c @@ -973,7 +973,7 @@ static int v810_execute(int cycles) while(v810_ICount>=0) { v810.PPC=PC; - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); OP=R_OP(PC); PC+=2; v810_ICount-= OpCodeTable[OP>>10](); @@ -1182,9 +1182,7 @@ void v810_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = NULL; break; case CPUINFO_PTR_EXECUTE: info->execute = v810_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = v810_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &v810_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/v810/v810.h b/src/emu/cpu/v810/v810.h index d2e83d2f45c..ea0cdb74134 100644 --- a/src/emu/cpu/v810/v810.h +++ b/src/emu/cpu/v810/v810.h @@ -46,9 +46,7 @@ void v810_get_info(UINT32, cpuinfo*); #define ADD(dst, src) { UINT64 res=(UINT64)(dst)+(UINT64)(src); SetCF(res); SetOF_Add(res,src,dst); SetSZPF(res); dst=(UINT32)res; } #define SUB(dst, src) { UINT64 res=(UINT64)(dst)-(INT64)(src); SetCF(res); SetOF_Sub(res,src,dst); SetSZPF(res); dst=(UINT32)res; } -#ifdef ENABLE_DEBUGGER offs_t v810_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif enum { diff --git a/src/emu/cpu/z180/z180.c b/src/emu/cpu/z180/z180.c index c86332cfc9c..6992499be9b 100644 --- a/src/emu/cpu/z180/z180.c +++ b/src/emu/cpu/z180/z180.c @@ -2211,7 +2211,7 @@ again: if ((IO_DSTAT & Z180_DSTAT_DE0) == Z180_DSTAT_DE0 && (IO_DMODE & Z180_DMODE_MMOD) == Z180_DMODE_MMOD) { - CALL_DEBUGGER(_PCD); + debugger_instruction_hook(Machine, _PCD); z180_dma0(); old_icount = handle_timers(z180_icount, old_icount); @@ -2224,7 +2224,7 @@ again: Z180.after_EI = 0; _PPC = _PCD; - CALL_DEBUGGER(_PCD); + debugger_instruction_hook(Machine, _PCD); _R++; EXEC_INLINE(op,ROP()); @@ -2251,7 +2251,7 @@ again: Z180.after_EI = 0; _PPC = _PCD; - CALL_DEBUGGER(_PCD); + debugger_instruction_hook(Machine, _PCD); _R++; EXEC_INLINE(op,ROP()); old_icount = handle_timers(z180_icount, old_icount); @@ -2589,9 +2589,7 @@ void z180_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_RESET: info->reset = z180_reset; break; case CPUINFO_PTR_EXECUTE: info->execute = z180_execute; break; case CPUINFO_PTR_BURN: info->burn = z180_burn; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = z180_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &z180_icount; break; case CPUINFO_PTR_TRANSLATE: info->translate = z180_translate; break; case CPUINFO_PTR_Z180_CYCLE_TABLE + Z180_TABLE_op: info->p = (void *)cc[Z180_TABLE_op]; break; diff --git a/src/emu/cpu/z180/z180.h b/src/emu/cpu/z180/z180.h index 04897283532..7191c1d1f20 100644 --- a/src/emu/cpu/z180/z180.h +++ b/src/emu/cpu/z180/z180.h @@ -127,9 +127,7 @@ extern void z180_setOPbase(int pc); extern void z180_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER offs_t z180_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif diff --git a/src/emu/cpu/z80/z80.c b/src/emu/cpu/z80/z80.c index 734544f34d3..1186f970611 100644 --- a/src/emu/cpu/z80/z80.c +++ b/src/emu/cpu/z80/z80.c @@ -3565,7 +3565,7 @@ static int z80_execute(int cycles) Z80.after_ei = FALSE; PRVPC = PCD; - CALL_DEBUGGER(PCD); + debugger_instruction_hook(Machine, PCD); R++; EXEC_INLINE(op,ROP()); } while( z80_ICount > 0 ); @@ -3755,9 +3755,7 @@ void z80_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = z80_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = z80_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = z80_dasm; break; -#endif case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &z80_ICount; break; case CPUINFO_PTR_Z80_CYCLE_TABLE + Z80_TABLE_op: info->p = (void *)cc[Z80_TABLE_op]; break; case CPUINFO_PTR_Z80_CYCLE_TABLE + Z80_TABLE_cb: info->p = (void *)cc[Z80_TABLE_cb]; break; diff --git a/src/emu/cpu/z80/z80.h b/src/emu/cpu/z80/z80.h index 94bb71ababa..7ab686ebd44 100644 --- a/src/emu/cpu/z80/z80.h +++ b/src/emu/cpu/z80/z80.h @@ -29,10 +29,7 @@ enum extern void z80_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER extern unsigned z80_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif - #endif diff --git a/src/emu/cpu/z8000/z8000.c b/src/emu/cpu/z8000/z8000.c index dbc3448a973..bcfb1ca74a3 100644 --- a/src/emu/cpu/z8000/z8000.c +++ b/src/emu/cpu/z8000/z8000.c @@ -483,7 +483,7 @@ static int z8000_execute(int cycles) if (IRQ_REQ) Interrupt(); - CALL_DEBUGGER(PC); + debugger_instruction_hook(Machine, PC); if (IRQ_REQ & Z8000_HALT) { @@ -692,9 +692,7 @@ void z8000_get_info(UINT32 state, cpuinfo *info) case CPUINFO_PTR_EXIT: info->exit = z8000_exit; break; case CPUINFO_PTR_EXECUTE: info->execute = z8000_execute; break; case CPUINFO_PTR_BURN: info->burn = NULL; break; -#ifdef ENABLE_DEBUGGER case CPUINFO_PTR_DISASSEMBLE: info->disassemble = z8000_dasm; break; -#endif /* ENABLE_DEBUGGER */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &z8000_ICount; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ diff --git a/src/emu/cpu/z8000/z8000.h b/src/emu/cpu/z8000/z8000.h index f6f80dc3fef..bb75f6396e8 100644 --- a/src/emu/cpu/z8000/z8000.h +++ b/src/emu/cpu/z8000/z8000.h @@ -22,8 +22,6 @@ enum { /* PUBLIC FUNCTIONS */ extern void z8000_get_info(UINT32 state, cpuinfo *info); -#ifdef ENABLE_DEBUGGER offs_t z8000_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); -#endif #endif /* Z8K_H */ diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c index 19314eaaeb4..82ecb841b71 100644 --- a/src/emu/cpuexec.c +++ b/src/emu/cpuexec.c @@ -11,6 +11,7 @@ #include "driver.h" #include "profiler.h" +#include "debugger.h" @@ -278,7 +279,9 @@ void cpuexec_timeslice(running_machine *machine) /* note that this global variable cycles_stolen can be modified */ /* via the call to the cpunum_execute */ cycles_stolen = 0; + debugger_start_cpu_hook(machine, cpunum, target); ran = cpunum_execute(cpunum, cycles_running); + debugger_stop_cpu_hook(machine, cpunum); #ifdef MAME_DEBUG if (ran < cycles_stolen) diff --git a/src/emu/cpuint.c b/src/emu/cpuint.c index fc64e66820d..4373abb4d74 100644 --- a/src/emu/cpuint.c +++ b/src/emu/cpuint.c @@ -11,10 +11,8 @@ #include "driver.h" #include "deprecat.h" - -#ifdef ENABLE_DEBUGGER #include "debug/debugcpu.h" -#endif + /************************************* @@ -350,10 +348,8 @@ INLINE int cpu_irq_callback(running_machine *machine, int cpunum, int line) if (drv_irq_callbacks[cpunum]) vector = (*drv_irq_callbacks[cpunum])(machine, line); -#ifdef ENABLE_DEBUGGER /* notify the debugger */ - debug_interrupt_hook(cpunum, line); -#endif + debug_cpu_interrupt_hook(machine, cpunum, line); /* otherwise, just return the current vector */ return vector; diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index 43bb646fadb..5457d17aebf 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -250,7 +250,7 @@ void debug_command_init(running_machine *machine) /* set up the initial debugscript if specified */ name = options_get_string(mame_options(), OPTION_DEBUGSCRIPT); if (name[0] != 0) - debug_source_script(name); + debug_cpu_source_script(name); } @@ -798,7 +798,7 @@ static void execute_ignore(int ref, int params, const char *param[]) const debug_cpu_info *info = debug_get_cpu_info(cpunum); /* build up a comma-separated list */ - if (info && info->valid && info->ignoring) + if (info && info->valid && (info->flags & DEBUG_FLAG_OBSERVING) == 0) { if (buflen == 0) buflen += sprintf(&buffer[buflen], "Currently ignoring CPU %d", cpunum); else buflen += sprintf(&buffer[buflen], ",%d", cpunum); @@ -833,7 +833,7 @@ static void execute_ignore(int ref, int params, const char *param[]) for (cpunum = 0; cpunum < MAX_CPU; cpunum++) { const debug_cpu_info *info = debug_get_cpu_info(cpunum); - if (cpunum != cpuwhich[paramnum] && info && info->valid && !info->ignoring) + if (cpunum != cpuwhich[paramnum] && info && info->valid && (info->flags & DEBUG_FLAG_OBSERVING) != 0) break; } if (cpunum == MAX_CPU) @@ -869,7 +869,7 @@ static void execute_observe(int ref, int params, const char *param[]) const debug_cpu_info *info = debug_get_cpu_info(cpunum); /* build up a comma-separated list */ - if (info && info->valid && !info->ignoring) + if (info && info->valid && (info->flags & DEBUG_FLAG_OBSERVING) != 0) { if (buflen == 0) buflen += sprintf(&buffer[buflen], "Currently observing CPU %d", cpunum); else buflen += sprintf(&buffer[buflen], ",%d", cpunum); @@ -994,7 +994,7 @@ static void execute_bpset(int ref, int params, const char *param[]) return; /* set the breakpoint */ - bpnum = debug_breakpoint_set(cpu_getactivecpu(), address, condition, action); + bpnum = debug_cpu_breakpoint_set(cpu_getactivecpu(), address, condition, action); debug_console_printf("Breakpoint %X set\n", bpnum); } @@ -1019,8 +1019,8 @@ static void execute_bpclear(int ref, int params, const char *param[]) if (cpuinfo->valid) { debug_cpu_breakpoint *bp; - while ((bp = cpuinfo->first_bp) != NULL) - debug_breakpoint_clear(bp->index); + while ((bp = cpuinfo->bplist) != NULL) + debug_cpu_breakpoint_clear(bp->index); } } debug_console_printf("Cleared all breakpoints\n"); @@ -1031,7 +1031,7 @@ static void execute_bpclear(int ref, int params, const char *param[]) return; else { - int found = debug_breakpoint_clear(bpindex); + int found = debug_cpu_breakpoint_clear(bpindex); if (found) debug_console_printf("Breakpoint %X cleared\n", (UINT32)bpindex); else @@ -1060,8 +1060,8 @@ static void execute_bpdisenable(int ref, int params, const char *param[]) if (cpuinfo->valid) { debug_cpu_breakpoint *bp; - for (bp = cpuinfo->first_bp; bp; bp = bp->next) - debug_breakpoint_enable(bp->index, ref); + for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) + debug_cpu_breakpoint_enable(bp->index, ref); } } if (ref == 0) @@ -1075,7 +1075,7 @@ static void execute_bpdisenable(int ref, int params, const char *param[]) return; else { - int found = debug_breakpoint_enable(bpindex, ref); + int found = debug_cpu_breakpoint_enable(bpindex, ref); if (found) debug_console_printf("Breakpoint %X %s\n", (UINT32)bpindex, ref ? "enabled" : "disabled"); else @@ -1099,14 +1099,14 @@ static void execute_bplist(int ref, int params, const char *param[]) { const debug_cpu_info *cpuinfo = debug_get_cpu_info(cpunum); - if (cpuinfo->valid && cpuinfo->first_bp) + if (cpuinfo->valid && cpuinfo->bplist != NULL) { debug_cpu_breakpoint *bp; debug_console_printf("CPU %d breakpoints:\n", cpunum); /* loop over the breakpoints */ - for (bp = cpuinfo->first_bp; bp; bp = bp->next) + for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) { int buflen; buflen = sprintf(buffer, "%c%4X @ %08X", bp->enabled ? ' ' : 'D', bp->index, bp->address); @@ -1168,7 +1168,7 @@ static void execute_wpset(int ref, int params, const char *param[]) return; /* set the watchpoint */ - wpnum = debug_watchpoint_set(cpu_getactivecpu(), ref, type, address, length, condition, action); + wpnum = debug_cpu_watchpoint_set(cpu_getactivecpu(), ref, type, address, length, condition, action); debug_console_printf("Watchpoint %X set\n", wpnum); } @@ -1197,8 +1197,8 @@ static void execute_wpclear(int ref, int params, const char *param[]) for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { debug_cpu_watchpoint *wp; - while ((wp = cpuinfo->space[spacenum].first_wp) != NULL) - debug_watchpoint_clear(wp->index); + while ((wp = cpuinfo->space[spacenum].wplist) != NULL) + debug_cpu_watchpoint_clear(wp->index); } } } @@ -1210,7 +1210,7 @@ static void execute_wpclear(int ref, int params, const char *param[]) return; else { - int found = debug_watchpoint_clear(wpindex); + int found = debug_cpu_watchpoint_clear(wpindex); if (found) debug_console_printf("Watchpoint %X cleared\n", (UINT32)wpindex); else @@ -1243,8 +1243,8 @@ static void execute_wpdisenable(int ref, int params, const char *param[]) for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { debug_cpu_watchpoint *wp; - for (wp = cpuinfo->space[spacenum].first_wp; wp; wp = wp->next) - debug_watchpoint_enable(wp->index, ref); + for (wp = cpuinfo->space[spacenum].wplist; wp != NULL; wp = wp->next) + debug_cpu_watchpoint_enable(wp->index, ref); } } } @@ -1259,7 +1259,7 @@ static void execute_wpdisenable(int ref, int params, const char *param[]) return; else { - int found = debug_watchpoint_enable(wpindex, ref); + int found = debug_cpu_watchpoint_enable(wpindex, ref); if (found) debug_console_printf("Watchpoint %X %s\n", (UINT32)wpindex, ref ? "enabled" : "disabled"); else @@ -1289,7 +1289,7 @@ static void execute_wplist(int ref, int params, const char *param[]) for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { - if (cpuinfo->space[spacenum].first_wp) + if (cpuinfo->space[spacenum].wplist != NULL) { static const char *const types[] = { "unkn ", "read ", "write", "r/w " }; debug_cpu_watchpoint *wp; @@ -1297,7 +1297,7 @@ static void execute_wplist(int ref, int params, const char *param[]) debug_console_printf("CPU %d %s space watchpoints:\n", cpunum, address_space_names[spacenum]); /* loop over the watchpoints */ - for (wp = cpuinfo->space[spacenum].first_wp; wp; wp = wp->next) + for (wp = cpuinfo->space[spacenum].wplist; wp != NULL; wp = wp->next) { int buflen; buflen = sprintf(buffer, "%c%4X @ %08X-%08X %s", wp->enabled ? ' ' : 'D', @@ -1342,7 +1342,7 @@ static void execute_hotspot(int ref, int params, const char *param[]) if (cpuinfo->valid && cpuinfo->hotspots) { - debug_hotspot_track(cpunum, 0, 0); + debug_cpu_hotspot_track(cpunum, 0, 0); debug_console_printf("Cleared hotspot tracking on CPU %d\n", (int)cpunum); cleared = TRUE; } @@ -1365,7 +1365,7 @@ static void execute_hotspot(int ref, int params, const char *param[]) return; /* attempt to install */ - if (debug_hotspot_track(cpunum, count, threshhold)) + if (debug_cpu_hotspot_track(cpunum, count, threshhold)) debug_console_printf("Now tracking hotspots on CPU %d using %d slots with a threshhold of %d\n", (int)cpunum, (int)count, (int)threshhold); else debug_console_printf("Error setting up the hotspot tracking\n"); @@ -1925,7 +1925,7 @@ static void execute_traceover(int ref, int params, const char *param[]) static void execute_traceflush(int ref, int params, const char *param[]) { - debug_flush_traces(); + debug_cpu_flush_traces(); } @@ -2041,7 +2041,7 @@ static void execute_snap(int ref, int params, const char *param[]) static void execute_source(int ref, int params, const char *param[]) { - debug_source_script(param[0]); + debug_cpu_source_script(param[0]); } diff --git a/src/emu/debug/debugcon.c b/src/emu/debug/debugcon.c index a4b710bf703..3dc268bdad8 100644 --- a/src/emu/debug/debugcon.c +++ b/src/emu/debug/debugcon.c @@ -16,6 +16,7 @@ #include "debugvw.h" #include "textbuf.h" #include "deprecat.h" +#include "debugger.h" #include <ctype.h> @@ -372,7 +373,7 @@ CMDERR debug_console_execute_command(const char *command, int echo) if (echo) { debug_view_update_all(); - debug_refresh_display(); + debugger_refresh_display(Machine); } return result; } @@ -399,7 +400,7 @@ void debug_console_register_command(const char *command, UINT32 flags, int ref, debug_command *cmd; assert_always(mame_get_phase(Machine) == MAME_PHASE_INIT, "Can only call debug_console_register_command() at init time!"); - assert_always(Machine->debug_mode, "Cannot call debug_console_register_command() when debugger is not running"); + assert_always((Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0, "Cannot call debug_console_register_command() when debugger is not running"); cmd = auto_malloc(sizeof(*cmd)); memset(cmd, 0, sizeof(*cmd)); diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 039024c2728..919c5138ad5 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -7,6 +7,12 @@ Copyright Nicola Salmoria and the MAME Team. Visit http://mamedev.org for licensing and usage restrictions. +********************************************************************** + + Future work: + + - enable history to be enabled/disabled to improve performance + *********************************************************************/ #include "osdepend.h" @@ -17,6 +23,7 @@ #include "debugcon.h" #include "express.h" #include "debugvw.h" +#include "debugger.h" #include "deprecat.h" #include <ctype.h> @@ -28,12 +35,42 @@ #define NUM_TEMP_VARIABLES 10 +enum +{ + EXECUTION_STATE_STOPPED, + EXECUTION_STATE_RUNNING +}; + /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ +typedef struct _debugger_private debugger_private; +struct _debugger_private +{ + debug_cpu_info cpuinfo[MAX_CPU]; + debug_cpu_info *livecpu; + debug_cpu_info *visiblecpu; + + UINT8 within_instruction_hook; + UINT8 vblank_occurred; + UINT8 memory_modified; + + int execution_state; + int memory_hook_cpunum; + + UINT32 bpindex; + UINT32 wpindex; + + UINT64 wpdata; + UINT64 wpaddr; + UINT64 tempvar[NUM_TEMP_VARIABLES]; + + osd_ticks_t last_periodic_update_time; +}; + /*************************************************************************** @@ -43,32 +80,8 @@ FILE *debug_source_file; symbol_table *global_symtable; -static UINT64 wpdata; -static UINT64 wpaddr; - -static int execution_state; -static UINT32 execution_counter; -static int next_index = 1; -static int within_debugger_code = FALSE; -static int last_cpunum; -static int last_stopped_cpunum; -static int steps_until_stop; -static offs_t step_overout_breakpoint; -static int step_overout_cpunum; -static int key_check_counter; -static osd_ticks_t last_periodic_update_time; -static int break_on_vblank; -static int break_on_interrupt; -static int break_on_interrupt_cpunum; -static int break_on_interrupt_irqline; -static int break_on_time; -static attotime break_on_time_target; -static int memory_modified; -static int memory_hook_cpunum; +static debugger_private global; -static debug_cpu_info debug_cpuinfo[MAX_CPU]; - -static UINT64 tempvar[NUM_TEMP_VARIABLES]; @@ -78,8 +91,13 @@ static UINT64 tempvar[NUM_TEMP_VARIABLES]; static void debug_cpu_exit(running_machine *machine); static void perform_trace(debug_cpu_info *info); -static void prepare_for_step_overout(void); +static void prepare_for_step_overout(debug_cpu_info *info); static void process_source_file(void); +static void breakpoint_check(debug_cpu_info *info, offs_t pc); +static void watchpoint_check(int cpunum, int spacenum, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask); +static void check_hotspots(int cpunum, int spacenum, offs_t address); + +/* variable getters/setters */ static UINT64 get_wpaddr(UINT32 ref); static UINT64 get_wpdata(UINT32 ref); static UINT64 get_cycles(UINT32 ref); @@ -93,8 +111,6 @@ static void set_logunmap(UINT32 ref, UINT64 value); static UINT64 get_current_pc(UINT32 ref); static UINT64 get_cpu_reg(UINT32 ref); static void set_cpu_reg(UINT32 ref, UINT64 value); -static void check_watchpoints(int cpunum, int spacenum, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask); -static void check_hotspots(int cpunum, int spacenum, offs_t address); @@ -103,40 +119,13 @@ static void check_hotspots(int cpunum, int spacenum, offs_t address); ***************************************************************************/ /*------------------------------------------------- - mame_debug_init - start up all subsections --------------------------------------------------*/ - -void mame_debug_init(running_machine *machine) -{ - /* initialize the various subsections */ - debug_cpu_init(machine); - debug_command_init(machine); - debug_console_init(machine); - debug_view_init(machine); - debug_comment_init(machine); - atexit(debug_flush_traces); - add_logerror_callback(machine, debug_errorlog_write_line); -} - - -/*------------------------------------------------- - mame_debug_break - break into the debugger + debug_cpu_within_instruction_hook - true if + the debugger is currently live -------------------------------------------------*/ -void mame_debug_break(void) +int debug_cpu_within_instruction_hook(running_machine *machine) { - debug_halt_on_next_instruction(); -} - - -/*------------------------------------------------- - mame_debug_is_active - true if the debugger - is currently live --------------------------------------------------*/ - -int mame_debug_is_active(void) -{ - return within_debugger_code; + return global.within_instruction_hook; } @@ -146,13 +135,9 @@ int mame_debug_is_active(void) static void on_vblank(const device_config *device, int vblank_state) { - /* if we're configured to stop on VBLANK, break */ - if (vblank_state && break_on_vblank) - { - execution_state = EXECUTION_STATE_STOPPED; - debug_console_printf("Stopped at VBLANK\n"); - break_on_vblank = 0; - } + /* just set a global flag to be consumed later */ + if (vblank_state) + global.vblank_occurred = TRUE; } @@ -170,16 +155,11 @@ void debug_cpu_init(running_machine *machine) int cpunum, spacenum, regnum; /* reset globals */ - execution_state = EXECUTION_STATE_STOPPED; - execution_counter = 0; - next_index = 1; - within_debugger_code = FALSE; - last_cpunum = 0; - last_stopped_cpunum = 0; - steps_until_stop = 0; - step_overout_breakpoint = ~0; - step_overout_cpunum = 0; - key_check_counter = 0; + global.execution_state = EXECUTION_STATE_STOPPED; + global.bpindex = 1; + global.wpindex = 1; + global.within_instruction_hook = FALSE; + global.visiblecpu = NULL; /* create a global symbol table */ global_symtable = symtable_alloc(NULL); @@ -203,36 +183,34 @@ void debug_cpu_init(running_machine *machine) symtable_add_register(global_symtable, symname, regnum, get_tempvar, set_tempvar); } - /* reset the CPU info */ - memset(debug_cpuinfo, 0, sizeof(debug_cpuinfo)); - /* loop over CPUs and build up their info */ for (cpunum = 0; cpunum < MAX_CPU; cpunum++) { cpu_type cputype = machine->config->cpu[cpunum].type; + debug_cpu_info *info = &global.cpuinfo[cpunum]; /* if this is a dummy, stop looking */ + memset(info, 0, sizeof(*info)); if (cputype == CPU_DUMMY) break; /* reset the PC data */ - debug_cpuinfo[cpunum].valid = 1; - debug_cpuinfo[cpunum].endianness = cpunum_endianness(cpunum); - debug_cpuinfo[cpunum].opwidth = cpunum_min_instruction_bytes(cpunum); - debug_cpuinfo[cpunum].ignoring = 0; - debug_cpuinfo[cpunum].temp_breakpoint_pc = ~0; + info->valid = TRUE; + info->flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; + info->endianness = cpunum_endianness(cpunum); + info->opwidth = cpunum_min_instruction_bytes(cpunum); /* fetch the memory accessors */ - debug_cpuinfo[cpunum].translate = (cpu_translate_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_TRANSLATE); - debug_cpuinfo[cpunum].read = (cpu_read_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_READ); - debug_cpuinfo[cpunum].write = (cpu_write_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_WRITE); - debug_cpuinfo[cpunum].readop = (cpu_readop_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_READOP); + info->translate = (cpu_translate_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_TRANSLATE); + info->read = (cpu_read_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_READ); + info->write = (cpu_write_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_WRITE); + info->readop = (cpu_readop_func)cpunum_get_info_fct(cpunum, CPUINFO_PTR_READOP); /* allocate a symbol table */ - debug_cpuinfo[cpunum].symtable = symtable_alloc(global_symtable); + info->symtable = symtable_alloc(global_symtable); /* add a global symbol for the current instruction pointer */ - symtable_add_register(debug_cpuinfo[cpunum].symtable, "curpc", 0, get_current_pc, 0); + symtable_add_register(info->symtable, "curpc", 0, get_current_pc, 0); /* add all registers into it */ for (regnum = 0; regnum < MAX_REGS; regnum++) @@ -258,13 +236,13 @@ void debug_cpu_init(running_machine *machine) symname[charnum] = 0; /* add the symbol to the table */ - symtable_add_register(debug_cpuinfo[cpunum].symtable, symname, regnum, get_cpu_reg, set_cpu_reg); + symtable_add_register(info->symtable, symname, regnum, get_cpu_reg, set_cpu_reg); } /* loop over address spaces and get info */ for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { - debug_space_info *spaceinfo = &debug_cpuinfo[cpunum].space[spacenum]; + debug_space_info *spaceinfo = &info->space[spacenum]; int datawidth = cpunum_databus_width(cpunum, spacenum); int logwidth = cpunum_logaddr_width(cpunum, spacenum); int physwidth = cpunum_addrbus_width(cpunum, spacenum); @@ -314,26 +292,28 @@ static void debug_cpu_exit(running_machine *machine) /* loop over all watchpoints and breakpoints to free their memory */ for (cpunum = 0; cpunum < MAX_CPU; cpunum++) { + debug_cpu_info *info = &global.cpuinfo[cpunum]; + /* close any tracefiles */ - if (debug_cpuinfo[cpunum].trace.file) - fclose(debug_cpuinfo[cpunum].trace.file); - if (debug_cpuinfo[cpunum].trace.action) - free(debug_cpuinfo[cpunum].trace.action); + if (info->trace.file) + fclose(info->trace.file); + if (info->trace.action) + free(info->trace.action); /* free the symbol table */ - if (debug_cpuinfo[cpunum].symtable) - symtable_free(debug_cpuinfo[cpunum].symtable); + if (info->symtable) + symtable_free(info->symtable); /* free all breakpoints */ - while (debug_cpuinfo[cpunum].first_bp) - debug_breakpoint_clear(debug_cpuinfo[cpunum].first_bp->index); + while (info->bplist) + debug_cpu_breakpoint_clear(info->bplist->index); /* loop over all address spaces */ for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { /* free all watchpoints */ - while (debug_cpuinfo[cpunum].space[spacenum].first_wp) - debug_watchpoint_clear(debug_cpuinfo[cpunum].space[spacenum].first_wp->index); + while (info->space[spacenum].wplist) + debug_cpu_watchpoint_clear(info->space[spacenum].wplist->index); } } @@ -345,546 +325,553 @@ static void debug_cpu_exit(running_machine *machine) /*************************************************************************** - EXECUTION CONTROL + MAIN CPU CALLBACK ***************************************************************************/ /*------------------------------------------------- - debug_cpu_single_step - single step past the - requested number of instructions + compute_debug_flags - compute the global + debug flags for optimal efficiency -------------------------------------------------*/ -void debug_cpu_single_step(int numsteps) +static void compute_debug_flags(running_machine *machine, const debug_cpu_info *info) { - if (!within_debugger_code) + /* clear out all global flags by default */ + machine->debug_flags = DEBUG_FLAG_ENABLED; + + /* if we are ignoring this CPU, or if events are pending, we're done */ + if ((info->flags & DEBUG_FLAG_OBSERVING) == 0 || mame_is_scheduled_event_pending(machine) || mame_is_save_or_load_pending(machine)) return; - steps_until_stop = numsteps; - execution_state = EXECUTION_STATE_STEP_INTO; + + /* many of our states require us to be called on each instruction */ + if (global.execution_state == EXECUTION_STATE_STOPPED) + machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; + if ((info->flags & (DEBUG_FLAG_HISTORY | DEBUG_FLAG_TRACING_ANY | DEBUG_FLAG_HOOKED | + DEBUG_FLAG_STEPPING_ANY | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) + machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; + + /* if we are stopping at a particular time and that time is within the current timeslice, we need to be called */ + if ((info->flags & DEBUG_FLAG_STOP_TIME) && attotime_compare(info->endexectime, info->stoptime) <= 0) + machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; + + /* add in the watchpoint flags */ + machine->debug_flags |= (info->flags & DEBUG_FLAG_WATCHPOINT) >> (24 - 4); } /*------------------------------------------------- - debug_cpu_single_step_over - single step over - a single instruction + reset_transient_flags - reset the transient + flags on all CPUs -------------------------------------------------*/ -void debug_cpu_single_step_over(int numsteps) +static void reset_transient_flags(running_machine *machine) { - if (!within_debugger_code) - return; - steps_until_stop = numsteps; - step_overout_cpunum = cpu_getactivecpu(); - execution_state = EXECUTION_STATE_STEP_OVER; + int cpunum; + + /* loop over CPUs and reset the transient flags */ + for (cpunum = 0; cpunum < ARRAY_LENGTH(global.cpuinfo); cpunum++) + global.cpuinfo[cpunum].flags &= ~DEBUG_FLAG_TRANSIENT; } /*------------------------------------------------- - debug_cpu_single_step_out - single step out of - the current function + debug_cpu_start_hook - the CPU execution + system calls this hook before beginning + execution for the given CPU -------------------------------------------------*/ -void debug_cpu_single_step_out(void) +void debug_cpu_start_hook(running_machine *machine, int cpunum, attotime endtime) { - if (!within_debugger_code) - return; - steps_until_stop = 100; - step_overout_cpunum = cpu_getactivecpu(); - execution_state = EXECUTION_STATE_STEP_OUT; -} + debug_cpu_info *info = &global.cpuinfo[cpunum]; + assert((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0); -/*------------------------------------------------- - debug_cpu_go - resume execution --------------------------------------------------*/ + /* stash a pointer to the current live CPU */ + assert(global.livecpu == NULL); + global.livecpu = info; -void debug_cpu_go(offs_t targetpc) -{ - if (!within_debugger_code) - return; - execution_state = EXECUTION_STATE_RUNNING; - debug_cpuinfo[cpu_getactivecpu()].temp_breakpoint_pc = targetpc; -} + /* update the target execution end time */ + info->endexectime = endtime; + + /* if a VBLANK occurred, check on things */ + if (global.vblank_occurred && global.execution_state != EXECUTION_STATE_STOPPED) + { + global.vblank_occurred = FALSE; + /* if we were waiting for a VBLANK, signal it now */ + if ((info->flags & DEBUG_FLAG_STOP_VBLANK) != 0) + { + global.execution_state = EXECUTION_STATE_STOPPED; + debug_console_printf("Stopped at VBLANK\n"); + } + + /* check for debug keypresses */ + else if (input_ui_pressed(machine, IPT_UI_DEBUG_BREAK)) + { + global.execution_state = EXECUTION_STATE_STOPPED; + debug_console_printf("User-initiated break\n"); + } -/*------------------------------------------------- - debug_cpu_go_vblank - run until the next - VBLANK --------------------------------------------------*/ + /* while we're here, check for a periodic update */ + else if (info == global.visiblecpu && osd_ticks() > global.last_periodic_update_time + osd_ticks_per_second()/4) + { + debug_view_update_all(); + global.last_periodic_update_time = osd_ticks(); + } + } -void debug_cpu_go_vblank(void) -{ - if (!within_debugger_code) - return; - execution_state = EXECUTION_STATE_RUNNING; - debug_cpuinfo[cpu_getactivecpu()].temp_breakpoint_pc = ~0; - break_on_vblank = 1; + /* recompute the debugging mode */ + compute_debug_flags(machine, info); } /*------------------------------------------------- - debug_cpu_go_interrupt - run until the - specified interrupt fires + debug_cpu_stop_hook - the CPU execution + system calls this hook when ending execution + for the given CPU -------------------------------------------------*/ -void debug_cpu_go_interrupt(int irqline) +void debug_cpu_stop_hook(running_machine *machine, int cpunum) { - if (!within_debugger_code) - return; - execution_state = EXECUTION_STATE_RUNNING; - debug_cpuinfo[cpu_getactivecpu()].temp_breakpoint_pc = ~0; - break_on_interrupt = 1; - break_on_interrupt_cpunum = cpu_getactivecpu(); - break_on_interrupt_irqline = irqline; + debug_cpu_info *info = &global.cpuinfo[cpunum]; + + assert(global.livecpu == info); + + /* if we're stopping on a context switch, handle it now */ + if (info->flags & DEBUG_FLAG_STOP_CONTEXT) + { + global.execution_state = EXECUTION_STATE_STOPPED; + reset_transient_flags(machine); + } + + /* clear the live CPU */ + global.livecpu = NULL; } /*------------------------------------------------- - debug_cpu_go_milliseconds - run until the - specified delay elapses + debug_cpu_interrupt_hook - called when an + interrupt is acknowledged -------------------------------------------------*/ -void debug_cpu_go_milliseconds(UINT64 milliseconds) +void debug_cpu_interrupt_hook(running_machine *machine, int cpunum, int irqline) { - if (!within_debugger_code) - return; - execution_state = EXECUTION_STATE_RUNNING; - debug_cpuinfo[cpu_getactivecpu()].temp_breakpoint_pc = ~0; - break_on_time = 1; - break_on_time_target = attotime_add( - timer_get_time(), - attotime_make(milliseconds / 1000, (milliseconds % 1000) * (ATTOSECONDS_PER_SECOND / 1000))); + debug_cpu_info *info = &global.cpuinfo[cpunum]; + + /* see if this matches a pending interrupt request */ + if ((info->flags & DEBUG_FLAG_STOP_INTERRUPT) != 0 && (info->stopirq == -1 || info->stopirq == irqline)) + { + global.execution_state = EXECUTION_STATE_STOPPED; + debug_console_printf("Stopped on interrupt (CPU %d, IRQ %d)\n", cpunum, irqline); + compute_debug_flags(machine, info); + } } /*------------------------------------------------- - debug_cpu_next_cpu - execute until we hit - the next CPU + debug_cpu_exception_hook - called when an + exception is generated -------------------------------------------------*/ -void debug_cpu_next_cpu(void) +void debug_cpu_exception_hook(running_machine *machine, int cpunum, int exception) { - if (!within_debugger_code) - return; - execution_state = EXECUTION_STATE_NEXT_CPU; + debug_cpu_info *info = &global.cpuinfo[cpunum]; + + /* see if this matches a pending interrupt request */ + if ((info->flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (info->stopexception == -1 || info->stopexception == exception)) + { + global.execution_state = EXECUTION_STATE_STOPPED; + debug_console_printf("Stopped on exception (CPU %d, exception %d)\n", cpunum, exception); + compute_debug_flags(machine, info); + } } /*------------------------------------------------- - debug_cpu_ignore_cpu - ignore/observe a given - CPU + debug_cpu_instruction_hook - called by the + CPU cores before executing each instruction -------------------------------------------------*/ -void debug_cpu_ignore_cpu(int cpunum, int ignore) +void debug_cpu_instruction_hook(running_machine *machine, offs_t curpc) { - debug_cpuinfo[cpunum].ignoring = ignore; - if (!within_debugger_code) - return; - if (cpunum == cpu_getactivecpu() && debug_cpuinfo[cpunum].ignoring) - execution_state = EXECUTION_STATE_NEXT_CPU; -} + debug_cpu_info *info = global.livecpu; + /* note that we are in the debugger code */ + global.within_instruction_hook = TRUE; -/*------------------------------------------------- - debug_cpu_trace - trace execution of a given - CPU --------------------------------------------------*/ + /* update the history */ + info->pc_history[info->pc_history_index++ % DEBUG_HISTORY_SIZE] = curpc; -void debug_cpu_trace(int cpunum, FILE *file, int trace_over, const char *action) -{ - /* close existing files and delete expressions */ - if (debug_cpuinfo[cpunum].trace.file) - fclose(debug_cpuinfo[cpunum].trace.file); - debug_cpuinfo[cpunum].trace.file = NULL; + /* are we tracing? */ + if (info->flags & DEBUG_FLAG_TRACING_ANY) + perform_trace(info); - if (debug_cpuinfo[cpunum].trace.action) - free(debug_cpuinfo[cpunum].trace.action); - debug_cpuinfo[cpunum].trace.action = NULL; + /* per-instruction hook? */ + if (global.execution_state != EXECUTION_STATE_STOPPED && (info->flags & DEBUG_FLAG_HOOKED) != 0 && (*info->instrhook)(curpc)) + global.execution_state = EXECUTION_STATE_STOPPED; - /* open any new files */ - debug_cpuinfo[cpunum].trace.file = file; - debug_cpuinfo[cpunum].trace.action = NULL; - if (action) + /* handle single stepping */ + if (global.execution_state != EXECUTION_STATE_STOPPED && (info->flags & DEBUG_FLAG_STEPPING_ANY) != 0) { - debug_cpuinfo[cpunum].trace.action = malloc(strlen(action) + 1); - if (debug_cpuinfo[cpunum].trace.action) - strcpy(debug_cpuinfo[cpunum].trace.action, action); + /* is this an actual step? */ + if (info->stepaddr == ~0 || curpc == info->stepaddr) + { + /* decrement the count and reset the breakpoint */ + info->stepsleft--; + info->stepaddr = ~0; + + /* if we hit 0, stop */ + if (info->stepsleft == 0) + global.execution_state = EXECUTION_STATE_STOPPED; + + /* update every 100 steps until we are within 200 of the end */ + else if ((info->flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (info->stepsleft < 200 || info->stepsleft % 100 == 0)) + { + debug_view_update_all(); + debugger_refresh_display(machine); + } + } } - /* specify trace over */ - debug_cpuinfo[cpunum].trace.trace_over_target = trace_over ? ~0 : 0; -} + /* handle breakpoints */ + if (global.execution_state != EXECUTION_STATE_STOPPED && (info->flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) + { + /* see if we hit a target time */ + if ((info->flags & DEBUG_FLAG_STOP_TIME) != 0 && attotime_compare(timer_get_time(), info->stoptime) >= 0) + { + debug_console_printf("Stopped at time interval %.1g\n", attotime_to_double(timer_get_time())); + global.execution_state = EXECUTION_STATE_STOPPED; + } + /* check the temp running breakpoint and break if we hit it */ + else if ((info->flags & DEBUG_FLAG_STOP_PC) != 0 && info->stopaddr == curpc) + { + debug_console_printf("Stopped at temporary breakpoint %X on CPU %d\n", info->stopaddr, info - global.cpuinfo); + global.execution_state = EXECUTION_STATE_STOPPED; + } + /* check for execution breakpoints */ + else if ((info->flags & DEBUG_FLAG_LIVE_BP) != 0) + breakpoint_check(info, curpc); + } -/*************************************************************************** - UTILITIES -***************************************************************************/ + /* if we are supposed to halt, do it now */ + if (global.execution_state == EXECUTION_STATE_STOPPED) + { + /* reset any transient state */ + reset_transient_flags(machine); -/*------------------------------------------------- - debug_get_cpu_info - returns the cpu info - block for a given CPU --------------------------------------------------*/ + /* update all views */ + debug_view_update_all(); + debugger_refresh_display(machine); -const debug_cpu_info *debug_get_cpu_info(int cpunum) -{ - return &debug_cpuinfo[cpunum]; -} + /* wait for the debugger; during this time, disable sound output */ + sound_mute(TRUE); + while (global.execution_state == EXECUTION_STATE_STOPPED) + { + /* clear the memory modified flag and wait */ + global.memory_modified = 0; + osd_wait_for_debugger(); + /* if something modified memory, update the screen */ + if (global.memory_modified) + debugger_refresh_display(machine); -/*------------------------------------------------- - debug_halt_on_next_instruction - halt in - the debugger on the next instruction --------------------------------------------------*/ + /* check for commands in the source file */ + process_source_file(); -void debug_halt_on_next_instruction(void) -{ - debug_console_printf("Internal breakpoint\n"); - execution_state = EXECUTION_STATE_STOPPED; -} + /* if an event got scheduled, resume */ + if (mame_is_scheduled_event_pending(machine)) + global.execution_state = EXECUTION_STATE_RUNNING; + } + sound_mute(FALSE); + /* remember the last visible CPU in the debugger */ + global.visiblecpu = info; + } -/*------------------------------------------------- - debug_refresh_display - redraw the current - video display --------------------------------------------------*/ + /* handle step out/over on the instruction we are about to execute */ + if ((info->flags & (DEBUG_FLAG_STEPPING_OVER | DEBUG_FLAG_STEPPING_OUT)) != 0 && info->stepaddr == ~0) + prepare_for_step_overout(info); -void debug_refresh_display(void) -{ - video_frame_update(Machine, TRUE); + /* no longer in debugger code */ + global.within_instruction_hook = FALSE; } -/*------------------------------------------------- - debug_get_execution_state - return the - current execution state --------------------------------------------------*/ - -int debug_get_execution_state(void) -{ - return execution_state; -} +/*************************************************************************** + EXECUTION CONTROL +***************************************************************************/ /*------------------------------------------------- - debug_get_execution_counter - return the - current execution counter + debug_cpu_single_step - single step past the + requested number of instructions -------------------------------------------------*/ -UINT32 debug_get_execution_counter(void) +void debug_cpu_single_step(int numsteps) { - return execution_counter; -} - + debug_cpu_info *info = global.livecpu; -/*------------------------------------------------- - get_wpaddr - getter callback for the - 'wpaddr' symbol --------------------------------------------------*/ + if (!global.within_instruction_hook) + return; + assert(info != NULL); -static UINT64 get_wpaddr(UINT32 ref) -{ - return wpaddr; + info->stepsleft = numsteps; + info->stepaddr = ~0; + info->flags |= DEBUG_FLAG_STEPPING; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - get_wpdata - getter callback for the - 'wpdata' symbol + debug_cpu_single_step_over - single step over + a single instruction -------------------------------------------------*/ -static UINT64 get_wpdata(UINT32 ref) +void debug_cpu_single_step_over(int numsteps) { - return wpdata; -} - + debug_cpu_info *info = global.livecpu; -/*------------------------------------------------- - get_cycles - getter callback for the - 'cycles' symbol --------------------------------------------------*/ + if (!global.within_instruction_hook) + return; + assert(info != NULL); -static UINT64 get_cycles(UINT32 ref) -{ - return activecpu_get_icount(); + info->stepsleft = numsteps; + info->stepaddr = ~0; + info->flags |= DEBUG_FLAG_STEPPING_OVER; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - get_cpunum - getter callback for the - 'cpunum' symbol + debug_cpu_single_step_out - single step out of + the current function -------------------------------------------------*/ -static UINT64 get_cpunum(UINT32 ref) +void debug_cpu_single_step_out(void) { - return cpu_getactivecpu(); -} - + debug_cpu_info *info = global.livecpu; -/*------------------------------------------------- - get_tempvar - getter callback for the - 'tempX' symbols --------------------------------------------------*/ + if (!global.within_instruction_hook) + return; + assert(info != NULL); -static UINT64 get_tempvar(UINT32 ref) -{ - return tempvar[ref]; + info->stepsleft = 100; + info->stepaddr = ~0; + info->flags |= DEBUG_FLAG_STEPPING_OUT; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - set_tempvar - setter callback for the - 'tempX' symbols + debug_cpu_go - resume execution -------------------------------------------------*/ -static void set_tempvar(UINT32 ref, UINT64 value) +void debug_cpu_go(offs_t targetpc) { - tempvar[ref] = value; -} - + debug_cpu_info *info = global.livecpu; -/*------------------------------------------------- - get_logunmap - getter callback for the logumap - symbols --------------------------------------------------*/ + if (!global.within_instruction_hook) + return; + assert(info != NULL); -static UINT64 get_logunmap(UINT32 ref) -{ - return memory_get_log_unmap(ref); + info->stopaddr = targetpc; + info->flags |= DEBUG_FLAG_STOP_PC; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - get_beamx - get beam horizontal position + debug_cpu_go_vblank - run until the next + VBLANK -------------------------------------------------*/ -static UINT64 get_beamx(UINT32 ref) +void debug_cpu_go_vblank(void) { - UINT64 ret = 0; - const device_config *screen = device_list_find_by_index(Machine->config->devicelist, VIDEO_SCREEN, ref); + debug_cpu_info *info = global.livecpu; - if (screen != NULL) - ret = video_screen_get_hpos(screen); + if (!global.within_instruction_hook) + return; + assert(info != NULL); - return ret; + global.vblank_occurred = FALSE; + info->flags |= DEBUG_FLAG_STOP_VBLANK; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - get_beamy - get beam vertical position + debug_cpu_go_interrupt - run until the + specified interrupt fires -------------------------------------------------*/ -static UINT64 get_beamy(UINT32 ref) +void debug_cpu_go_interrupt(int irqline) { - UINT64 ret = 0; - const device_config *screen = device_list_find_by_index(Machine->config->devicelist, VIDEO_SCREEN, ref); + debug_cpu_info *info = global.livecpu; - if (screen != NULL) - ret = video_screen_get_vpos(screen); + if (!global.within_instruction_hook) + return; + assert(info != NULL); - return ret; + info->stopirq = irqline; + info->flags |= DEBUG_FLAG_STOP_INTERRUPT; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - set_logunmap - setter callback for the logumap - symbols + debug_cpu_go_exception - run until the + specified exception fires -------------------------------------------------*/ -static void set_logunmap(UINT32 ref, UINT64 value) +void debug_cpu_go_exception(int exception) { - memory_set_log_unmap(ref, value ? 1 : 0); -} - + debug_cpu_info *info = global.livecpu; -/*------------------------------------------------- - get_current_pc - getter callback for a CPU's - current instruction pointer --------------------------------------------------*/ + if (!global.within_instruction_hook) + return; + assert(info != NULL); -static UINT64 get_current_pc(UINT32 ref) -{ - return activecpu_get_pc(); + info->stopexception = exception; + info->flags |= DEBUG_FLAG_STOP_EXCEPTION; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - get_cpu_reg - getter callback for a CPU's - register symbols + debug_cpu_go_milliseconds - run until the + specified delay elapses -------------------------------------------------*/ -static UINT64 get_cpu_reg(UINT32 ref) +void debug_cpu_go_milliseconds(UINT64 milliseconds) { - return activecpu_get_reg(ref); + debug_cpu_info *info = global.livecpu; + + if (!global.within_instruction_hook) + return; + assert(info != NULL); + + info->stoptime = attotime_add(timer_get_time(), ATTOTIME_IN_MSEC(milliseconds)); + info->flags |= DEBUG_FLAG_STOP_TIME; + global.execution_state = EXECUTION_STATE_RUNNING; } /*------------------------------------------------- - set_cpu_reg - setter callback for a CPU's - register symbols + debug_cpu_next_cpu - execute until we hit + the next CPU -------------------------------------------------*/ -static void set_cpu_reg(UINT32 ref, UINT64 value) +void debug_cpu_next_cpu(void) { - activecpu_set_reg(ref, value); -} + debug_cpu_info *info = global.livecpu; + if (!global.within_instruction_hook) + return; + assert(info != NULL); + info->flags |= DEBUG_FLAG_STOP_CONTEXT; + global.execution_state = EXECUTION_STATE_RUNNING; +} -/*************************************************************************** - MAIN CPU CALLBACK -***************************************************************************/ /*------------------------------------------------- - mame_debug_hook - called by the CPU cores - before executing each instruction + debug_cpu_ignore_cpu - ignore/observe a given + CPU -------------------------------------------------*/ -void mame_debug_hook(offs_t curpc) +void debug_cpu_ignore_cpu(int cpunum, int ignore) { - int cpunum = cpu_getactivecpu(); - debug_cpu_info *info = &debug_cpuinfo[cpunum]; + debug_cpu_info *info = &global.cpuinfo[cpunum]; - /* update the history */ - info->pc_history[info->pc_history_index++ % DEBUG_HISTORY_SIZE] = curpc; - - /* quick out if we are ignoring */ - if (info->ignoring) + if (!global.within_instruction_hook) return; - /* note that we are in the debugger code */ - within_debugger_code = TRUE; - - /* bump the counter */ - execution_counter++; - - /* are we tracing? */ - if (info->trace.file) - perform_trace(info); + if (ignore) + info->flags &= ~DEBUG_FLAG_OBSERVING; + else + info->flags |= DEBUG_FLAG_OBSERVING; + + if (info == global.livecpu && ignore) + debug_cpu_next_cpu(); +} - /* per-instruction hook? */ - if (info->instrhook != NULL && (*info->instrhook)(curpc)) - execution_state = EXECUTION_STATE_STOPPED; - /* check for execution breakpoints */ - if (execution_state != EXECUTION_STATE_STOPPED) - { - /* see if we hit an interrupt break */ - if (break_on_interrupt == 2 && break_on_interrupt_cpunum == cpunum) - { - debug_console_printf("Stopped on interrupt (CPU %d, IRQ %d)\n", break_on_interrupt_cpunum, break_on_interrupt_irqline); - break_on_interrupt = 0; - execution_state = EXECUTION_STATE_STOPPED; - } +/*------------------------------------------------- + debug_cpu_trace - trace execution of a given + CPU +-------------------------------------------------*/ - /* see if we hit a target time */ - if (break_on_time && attotime_compare(timer_get_time(), break_on_time_target) > 0) - { - debug_console_printf("Stopped at time interval %.1g\n", attotime_to_double(timer_get_time())); - break_on_time = 0; - execution_state = EXECUTION_STATE_STOPPED; - } +void debug_cpu_trace(int cpunum, FILE *file, int trace_over, const char *action) +{ + debug_cpu_info *info = &global.cpuinfo[cpunum]; - /* see if the CPU changed and break if we are waiting for that to happen */ - if (cpunum != last_cpunum) - { - if (execution_state == EXECUTION_STATE_NEXT_CPU) - execution_state = EXECUTION_STATE_STOPPED; - last_cpunum = cpunum; - } + /* close existing files and delete expressions */ + if (info->trace.file != NULL) + fclose(info->trace.file); + info->trace.file = NULL; - /* check the temp running breakpoint and break if we hit it */ - if (info->temp_breakpoint_pc != ~0 && execution_state == EXECUTION_STATE_RUNNING && curpc == info->temp_breakpoint_pc) - { - execution_state = EXECUTION_STATE_STOPPED; - debug_console_printf("Stopped at temporary breakpoint %X on CPU %d\n", info->temp_breakpoint_pc, cpunum); - info->temp_breakpoint_pc = ~0; - } + if (info->trace.action != NULL) + free(info->trace.action); + info->trace.action = NULL; - /* check for execution breakpoints */ - if (info->first_bp) - debug_check_breakpoints(cpunum, curpc); + /* open any new files */ + info->trace.file = file; + info->trace.action = NULL; + info->trace.trace_over_target = ~0; + if (action != NULL) + { + info->trace.action = malloc_or_die(strlen(action) + 1); + if (info->trace.action != NULL) + strcpy(info->trace.action, action); + } - /* handle single stepping */ - if (steps_until_stop > 0 && (execution_state >= EXECUTION_STATE_STEP_INTO && execution_state <= EXECUTION_STATE_STEP_OUT)) - { - /* is this an actual step? */ - if (step_overout_breakpoint == ~0 || (cpunum == step_overout_cpunum && curpc == step_overout_breakpoint)) - { - /* decrement the count and reset the breakpoint */ - steps_until_stop--; - step_overout_breakpoint = ~0; - - /* if we hit 0, stop; otherwise, we might want to update everything */ - if (steps_until_stop == 0) - execution_state = EXECUTION_STATE_STOPPED; - else if (execution_state != EXECUTION_STATE_STEP_OUT && (steps_until_stop < 200 || steps_until_stop % 100 == 0)) - { - debug_view_update_all(); - debug_refresh_display(); - } - } - } + /* update flags */ + if (info->trace.file != NULL) + info->flags |= trace_over ? DEBUG_FLAG_TRACING_OVER : DEBUG_FLAG_TRACING; + else + info->flags &= ~DEBUG_FLAG_TRACING_ANY; +} - /* check for debug keypresses */ - if (execution_state != EXECUTION_STATE_STOPPED && ++key_check_counter > 10000) - { - key_check_counter = 0; - if (input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK)) - { - execution_state = EXECUTION_STATE_STOPPED; - debug_console_printf("User-initiated break\n"); - } - /* while we're here, check for a periodic update */ - if (cpunum == last_stopped_cpunum && execution_state != EXECUTION_STATE_STOPPED && osd_ticks() > last_periodic_update_time + osd_ticks_per_second()/4) - { - debug_view_update_all(); - last_periodic_update_time = osd_ticks(); - } - } - } - /* if we are supposed to halt, do it now */ - if (execution_state == EXECUTION_STATE_STOPPED && !mame_is_scheduled_event_pending(Machine) && !mame_is_save_or_load_pending(Machine)) - { - /* reset the state */ - steps_until_stop = 0; - step_overout_breakpoint = ~0; +/*************************************************************************** + UTILITIES +***************************************************************************/ - /* update all views */ - debug_view_update_all(); - debug_refresh_display(); +/*------------------------------------------------- + debug_get_cpu_info - returns the cpu info + block for a given CPU +-------------------------------------------------*/ - /* wait for the debugger; during this time, disable sound output */ - sound_mute(TRUE); - while (execution_state == EXECUTION_STATE_STOPPED) - { - /* clear the memory modified flag and wait */ - memory_modified = 0; - osd_wait_for_debugger(); +const debug_cpu_info *debug_get_cpu_info(int cpunum) +{ + return &global.cpuinfo[cpunum]; +} - /* if something modified memory, update the screen */ - if (memory_modified) - debug_refresh_display(); - /* check for commands in the source file */ - process_source_file(); +/*------------------------------------------------- + debug_cpu_halt_on_next_instruction - halt in + the debugger on the next instruction +-------------------------------------------------*/ - /* if an event got scheduled, resume */ - if (mame_is_scheduled_event_pending(Machine)) - execution_state = EXECUTION_STATE_RUNNING; - } - sound_mute(FALSE); +void debug_cpu_halt_on_next_instruction(running_machine *machine) +{ + debug_console_printf("Internal breakpoint\n"); + global.execution_state = EXECUTION_STATE_STOPPED; + if (global.livecpu != NULL) + compute_debug_flags(machine, global.livecpu); +} - /* remember the last cpunum where we stopped */ - last_stopped_cpunum = cpunum; - } - /* handle step out/over on the instruction we are about to execute */ - if ((execution_state == EXECUTION_STATE_STEP_OVER || execution_state == EXECUTION_STATE_STEP_OUT) && cpunum == step_overout_cpunum && step_overout_breakpoint == ~0) - prepare_for_step_overout(); +/*------------------------------------------------- + debug_cpu_is_stopped - return the + current execution state +-------------------------------------------------*/ - /* no longer in debugger code */ - within_debugger_code = FALSE; +int debug_cpu_is_stopped(running_machine *machine) +{ + return global.execution_state == EXECUTION_STATE_STOPPED; } @@ -921,7 +908,7 @@ static void perform_trace(debug_cpu_info *info) offs_t dasmresult; /* are we in trace over mode and in a subroutine? */ - if (info->trace.trace_over_target && (info->trace.trace_over_target != ~0)) + if ((info->flags & DEBUG_FLAG_TRACING_OVER) != 0 && info->trace.trace_over_target != ~0) { if (info->trace.trace_over_target != pc) return; @@ -937,12 +924,12 @@ static void perform_trace(debug_cpu_info *info) if (count <= 1) { /* if we just finished looping, indicate as much */ - if (info->trace.loops) + if (info->trace.loops != 0) fprintf(info->trace.file, "\n (loops for %d instructions)\n\n", info->trace.loops); info->trace.loops = 0; /* execute any trace actions first */ - if (info->trace.action) + if (info->trace.action != NULL) debug_console_execute_command(info->trace.action, 0); /* print the address */ @@ -955,8 +942,7 @@ static void perform_trace(debug_cpu_info *info) fprintf(info->trace.file, "%s\n", buffer); /* do we need to step the trace over this instruction? */ - if (info->trace.trace_over_target && (dasmresult & DASMFLAG_SUPPORTED) - && (dasmresult & DASMFLAG_STEP_OVER)) + if ((info->flags & DEBUG_FLAG_TRACING_OVER) != 0 && (dasmresult & DASMFLAG_SUPPORTED) != 0 && (dasmresult & DASMFLAG_STEP_OVER) != 0) { int extraskip = (dasmresult & DASMFLAG_OVERINSTMASK) >> DASMFLAG_OVERINSTSHIFT; offs_t trace_over_target = pc + (dasmresult & DASMFLAG_LENGTHMASK); @@ -984,7 +970,7 @@ static void perform_trace(debug_cpu_info *info) stepping over an instruction -------------------------------------------------*/ -static void prepare_for_step_overout(void) +static void prepare_for_step_overout(debug_cpu_info *info) { offs_t pc = activecpu_get_pc(); char dasmbuffer[100]; @@ -994,7 +980,7 @@ static void prepare_for_step_overout(void) dasmresult = dasm_wrapped(dasmbuffer, pc); /* if flags are supported and it's a call-style opcode, set a temp breakpoint after that instruction */ - if ((dasmresult & DASMFLAG_SUPPORTED) && (dasmresult & DASMFLAG_STEP_OVER)) + if ((dasmresult & DASMFLAG_SUPPORTED) != 0 && (dasmresult & DASMFLAG_STEP_OVER) != 0) { int extraskip = (dasmresult & DASMFLAG_OVERINSTMASK) >> DASMFLAG_OVERINSTSHIFT; pc += dasmresult & DASMFLAG_LENGTHMASK; @@ -1002,16 +988,16 @@ static void prepare_for_step_overout(void) /* if we need to skip additional instructions, advance as requested */ while (extraskip-- > 0) pc += dasm_wrapped(dasmbuffer, pc) & DASMFLAG_LENGTHMASK; - step_overout_breakpoint = pc; + info->stepaddr = pc; } /* if we're stepping out and this isn't a step out instruction, reset the steps until stop to a high number */ - if (execution_state == EXECUTION_STATE_STEP_OUT) + if ((info->flags & DEBUG_FLAG_STEPPING_OUT) != 0) { - if ((dasmresult & DASMFLAG_SUPPORTED) && !(dasmresult & DASMFLAG_STEP_OUT)) - steps_until_stop = 100; + if ((dasmresult & DASMFLAG_SUPPORTED) != 0 && (dasmresult & DASMFLAG_STEP_OUT) == 0) + info->stepsleft = 100; else - steps_until_stop = 1; + info->stepsleft = 1; } } @@ -1024,7 +1010,7 @@ static void prepare_for_step_overout(void) static void process_source_file(void) { /* loop until the file is exhausted or until we are executing again */ - while (debug_source_file && (execution_state == EXECUTION_STATE_STOPPED)) + while (debug_source_file != NULL && global.execution_state == EXECUTION_STATE_STOPPED) { char buf[512]; int i; @@ -1060,36 +1046,20 @@ static void process_source_file(void) /*------------------------------------------------- - debug_vblank_hook - called when an interrupt - is acknowledged --------------------------------------------------*/ - -void debug_interrupt_hook(int cpunum, int irqline) -{ - /* if we're configured to stop on interrupt, break */ - if (break_on_interrupt && cpunum == break_on_interrupt_cpunum && (break_on_interrupt_irqline == -1 || irqline == break_on_interrupt_irqline)) - { - break_on_interrupt = 2; - break_on_interrupt_irqline = irqline; - } -} - - -/*------------------------------------------------- standard_debug_hook_read - standard read hook -------------------------------------------------*/ static void standard_debug_hook_read(int spacenum, offs_t address, UINT64 mem_mask) { - debug_cpu_info *info = &debug_cpuinfo[memory_hook_cpunum]; + debug_cpu_info *info = &global.cpuinfo[global.memory_hook_cpunum]; /* check watchpoints */ - if (info->read_watchpoints) - check_watchpoints(memory_hook_cpunum, spacenum, WATCHPOINT_READ, address, 0, mem_mask); + if ((info->flags & (DEBUG_FLAG_LIVE_WPR_PROGRAM << spacenum)) != 0) + watchpoint_check(global.memory_hook_cpunum, spacenum, WATCHPOINT_READ, address, 0, mem_mask); /* check hotspots */ - if (info->hotspots) - check_hotspots(memory_hook_cpunum, spacenum, address); + if (info->hotspots != NULL) + check_hotspots(global.memory_hook_cpunum, spacenum, address); } @@ -1099,29 +1069,31 @@ static void standard_debug_hook_read(int spacenum, offs_t address, UINT64 mem_ma static void standard_debug_hook_write(int spacenum, offs_t address, UINT64 data, UINT64 mem_mask) { - debug_cpu_info *info = &debug_cpuinfo[memory_hook_cpunum]; + debug_cpu_info *info = &global.cpuinfo[global.memory_hook_cpunum]; /* check watchpoints */ - if (info->write_watchpoints) - check_watchpoints(memory_hook_cpunum, spacenum, WATCHPOINT_WRITE, address, data, mem_mask); + if ((info->flags & (DEBUG_FLAG_LIVE_WPW_PROGRAM << spacenum)) != 0) + watchpoint_check(global.memory_hook_cpunum, spacenum, WATCHPOINT_WRITE, address, data, mem_mask); } /*------------------------------------------------- - debug_get_memory_hooks - get memory hooks + debug_cpu_get_memory_hooks - get memory hooks for the specified CPU -------------------------------------------------*/ -void debug_get_memory_hooks(int cpunum, debug_hook_read_func *read, debug_hook_write_func *write) +void debug_cpu_get_memory_hooks(int cpunum, debug_hook_read_func *read, debug_hook_write_func *write) { - memory_hook_cpunum = cpunum; + debug_cpu_info *info = &global.cpuinfo[cpunum]; - if (debug_cpuinfo[cpunum].read_watchpoints || debug_cpuinfo[cpunum].hotspots) + global.memory_hook_cpunum = cpunum; + + if ((info->flags & DEBUG_FLAG_READ_WATCHPOINT) != 0 || info->hotspots != NULL) *read = standard_debug_hook_read; else *read = NULL; - if (debug_cpuinfo[cpunum].write_watchpoints) + if ((info->flags & DEBUG_FLAG_WRITE_WATCHPOINT) != 0) *write = standard_debug_hook_write; else *write = NULL; @@ -1129,13 +1101,20 @@ void debug_get_memory_hooks(int cpunum, debug_hook_read_func *read, debug_hook_w /*------------------------------------------------- - debug_set_instruction_hook - set a hook to + debug_cpu_set_instruction_hook - set a hook to be called on each instruction for a given CPU -------------------------------------------------*/ -void debug_set_instruction_hook(int cpunum, int (*hook)(offs_t pc)) +void debug_cpu_set_instruction_hook(int cpunum, int (*hook)(offs_t pc)) { - debug_cpuinfo[cpunum].instrhook = hook; + debug_cpu_info *info = &global.cpuinfo[cpunum]; + + /* set the hook and also the CPU's flag for fast knowledge of the hook */ + info->instrhook = hook; + if (hook != NULL) + info->flags |= DEBUG_FLAG_HOOKED; + else + info->flags &= ~DEBUG_FLAG_HOOKED; } @@ -1145,31 +1124,51 @@ void debug_set_instruction_hook(int cpunum, int (*hook)(offs_t pc)) ***************************************************************************/ /*------------------------------------------------- - debug_check_breakpoints - check the - breakpoints for a given CPU + breakpoint_update_flags - update the CPU's + breakpoint flags +-------------------------------------------------*/ + +static void breakpoint_update_flags(debug_cpu_info *info) +{ + debug_cpu_breakpoint *bp; + + /* see if there are any enabled breakpoints */ + info->flags &= ~DEBUG_FLAG_LIVE_BP; + for (bp = info->bplist; bp != NULL; bp = bp->next) + if (bp->enabled) + { + info->flags |= DEBUG_FLAG_LIVE_BP; + break; + } +} + + +/*------------------------------------------------- + breakpoint_check - check the breakpoints for + a given CPU -------------------------------------------------*/ -void debug_check_breakpoints(int cpunum, offs_t pc) +static void breakpoint_check(debug_cpu_info *info, offs_t pc) { debug_cpu_breakpoint *bp; UINT64 result; /* see if we match */ - for (bp = debug_cpuinfo[cpunum].first_bp; bp; bp = bp->next) + for (bp = info->bplist; bp != NULL; bp = bp->next) if (bp->enabled && bp->address == pc) /* if we do, evaluate the condition */ - if (bp->condition == NULL || (expression_execute(bp->condition, &result) == EXPRERR_NONE && result)) + if (bp->condition == NULL || (expression_execute(bp->condition, &result) == EXPRERR_NONE && result != 0)) { /* halt in the debugger by default */ - execution_state = EXECUTION_STATE_STOPPED; + global.execution_state = EXECUTION_STATE_STOPPED; /* if we hit, evaluate the action */ if (bp->action != NULL) debug_console_execute_command(bp->action, 0); /* print a notification, unless the action made us go again */ - if (execution_state == EXECUTION_STATE_STOPPED) + if (global.execution_state == EXECUTION_STATE_STOPPED) debug_console_printf("Stopped at breakpoint %X\n", bp->index); break; } @@ -1177,101 +1176,73 @@ void debug_check_breakpoints(int cpunum, offs_t pc) /*------------------------------------------------- - debug_breakpoint_first - find the first - breakpoint for a given CPU --------------------------------------------------*/ - -static debug_cpu_breakpoint *find_breakpoint(int bpnum) -{ - debug_cpu_breakpoint *bp; - int cpunum; - - /* loop over CPUs and find the requested breakpoint */ - for (cpunum = 0; cpunum < MAX_CPU; cpunum++) - for (bp = debug_cpuinfo[cpunum].first_bp; bp; bp = bp->next) - if (bp->index == bpnum) - return bp; - - return NULL; -} - - -/*------------------------------------------------- - debug_breakpoint_first - return the first - breakpoint for a given CPU --------------------------------------------------*/ - -debug_cpu_breakpoint *debug_breakpoint_first(int cpunum) -{ - return (cpunum < MAX_CPU) ? debug_cpuinfo[cpunum].first_bp : NULL; -} - - -/*------------------------------------------------- - debug_breakpoint_set - set a new breakpoint + debug_cpu_breakpoint_set - set a new breakpoint -------------------------------------------------*/ -int debug_breakpoint_set(int cpunum, offs_t address, parsed_expression *condition, const char *action) +int debug_cpu_breakpoint_set(int cpunum, offs_t address, parsed_expression *condition, const char *action) { + debug_cpu_info *info = &global.cpuinfo[cpunum]; debug_cpu_breakpoint *bp; - assert_always((cpunum >= 0) && (cpunum < cpu_gettotalcpu()), "debug_breakpoint_set() called with invalid cpunum!"); + assert_always(cpunum >= 0 && cpunum < cpu_gettotalcpu(), "debug_cpu_breakpoint_set() called with invalid cpunum!"); /* allocate breakpoint */ - bp = malloc(sizeof(*bp)); - - /* if we can't allocate, return failure */ - if (!bp) - return 0; - - /* fill in the structure */ - bp->index = next_index++; - bp->enabled = 1; + bp = malloc_or_die(sizeof(*bp)); + bp->index = global.bpindex++; + bp->enabled = TRUE; bp->address = address; bp->condition = condition; bp->action = NULL; - if (action) + if (action != NULL) { - bp->action = malloc(strlen(action) + 1); - if (bp->action) - strcpy(bp->action, action); + bp->action = malloc_or_die(strlen(action) + 1); + strcpy(bp->action, action); } /* hook us in */ - bp->next = debug_cpuinfo[cpunum].first_bp; - debug_cpuinfo[cpunum].first_bp = bp; + bp->next = info->bplist; + info->bplist = bp; + + /* ensure the live breakpoint flag is set */ + breakpoint_update_flags(info); return bp->index; } /*------------------------------------------------- - debug_breakpoint_clear - clear a breakpoint + debug_cpu_breakpoint_clear - clear a breakpoint -------------------------------------------------*/ -int debug_breakpoint_clear(int bpnum) +int debug_cpu_breakpoint_clear(int bpnum) { debug_cpu_breakpoint *bp, *pbp; int cpunum; /* loop over CPUs and find the requested breakpoint */ for (cpunum = 0; cpunum < MAX_CPU; cpunum++) - for (pbp = NULL, bp = debug_cpuinfo[cpunum].first_bp; bp; pbp = bp, bp = bp->next) + { + debug_cpu_info *info = &global.cpuinfo[cpunum]; + for (pbp = NULL, bp = info->bplist; bp != NULL; pbp = bp, bp = bp->next) if (bp->index == bpnum) { /* unlink us from the list */ if (pbp == NULL) - debug_cpuinfo[cpunum].first_bp = bp->next; + info->bplist = bp->next; else pbp->next = bp->next; /* free the memory */ - if (bp->condition) + if (bp->condition != NULL) expression_free(bp->condition); - if (bp->action) + if (bp->action != NULL) free(bp->action); free(bp); + + /* update the flags */ + breakpoint_update_flags(info); return 1; } + } /* we didn't find it; return an error */ return 0; @@ -1279,20 +1250,28 @@ int debug_breakpoint_clear(int bpnum) /*------------------------------------------------- - debug_breakpoint_enable - enable/disable a + debug_cpu_breakpoint_enable - enable/disable a breakpoint -------------------------------------------------*/ -int debug_breakpoint_enable(int bpnum, int enable) +int debug_cpu_breakpoint_enable(int bpnum, int enable) { - debug_cpu_breakpoint *bp = find_breakpoint(bpnum); + debug_cpu_breakpoint *bp; + int cpunum; - /* if we found it, set it */ - if (bp != NULL) + /* loop over CPUs and find the requested breakpoint */ + for (cpunum = 0; cpunum < MAX_CPU; cpunum++) { - bp->enabled = (enable != 0); - return 1; + debug_cpu_info *info = &global.cpuinfo[cpunum]; + for (bp = info->bplist; bp != NULL; bp = bp->next) + if (bp->index == bpnum) + { + bp->enabled = (enable != 0); + breakpoint_update_flags(info); + return 1; + } } + return 0; } @@ -1303,28 +1282,60 @@ int debug_breakpoint_enable(int bpnum, int enable) ***************************************************************************/ /*------------------------------------------------- - check_watchpoints - check the - breakpoints for a given CPU and address space + watchpoint_update_flags - update the CPU's + watchpoint flags -------------------------------------------------*/ -static void check_watchpoints(int cpunum, int spacenum, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask) +static void watchpoint_update_flags(debug_cpu_info *info, int spacenum) { + UINT32 writeflag = DEBUG_FLAG_LIVE_WPW_PROGRAM << spacenum; + UINT32 readflag = DEBUG_FLAG_LIVE_WPR_PROGRAM << spacenum; + debug_cpu_watchpoint *wp; + + /* see if there are any enabled breakpoints */ + info->flags &= ~(readflag | writeflag); + for (wp = info->space[spacenum].wplist; wp != NULL; wp = wp->next) + if (wp->enabled) + { + if (wp->type & WATCHPOINT_READ) + { + info->flags |= readflag; + readflag = 0; + } + if (wp->type & WATCHPOINT_WRITE) + { + info->flags |= writeflag; + writeflag = 0; + } + if ((readflag | writeflag) == 0) + break; + } +} + + +/*------------------------------------------------- + watchpoint_check - check the watchpoints + for a given CPU and address space +-------------------------------------------------*/ + +static void watchpoint_check(int cpunum, int spacenum, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask) +{ + const debug_cpu_info *info = &global.cpuinfo[cpunum]; debug_cpu_watchpoint *wp; - UINT64 result; offs_t size = 0; + UINT64 result; /* if we're within debugger code, don't stop */ - if (within_debugger_code) + if (global.within_instruction_hook) return; - within_debugger_code = TRUE; + global.within_instruction_hook = TRUE; /* adjust address, size & value_to_write based on mem_mask. */ if (mem_mask != 0) { - const debug_cpu_info *info = &debug_cpuinfo[cpunum]; - int address_offset = 0; int bus_size = info->space[spacenum].databytes; + int address_offset = 0; while (address_offset < bus_size && (mem_mask & 0xff) == 0) { @@ -1346,26 +1357,26 @@ static void check_watchpoints(int cpunum, int spacenum, int type, offs_t address } /* if we are a write watchpoint, stash the value that will be written */ - wpaddr = address; + global.wpaddr = address; if (type & WATCHPOINT_WRITE) - wpdata = value_to_write; + global.wpdata = value_to_write; /* see if we match */ - for (wp = debug_cpuinfo[cpunum].space[spacenum].first_wp; wp; wp = wp->next) - if (wp->enabled && (wp->type & type) && address + size > wp->address && address < wp->address + wp->length) + for (wp = info->space[spacenum].wplist; wp != NULL; wp = wp->next) + if (wp->enabled && (wp->type & type) != 0 && address + size > wp->address && address < wp->address + wp->length) /* if we do, evaluate the condition */ - if (wp->condition == NULL || (expression_execute(wp->condition, &result) == EXPRERR_NONE && result)) + if (wp->condition == NULL || (expression_execute(wp->condition, &result) == EXPRERR_NONE && result != 0)) { /* halt in the debugger by default */ - execution_state = EXECUTION_STATE_STOPPED; + global.execution_state = EXECUTION_STATE_STOPPED; /* if we hit, evaluate the action */ if (wp->action != NULL) debug_console_execute_command(wp->action, 0); /* print a notification, unless the action made us go again */ - if (execution_state == EXECUTION_STATE_STOPPED) + if (global.execution_state == EXECUTION_STATE_STOPPED) { static const char *const sizes[] = { @@ -1375,91 +1386,53 @@ static void check_watchpoints(int cpunum, int spacenum, int type, offs_t address if (type & WATCHPOINT_WRITE) { - sprintf(buffer, "Stopped at watchpoint %X writing %s to %08X (PC=%X)", wp->index, sizes[size], BYTE2ADDR(address, &debug_cpuinfo[cpunum], spacenum), activecpu_get_pc()); + sprintf(buffer, "Stopped at watchpoint %X writing %s to %08X (PC=%X)", wp->index, sizes[size], BYTE2ADDR(address, &global.cpuinfo[cpunum], spacenum), activecpu_get_pc()); if (value_to_write >> 32) sprintf(&buffer[strlen(buffer)], " (data=%X%08X)", (UINT32)(value_to_write >> 32), (UINT32)value_to_write); else sprintf(&buffer[strlen(buffer)], " (data=%X)", (UINT32)value_to_write); } else - sprintf(buffer, "Stopped at watchpoint %X reading %s from %08X (PC=%X)", wp->index, sizes[size], BYTE2ADDR(address, &debug_cpuinfo[cpunum], spacenum), activecpu_get_pc()); + sprintf(buffer, "Stopped at watchpoint %X reading %s from %08X (PC=%X)", wp->index, sizes[size], BYTE2ADDR(address, &global.cpuinfo[cpunum], spacenum), activecpu_get_pc()); debug_console_printf("%s\n", buffer); } break; } - within_debugger_code = FALSE; + global.within_instruction_hook = FALSE; } /*------------------------------------------------- - debug_watchpoint_first - find the first - watchpoint for a given CPU + debug_cpu_watchpoint_set - set a new watchpoint -------------------------------------------------*/ -static debug_cpu_watchpoint *find_watchpoint(int wpnum) +int debug_cpu_watchpoint_set(int cpunum, int spacenum, int type, offs_t address, offs_t length, parsed_expression *condition, const char *action) { - debug_cpu_watchpoint *wp; - int cpunum, spacenum; - - /* loop over CPUs and address spaces and find the requested watchpoint */ - for (cpunum = 0; cpunum < MAX_CPU; cpunum++) - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - for (wp = debug_cpuinfo[cpunum].space[spacenum].first_wp; wp; wp = wp->next) - if (wp->index == wpnum) - return wp; - - return NULL; -} - - -/*------------------------------------------------- - debug_watchpoint_first - return the first - watchpoint for a given CPU --------------------------------------------------*/ - -debug_cpu_watchpoint *debug_watchpoint_first(int cpunum, int spacenum) -{ - return (cpunum < MAX_CPU && spacenum < ADDRESS_SPACES) ? debug_cpuinfo[cpunum].space[spacenum].first_wp : NULL; -} - - -/*------------------------------------------------- - debug_watchpoint_set - set a new watchpoint --------------------------------------------------*/ - -int debug_watchpoint_set(int cpunum, int spacenum, int type, offs_t address, offs_t length, parsed_expression *condition, const char *action) -{ - debug_cpu_watchpoint *wp = malloc(sizeof(*wp)); - - /* if we can't allocate, return failure */ - if (!wp) - return 0; + debug_cpu_info *info = &global.cpuinfo[cpunum]; + debug_cpu_watchpoint *wp = malloc_or_die(sizeof(*wp)); /* fill in the structure */ - wp->index = next_index++; - wp->enabled = 1; + wp->index = global.wpindex++; + wp->enabled = TRUE; wp->type = type; - wp->address = ADDR2BYTE_MASKED(address, &debug_cpuinfo[cpunum], spacenum); - wp->length = ADDR2BYTE(length, &debug_cpuinfo[cpunum], spacenum); + wp->address = ADDR2BYTE_MASKED(address, &global.cpuinfo[cpunum], spacenum); + wp->length = ADDR2BYTE(length, &global.cpuinfo[cpunum], spacenum); wp->condition = condition; wp->action = NULL; - if (action) + if (action != NULL) { - wp->action = malloc(strlen(action) + 1); - if (wp->action) - strcpy(wp->action, action); + wp->action = malloc_or_die(strlen(action) + 1); + strcpy(wp->action, action); } /* hook us in */ - wp->next = debug_cpuinfo[cpunum].space[spacenum].first_wp; - debug_cpuinfo[cpunum].space[spacenum].first_wp = wp; - if (wp->type & WATCHPOINT_READ) - debug_cpuinfo[cpunum].read_watchpoints++; - if (wp->type & WATCHPOINT_WRITE) - debug_cpuinfo[cpunum].write_watchpoints++; - - /* force debug_get_memory_hooks() to be called */ + wp->next = info->space[spacenum].wplist; + info->space[spacenum].wplist = wp; + + watchpoint_update_flags(info, spacenum); + + /* force debug_cpu_get_memory_hooks() to be called */ cpuintrf_push_context(-1); cpuintrf_pop_context(); @@ -1468,43 +1441,45 @@ int debug_watchpoint_set(int cpunum, int spacenum, int type, offs_t address, off /*------------------------------------------------- - debug_watchpoint_clear - clear a watchpoint + debug_cpu_watchpoint_clear - clear a watchpoint -------------------------------------------------*/ -int debug_watchpoint_clear(int wpnum) +int debug_cpu_watchpoint_clear(int wpnum) { debug_cpu_watchpoint *wp, *pwp; int cpunum, spacenum; /* loop over CPUs and find the requested watchpoint */ for (cpunum = 0; cpunum < MAX_CPU; cpunum++) + { + debug_cpu_info *info = &global.cpuinfo[cpunum]; + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - for (pwp = NULL, wp = debug_cpuinfo[cpunum].space[spacenum].first_wp; wp; pwp = wp, wp = wp->next) + for (pwp = NULL, wp = info->space[spacenum].wplist; wp != NULL; pwp = wp, wp = wp->next) if (wp->index == wpnum) { /* unlink us from the list */ if (pwp == NULL) - debug_cpuinfo[cpunum].space[spacenum].first_wp = wp->next; + info->space[spacenum].wplist = wp->next; else pwp->next = wp->next; /* free the memory */ - if (wp->condition) + if (wp->condition != NULL) expression_free(wp->condition); - if (wp->action) + if (wp->action != NULL) free(wp->action); - if (wp->type & WATCHPOINT_READ) - debug_cpuinfo[cpunum].read_watchpoints--; - if (wp->type & WATCHPOINT_WRITE) - debug_cpuinfo[cpunum].write_watchpoints--; free(wp); - /* force debug_get_memory_hooks() to be called */ + watchpoint_update_flags(info, spacenum); + + /* force debug_cpu_get_memory_hooks() to be called */ cpuintrf_push_context(-1); cpuintrf_pop_context(); return 1; } + } /* we didn't find it; return an error */ return 0; @@ -1512,20 +1487,30 @@ int debug_watchpoint_clear(int wpnum) /*------------------------------------------------- - debug_watchpoint_enable - enable/disable a + debug_cpu_watchpoint_enable - enable/disable a watchpoint -------------------------------------------------*/ -int debug_watchpoint_enable(int wpnum, int enable) +int debug_cpu_watchpoint_enable(int wpnum, int enable) { - debug_cpu_watchpoint *wp = find_watchpoint(wpnum); + debug_cpu_watchpoint *wp; + int cpunum, spacenum; - /* if we found it, set it */ - if (wp != NULL) + /* loop over CPUs and address spaces and find the requested watchpoint */ + for (cpunum = 0; cpunum < MAX_CPU; cpunum++) { - wp->enabled = (enable != 0); - return 1; + debug_cpu_info *info = &global.cpuinfo[cpunum]; + + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + for (wp = info->space[spacenum].wplist; wp; wp = wp->next) + if (wp->index == wpnum) + { + wp->enabled = (enable != 0); + watchpoint_update_flags(info, spacenum); + return 1; + } } + return 0; } @@ -1536,13 +1521,13 @@ int debug_watchpoint_enable(int wpnum, int enable) ***************************************************************************/ /*------------------------------------------------- - debug_hotspot_track - enable/disable tracking + debug_cpu_hotspot_track - enable/disable tracking of hotspots -------------------------------------------------*/ -int debug_hotspot_track(int cpunum, int numspots, int threshhold) +int debug_cpu_hotspot_track(int cpunum, int numspots, int threshhold) { - debug_cpu_info *info = &debug_cpuinfo[cpunum]; + debug_cpu_info *info = &global.cpuinfo[cpunum]; /* if we already have tracking info, kill it */ if (info->hotspots) @@ -1561,7 +1546,7 @@ int debug_hotspot_track(int cpunum, int numspots, int threshhold) info->hotspot_threshhold = threshhold; } - /* force debug_get_memory_hooks() to be called */ + /* force debug_cpu_get_memory_hooks() to be called */ cpuintrf_push_context(-1); cpuintrf_pop_context(); @@ -1576,7 +1561,7 @@ int debug_hotspot_track(int cpunum, int numspots, int threshhold) static void check_hotspots(int cpunum, int spacenum, offs_t address) { - debug_cpu_info *info = &debug_cpuinfo[cpunum]; + debug_cpu_info *info = &global.cpuinfo[cpunum]; offs_t pc = activecpu_get_pc(); int hotindex; @@ -1626,7 +1611,7 @@ static void check_hotspots(int cpunum, int spacenum, offs_t address) UINT8 debug_read_byte(int spacenum, offs_t address, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; UINT64 custom; UINT8 result; @@ -1661,7 +1646,7 @@ UINT8 debug_read_byte(int spacenum, offs_t address, int apply_translation) UINT16 debug_read_word(int spacenum, offs_t address, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; UINT64 custom; UINT16 result; @@ -1675,7 +1660,7 @@ UINT16 debug_read_word(int spacenum, offs_t address, int apply_translation) UINT8 byte1 = debug_read_byte(spacenum, address + 1, apply_translation); /* based on the endianness, the result is assembled differently */ - if (debug_cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) + if (global.cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) result = byte0 | (byte1 << 8); else result = byte1 | (byte0 << 8); @@ -1714,7 +1699,7 @@ UINT16 debug_read_word(int spacenum, offs_t address, int apply_translation) UINT32 debug_read_dword(int spacenum, offs_t address, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; UINT64 custom; UINT32 result; @@ -1728,7 +1713,7 @@ UINT32 debug_read_dword(int spacenum, offs_t address, int apply_translation) UINT16 word1 = debug_read_word(spacenum, address + 2, apply_translation); /* based on the endianness, the result is assembled differently */ - if (debug_cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) + if (global.cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) result = word0 | (word1 << 16); else result = word1 | (word0 << 16); @@ -1767,7 +1752,7 @@ UINT32 debug_read_dword(int spacenum, offs_t address, int apply_translation) UINT64 debug_read_qword(int spacenum, offs_t address, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; UINT64 custom; UINT64 result; @@ -1781,7 +1766,7 @@ UINT64 debug_read_qword(int spacenum, offs_t address, int apply_translation) UINT32 dword1 = debug_read_dword(spacenum, address + 4, apply_translation); /* based on the endianness, the result is assembled differently */ - if (debug_cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) + if (global.cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) result = dword0 | ((UINT64)dword1 << 32); else result = dword1 | ((UINT64)dword0 << 32); @@ -1820,7 +1805,7 @@ UINT64 debug_read_qword(int spacenum, offs_t address, int apply_translation) void debug_write_byte(int spacenum, offs_t address, UINT8 data, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; /* mask against the logical byte mask */ address &= info->space[spacenum].logbytemask; @@ -1842,7 +1827,7 @@ void debug_write_byte(int spacenum, offs_t address, UINT8 data, int apply_transl /* no longer accessing via the debugger */ memory_set_debugger_access(0); - memory_modified = 1; + global.memory_modified = TRUE; } @@ -1853,7 +1838,7 @@ void debug_write_byte(int spacenum, offs_t address, UINT8 data, int apply_transl void debug_write_word(int spacenum, offs_t address, UINT16 data, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; /* mask against the logical byte mask */ address &= info->space[spacenum].logbytemask; @@ -1861,7 +1846,7 @@ void debug_write_word(int spacenum, offs_t address, UINT16 data, int apply_trans /* if this is a misaligned write, or if there are no word writers, just read two bytes */ if ((address & 1) || !active_address_space[spacenum].accessors->write_word) { - if (debug_cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) + if (global.cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) { debug_write_byte(spacenum, address + 0, data >> 0, apply_translation); debug_write_byte(spacenum, address + 1, data >> 8, apply_translation); @@ -1893,7 +1878,7 @@ void debug_write_word(int spacenum, offs_t address, UINT16 data, int apply_trans /* no longer accessing via the debugger */ memory_set_debugger_access(0); - memory_modified = 1; + global.memory_modified = TRUE; } } @@ -1905,7 +1890,7 @@ void debug_write_word(int spacenum, offs_t address, UINT16 data, int apply_trans void debug_write_dword(int spacenum, offs_t address, UINT32 data, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; /* mask against the logical byte mask */ address &= info->space[spacenum].logbytemask; @@ -1913,7 +1898,7 @@ void debug_write_dword(int spacenum, offs_t address, UINT32 data, int apply_tran /* if this is a misaligned write, or if there are no dword writers, just read two words */ if ((address & 3) || !active_address_space[spacenum].accessors->write_dword) { - if (debug_cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) + if (global.cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) { debug_write_word(spacenum, address + 0, data >> 0, apply_translation); debug_write_word(spacenum, address + 2, data >> 16, apply_translation); @@ -1945,7 +1930,7 @@ void debug_write_dword(int spacenum, offs_t address, UINT32 data, int apply_tran /* no longer accessing via the debugger */ memory_set_debugger_access(0); - memory_modified = 1; + global.memory_modified = TRUE; } } @@ -1957,7 +1942,7 @@ void debug_write_dword(int spacenum, offs_t address, UINT32 data, int apply_tran void debug_write_qword(int spacenum, offs_t address, UINT64 data, int apply_translation) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; /* mask against the logical byte mask */ address &= info->space[spacenum].logbytemask; @@ -1965,7 +1950,7 @@ void debug_write_qword(int spacenum, offs_t address, UINT64 data, int apply_tran /* if this is a misaligned write, or if there are no qword writers, just read two dwords */ if ((address & 7) || !active_address_space[spacenum].accessors->write_qword) { - if (debug_cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) + if (global.cpuinfo[cpu_getactivecpu()].endianness == CPU_IS_LE) { debug_write_dword(spacenum, address + 0, data >> 0, apply_translation); debug_write_dword(spacenum, address + 4, data >> 32, apply_translation); @@ -1996,7 +1981,7 @@ void debug_write_qword(int spacenum, offs_t address, UINT64 data, int apply_tran /* no longer accessing via the debugger */ memory_set_debugger_access(0); - memory_modified = 1; + global.memory_modified = TRUE; } } @@ -2008,7 +1993,7 @@ void debug_write_qword(int spacenum, offs_t address, UINT64 data, int apply_tran UINT64 debug_read_opcode(offs_t address, int size, int arg) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; offs_t lowbits_mask; const void *ptr; @@ -2131,7 +2116,7 @@ UINT64 debug_read_opcode(offs_t address, int size, int arg) UINT64 external_read_memory(int space, UINT32 offset, int size) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; if (info->space[space].databytes == 0) return ~0; @@ -2155,7 +2140,7 @@ UINT64 external_read_memory(int space, UINT32 offset, int size) void external_write_memory(int space, UINT32 offset, int size, UINT64 value) { - const debug_cpu_info *info = &debug_cpuinfo[cpu_getactivecpu()]; + const debug_cpu_info *info = &global.cpuinfo[cpu_getactivecpu()]; if (info->space[space].databytes == 0) return; @@ -2172,15 +2157,15 @@ void external_write_memory(int space, UINT32 offset, int size, UINT64 value) /*------------------------------------------------- - debug_trace_printf - writes text to a given + debug_cpu_trace_printf - writes text to a given CPU's trace file -------------------------------------------------*/ -void debug_trace_printf(int cpunum, const char *fmt, ...) +void debug_cpu_trace_printf(int cpunum, const char *fmt, ...) { va_list va; - debug_cpu_info *info = &debug_cpuinfo[cpunum]; + debug_cpu_info *info = &global.cpuinfo[cpunum]; if (info->trace.file) { @@ -2192,11 +2177,11 @@ void debug_trace_printf(int cpunum, const char *fmt, ...) /*------------------------------------------------- - debug_source_script - specifies a debug command + debug_cpu_source_script - specifies a debug command script to use -------------------------------------------------*/ -void debug_source_script(const char *file) +void debug_cpu_source_script(const char *file) { if (debug_source_file) { @@ -2219,17 +2204,175 @@ void debug_source_script(const char *file) /*------------------------------------------------- - debug_flush_traces - flushes all traces; this is + debug_cpu_flush_traces - flushes all traces; this is useful if a trace is going on when we fatalerror -------------------------------------------------*/ -void debug_flush_traces(void) +void debug_cpu_flush_traces(void) { int cpunum; for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++) { - if (debug_cpuinfo[cpunum].trace.file) - fflush(debug_cpuinfo[cpunum].trace.file); + if (global.cpuinfo[cpunum].trace.file) + fflush(global.cpuinfo[cpunum].trace.file); } } + + + +/*************************************************************************** + VARIABLE GETTERS/SETTERS +***************************************************************************/ + +/*------------------------------------------------- + get_wpaddr - getter callback for the + 'wpaddr' symbol +-------------------------------------------------*/ + +static UINT64 get_wpaddr(UINT32 ref) +{ + return global.wpaddr; +} + + +/*------------------------------------------------- + get_wpdata - getter callback for the + 'wpdata' symbol +-------------------------------------------------*/ + +static UINT64 get_wpdata(UINT32 ref) +{ + return global.wpdata; +} + + +/*------------------------------------------------- + get_cycles - getter callback for the + 'cycles' symbol +-------------------------------------------------*/ + +static UINT64 get_cycles(UINT32 ref) +{ + return activecpu_get_icount(); +} + + +/*------------------------------------------------- + get_cpunum - getter callback for the + 'cpunum' symbol +-------------------------------------------------*/ + +static UINT64 get_cpunum(UINT32 ref) +{ + return cpu_getactivecpu(); +} + + +/*------------------------------------------------- + get_tempvar - getter callback for the + 'tempX' symbols +-------------------------------------------------*/ + +static UINT64 get_tempvar(UINT32 ref) +{ + return global.tempvar[ref]; +} + + +/*------------------------------------------------- + set_tempvar - setter callback for the + 'tempX' symbols +-------------------------------------------------*/ + +static void set_tempvar(UINT32 ref, UINT64 value) +{ + global.tempvar[ref] = value; +} + + +/*------------------------------------------------- + get_logunmap - getter callback for the logumap + symbols +-------------------------------------------------*/ + +static UINT64 get_logunmap(UINT32 ref) +{ + return memory_get_log_unmap(ref); +} + + +/*------------------------------------------------- + get_beamx - get beam horizontal position +-------------------------------------------------*/ + +static UINT64 get_beamx(UINT32 ref) +{ + UINT64 ret = 0; + const device_config *screen = device_list_find_by_index(Machine->config->devicelist, VIDEO_SCREEN, ref); + + if (screen != NULL) + ret = video_screen_get_hpos(screen); + + return ret; +} + + +/*------------------------------------------------- + get_beamy - get beam vertical position +-------------------------------------------------*/ + +static UINT64 get_beamy(UINT32 ref) +{ + UINT64 ret = 0; + const device_config *screen = device_list_find_by_index(Machine->config->devicelist, VIDEO_SCREEN, ref); + + if (screen != NULL) + ret = video_screen_get_vpos(screen); + + return ret; +} + + +/*------------------------------------------------- + set_logunmap - setter callback for the logumap + symbols +-------------------------------------------------*/ + +static void set_logunmap(UINT32 ref, UINT64 value) +{ + memory_set_log_unmap(ref, value ? 1 : 0); +} + + +/*------------------------------------------------- + get_current_pc - getter callback for a CPU's + current instruction pointer +-------------------------------------------------*/ + +static UINT64 get_current_pc(UINT32 ref) +{ + return activecpu_get_pc(); +} + + +/*------------------------------------------------- + get_cpu_reg - getter callback for a CPU's + register symbols +-------------------------------------------------*/ + +static UINT64 get_cpu_reg(UINT32 ref) +{ + return activecpu_get_reg(ref); +} + + +/*------------------------------------------------- + set_cpu_reg - setter callback for a CPU's + register symbols +-------------------------------------------------*/ + +static void set_cpu_reg(UINT32 ref, UINT64 value) +{ + activecpu_set_reg(ref, value); +} diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 91b8f1e03d7..ae898cb0098 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -14,6 +14,7 @@ #ifndef __DEBUGCPU_H__ #define __DEBUGCPU_H__ +#include "cpuintrf.h" #include "express.h" @@ -21,22 +22,60 @@ CONSTANTS ***************************************************************************/ -#define TRACE_LOOPS 64 -#define DEBUG_HISTORY_SIZE 256 - -#define WATCHPOINT_READ 1 -#define WATCHPOINT_WRITE 2 -#define WATCHPOINT_READWRITE (WATCHPOINT_READ | WATCHPOINT_WRITE) - -enum -{ - EXECUTION_STATE_STOPPED, - EXECUTION_STATE_RUNNING, - EXECUTION_STATE_NEXT_CPU, - EXECUTION_STATE_STEP_INTO, - EXECUTION_STATE_STEP_OVER, - EXECUTION_STATE_STEP_OUT -}; +#define TRACE_LOOPS 64 +#define DEBUG_HISTORY_SIZE 256 + +#define WATCHPOINT_READ 1 +#define WATCHPOINT_WRITE 2 +#define WATCHPOINT_READWRITE (WATCHPOINT_READ | WATCHPOINT_WRITE) + +#define DEBUG_FLAG_OBSERVING 0x00000001 /* observing this CPU */ +#define DEBUG_FLAG_HISTORY 0x00000002 /* tracking this CPU's history */ +#define DEBUG_FLAG_TRACING 0x00000004 /* tracing this CPU */ +#define DEBUG_FLAG_TRACING_OVER 0x00000008 /* tracing this CPU with step over behavior */ +#define DEBUG_FLAG_HOOKED 0x00000010 /* per-instruction callback hook */ +#define DEBUG_FLAG_STEPPING 0x00000020 /* CPU is single stepping */ +#define DEBUG_FLAG_STEPPING_OVER 0x00000040 /* CPU is stepping over a function */ +#define DEBUG_FLAG_STEPPING_OUT 0x00000080 /* CPU is stepping out of a function */ +#define DEBUG_FLAG_STOP_PC 0x00000100 /* there is a pending stop at cpu->breakpc */ +#define DEBUG_FLAG_STOP_CONTEXT 0x00000200 /* there is a pending stop on next context switch */ +#define DEBUG_FLAG_STOP_INTERRUPT 0x00000400 /* there is a pending stop on the next interrupt */ +#define DEBUG_FLAG_STOP_EXCEPTION 0x00000800 /* there is a pending stop on the next exception */ +#define DEBUG_FLAG_STOP_VBLANK 0x00001000 /* there is a pending stop on the next VBLANK */ +#define DEBUG_FLAG_STOP_TIME 0x00002000 /* there is a pending stop at cpu->stoptime */ +#define DEBUG_FLAG_LIVE_BP 0x00010000 /* there are live breakpoints for this CPU */ +#define DEBUG_FLAG_LIVE_WPR_PROGRAM 0x01000000 /* there are live read watchpoints in program address space */ +#define DEBUG_FLAG_LIVE_WPR_DATA 0x02000000 /* there are live read watchpoints in data address space */ +#define DEBUG_FLAG_LIVE_WPR_IO 0x04000000 /* there are live read watchpoints in io address space */ +#define DEBUG_FLAG_LIVE_WPW_PROGRAM 0x10000000 /* there are live write watchpoints in program address space */ +#define DEBUG_FLAG_LIVE_WPW_DATA 0x20000000 /* there are live write watchpoints in data address space */ +#define DEBUG_FLAG_LIVE_WPW_IO 0x40000000 /* there are live write watchpoints in io address space */ + +#define DEBUG_FLAG_STEPPING_ANY (DEBUG_FLAG_STEPPING | \ + DEBUG_FLAG_STEPPING_OVER | \ + DEBUG_FLAG_STEPPING_OUT) + +#define DEBUG_FLAG_TRACING_ANY (DEBUG_FLAG_TRACING | \ + DEBUG_FLAG_TRACING_OVER) + +#define DEBUG_FLAG_TRANSIENT (DEBUG_FLAG_STEPPING_ANY | \ + DEBUG_FLAG_STOP_PC | \ + DEBUG_FLAG_STOP_CONTEXT | \ + DEBUG_FLAG_STOP_INTERRUPT | \ + DEBUG_FLAG_STOP_EXCEPTION | \ + DEBUG_FLAG_STOP_VBLANK | \ + DEBUG_FLAG_STOP_TIME) + +#define DEBUG_FLAG_READ_WATCHPOINT (DEBUG_FLAG_LIVE_WPR_PROGRAM | \ + DEBUG_FLAG_LIVE_WPR_DATA | \ + DEBUG_FLAG_LIVE_WPR_IO) + +#define DEBUG_FLAG_WRITE_WATCHPOINT (DEBUG_FLAG_LIVE_WPW_PROGRAM | \ + DEBUG_FLAG_LIVE_WPW_DATA | \ + DEBUG_FLAG_LIVE_WPW_IO) + +#define DEBUG_FLAG_WATCHPOINT (DEBUG_FLAG_READ_WATCHPOINT | \ + DEBUG_FLAG_WRITE_WATCHPOINT) @@ -58,14 +97,11 @@ typedef void (*debug_hook_read_func)(int spacenum, offs_t address, UINT64 mem_ma typedef void (*debug_hook_write_func)(int spacenum, offs_t address, UINT64 data, UINT64 mem_mask); -typedef struct _debug_trace_info debug_trace_info; -typedef struct _debug_space_info debug_space_info; -typedef struct _debug_hotspot_entry debug_hotspot_entry; -typedef struct _debug_cpu_info debug_cpu_info; typedef struct _debug_cpu_breakpoint debug_cpu_breakpoint; typedef struct _debug_cpu_watchpoint debug_cpu_watchpoint; +typedef struct _debug_trace_info debug_trace_info; struct _debug_trace_info { FILE * file; /* tracing file for this CPU */ @@ -79,6 +115,7 @@ struct _debug_trace_info }; +typedef struct _debug_space_info debug_space_info; struct _debug_space_info { UINT8 databytes; /* width of the data bus, in bytes */ @@ -91,10 +128,11 @@ struct _debug_space_info offs_t logaddrmask; /* logical address mask */ offs_t physbytemask; /* physical byte mask */ offs_t logbytemask; /* logical byte mask */ - debug_cpu_watchpoint *first_wp; /* first watchpoint */ + debug_cpu_watchpoint *wplist; /* list of watchpoints */ }; +typedef struct _debug_hotspot_entry debug_hotspot_entry; struct _debug_hotspot_entry { offs_t access; /* access address */ @@ -104,18 +142,23 @@ struct _debug_hotspot_entry }; +typedef struct _debug_cpu_info debug_cpu_info; struct _debug_cpu_info { UINT8 valid; /* are we valid? */ UINT8 endianness; /* little or bigendian */ UINT8 opwidth; /* width of an opcode */ - UINT8 ignoring; /* are we ignoring this CPU's execution? */ - offs_t temp_breakpoint_pc; /* temporary breakpoint PC */ - int read_watchpoints; /* total read watchpoints on this CPU */ - int write_watchpoints; /* total write watchpoints on this CPU */ + UINT32 flags; /* debugging flags for this CPU */ + offs_t stepaddr; /* step target address for DEBUG_FLAG_STEPPING_OVER */ + int stepsleft; /* number of steps left until done */ + offs_t stopaddr; /* stop address for DEBUG_FLAG_STOP_PC */ + attotime stoptime; /* stop time for DEBUG_FLAG_STOP_TIME */ + int stopirq; /* stop IRQ number for DEBUG_FLAG_STOP_INTERRUPT */ + int stopexception; /* stop exception number for DEBUG_FLAG_STOP_EXCEPTION */ + attotime endexectime; /* ending time of the current execution */ symbol_table * symtable; /* symbol table for expression evaluation */ debug_trace_info trace; /* trace info */ - debug_cpu_breakpoint *first_bp; /* first breakpoint */ + debug_cpu_breakpoint *bplist; /* list of breakpoints */ debug_space_info space[ADDRESS_SPACES]; /* per-address space info */ debug_hotspot_entry *hotspots; /* hotspot list */ offs_t pc_history[DEBUG_HISTORY_SIZE]; /* history of recent PCs */ @@ -132,12 +175,12 @@ struct _debug_cpu_info struct _debug_cpu_breakpoint { + debug_cpu_breakpoint *next; /* next in the list */ int index; /* user reported index */ UINT8 enabled; /* enabled? */ offs_t address; /* execution address */ - parsed_expression *condition; /* condition */ + parsed_expression *condition; /* condition */ char * action; /* action */ - debug_cpu_breakpoint *next; /* next in the list */ }; @@ -148,7 +191,7 @@ struct _debug_cpu_watchpoint UINT8 type; /* type (read/write) */ offs_t address; /* start address */ offs_t length; /* length of watch area */ - parsed_expression *condition; /* condition */ + parsed_expression *condition; /* condition */ char * action; /* action */ debug_cpu_watchpoint *next; /* next in the list */ }; @@ -168,23 +211,44 @@ extern symbol_table *global_symtable; FUNCTION PROTOTYPES ***************************************************************************/ -/* initialization */ -void debug_cpu_init(running_machine *machine); +/* ----- initialization ----- */ + +/* initialize the CPU tracking for the debugger */ +void debug_cpu_init(running_machine *machine); + + +/* ----- core debugger hooks ----- */ + +/* the CPU execution system calls this hook before beginning execution for the given CPU */ +void debug_cpu_start_hook(running_machine *machine, int cpunum, attotime endtime); + +/* the CPU execution system calls this hook when ending execution for the given CPU */ +void debug_cpu_stop_hook(running_machine *machine, int cpunum); + +/* the CPU execution system calls this hook when an interrupt is acknowledged */ +void debug_cpu_interrupt_hook(running_machine *machine, int cpunum, int irqline); + +/* the CPU execution system calls this hook when an exception is generated */ +void debug_cpu_exception_hook(running_machine *machine, int cpunum, int exception); + +/* called by the CPU cores before executing each instruction */ +void debug_cpu_instruction_hook(running_machine *machine, offs_t curpc); + + + +/* ----- core debugger functions ----- */ -/* utilities */ +int debug_cpu_within_instruction_hook(running_machine *machine); const debug_cpu_info *debug_get_cpu_info(int cpunum); -void debug_halt_on_next_instruction(void); -void debug_refresh_display(void); -int debug_get_execution_state(void); -UINT32 debug_get_execution_counter(void); -void debug_trace_printf(int cpunum, const char *fmt, ...) ATTR_PRINTF(2,3); -void debug_source_script(const char *file); -void debug_flush_traces(void); +void debug_cpu_halt_on_next_instruction(running_machine *machine); +int debug_cpu_is_stopped(running_machine *machine); +void debug_cpu_trace_printf(int cpunum, const char *fmt, ...) ATTR_PRINTF(2,3); +void debug_cpu_source_script(const char *file); +void debug_cpu_flush_traces(void); /* debugging hooks */ -void debug_interrupt_hook(int cpunum, int irqline); -void debug_get_memory_hooks(int cpunum, debug_hook_read_func *read, debug_hook_write_func *write); -void debug_set_instruction_hook(int cpunum, int (*hook)(offs_t pc)); +void debug_cpu_get_memory_hooks(int cpunum, debug_hook_read_func *read, debug_hook_write_func *write); +void debug_cpu_set_instruction_hook(int cpunum, int (*hook)(offs_t pc)); /* execution control */ void debug_cpu_single_step(int numsteps); @@ -201,20 +265,17 @@ void debug_cpu_ignore_cpu(int cpunum, int ignore); void debug_cpu_trace(int cpunum, FILE *file, int trace_over, const char *action); /* breakpoints */ -void debug_check_breakpoints(int cpunum, offs_t pc); -debug_cpu_breakpoint *debug_breakpoint_first(int cpunum); -int debug_breakpoint_set(int cpunum, offs_t address, parsed_expression *condition, const char *action); -int debug_breakpoint_clear(int bpnum); -int debug_breakpoint_enable(int bpnum, int enable); +int debug_cpu_breakpoint_set(int cpunum, offs_t address, parsed_expression *condition, const char *action); +int debug_cpu_breakpoint_clear(int bpnum); +int debug_cpu_breakpoint_enable(int bpnum, int enable); /* watchpoints */ -debug_cpu_watchpoint *debug_watchpoint_first(int cpunum, int spacenum); -int debug_watchpoint_set(int cpunum, int spacenum, int type, offs_t address, offs_t length, parsed_expression *condition, const char *action); -int debug_watchpoint_clear(int wpnum); -int debug_watchpoint_enable(int wpnum, int enable); +int debug_cpu_watchpoint_set(int cpunum, int spacenum, int type, offs_t address, offs_t length, parsed_expression *condition, const char *action); +int debug_cpu_watchpoint_clear(int wpnum); +int debug_cpu_watchpoint_enable(int wpnum, int enable); /* hotspots */ -int debug_hotspot_track(int cpunum, int numspots, int threshhold); +int debug_cpu_hotspot_track(int cpunum, int numspots, int threshhold); /* memory accessors */ UINT8 debug_read_byte(int spacenum, offs_t address, int apply_translation); diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index 24ae7a8c305..fc3f17cf471 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -99,7 +99,7 @@ struct _debug_view_registers UINT8 recompute; /* do we need to recompute the layout the next change? */ UINT8 cpunum; /* target CPU number */ int divider; /* dividing column */ - UINT32 last_update; /* execution counter at last update */ + UINT64 last_update; /* execution counter at last update */ debug_view_register reg[MAX_REGS]; /* register data */ }; @@ -1072,15 +1072,16 @@ static void registers_recompute(debug_view *view) static void registers_update(debug_view *view) { - UINT32 execution_counter = debug_get_execution_counter(); debug_view_registers *regdata = view->extra_data; debug_view_char *dest = view->viewdata; + UINT64 total_cycles; UINT32 row, i; const device_config *screen = Machine->primary_screen; /* cannot update if no active CPU */ if (cpu_getactivecpu() < 0) return; + total_cycles = activecpu_gettotalcycles(); /* if our assumptions changed, revisit them */ if (regdata->recompute) @@ -1140,7 +1141,7 @@ static void registers_update(debug_view *view) else { data = (char *)cpunum_reg_string(regdata->cpunum, reg->regnum); - if (regdata->last_update != execution_counter) + if (regdata->last_update != total_cycles) reg->lastval = reg->currval; reg->currval = cpunum_get_reg(regdata->cpunum, reg->regnum); } @@ -1189,7 +1190,7 @@ static void registers_update(debug_view *view) } /* remember the last update */ - regdata->last_update = execution_counter; + regdata->last_update = total_cycles; } @@ -1761,7 +1762,7 @@ recompute: /* if we're on a line with a breakpoint, tag it changed */ else { - for (bp = cpuinfo->first_bp; bp; bp = bp->next) + for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) if (dasmdata->address[effrow] == ADDR2BYTE_MASKED(bp->address, cpuinfo, ADDRESS_SPACE_PROGRAM)) attrib = DCA_CHANGED; } diff --git a/src/emu/debugger.c b/src/emu/debugger.c new file mode 100644 index 00000000000..214ce135d44 --- /dev/null +++ b/src/emu/debugger.c @@ -0,0 +1,58 @@ +/********************************************************************* + + debugger.c + + Front-end debugger interfaces. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +*********************************************************************/ + +#include "driver.h" +#include "debugger.h" +#include "debug/debugcpu.h" +#include "debug/debugcmd.h" +#include "debug/debugcmt.h" +#include "debug/debugcon.h" +#include "debug/express.h" +#include "debug/debugvw.h" +#include <ctype.h> + + + +/*************************************************************************** + CENTRAL INITIALIZATION POINT +***************************************************************************/ + +/*------------------------------------------------- + debugger_init - start up all subsections +-------------------------------------------------*/ + +void debugger_init(running_machine *machine) +{ + /* only if debugging is enabled */ + if (machine->debug_flags & DEBUG_FLAG_ENABLED) + { + debug_cpu_init(machine); + debug_command_init(machine); + debug_console_init(machine); + debug_view_init(machine); + debug_comment_init(machine); + atexit(debug_cpu_flush_traces); + add_logerror_callback(machine, debug_errorlog_write_line); + } +} + + +/*------------------------------------------------- + debugger_refresh_display - redraw the current + video display +-------------------------------------------------*/ + +void debugger_refresh_display(running_machine *machine) +{ + video_frame_update(machine, TRUE); +} + + diff --git a/src/emu/debugger.h b/src/emu/debugger.h index 513c6eb613f..fed1da3b997 100644 --- a/src/emu/debugger.h +++ b/src/emu/debugger.h @@ -15,61 +15,90 @@ #define __DEBUGGER_H__ #include "mame.h" -#include "memory.h" -#ifdef ENABLE_DEBUGGER #include "deprecat.h" -#endif - - -/*************************************************************************** - MACROS -***************************************************************************/ - -/* handy macro for hard-coding debugger breaks */ -#ifdef ENABLE_DEBUGGER -#define DEBUGGER_BREAK if (Machine->debug_mode) mame_debug_break(); -#else -#define DEBUGGER_BREAK -#endif - - -/* handy macro for CPU cores */ -#ifdef ENABLE_DEBUGGER -#define CALL_DEBUGGER(p) if (Machine->debug_mode) mame_debug_hook(p); -#else -#define CALL_DEBUGGER(p) -#endif - +#include "debug/debugcpu.h" /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ -/* initialize the debugger */ -void mame_debug_init(running_machine *machine); +/* ----- core debugger functions ----- */ -/* call this once per instruction from CPU cores */ -void mame_debug_hook(offs_t curpc); - -/* call this to break into the debugger as soon as possible */ -void mame_debug_break(void); +/* initialize the debugger */ +void debugger_init(running_machine *machine); -/* call this to determine if the debugger is currently active (broken) */ -int mame_debug_is_active(void); +/* redraw the current video display */ +void debugger_refresh_display(running_machine *machine); /*************************************************************************** - STUBS + INLINE FUNCTIONS ***************************************************************************/ -#ifndef ENABLE_DEBUGGER -#define mame_debug_init(m) do { } while (0) -#define mame_debug_hook() do { } while (0) -#define mame_debug_break() do { } while (0) -#define mame_debug_is_active() FALSE -#endif +/*------------------------------------------------- + debugger_instruction_hook - CPU cores call + this once per instruction from CPU cores +-------------------------------------------------*/ + +INLINE void debugger_instruction_hook(running_machine *machine, offs_t curpc) +{ + if ((machine->debug_flags & DEBUG_FLAG_CALL_HOOK) != 0) + debug_cpu_instruction_hook(machine, curpc); +} + + +/*------------------------------------------------- + debugger_start_cpu_hook - the CPU execution + system calls this hook before beginning + execution for the given CPU +-------------------------------------------------*/ + +INLINE void debugger_start_cpu_hook(running_machine *machine, int cpunum, attotime endtime) +{ + if ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + debug_cpu_start_hook(machine, cpunum, endtime); +} + + +/*------------------------------------------------- + debugger_stop_cpu_hook - the CPU execution + system calls this hook when ending execution + for the given CPU +-------------------------------------------------*/ + +INLINE void debugger_stop_cpu_hook(running_machine *machine, int cpunum) +{ + if ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + debug_cpu_stop_hook(machine, cpunum); +} + + +/*------------------------------------------------- + debugger_break - stop in the debugger at the + next opportunity +-------------------------------------------------*/ + +INLINE void debugger_break(running_machine *machine) +{ + if ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + debug_cpu_halt_on_next_instruction(machine); +} + + +/*------------------------------------------------- + debugger_within_instruction_hook - call this + to determine if the debugger is currently + halted within the instruction hook +-------------------------------------------------*/ + +INLINE int debugger_within_instruction_hook(running_machine *machine) +{ + if ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + return debug_cpu_within_instruction_hook(machine); + return FALSE; +} #endif /* __DEBUGGER_H__ */ diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 1c8c18c409b..ee150a6d5f3 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -45,6 +45,7 @@ EMUOBJS = \ $(EMUOBJ)/cpuint.o \ $(EMUOBJ)/cpuintrf.o \ $(EMUOBJ)/crsshair.o \ + $(EMUOBJ)/debugger.o \ $(EMUOBJ)/devintrf.o \ $(EMUOBJ)/drawgfx.o \ $(EMUOBJ)/driver.o \ @@ -78,15 +79,7 @@ EMUOBJS = \ $(EMUOBJ)/uimenu.o \ $(EMUOBJ)/validity.o \ $(EMUOBJ)/video.o \ - $(EMUOBJ)/watchdog.o - -ifdef PROFILER -EMUOBJS += \ - $(EMUOBJ)/profiler.o -endif - -ifdef DEBUGGER -EMUOBJS += \ + $(EMUOBJ)/watchdog.o \ $(EMUOBJ)/debug/debugcmd.o \ $(EMUOBJ)/debug/debugcmt.o \ $(EMUOBJ)/debug/debugcon.o \ @@ -95,6 +88,10 @@ EMUOBJS += \ $(EMUOBJ)/debug/debugvw.o \ $(EMUOBJ)/debug/express.o \ $(EMUOBJ)/debug/textbuf.o + +ifdef PROFILER +EMUOBJS += \ + $(EMUOBJ)/profiler.o endif EMUSOUNDOBJS = \ @@ -195,11 +192,7 @@ $(LIBEMU): $(EMUOBJS) $(EMUSOUNDOBJS) $(EMUAUDIOOBJS) $(EMUDRIVEROBJS) $(EMUMACH include $(EMUSRC)/cpu/cpu.mak -$(LIBCPU): $(CPUOBJS) - -ifdef DEBUGGER -$(LIBCPU): $(DBGOBJS) -endif +$(LIBCPU): $(CPUOBJS) $(DBGOBJS) diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c index 664a45e2974..342ef2f7b74 100644 --- a/src/emu/emuopts.c +++ b/src/emu/emuopts.c @@ -149,13 +149,8 @@ const options_entry mame_core_options[] = { "log", "0", OPTION_BOOLEAN, "generate an error.log file" }, { "verbose;v", "0", OPTION_BOOLEAN, "display additional diagnostic information" }, { "update_in_pause", "0", OPTION_BOOLEAN, "keep calling video updates while in pause" }, -#ifdef ENABLE_DEBUGGER { "debug;d", "1", OPTION_BOOLEAN, "enable/disable debugger" }, { "debugscript", NULL, 0, "script for debugger" }, -#else - { "debug;d", "1", OPTION_DEPRECATED, "(debugger-only command)" }, - { "debugscript", NULL, OPTION_DEPRECATED, "(debugger-only command)" }, -#endif /* misc options */ { NULL, NULL, OPTION_HEADER, "CORE MISC OPTIONS" }, diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c index 8c5c9d74c0e..785f4b323e3 100644 --- a/src/emu/machine/idectrl.c +++ b/src/emu/machine/idectrl.c @@ -1162,7 +1162,7 @@ static void handle_command(ide_state *ide, UINT8 command) default: LOGPRINT(("IDE unknown command (%02X)\n", command)); - DEBUGGER_BREAK; + debugger_break(ide->device->machine); break; } } diff --git a/src/emu/mame.c b/src/emu/mame.c index 0edc32d73db..063ac872c1a 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -54,7 +54,7 @@ - calls tilemap_init() [tilemap.c] to start the tilemap system - calls crosshair_init() [crsshair.c] to configure the crosshairs - calls sound_init() [sound.c] to start the audio system - - calls mame_debug_init() [debugcpu.c] to set up the debugger + - calls debugger_init() [debugger.c] to set up the debugger - calls the driver's MACHINE_START, SOUND_START, and VIDEO_START callbacks - disposes of regions marked as disposable - calls saveload_init() [mame.c] to set up for save/load @@ -89,10 +89,7 @@ #include "ui.h" #include "uimenu.h" #include "deprecat.h" - -#ifdef ENABLE_DEBUGGER #include "debug/debugcon.h" -#endif #include <stdarg.h> #include <setjmp.h> @@ -1335,10 +1332,9 @@ void mame_parse_ini_files(core_options *options, const game_driver *driver) parse_ini_file(options, CONFIGNAME); parse_ini_file(options, CONFIGNAME); - /* debug builds: parse "debug.ini" as well */ -#ifdef ENABLE_DEBUGGER - parse_ini_file(options, "debug"); -#endif + /* debug mode: parse "debug.ini" as well */ + if (options_get_bool(mame_options(), OPTION_DEBUG)) + parse_ini_file(options, "debug"); /* if we have a valid game driver, parse game-specific INI files */ if (driver != NULL) @@ -1482,11 +1478,7 @@ static void prepare_machine(running_machine *machine) machine->portconfig = NULL; /* debugger-related information */ -#ifdef ENABLE_DEBUGGER - machine->debug_mode = options_get_bool(mame_options(), OPTION_DEBUG); -#else - machine->debug_mode = 0; -#endif + machine->debug_flags = options_get_bool(mame_options(), OPTION_DEBUG) ? (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) : 0; /* reset the global MAME data and clear the other privates */ memset(machine->mame_data, 0, sizeof(*machine->mame_data)); @@ -1601,11 +1593,9 @@ static void init_machine(running_machine *machine) sound_init(machine); -#ifdef ENABLE_DEBUGGER /* initialize the debugger */ - if (machine->debug_mode) - mame_debug_init(machine); -#endif + if ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + debugger_init(machine); /* call the driver's _START callbacks */ if (machine->config->machine_start != NULL) diff --git a/src/emu/mame.h b/src/emu/mame.h index 33598c850a8..16463489aa7 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -31,24 +31,41 @@ ***************************************************************************/ /* return values from run_game */ -#define MAMERR_NONE 0 /* no error */ -#define MAMERR_FAILED_VALIDITY 1 /* failed validity checks */ -#define MAMERR_MISSING_FILES 2 /* missing files */ -#define MAMERR_FATALERROR 3 /* some other fatal error */ -#define MAMERR_DEVICE 4 /* device initialization error (MESS-specific) */ -#define MAMERR_NO_SUCH_GAME 5 /* game was specified but doesn't exist */ -#define MAMERR_INVALID_CONFIG 6 /* some sort of error in configuration */ -#define MAMERR_IDENT_NONROMS 7 /* identified all non-ROM files */ -#define MAMERR_IDENT_PARTIAL 8 /* identified some files but not all */ -#define MAMERR_IDENT_NONE 9 /* identified no files */ +enum +{ + MAMERR_NONE = 0, /* no error */ + MAMERR_FAILED_VALIDITY = 1, /* failed validity checks */ + MAMERR_MISSING_FILES = 2, /* missing files */ + MAMERR_FATALERROR = 3, /* some other fatal error */ + MAMERR_DEVICE = 4, /* device initialization error (MESS-specific) */ + MAMERR_NO_SUCH_GAME = 5, /* game was specified but doesn't exist */ + MAMERR_INVALID_CONFIG = 6, /* some sort of error in configuration */ + MAMERR_IDENT_NONROMS = 7, /* identified all non-ROM files */ + MAMERR_IDENT_PARTIAL = 8, /* identified some files but not all */ + MAMERR_IDENT_NONE = 9 /* identified no files */ +}; /* program phases */ -#define MAME_PHASE_PREINIT 0 -#define MAME_PHASE_INIT 1 -#define MAME_PHASE_RESET 2 -#define MAME_PHASE_RUNNING 3 -#define MAME_PHASE_EXIT 4 +enum +{ + MAME_PHASE_PREINIT, + MAME_PHASE_INIT, + MAME_PHASE_RESET, + MAME_PHASE_RUNNING, + MAME_PHASE_EXIT +}; + + +/* debug flags */ +#define DEBUG_FLAG_ENABLED 0x00000001 /* debugging is enabled */ +#define DEBUG_FLAG_CALL_HOOK 0x00000002 /* CPU cores must call instruction hook */ +#define DEBUG_FLAG_WPR_PROGRAM 0x00000010 /* watchpoints are enabled for PROGRAM memory reads */ +#define DEBUG_FLAG_WPR_DATA 0x00000020 /* watchpoints are enabled for DATA memory reads */ +#define DEBUG_FLAG_WPR_IO 0x00000040 /* watchpoints are enabled for IO memory reads */ +#define DEBUG_FLAG_WPW_PROGRAM 0x00000100 /* watchpoints are enabled for PROGRAM memory writes */ +#define DEBUG_FLAG_WPW_DATA 0x00000200 /* watchpoints are enabled for DATA memory writes */ +#define DEBUG_FLAG_WPW_IO 0x00000400 /* watchpoints are enabled for IO memory writes */ /* maxima */ @@ -196,7 +213,7 @@ struct _running_machine int sample_rate; /* the digital audio sample rate */ /* debugger-related information */ - int debug_mode; /* was debug mode enabled? */ + UINT32 debug_flags; /* the current debug flags */ /* internal core information */ mame_private * mame_data; /* internal data from mame.c */ diff --git a/src/emu/memory.c b/src/emu/memory.c index a350fbcad23..e30a2d3a3e5 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -116,9 +116,7 @@ #include "driver.h" #include "profiler.h" #include "deprecat.h" -#ifdef ENABLE_DEBUGGER #include "debug/debugcpu.h" -#endif /*************************************************************************** @@ -195,13 +193,8 @@ typedef enum _read_or_write read_or_write; #define SUBTABLE_PTR(tabledata, entry) (&(tabledata)->table[(1 << LEVEL1_BITS) + (((entry) - SUBTABLE_BASE) << LEVEL2_BITS)]) -#ifdef ENABLE_DEBUGGER #define DEBUG_HOOK_READ(spacenum,address,mem_mask) if (debug_hook_read) (*debug_hook_read)(spacenum,address,mem_mask) #define DEBUG_HOOK_WRITE(spacenum,address,data,mem_mask) if (debug_hook_write) (*debug_hook_write)(spacenum,address,data,mem_mask) -#else -#define DEBUG_HOOK_READ(spacenum,address,mem_mask) -#define DEBUG_HOOK_WRITE(spacenum,address,data,mem_mask) -#endif @@ -326,10 +319,8 @@ static UINT8 log_unmap[ADDRESS_SPACES]; /* log unmapped memory accesses */ static cpu_data cpudata[MAX_CPU]; /* data gathered for each CPU */ static bank_info bankdata[STATIC_COUNT]; /* data gathered for each bank */ -#ifdef ENABLE_DEBUGGER static debug_hook_read_func debug_hook_read; /* pointer to debugger callback for memory reads */ static debug_hook_write_func debug_hook_write; /* pointer to debugger callback for memory writes */ -#endif #define ACCESSOR_GROUP(type, width) \ { \ @@ -579,15 +570,13 @@ void memory_set_context(int activecpu) opbase_handler = cpudata[activecpu].opbase_handler; -#ifdef ENABLE_DEBUGGER - if (activecpu != -1 && Machine->debug_mode) - debug_get_memory_hooks(activecpu, &debug_hook_read, &debug_hook_write); + if (activecpu != -1 && (Machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) + debug_cpu_get_memory_hooks(activecpu, &debug_hook_read, &debug_hook_write); else { debug_hook_read = NULL; debug_hook_write = NULL; } -#endif } diff --git a/src/emu/ui.c b/src/emu/ui.c index 82479d2d93e..0b43ad8aae7 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -317,7 +317,7 @@ int ui_display_startup_screens(running_machine *machine, int first_time, int sho /* disable everything if we are using -str for 300 or fewer seconds, or if we're the empty driver, or if we are debugging */ - if (!first_time || (str > 0 && str < 60*5) || machine->gamedrv == &driver_empty || machine->debug_mode) + if (!first_time || (str > 0 && str < 60*5) || machine->gamedrv == &driver_empty || (machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) show_gameinfo = show_warnings = show_disclaimer = FALSE; /* initialize the on-screen display system */ @@ -1264,7 +1264,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) return ui_set_handler(ui_menu_ui_handler, 0); /* if the on-screen display isn't up and the user has toggled it, turn it on */ - if (!machine->debug_mode && input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY)) + if ((machine->debug_flags & DEBUG_FLAG_ENABLED) == 0 && input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY)) return ui_set_handler(handler_slider, 0); /* handle a reset request */ diff --git a/src/emu/video.c b/src/emu/video.c index be3e724ba7f..b2d91361e20 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -1517,7 +1517,7 @@ void video_frame_update(running_machine *machine, int debug) if (phase == MAME_PHASE_RUNNING) { /* reset partial updates if we're paused or if the debugger is active */ - if (machine->primary_screen != NULL && (mame_is_paused(machine) || debug || mame_debug_is_active())) + if (machine->primary_screen != NULL && (mame_is_paused(machine) || debug || debugger_within_instruction_hook(machine))) { void *param = (void *)machine->primary_screen; scanline0_callback(machine, param, 0); diff --git a/src/mame/drivers/segas24.c b/src/mame/drivers/segas24.c index 3e4c42e31c8..4d661917802 100644 --- a/src/mame/drivers/segas24.c +++ b/src/mame/drivers/segas24.c @@ -696,7 +696,7 @@ static void reset_reset(running_machine *machine) cpunum_set_input_line(machine, 1, INPUT_LINE_HALT, CLEAR_LINE); cpunum_set_input_line(machine, 1, INPUT_LINE_RESET, PULSE_LINE); // mame_printf_debug("enable 2nd cpu!\n"); -// DEBUGGER_BREAK; +// debugger_break(machine); s24_fd1094_machine_init(); } else diff --git a/src/mame/machine/dc.c b/src/mame/machine/dc.c index 4cc0753ccd5..ad5a418ae22 100644 --- a/src/mame/machine/dc.c +++ b/src/mame/machine/dc.c @@ -144,9 +144,7 @@ INLINE int decode_reg_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift) if ((mem_mask != U64(0xffffffff00000000)) && (mem_mask != U64(0x00000000ffffffff))) { mame_printf_verbose("Wrong mask! (PC=%x)\n", activecpu_get_pc()); - #ifdef ENABLE_DEBUGGER -// mame_debug_break(); - #endif +// debugger_break(Machine); } if (mem_mask == U64(0xffffffff00000000)) diff --git a/src/mame/machine/fd1094.h b/src/mame/machine/fd1094.h index a9489853b34..3eb4fe06937 100644 --- a/src/mame/machine/fd1094.h +++ b/src/mame/machine/fd1094.h @@ -5,8 +5,6 @@ int fd1094_set_state(UINT8 *key,int state); int fd1094_decode(int address,int val,UINT8 *key,int vector_fetch); -#ifdef ENABLE_DEBUGGER - typedef struct _fd1094_constraint fd1094_constraint; struct _fd1094_constraint { @@ -15,5 +13,3 @@ struct _fd1094_constraint UINT16 value; UINT16 mask; }; - -#endif diff --git a/src/mame/machine/fddebug.c b/src/mame/machine/fddebug.c index 76702632bb2..10fac8e6f44 100644 --- a/src/mame/machine/fddebug.c +++ b/src/mame/machine/fddebug.c @@ -105,8 +105,6 @@ ***************************************************************************/ -#ifdef ENABLE_DEBUGGER - #include "driver.h" #include "deprecat.h" #include "machine/fd1094.h" @@ -539,7 +537,7 @@ void fd1094_init_debugging(running_machine *machine, int cpureg, int keyreg, int debug_console_register_command("fdcsearch", CMDFLAG_NONE, 0, 0, 0, execute_fdcsearch); /* set up the instruction hook */ - debug_set_instruction_hook(0, instruction_hook); + debug_cpu_set_instruction_hook(0, instruction_hook); /* regenerate the key */ if (keydirty) @@ -2425,5 +2423,3 @@ static int validate_opcode(UINT32 pc, const UINT8 *opdata, int maxwords) assert(offset == oplength); return iffy ? -oplength : oplength; } - -#endif diff --git a/src/mame/machine/midwayic.c b/src/mame/machine/midwayic.c index 8bed987f84c..89c23deafaf 100644 --- a/src/mame/machine/midwayic.c +++ b/src/mame/machine/midwayic.c @@ -369,7 +369,7 @@ void midway_serial_pic2_w(running_machine *machine, UINT8 data) memcpy(pic.buffer, serial.data, 16); pic.total = 16; pic.index = 0; - DEBUGGER_BREAK; + debugger_break(machine); } break; diff --git a/src/mame/machine/s16fd.c b/src/mame/machine/s16fd.c index 617be67aaed..c5b153f29d5 100644 --- a/src/mame/machine/s16fd.c +++ b/src/mame/machine/s16fd.c @@ -170,7 +170,6 @@ static STATE_POSTLOAD( fd1094_postload ) } -#ifdef ENABLE_DEBUGGER static void key_changed(void) { int addr; @@ -191,7 +190,6 @@ static void key_changed(void) /* flush the prefetch queue */ cpunum_set_info_int(0, CPUINFO_INT_REGISTER + M68K_PREF_ADDR, 0x0010); } -#endif /* startup function, to be called from DRIVER_INIT (once on startup) */ @@ -216,14 +214,12 @@ void fd1094_driver_init(running_machine *machine, void (*set_decrypted)(running_ fd1094_current_cacheposition = 0; fd1094_state = -1; -#ifdef ENABLE_DEBUGGER /* key debugging */ - if (machine->debug_mode && memory_region(machine, REGION_USER2) != NULL) + if ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0 && memory_region(machine, REGION_USER2) != NULL) { void fd1094_init_debugging(running_machine *, int, int, int, void (*changed)(void)); fd1094_init_debugging(machine, REGION_CPU1, REGION_USER1, REGION_USER2, key_changed); } -#endif state_save_register_global(fd1094_selected_state); state_save_register_global(fd1094_state); diff --git a/src/mame/machine/tx1.c b/src/mame/machine/tx1.c index be701976c79..fd301e02901 100644 --- a/src/mame/machine/tx1.c +++ b/src/mame/machine/tx1.c @@ -1288,13 +1288,13 @@ WRITE16_HANDLER( buggyboy_math_w ) else { mame_printf_debug("BB_DSEL was not 3 for P->S load!\n"); - DEBUGGER_BREAK; + debugger_break(machine); } } else { mame_printf_debug("Buggy Boy unknown math state!\n"); - DEBUGGER_BREAK; + debugger_break(machine); } if ( offset & BB_INSLD ) diff --git a/src/mame/video/namcos2.c b/src/mame/video/namcos2.c index 1bcf6e5486a..00e05006b9e 100644 --- a/src/mame/video/namcos2.c +++ b/src/mame/video/namcos2.c @@ -209,7 +209,7 @@ WRITE16_HANDLER( namcos2_68k_roz_ram_w ) tilemap_mark_tile_dirty(tilemap_roz,offset); // if( input_code_pressed(KEYCODE_Q) ) // { -// DEBUGGER_BREAK; +// debugger_break(machine); // } } diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index 4c77142ac02..816a3abd577 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -21,6 +21,7 @@ #include "debug/debugvw.h" #include "debug/debugcon.h" #include "debug/debugcpu.h" +#include "debugger.h" #include "deprecat.h" // MAMEOS headers @@ -420,10 +421,8 @@ void debugwin_show(int type) void debugwin_update_during_game(void) { - int execution_state = debug_get_execution_state(); - // if we're running live, do some checks - if (execution_state != EXECUTION_STATE_STOPPED) + if (!debug_cpu_is_stopped(Machine)) { // see if the interrupt key is pressed and break if it is temporarily_fake_that_we_are_not_visible = TRUE; @@ -432,7 +431,7 @@ void debugwin_update_during_game(void) debugwin_info *info; HWND focuswnd = GetFocus(); - debug_halt_on_next_instruction(); + debugger_break(Machine); debug_console_printf("User-initiated break\n"); // if we were focused on some window's edit box, reset it to default @@ -2449,7 +2448,7 @@ static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar cpu_num = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM); cpuinfo = (debug_cpu_info*)debug_get_cpu_info(cpu_num); - for (bp = cpuinfo->first_bp; bp; bp = bp->next) + for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) { if (BYTE2ADDR(active_address, cpuinfo, ADDRESS_SPACE_PROGRAM) == bp->address) { diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index c180da0587c..848781c1894 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -107,10 +107,8 @@ void winvideo_init(running_machine *machine) SetForegroundWindow(win_window_list->hwnd); // possibly create the debug window, but don't show it yet -#ifdef ENABLE_DEBUGGER if (options_get_bool(mame_options(), OPTION_DEBUG)) debugwin_init_windows(); -#endif } @@ -126,10 +124,8 @@ static void video_exit(running_machine *machine) effect_bitmap = NULL; // possibly kill the debug window -#ifdef ENABLE_DEBUGGER if (options_get_bool(mame_options(), OPTION_DEBUG)) debugwin_destroy_windows(); -#endif // free all of our monitor information while (win_monitor_list != NULL) @@ -380,11 +376,10 @@ static void extract_video_config(running_machine *machine) video_config.prescale = options_get_int(mame_options(), WINOPTION_PRESCALE); video_config.keepaspect = options_get_bool(mame_options(), WINOPTION_KEEPASPECT); video_config.numscreens = options_get_int(mame_options(), WINOPTION_NUMSCREENS); -#ifdef ENABLE_DEBUGGER + // if we are in debug mode, never go full screen if (options_get_bool(mame_options(), OPTION_DEBUG)) video_config.windowed = TRUE; -#endif stemp = options_get_string(mame_options(), WINOPTION_EFFECT); if (strcmp(stemp, "none") != 0) load_effect_overlay(machine, stemp); diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 5c19b1a6026..88fda3cd54b 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -352,10 +352,8 @@ void winwindow_process_events(running_machine *machine, int ingame) assert(GetCurrentThreadId() == main_threadid); // if we're running, disable some parts of the debugger -#ifdef ENABLE_DEBUGGER - if (ingame) + if (ingame && (machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) debugwin_update_during_game(); -#endif // remember the last time we did this last_event_check = GetTickCount(); @@ -494,11 +492,9 @@ void winwindow_toggle_full_screen(void) assert(GetCurrentThreadId() == main_threadid); -#ifdef ENABLE_DEBUGGER // if we are in debug mode, never go full screen if (options_get_bool(mame_options(), OPTION_DEBUG)) return; -#endif // toggle the window mode video_config.windowed = !video_config.windowed; diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak index e8a63a9d6ed..5946cda0c24 100644 --- a/src/osd/windows/windows.mak +++ b/src/osd/windows/windows.mak @@ -254,10 +254,8 @@ $(WINOBJ)/drawdd.o : $(SRC)/emu/rendersw.c $(WINOBJ)/drawgdi.o : $(SRC)/emu/rendersw.c # add debug-specific files -ifdef DEBUGGER OSDOBJS += \ $(WINOBJ)/debugwin.o -endif # add a stub resource file RESFILE = $(WINOBJ)/mame.res diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 029f868a2f3..c21186648f2 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -34,6 +34,7 @@ #include "strconv.h" #include "winutf8.h" #include "winutil.h" +#include "debug/debugcpu.h" #define ENABLE_PROFILER 0 #define DEBUG_SLOW_LOCKS 0 @@ -453,12 +454,8 @@ static LONG CALLBACK exception_filter(struct _EXCEPTION_POINTERS *info) ExitProcess(100); already_hit = 1; -#ifdef ENABLE_DEBUGGER -{ -extern void debug_flush_traces(void); -debug_flush_traces(); -} -#endif + // flush any debugging traces that were live + debug_cpu_flush_traces(); // find our man for (i = 0; exception_table[i].code != 0; i++) |