diff options
Diffstat (limited to 'src/emu/debug/debugcpu.h')
| -rw-r--r-- | src/emu/debug/debugcpu.h | 165 |
1 files changed, 113 insertions, 52 deletions
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); |
