revision 43:0cf3e339cc59
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 43:0cf3e339cc59 |
parent | 42:d06affd949ec |
child | 44:8da2cbcffe24 |
author | nkeynes |
date | Mon Dec 26 11:47:15 2005 +0000 (18 years ago) |
Add sh4 + arm breakpoints
Hook up break button in GUI
Enable ARM slice in main loop
Hook up break button in GUI
Enable ARM slice in main loop
src/Makefile.am | view | annotate | diff | log | ||
src/Makefile.in | view | annotate | diff | log | ||
src/aica/aica.c | view | annotate | diff | log | ||
src/aica/armcore.c | view | annotate | diff | log | ||
src/aica/armcore.h | view | annotate | diff | log | ||
src/aica/armdasm.c | view | annotate | diff | log | ||
src/cpu.h | view | annotate | diff | log | ||
src/gui/callbacks.c | view | annotate | diff | log | ||
src/gui/debug_win.c | view | annotate | diff | log | ||
src/gui/gui.c | view | annotate | diff | log | ||
src/gui/gui.h | view | annotate | diff | log | ||
src/mem.h | view | annotate | diff | log | ||
src/sh4/sh4core.c | view | annotate | diff | log | ||
src/sh4/sh4core.h | view | annotate | diff | log | ||
src/sh4/sh4dasm.c | view | annotate | diff | log |
1.1 --- a/src/Makefile.am Mon Dec 26 10:48:55 2005 +00001.2 +++ b/src/Makefile.am Mon Dec 26 11:47:15 2005 +00001.3 @@ -10,14 +10,14 @@1.5 dream_SOURCES = \1.6 main.c \1.7 - mem.c mem.h mmio.h \1.8 + mem.c mem.h mmio.h watch.c \1.9 asic.c asic.h \1.10 pvr2.c pvr2.h \1.11 gdrom/ide.c gdrom/ide.h \1.12 video.c dreamcast.c dreamcast.h \1.13 sh4/intc.c sh4/intc.h sh4/sh4mem.c sh4/timer.c \1.14 sh4/sh4core.c sh4/sh4core.h sh4/sh4dasm.c sh4/sh4dasm.h \1.15 - sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c sh4/watch.c \1.16 + sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c \1.17 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armmem.c \1.18 aica/aica.c aica/aica.h \1.19 maple/maple.c maple/maple.h \
2.1 --- a/src/Makefile.in Mon Dec 26 10:48:55 2005 +00002.2 +++ b/src/Makefile.in Mon Dec 26 11:47:15 2005 +00002.3 @@ -137,14 +137,14 @@2.5 dream_SOURCES = \2.6 main.c \2.7 - mem.c mem.h mmio.h \2.8 + mem.c mem.h mmio.h watch.c \2.9 asic.c asic.h \2.10 pvr2.c pvr2.h \2.11 gdrom/ide.c gdrom/ide.h \2.12 video.c dreamcast.c dreamcast.h \2.13 sh4/intc.c sh4/intc.h sh4/sh4mem.c sh4/timer.c \2.14 sh4/sh4core.c sh4/sh4core.h sh4/sh4dasm.c sh4/sh4dasm.h \2.15 - sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c sh4/watch.c \2.16 + sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c \2.17 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armmem.c \2.18 aica/aica.c aica/aica.h \2.19 maple/maple.c maple/maple.h \2.20 @@ -168,17 +168,16 @@2.21 bin_PROGRAMS = dream$(EXEEXT)2.22 PROGRAMS = $(bin_PROGRAMS)2.24 -am_dream_OBJECTS = main.$(OBJEXT) mem.$(OBJEXT) asic.$(OBJEXT) \2.25 - pvr2.$(OBJEXT) ide.$(OBJEXT) video.$(OBJEXT) \2.26 +am_dream_OBJECTS = main.$(OBJEXT) mem.$(OBJEXT) watch.$(OBJEXT) \2.27 + asic.$(OBJEXT) pvr2.$(OBJEXT) ide.$(OBJEXT) video.$(OBJEXT) \2.28 dreamcast.$(OBJEXT) intc.$(OBJEXT) sh4mem.$(OBJEXT) \2.29 timer.$(OBJEXT) sh4core.$(OBJEXT) sh4dasm.$(OBJEXT) \2.30 - sh4mmio.$(OBJEXT) scif.$(OBJEXT) watch.$(OBJEXT) \2.31 - armcore.$(OBJEXT) armdasm.$(OBJEXT) armmem.$(OBJEXT) \2.32 - aica.$(OBJEXT) maple.$(OBJEXT) controller.$(OBJEXT) \2.33 - support.$(OBJEXT) interface.$(OBJEXT) callbacks.$(OBJEXT) \2.34 - gui.$(OBJEXT) mmr_win.$(OBJEXT) debug_win.$(OBJEXT) \2.35 - dump_win.$(OBJEXT) loader.$(OBJEXT) bootstrap.$(OBJEXT) \2.36 - util.$(OBJEXT)2.37 + sh4mmio.$(OBJEXT) scif.$(OBJEXT) armcore.$(OBJEXT) \2.38 + armdasm.$(OBJEXT) armmem.$(OBJEXT) aica.$(OBJEXT) \2.39 + maple.$(OBJEXT) controller.$(OBJEXT) support.$(OBJEXT) \2.40 + interface.$(OBJEXT) callbacks.$(OBJEXT) gui.$(OBJEXT) \2.41 + mmr_win.$(OBJEXT) debug_win.$(OBJEXT) dump_win.$(OBJEXT) \2.42 + loader.$(OBJEXT) bootstrap.$(OBJEXT) util.$(OBJEXT)2.43 dream_OBJECTS = $(am_dream_OBJECTS)2.44 dream_DEPENDENCIES =2.45 dream_LDFLAGS =2.46 @@ -483,28 +482,6 @@2.47 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@2.48 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o scif.obj `if test -f 'sh4/scif.c'; then $(CYGPATH_W) 'sh4/scif.c'; else $(CYGPATH_W) '$(srcdir)/sh4/scif.c'; fi`2.50 -watch.o: sh4/watch.c2.51 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT watch.o -MD -MP -MF "$(DEPDIR)/watch.Tpo" \2.52 -@am__fastdepCC_TRUE@ -c -o watch.o `test -f 'sh4/watch.c' || echo '$(srcdir)/'`sh4/watch.c; \2.53 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/watch.Tpo" "$(DEPDIR)/watch.Po"; \2.54 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/watch.Tpo"; exit 1; \2.55 -@am__fastdepCC_TRUE@ fi2.56 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sh4/watch.c' object='watch.o' libtool=no @AMDEPBACKSLASH@2.57 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/watch.Po' tmpdepfile='$(DEPDIR)/watch.TPo' @AMDEPBACKSLASH@2.58 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@2.59 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o watch.o `test -f 'sh4/watch.c' || echo '$(srcdir)/'`sh4/watch.c2.60 -2.61 -watch.obj: sh4/watch.c2.62 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT watch.obj -MD -MP -MF "$(DEPDIR)/watch.Tpo" \2.63 -@am__fastdepCC_TRUE@ -c -o watch.obj `if test -f 'sh4/watch.c'; then $(CYGPATH_W) 'sh4/watch.c'; else $(CYGPATH_W) '$(srcdir)/sh4/watch.c'; fi`; \2.64 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/watch.Tpo" "$(DEPDIR)/watch.Po"; \2.65 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/watch.Tpo"; exit 1; \2.66 -@am__fastdepCC_TRUE@ fi2.67 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sh4/watch.c' object='watch.obj' libtool=no @AMDEPBACKSLASH@2.68 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/watch.Po' tmpdepfile='$(DEPDIR)/watch.TPo' @AMDEPBACKSLASH@2.69 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@2.70 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o watch.obj `if test -f 'sh4/watch.c'; then $(CYGPATH_W) 'sh4/watch.c'; else $(CYGPATH_W) '$(srcdir)/sh4/watch.c'; fi`2.71 -2.72 armcore.o: aica/armcore.c2.73 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT armcore.o -MD -MP -MF "$(DEPDIR)/armcore.Tpo" \2.74 @am__fastdepCC_TRUE@ -c -o armcore.o `test -f 'aica/armcore.c' || echo '$(srcdir)/'`aica/armcore.c; \
3.1 --- a/src/aica/aica.c Mon Dec 26 10:48:55 2005 +00003.2 +++ b/src/aica/aica.c Mon Dec 26 11:47:15 2005 +00003.3 @@ -1,5 +1,5 @@3.4 /**3.5 - * $Id: aica.c,v 1.7 2005-12-26 06:38:51 nkeynes Exp $3.6 + * $Id: aica.c,v 1.8 2005-12-26 11:47:15 nkeynes Exp $3.7 *3.8 * This is the core sound system (ie the bit which does the actual work)3.9 *3.10 @@ -69,9 +69,10 @@3.11 int reset = MMIO_READ( AICA2, AICA_RESET );3.12 if( reset & 1 == 0 ) {3.13 /* Running */3.14 - /* nanosecs = arm_run_slice( nanosecs ); */3.15 + nanosecs = arm_run_slice( nanosecs );3.16 }3.17 /* Generate audio buffer */3.18 + return nanosecs;3.19 }3.21 void aica_stop( void )3.22 @@ -90,15 +91,15 @@3.23 }3.25 /** Channel register structure:3.26 - * 003.27 - * 043.28 + * 00 4 Channel config3.29 + * 04 4 Waveform address lo (16 bits)3.30 * 08 4 Loop start address3.31 * 0C 4 Loop end address3.32 * 10 4 Volume envelope3.33 - * 143.34 - * 18 4 Frequency (floating point3.35 - * 1C3.36 - * 203.37 + * 14 4 Init to 0x1F3.38 + * 18 4 Frequency (floating point)3.39 + * 1C 4 ??3.40 + * 20 4 ??3.41 * 24 1 Pan3.42 * 25 1 ??3.43 * 26
4.1 --- a/src/aica/armcore.c Mon Dec 26 10:48:55 2005 +00004.2 +++ b/src/aica/armcore.c Mon Dec 26 11:47:15 2005 +00004.3 @@ -1,5 +1,5 @@4.4 /**4.5 - * $Id: armcore.c,v 1.7 2005-12-26 06:38:51 nkeynes Exp $4.6 + * $Id: armcore.c,v 1.8 2005-12-26 11:47:15 nkeynes Exp $4.7 *4.8 * ARM7TDMI CPU emulation core.4.9 *4.10 @@ -19,6 +19,7 @@4.11 #define MODULE aica_module4.12 #include "dream.h"4.13 #include "aica/armcore.h"4.14 +#include "mem.h"4.16 struct arm_registers armr;4.18 @@ -43,14 +44,67 @@4.19 uint32_t arm_cpu_freq = ARM_BASE_RATE;4.20 uint32_t arm_cpu_period = 1000 / ARM_BASE_RATE;4.22 +4.23 +static struct breakpoint_struct arm_breakpoints[MAX_BREAKPOINTS];4.24 +static int arm_breakpoint_count = 0;4.25 +4.26 +void arm_set_breakpoint( uint32_t pc, int type )4.27 +{4.28 + arm_breakpoints[arm_breakpoint_count].address = pc;4.29 + arm_breakpoints[arm_breakpoint_count].type = type;4.30 + arm_breakpoint_count++;4.31 +}4.32 +4.33 +gboolean arm_clear_breakpoint( uint32_t pc, int type )4.34 +{4.35 + int i;4.36 +4.37 + for( i=0; i<arm_breakpoint_count; i++ ) {4.38 + if( arm_breakpoints[i].address == pc &&4.39 + arm_breakpoints[i].type == type ) {4.40 + while( ++i < arm_breakpoint_count ) {4.41 + arm_breakpoints[i-1].address = arm_breakpoints[i].address;4.42 + arm_breakpoints[i-1].type = arm_breakpoints[i].type;4.43 + }4.44 + arm_breakpoint_count--;4.45 + return TRUE;4.46 + }4.47 + }4.48 + return FALSE;4.49 +}4.50 +4.51 +int arm_get_breakpoint( uint32_t pc )4.52 +{4.53 + int i;4.54 + for( i=0; i<arm_breakpoint_count; i++ ) {4.55 + if( arm_breakpoints[i].address == pc )4.56 + return arm_breakpoints[i].type;4.57 + }4.58 + return 0;4.59 +}4.60 +4.61 uint32_t arm_run_slice( uint32_t nanosecs )4.62 {4.63 + int i;4.64 uint32_t target = armr.icount + nanosecs / arm_cpu_period;4.65 uint32_t start = armr.icount;4.66 while( armr.icount < target ) {4.67 armr.icount++;4.68 if( !arm_execute_instruction() )4.69 break;4.70 +#ifdef ENABLE_DEBUG_MODE4.71 + for( i=0; i<arm_breakpoint_count; i++ ) {4.72 + if( arm_breakpoints[i].address == armr.r[15] ) {4.73 + break;4.74 + }4.75 + }4.76 + if( i != arm_breakpoint_count ) {4.77 + dreamcast_stop();4.78 + if( arm_breakpoints[i].type == BREAK_ONESHOT )4.79 + arm_clear_breakpoint( armr.r[15], BREAK_ONESHOT );4.80 + break;4.81 + }4.82 +#endif4.83 }4.85 if( target != armr.icount ) {
5.1 --- a/src/aica/armcore.h Mon Dec 26 10:48:55 2005 +00005.2 +++ b/src/aica/armcore.h Mon Dec 26 11:47:15 2005 +00005.3 @@ -1,5 +1,5 @@5.4 /**5.5 - * $Id: armcore.h,v 1.8 2005-12-26 06:38:51 nkeynes Exp $5.6 + * $Id: armcore.h,v 1.9 2005-12-26 11:47:15 nkeynes Exp $5.7 *5.8 * Interface definitions for the ARM CPU emulation core proper.5.9 *5.10 @@ -84,6 +84,9 @@5.11 void arm_save_state( FILE *f );5.12 int arm_load_state( FILE *f );5.13 gboolean arm_execute_instruction( void );5.14 +void arm_set_breakpoint( uint32_t pc, int type );5.15 +gboolean arm_clear_breakpoint( uint32_t pc, int type );5.16 +int arm_get_breakpoint( uint32_t pc );5.18 /* ARM Memory */5.19 uint32_t arm_read_long( uint32_t addr );
6.1 --- a/src/aica/armdasm.c Mon Dec 26 10:48:55 2005 +00006.2 +++ b/src/aica/armdasm.c Mon Dec 26 11:47:15 2005 +00006.3 @@ -1,5 +1,5 @@6.4 /**6.5 - * $Id: armdasm.c,v 1.6 2005-12-25 05:57:00 nkeynes Exp $6.6 + * $Id: armdasm.c,v 1.7 2005-12-26 11:47:15 nkeynes Exp $6.7 *6.8 * armdasm.c 21 Aug 2004 - ARM7tdmi (ARMv4) disassembler6.9 *6.10 @@ -61,7 +61,8 @@6.13 const struct cpu_desc_struct arm_cpu_desc =6.14 - { "ARM7", arm_disasm_instruction, arm_execute_instruction, arm_has_page, 4,6.15 + { "ARM7", arm_disasm_instruction, arm_execute_instruction, arm_has_page,6.16 + arm_set_breakpoint, arm_clear_breakpoint, arm_get_breakpoint, 4,6.17 (char *)&armr, sizeof(armr), arm_reg_map,6.18 &armr.r[15], &armr.icount };6.19 const struct cpu_desc_struct armt_cpu_desc =
7.1 --- a/src/cpu.h Mon Dec 26 10:48:55 2005 +00007.2 +++ b/src/cpu.h Mon Dec 26 11:47:15 2005 +00007.3 @@ -1,5 +1,5 @@7.4 /**7.5 - * $Id: cpu.h,v 1.6 2005-12-25 05:56:55 nkeynes Exp $7.6 + * $Id: cpu.h,v 1.7 2005-12-26 11:47:12 nkeynes Exp $7.7 *7.8 * Generic CPU definitions, primarily for providing information to the GUI.7.9 *7.10 @@ -37,9 +37,6 @@7.11 */7.12 typedef uint32_t (*disasm_func_t)(uint32_t pc, char *buffer, int buflen, char *opcode );7.14 -typedef int (*is_valid_page_t)(uint32_t pc);7.15 -typedef gboolean (*step_func_t)();7.16 -7.17 #define REG_INT 07.18 #define REG_FLT 17.19 #define REG_SPECIAL 27.20 @@ -57,16 +54,19 @@7.21 * CPU definition structure - basic information and support functions.7.22 */7.23 typedef struct cpu_desc_struct {7.24 - char *name; /* CPU Name */7.25 - disasm_func_t disasm_func; /* Disassembly function */7.26 - step_func_t step_func; /* Single step function */7.27 - is_valid_page_t is_valid_page_func; /* Test for valid memory page */7.28 - size_t instr_size; /* Size of instruction */7.29 - char *regs; /* Pointer to start of registers */7.30 - size_t regs_size; /* Size of register structure in bytes */7.31 - const struct reg_desc_struct *regs_info; /* Description of all registers */7.32 - uint32_t *pc; /* Pointer to PC register */7.33 - uint32_t *icount; /* Pointer to instruction counter */7.34 + char *name; /* CPU Name */7.35 + disasm_func_t disasm_func; /* Disassembly function */7.36 + gboolean (*step_func)(); /* Single step function */7.37 + int (*is_valid_page_func)(uint32_t); /* Test for valid memory page */7.38 + void (*set_breakpoint)(uint32_t, int);7.39 + gboolean (*clear_breakpoint)(uint32_t, int);7.40 + int (*get_breakpoint)(uint32_t);7.41 + size_t instr_size; /* Size of instruction */7.42 + char *regs; /* Pointer to start of registers */7.43 + size_t regs_size; /* Size of register structure in bytes */7.44 + const struct reg_desc_struct *regs_info; /* Description of all registers */7.45 + uint32_t *pc; /* Pointer to PC register */7.46 + uint32_t *icount; /* Pointer to instruction counter */7.47 } *cpu_desc_t;7.49 #ifdef __cplusplus
8.1 --- a/src/gui/callbacks.c Mon Dec 26 10:48:55 2005 +00008.2 +++ b/src/gui/callbacks.c Mon Dec 26 11:47:15 2005 +00008.3 @@ -1,5 +1,5 @@8.4 /**8.5 - * $Id: callbacks.c,v 1.10 2005-12-25 05:57:00 nkeynes Exp $8.6 + * $Id: callbacks.c,v 1.11 2005-12-26 11:47:15 nkeynes Exp $8.7 *8.8 * All GTK callbacks go here (stubs are autogenerated by Glade)8.9 *8.10 @@ -26,11 +26,12 @@8.11 #include "gui/interface.h"8.12 #include "gui/gui.h"8.13 #include "sh4core.h"8.14 -#include "asic.h"8.15 +#include "mem.h"8.16 #include "dreamcast.h"8.17 #include "loader.h"8.19 int selected_pc = -1;8.20 +int selected_row = -1;8.22 void8.23 on_new_file1_activate (GtkMenuItem *menuitem,8.24 @@ -148,7 +149,8 @@8.25 on_break_btn_clicked (GtkButton *button,8.26 gpointer user_data)8.27 {8.28 -8.29 + debug_info_t data = get_debug_info(GTK_WIDGET(button));8.30 + debug_win_toggle_breakpoint( data, selected_row, BREAK_KEEP );8.31 }8.34 @@ -171,6 +173,7 @@8.35 {8.36 debug_info_t data = get_debug_info(GTK_WIDGET(clist));8.37 selected_pc = row_to_address(data, row);8.38 + selected_row = row;8.39 }
9.1 --- a/src/gui/debug_win.c Mon Dec 26 10:48:55 2005 +00009.2 +++ b/src/gui/debug_win.c Mon Dec 26 11:47:15 2005 +00009.3 @@ -1,5 +1,5 @@9.4 /**9.5 - * $Id: debug_win.c,v 1.12 2005-12-26 03:54:55 nkeynes Exp $9.6 + * $Id: debug_win.c,v 1.13 2005-12-26 11:47:15 nkeynes Exp $9.7 * This file is responsible for the main debugger gui frame.9.8 *9.9 * Copyright (c) 2005 Nathan Keynes.9.10 @@ -18,7 +18,7 @@9.11 #include <stdarg.h>9.12 #include <gnome.h>9.13 #include <math.h>9.14 -#include "gui.h"9.15 +#include "gui/gui.h"9.16 #include "mem.h"9.17 #include "cpu.h"9.19 @@ -158,6 +158,17 @@9.20 posn = gtk_clist_append( data->disasm_list, arr );9.21 if( buf[0] == '?' )9.22 gtk_clist_set_foreground( data->disasm_list, posn, &clrWarn );9.23 + if( data->cpu->get_breakpoint != NULL ) {9.24 + int type = data->cpu->get_breakpoint( i );9.25 + switch(type) {9.26 + case BREAK_ONESHOT:9.27 + gtk_clist_set_background( data->disasm_list, posn, &clrTempBreak );9.28 + break;9.29 + case BREAK_KEEP:9.30 + gtk_clist_set_background( data->disasm_list, posn, &clrBreak );9.31 + break;9.32 + }9.33 + }9.34 }9.35 if( data->disasm_pc != -1 && data->disasm_pc >= from && data->disasm_pc < to )9.36 gtk_clist_set_foreground( data->disasm_list, address_to_row(data, data->disasm_pc),9.37 @@ -223,6 +234,30 @@9.38 }9.39 }9.41 +void debug_win_toggle_breakpoint( debug_info_t data, int row, int type )9.42 +{9.43 + uint32_t pc = row_to_address( data, row );9.44 + int oldType = data->cpu->get_breakpoint( pc );9.45 + if( oldType != BREAK_NONE ) {9.46 + data->cpu->clear_breakpoint( pc, oldType );9.47 + type = BREAK_NONE;9.48 + } else {9.49 + if( data->cpu->set_breakpoint != NULL )9.50 + data->cpu->set_breakpoint( pc, type );9.51 + }9.52 + switch(type) {9.53 + case BREAK_ONESHOT:9.54 + gtk_clist_set_background( data->disasm_list, row, &clrTempBreak );9.55 + break;9.56 + case BREAK_KEEP:9.57 + gtk_clist_set_background( data->disasm_list, row, &clrBreak );9.58 + break;9.59 + default:9.60 + gtk_clist_set_background( data->disasm_list, row, &clrWhite );9.61 + break;9.62 + }9.63 +}9.64 +9.65 /**9.66 * Execute a single instruction using the current CPU mode.9.67 */9.68 @@ -258,7 +293,6 @@9.69 va_start(ap, msg);9.70 p = g_strdup_vprintf( msg, ap );9.71 strftime( buf, sizeof(buf), "%H:%M:%S", localtime(&tm) );9.72 - // if( source == NULL )9.73 sprintf( addr, "%08X", *data->cpu->pc );9.74 arr[3] = p;9.75 posn = gtk_clist_append(data->msgs_list, arr);
10.1 --- a/src/gui/gui.c Mon Dec 26 10:48:55 2005 +000010.2 +++ b/src/gui/gui.c Mon Dec 26 11:47:15 2005 +000010.3 @@ -1,5 +1,5 @@10.4 /**10.5 - * $Id: gui.c,v 1.8 2005-12-25 05:57:00 nkeynes Exp $10.6 + * $Id: gui.c,v 1.9 2005-12-26 11:47:15 nkeynes Exp $10.7 *10.8 * Top-level GUI (GTK2) module.10.9 *10.10 @@ -30,6 +30,7 @@10.11 #define REGISTER_FONT "-*-fixed-medium-r-normal--12-*-*-*-*-*-iso8859-1"10.13 GdkColor clrNormal, clrChanged, clrError, clrWarn, clrPC, clrDebug, clrTrace;10.14 +GdkColor clrBreak, clrTempBreak, clrWhite;10.15 PangoFontDescription *fixed_list_font;10.17 debug_info_t main_debug;10.18 @@ -69,6 +70,11 @@10.19 clrTrace.green = 78*256;10.20 clrTrace.blue = 201*256;10.21 clrDebug = clrPC;10.22 + clrBreak.red = 65535;10.23 + clrBreak.green = clrBreak.blue = 192*256;10.24 + clrTempBreak.red = clrTempBreak.green = 128*256;10.25 + clrTempBreak.blue = 32*256;10.26 + clrWhite.red = clrWhite.green = clrWhite.blue = 65535;10.28 map = gdk_colormap_new(gdk_visual_get_best(), TRUE);10.29 gdk_colormap_alloc_color(map, &clrNormal, TRUE, TRUE);10.30 @@ -78,6 +84,9 @@10.31 gdk_colormap_alloc_color(map, &clrPC, TRUE, TRUE);10.32 gdk_colormap_alloc_color(map, &clrDebug, TRUE, TRUE);10.33 gdk_colormap_alloc_color(map, &clrTrace, TRUE, TRUE);10.34 + gdk_colormap_alloc_color(map, &clrBreak, TRUE, TRUE);10.35 + gdk_colormap_alloc_color(map, &clrTempBreak, TRUE, TRUE);10.36 + gdk_colormap_alloc_color(map, &clrWhite, TRUE, TRUE);10.37 fixed_list_font = pango_font_description_from_string("Courier 10");10.38 debug_win = create_debug_win ();10.39 main_debug = init_debug_win(debug_win, cpu_descs);
11.1 --- a/src/gui/gui.h Mon Dec 26 10:48:55 2005 +000011.2 +++ b/src/gui/gui.h Mon Dec 26 11:47:15 2005 +000011.3 @@ -1,5 +1,5 @@11.4 /**11.5 - * $Id: gui.h,v 1.12 2005-12-26 03:54:55 nkeynes Exp $11.6 + * $Id: gui.h,v 1.13 2005-12-26 11:47:15 nkeynes Exp $11.7 *11.8 * General GUI definitions11.9 *11.10 @@ -57,12 +57,13 @@11.11 void jump_to_pc( debug_info_t debug, gboolean select );11.12 void debug_win_set_running( debug_info_t debug, gboolean isRunning );11.13 void debug_win_single_step( debug_info_t debug );11.14 +void debug_win_toggle_breakpoint( debug_info_t debug, int row, int type );11.15 uint32_t row_to_address( debug_info_t debug, int row );11.16 int address_to_row( debug_info_t debug, uint32_t address );11.18 extern PangoFontDescription *fixed_list_font;11.19 extern GdkColor clrNormal, clrChanged, clrError, clrWarn,11.20 - clrPC, clrDebug, clrTrace;11.21 + clrPC, clrDebug, clrTrace, clrBreak, clrTempBreak, clrWhite;11.23 void mmr_open_win( void );11.24 void mmr_close_win( void );
12.1 --- a/src/mem.h Mon Dec 26 10:48:55 2005 +000012.2 +++ b/src/mem.h Mon Dec 26 11:47:15 2005 +000012.3 @@ -1,5 +1,5 @@12.4 /**12.5 - * $Id: mem.h,v 1.5 2005-12-25 08:24:07 nkeynes Exp $12.6 + * $Id: mem.h,v 1.6 2005-12-26 11:47:12 nkeynes Exp $12.7 *12.8 * mem is responsible for creating and maintaining the overall system memory12.9 * map, as visible from the SH4 processor. (Note the ARM has a different map)12.10 @@ -56,6 +56,18 @@12.11 void mem_init( void );12.12 void mem_reset( void );12.14 +#define ENABLE_DEBUG_MODE 112.15 +12.16 +struct breakpoint_struct {12.17 + uint32_t address;12.18 + int type;12.19 +};12.20 +12.21 +#define MAX_BREAKPOINTS 3212.22 +#define BREAK_NONE 012.23 +#define BREAK_ONESHOT 112.24 +#define BREAK_KEEP 212.25 +12.26 #define ENABLE_WATCH 112.28 #define WATCH_WRITE 1
13.1 --- a/src/sh4/sh4core.c Mon Dec 26 10:48:55 2005 +000013.2 +++ b/src/sh4/sh4core.c Mon Dec 26 11:47:15 2005 +000013.3 @@ -1,5 +1,5 @@13.4 /**13.5 - * $Id: sh4core.c,v 1.15 2005-12-26 10:47:10 nkeynes Exp $13.6 + * $Id: sh4core.c,v 1.16 2005-12-26 11:47:15 nkeynes Exp $13.7 *13.8 * SH4 emulation core, and parent module for all the SH4 peripheral13.9 * modules.13.10 @@ -90,6 +90,44 @@13.11 SCIF_reset();13.12 }13.14 +static struct breakpoint_struct sh4_breakpoints[MAX_BREAKPOINTS];13.15 +static int sh4_breakpoint_count = 0;13.16 +13.17 +void sh4_set_breakpoint( uint32_t pc, int type )13.18 +{13.19 + sh4_breakpoints[sh4_breakpoint_count].address = pc;13.20 + sh4_breakpoints[sh4_breakpoint_count].type = type;13.21 + sh4_breakpoint_count++;13.22 +}13.23 +13.24 +gboolean sh4_clear_breakpoint( uint32_t pc, int type )13.25 +{13.26 + int i;13.27 +13.28 + for( i=0; i<sh4_breakpoint_count; i++ ) {13.29 + if( sh4_breakpoints[i].address == pc &&13.30 + sh4_breakpoints[i].type == type ) {13.31 + while( ++i < sh4_breakpoint_count ) {13.32 + sh4_breakpoints[i-1].address = sh4_breakpoints[i].address;13.33 + sh4_breakpoints[i-1].type = sh4_breakpoints[i].type;13.34 + }13.35 + sh4_breakpoint_count--;13.36 + return TRUE;13.37 + }13.38 + }13.39 + return FALSE;13.40 +}13.41 +13.42 +int sh4_get_breakpoint( uint32_t pc )13.43 +{13.44 + int i;13.45 + for( i=0; i<sh4_breakpoint_count; i++ ) {13.46 + if( sh4_breakpoints[i].address == pc )13.47 + return sh4_breakpoints[i].type;13.48 + }13.49 + return 0;13.50 +}13.51 +13.52 uint32_t sh4_run_slice( uint32_t nanosecs )13.53 {13.54 int target = sh4r.icount + nanosecs / sh4_cpu_period;13.55 @@ -105,6 +143,19 @@13.56 sh4r.icount++;13.57 if( !sh4_execute_instruction() )13.58 break;13.59 +#ifdef ENABLE_DEBUG_MODE13.60 + for( i=0; i<sh4_breakpoint_count; i++ ) {13.61 + if( sh4_breakpoints[i].address == sh4r.pc ) {13.62 + break;13.63 + }13.64 + }13.65 + if( i != sh4_breakpoint_count ) {13.66 + dreamcast_stop();13.67 + if( sh4_breakpoints[i].type == BREAK_ONESHOT )13.68 + sh4_clear_breakpoint( sh4r.pc, BREAK_ONESHOT );13.69 + break;13.70 + }13.71 +#endif13.72 }13.74 /* If we aborted early, but the cpu is still technically running,13.75 @@ -147,11 +198,6 @@13.76 sh4r.new_pc = pc+2;13.77 }13.79 -void sh4_set_breakpoint( uint32_t pc, int type )13.80 -{13.81 -13.82 -}13.83 -13.84 #define UNDEF(ir) do{ ERROR( "Raising exception on undefined instruction at %08x, opcode = %04x", sh4r.pc, ir ); RAISE( EXC_ILLEGAL, EXV_ILLEGAL ); }while(0)13.85 #define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", sh4r.pc, ir ); dreamcast_stop(); return FALSE; }while(0)
14.1 --- a/src/sh4/sh4core.h Mon Dec 26 10:48:55 2005 +000014.2 +++ b/src/sh4/sh4core.h Mon Dec 26 11:47:15 2005 +000014.3 @@ -1,5 +1,5 @@14.4 /**14.5 - * $Id: sh4core.h,v 1.7 2005-12-26 03:10:23 nkeynes Exp $14.6 + * $Id: sh4core.h,v 1.8 2005-12-26 11:47:15 nkeynes Exp $14.7 *14.8 * This file defines the public functions exported by the SH4 core, except14.9 * for disassembly functions defined in sh4dasm.h14.10 @@ -88,6 +88,8 @@14.11 gboolean sh4_execute_instruction( void );14.12 void sh4_raise_exception( int, int );14.13 void sh4_set_breakpoint( uint32_t pc, int type );14.14 +gboolean sh4_clear_breakpoint( uint32_t pc, int type );14.15 +int sh4_get_breakpoint( uint32_t pc );14.17 #define BREAK_ONESHOT 114.18 #define BREAK_PERM 2
15.1 --- a/src/sh4/sh4dasm.c Mon Dec 26 10:48:55 2005 +000015.2 +++ b/src/sh4/sh4dasm.c Mon Dec 26 11:47:15 2005 +000015.3 @@ -1,5 +1,5 @@15.4 /**15.5 - * $Id: sh4dasm.c,v 1.7 2005-12-25 05:57:00 nkeynes Exp $15.6 + * $Id: sh4dasm.c,v 1.8 2005-12-26 11:47:15 nkeynes Exp $15.7 *15.8 * SH4 CPU definition and disassembly functions15.9 *15.10 @@ -43,7 +43,8 @@15.13 const struct cpu_desc_struct sh4_cpu_desc =15.14 - { "SH4", sh4_disasm_instruction, sh4_execute_instruction, mem_has_page, 2,15.15 + { "SH4", sh4_disasm_instruction, sh4_execute_instruction, mem_has_page,15.16 + sh4_set_breakpoint, sh4_clear_breakpoint, sh4_get_breakpoint, 2,15.17 (char *)&sh4r, sizeof(sh4r), sh4_reg_map,15.18 &sh4r.pc, &sh4r.icount };
.