Search
lxdream.org :: lxdream :: r43:0cf3e339cc59
lxdream 0.9.1
released Jun 29
Download Now
changeset43:0cf3e339cc59
parent42:d06affd949ec
child44:8da2cbcffe24
authornkeynes
dateMon Dec 26 11:47:15 2005 +0000 (13 years ago)
Add sh4 + arm breakpoints
Hook up break button in GUI
Enable ARM slice in main loop
src/Makefile.am
src/Makefile.in
src/aica/aica.c
src/aica/armcore.c
src/aica/armcore.h
src/aica/armdasm.c
src/cpu.h
src/gui/callbacks.c
src/gui/debug_win.c
src/gui/gui.c
src/gui/gui.h
src/mem.h
src/sh4/sh4core.c
src/sh4/sh4core.h
src/sh4/sh4dasm.c
1.1 --- a/src/Makefile.am Mon Dec 26 10:48:55 2005 +0000
1.2 +++ b/src/Makefile.am Mon Dec 26 11:47:15 2005 +0000
1.3 @@ -10,14 +10,14 @@
1.4
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 +0000
2.2 +++ b/src/Makefile.in Mon Dec 26 11:47:15 2005 +0000
2.3 @@ -137,14 +137,14 @@
2.4
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.23
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.49
2.50 -watch.o: sh4/watch.c
2.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@ fi
2.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.c
2.60 -
2.61 -watch.obj: sh4/watch.c
2.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@ fi
2.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.c
2.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 +0000
3.2 +++ b/src/aica/aica.c Mon Dec 26 11:47:15 2005 +0000
3.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.20
3.21 void aica_stop( void )
3.22 @@ -90,15 +91,15 @@
3.23 }
3.24
3.25 /** Channel register structure:
3.26 - * 00
3.27 - * 04
3.28 + * 00 4 Channel config
3.29 + * 04 4 Waveform address lo (16 bits)
3.30 * 08 4 Loop start address
3.31 * 0C 4 Loop end address
3.32 * 10 4 Volume envelope
3.33 - * 14
3.34 - * 18 4 Frequency (floating point
3.35 - * 1C
3.36 - * 20
3.37 + * 14 4 Init to 0x1F
3.38 + * 18 4 Frequency (floating point)
3.39 + * 1C 4 ??
3.40 + * 20 4 ??
3.41 * 24 1 Pan
3.42 * 25 1 ??
3.43 * 26
4.1 --- a/src/aica/armcore.c Mon Dec 26 10:48:55 2005 +0000
4.2 +++ b/src/aica/armcore.c Mon Dec 26 11:47:15 2005 +0000
4.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_module
4.12 #include "dream.h"
4.13 #include "aica/armcore.h"
4.14 +#include "mem.h"
4.15
4.16 struct arm_registers armr;
4.17
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.21
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_MODE
4.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 +#endif
4.83 }
4.84
4.85 if( target != armr.icount ) {
5.1 --- a/src/aica/armcore.h Mon Dec 26 10:48:55 2005 +0000
5.2 +++ b/src/aica/armcore.h Mon Dec 26 11:47:15 2005 +0000
5.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.17
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 +0000
6.2 +++ b/src/aica/armdasm.c Mon Dec 26 11:47:15 2005 +0000
6.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) disassembler
6.9 *
6.10 @@ -61,7 +61,8 @@
6.11
6.12
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 +0000
7.2 +++ b/src/cpu.h Mon Dec 26 11:47:15 2005 +0000
7.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.13
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 0
7.18 #define REG_FLT 1
7.19 #define REG_SPECIAL 2
7.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.48
7.49 #ifdef __cplusplus
8.1 --- a/src/gui/callbacks.c Mon Dec 26 10:48:55 2005 +0000
8.2 +++ b/src/gui/callbacks.c Mon Dec 26 11:47:15 2005 +0000
8.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.18
8.19 int selected_pc = -1;
8.20 +int selected_row = -1;
8.21
8.22 void
8.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.32
8.33
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 }
8.40
8.41
9.1 --- a/src/gui/debug_win.c Mon Dec 26 10:48:55 2005 +0000
9.2 +++ b/src/gui/debug_win.c Mon Dec 26 11:47:15 2005 +0000
9.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.18
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.40
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 +0000
10.2 +++ b/src/gui/gui.c Mon Dec 26 11:47:15 2005 +0000
10.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.12
10.13 GdkColor clrNormal, clrChanged, clrError, clrWarn, clrPC, clrDebug, clrTrace;
10.14 +GdkColor clrBreak, clrTempBreak, clrWhite;
10.15 PangoFontDescription *fixed_list_font;
10.16
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.27
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 +0000
11.2 +++ b/src/gui/gui.h Mon Dec 26 11:47:15 2005 +0000
11.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 definitions
11.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.17
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.22
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 +0000
12.2 +++ b/src/mem.h Mon Dec 26 11:47:15 2005 +0000
12.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 memory
12.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.13
12.14 +#define ENABLE_DEBUG_MODE 1
12.15 +
12.16 +struct breakpoint_struct {
12.17 + uint32_t address;
12.18 + int type;
12.19 +};
12.20 +
12.21 +#define MAX_BREAKPOINTS 32
12.22 +#define BREAK_NONE 0
12.23 +#define BREAK_ONESHOT 1
12.24 +#define BREAK_KEEP 2
12.25 +
12.26 #define ENABLE_WATCH 1
12.27
12.28 #define WATCH_WRITE 1
13.1 --- a/src/sh4/sh4core.c Mon Dec 26 10:48:55 2005 +0000
13.2 +++ b/src/sh4/sh4core.c Mon Dec 26 11:47:15 2005 +0000
13.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 peripheral
13.9 * modules.
13.10 @@ -90,6 +90,44 @@
13.11 SCIF_reset();
13.12 }
13.13
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_MODE
13.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 +#endif
13.72 }
13.73
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.78
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)
13.86
14.1 --- a/src/sh4/sh4core.h Mon Dec 26 10:48:55 2005 +0000
14.2 +++ b/src/sh4/sh4core.h Mon Dec 26 11:47:15 2005 +0000
14.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, except
14.9 * for disassembly functions defined in sh4dasm.h
14.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.16
14.17 #define BREAK_ONESHOT 1
14.18 #define BREAK_PERM 2
15.1 --- a/src/sh4/sh4dasm.c Mon Dec 26 10:48:55 2005 +0000
15.2 +++ b/src/sh4/sh4dasm.c Mon Dec 26 11:47:15 2005 +0000
15.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 functions
15.9 *
15.10 @@ -43,7 +43,8 @@
15.11
15.12
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 };
15.19
.