Search
lxdream.org :: lxdream/src/gui/debug_win.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/debug_win.c
changeset 435:7a5d71e8560b
prev429:e581b90c3fb3
next437:2c259474b474
author nkeynes
date Wed Oct 10 11:02:04 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change First cut of new GUI
file annotate diff log raw
1.1 --- a/src/gui/debug_win.c Mon Oct 08 11:52:13 2007 +0000
1.2 +++ b/src/gui/debug_win.c Wed Oct 10 11:02:04 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: debug_win.c,v 1.22 2007-10-08 11:48:56 nkeynes Exp $
1.6 + * $Id: debug_win.c,v 1.23 2007-10-10 11:02:04 nkeynes Exp $
1.7 * This file is responsible for the main debugger gui frame.
1.8 *
1.9 * Copyright (c) 2005 Nathan Keynes.
1.10 @@ -19,21 +19,27 @@
1.11 #include <stdio.h>
1.12 #include <gnome.h>
1.13 #include <math.h>
1.14 -#include "sh4/sh4dasm.h"
1.15 -#include "gui/gui.h"
1.16 #include "mem.h"
1.17 #include "cpu.h"
1.18 -#include "display.h"
1.19 -#include "pvr2/pvr2.h"
1.20 +#include "debugif.h"
1.21 +#include "gui/gtkui.h"
1.22 +#include "sh4/sh4dasm.h"
1.23 +#include "aica/armdasm.h"
1.24
1.25 -GdkColor *msg_colors[] = { &clrError, &clrError, &clrWarn, &clrNormal,
1.26 - &clrDebug, &clrTrace };
1.27 +GdkColor *msg_colors[] = { &gui_colour_error, &gui_colour_error, &gui_colour_warn,
1.28 + &gui_colour_normal,&gui_colour_debug, &gui_colour_trace };
1.29 char *msg_levels[] = { "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" };
1.30 int global_msg_level = EMIT_WARN;
1.31
1.32 -void init_register_list( debug_info_t data );
1.33 +const cpu_desc_t cpu_list[4] = { &sh4_cpu_desc, &arm_cpu_desc, &armt_cpu_desc, NULL };
1.34
1.35 -struct debug_info_struct {
1.36 +void init_register_list( debug_window_t data );
1.37 +uint32_t row_to_address( debug_window_t data, int row );
1.38 +void set_disassembly_pc( debug_window_t data, unsigned int pc, gboolean select );
1.39 +void set_disassembly_region( debug_window_t data, unsigned int page );
1.40 +void set_disassembly_cpu( debug_window_t data, const gchar *cpu );
1.41 +
1.42 +struct debug_window_info {
1.43 int disasm_from;
1.44 int disasm_to;
1.45 int disasm_pc;
1.46 @@ -49,11 +55,12 @@
1.47 char saved_regs[0];
1.48 };
1.49
1.50 -debug_info_t init_debug_win(GtkWidget *win, const cpu_desc_t *cpu_list )
1.51 +debug_window_t debug_window_new( )
1.52 {
1.53 + GtkWidget *win = create_debug_win();
1.54 GnomeAppBar *appbar;
1.55
1.56 - debug_info_t data = g_malloc0( sizeof(struct debug_info_struct) + cpu_list[0]->regs_size );
1.57 + debug_window_t data = g_malloc0( sizeof(struct debug_window_info) + cpu_list[0]->regs_size );
1.58 data->disasm_from = -1;
1.59 data->disasm_to = -1;
1.60 data->disasm_pc = -1;
1.61 @@ -62,7 +69,7 @@
1.62
1.63 data->regs_list= gtk_object_get_data(GTK_OBJECT(win), "reg_list");
1.64 data->win = win;
1.65 - gtk_widget_modify_font( GTK_WIDGET(data->regs_list), fixed_list_font );
1.66 + gtk_widget_modify_font( GTK_WIDGET(data->regs_list), gui_fixed_font );
1.67 init_register_list( data );
1.68 data->msgs_list = gtk_object_get_data(GTK_OBJECT(win), "output_list");
1.69 data->disasm_list = gtk_object_get_data(GTK_OBJECT(win), "disasm_list");
1.70 @@ -75,11 +82,22 @@
1.71
1.72 gtk_object_set_data( GTK_OBJECT(win), "debug_data", data );
1.73 set_disassembly_pc( data, *data->cpu->pc, FALSE );
1.74 - debug_win_set_running( data, FALSE );
1.75 + debug_window_set_running( data, FALSE );
1.76 +
1.77 + gtk_widget_show( win );
1.78 return data;
1.79 }
1.80
1.81 -void init_register_list( debug_info_t data )
1.82 +void debug_window_show( debug_window_t data, gboolean show )
1.83 +{
1.84 + if( show ) {
1.85 + gtk_widget_show( data->win );
1.86 + } else {
1.87 + gtk_widget_hide( data->win );
1.88 + }
1.89 +}
1.90 +
1.91 +void init_register_list( debug_window_t data )
1.92 {
1.93 int i;
1.94 char buf[20];
1.95 @@ -100,7 +118,7 @@
1.96 /*
1.97 * Check for changed registers and update the display
1.98 */
1.99 -void update_registers( debug_info_t data )
1.100 +void debug_window_update( debug_window_t data )
1.101 {
1.102 int i;
1.103 for( i=0; data->cpu->regs_info[i].name != NULL; i++ ) {
1.104 @@ -111,9 +129,9 @@
1.105 char buf[20];
1.106 sprintf( buf, "%08X", *((uint32_t *)data->cpu->regs_info[i].value) );
1.107 gtk_clist_set_text( data->regs_list, i, 1, buf );
1.108 - gtk_clist_set_foreground( data->regs_list, i, &clrChanged );
1.109 + gtk_clist_set_foreground( data->regs_list, i, &gui_colour_changed );
1.110 } else {
1.111 - gtk_clist_set_foreground( data->regs_list, i, &clrNormal );
1.112 + gtk_clist_set_foreground( data->regs_list, i, &gui_colour_normal );
1.113 }
1.114 } else {
1.115 if( *((float *)data->cpu->regs_info[i].value) !=
1.116 @@ -121,9 +139,9 @@
1.117 char buf[20];
1.118 sprintf( buf, "%f", *((float *)data->cpu->regs_info[i].value) );
1.119 gtk_clist_set_text( data->regs_list, i, 1, buf );
1.120 - gtk_clist_set_foreground( data->regs_list, i, &clrChanged );
1.121 + gtk_clist_set_foreground( data->regs_list, i, &gui_colour_changed );
1.122 } else {
1.123 - gtk_clist_set_foreground( data->regs_list, i, &clrNormal );
1.124 + gtk_clist_set_foreground( data->regs_list, i, &gui_colour_normal );
1.125 }
1.126 }
1.127 }
1.128 @@ -132,16 +150,7 @@
1.129 memcpy( data->saved_regs, data->cpu->regs, data->cpu->regs_size );
1.130 }
1.131
1.132 -void update_icount( debug_info_t data )
1.133 -{
1.134 - if( data != NULL ) {
1.135 - // sprintf( data->icounter_text, "%d", *data->cpu->icount );
1.136 - sprintf( data->icounter_text, "%d", pvr2_get_frame_count() );
1.137 - gtk_progress_bar_set_text( data->icounter, data->icounter_text );
1.138 - }
1.139 -}
1.140 -
1.141 -void set_disassembly_region( debug_info_t data, unsigned int page )
1.142 +void set_disassembly_region( debug_window_t data, unsigned int page )
1.143 {
1.144 uint32_t i, posn, next;
1.145 char buf[80];
1.146 @@ -159,29 +168,29 @@
1.147 if( !data->cpu->is_valid_page_func( from ) ) {
1.148 arr[3] = "This page is currently unmapped";
1.149 gtk_clist_append( data->disasm_list, arr );
1.150 - gtk_clist_set_foreground( data->disasm_list, 0, &clrError );
1.151 + gtk_clist_set_foreground( data->disasm_list, 0, &gui_colour_error );
1.152 } else {
1.153 for( i=from; i<to; i = next ) {
1.154 next = data->cpu->disasm_func( i, buf, sizeof(buf), opcode );
1.155 sprintf( addr, "%08X", i );
1.156 posn = gtk_clist_append( data->disasm_list, arr );
1.157 if( buf[0] == '?' )
1.158 - gtk_clist_set_foreground( data->disasm_list, posn, &clrWarn );
1.159 + gtk_clist_set_foreground( data->disasm_list, posn, &gui_colour_warn );
1.160 if( data->cpu->get_breakpoint != NULL ) {
1.161 int type = data->cpu->get_breakpoint( i );
1.162 switch(type) {
1.163 case BREAK_ONESHOT:
1.164 - gtk_clist_set_background( data->disasm_list, posn, &clrTempBreak );
1.165 + gtk_clist_set_background( data->disasm_list, posn, &gui_colour_temp_break );
1.166 break;
1.167 case BREAK_KEEP:
1.168 - gtk_clist_set_background( data->disasm_list, posn, &clrBreak );
1.169 + gtk_clist_set_background( data->disasm_list, posn, &gui_colour_break );
1.170 break;
1.171 }
1.172 }
1.173 }
1.174 if( data->disasm_pc != -1 && data->disasm_pc >= from && data->disasm_pc < to )
1.175 gtk_clist_set_foreground( data->disasm_list, address_to_row(data, data->disasm_pc),
1.176 - &clrPC );
1.177 + &gui_colour_pc );
1.178 }
1.179
1.180 if( page != from ) { /* not a page boundary */
1.181 @@ -191,7 +200,7 @@
1.182 data->disasm_to = to;
1.183 }
1.184
1.185 -void jump_to_disassembly( debug_info_t data, unsigned int addr, gboolean select )
1.186 +void jump_to_disassembly( debug_window_t data, unsigned int addr, gboolean select )
1.187 {
1.188 int row;
1.189
1.190 @@ -207,12 +216,12 @@
1.191 }
1.192 }
1.193
1.194 -void jump_to_pc( debug_info_t data, gboolean select )
1.195 +void jump_to_pc( debug_window_t data, gboolean select )
1.196 {
1.197 jump_to_disassembly( data, *data->cpu->pc, select );
1.198 }
1.199
1.200 -void set_disassembly_pc( debug_info_t data, unsigned int pc, gboolean select )
1.201 +void set_disassembly_pc( debug_window_t data, unsigned int pc, gboolean select )
1.202 {
1.203 int row;
1.204
1.205 @@ -221,13 +230,13 @@
1.206 data->disasm_pc < data->disasm_to )
1.207 gtk_clist_set_foreground( data->disasm_list,
1.208 (data->disasm_pc - data->disasm_from) / data->cpu->instr_size,
1.209 - &clrNormal );
1.210 + &gui_colour_normal );
1.211 row = address_to_row( data, pc );
1.212 - gtk_clist_set_foreground( data->disasm_list, row, &clrPC );
1.213 + gtk_clist_set_foreground( data->disasm_list, row, &gui_colour_pc );
1.214 data->disasm_pc = pc;
1.215 }
1.216
1.217 -void set_disassembly_cpu( debug_info_t data, const gchar *cpu )
1.218 +void set_disassembly_cpu( debug_window_t data, const gchar *cpu )
1.219 {
1.220 int i;
1.221 for( i=0; data->cpu_list[i] != NULL; i++ ) {
1.222 @@ -237,48 +246,47 @@
1.223 data->disasm_from = data->disasm_to = -1; /* Force reload */
1.224 set_disassembly_pc( data, *data->cpu->pc, FALSE );
1.225 init_register_list( data );
1.226 - update_icount( data );
1.227 }
1.228 return;
1.229 }
1.230 }
1.231 }
1.232
1.233 -void debug_win_toggle_breakpoint( debug_info_t data, int row )
1.234 +void debug_win_toggle_breakpoint( debug_window_t data, int row )
1.235 {
1.236 uint32_t pc = row_to_address( data, row );
1.237 int oldType = data->cpu->get_breakpoint( pc );
1.238 if( oldType != BREAK_NONE ) {
1.239 data->cpu->clear_breakpoint( pc, oldType );
1.240 - gtk_clist_set_background( data->disasm_list, row, &clrWhite );
1.241 + gtk_clist_set_background( data->disasm_list, row, &gui_colour_white );
1.242 } else {
1.243 data->cpu->set_breakpoint( pc, BREAK_KEEP );
1.244 - gtk_clist_set_background( data->disasm_list, row, &clrBreak );
1.245 + gtk_clist_set_background( data->disasm_list, row, &gui_colour_break );
1.246 }
1.247 }
1.248
1.249 -void debug_win_set_oneshot_breakpoint( debug_info_t data, int row )
1.250 +void debug_win_set_oneshot_breakpoint( debug_window_t data, int row )
1.251 {
1.252 uint32_t pc = row_to_address( data, row );
1.253 data->cpu->clear_breakpoint( pc, BREAK_ONESHOT );
1.254 data->cpu->set_breakpoint( pc, BREAK_ONESHOT );
1.255 - gtk_clist_set_background( data->disasm_list, row, &clrTempBreak );
1.256 + gtk_clist_set_background( data->disasm_list, row, &gui_colour_temp_break );
1.257 }
1.258
1.259 /**
1.260 * Execute a single instruction using the current CPU mode.
1.261 */
1.262 -void debug_win_single_step( debug_info_t data )
1.263 +void debug_win_single_step( debug_window_t data )
1.264 {
1.265 data->cpu->step_func();
1.266 gtk_gui_update();
1.267 }
1.268
1.269 -uint32_t row_to_address( debug_info_t data, int row ) {
1.270 +uint32_t row_to_address( debug_window_t data, int row ) {
1.271 return data->cpu->instr_size * row + data->disasm_from;
1.272 }
1.273
1.274 -int address_to_row( debug_info_t data, uint32_t address ) {
1.275 +int address_to_row( debug_window_t data, uint32_t address ) {
1.276 if( data->disasm_from > address || data->disasm_to <= address )
1.277 return -1;
1.278 return (address - data->disasm_from) / data->cpu->instr_size;
1.279 @@ -292,11 +300,12 @@
1.280 int posn;
1.281 time_t tm = time(NULL);
1.282 va_list ap;
1.283 - debug_info_t data;
1.284 + debug_window_t data = NULL;
1.285 + /*
1.286 if( ptr == NULL )
1.287 - data = main_debug;
1.288 - else data = (debug_info_t)ptr;
1.289 -
1.290 + data = debug_win;
1.291 + else data = (debug_window_t)ptr;
1.292 + */
1.293 if( level > global_msg_level ) {
1.294 return; // ignored
1.295 }
1.296 @@ -329,21 +338,21 @@
1.297 gtk_main_iteration();
1.298 }
1.299
1.300 -debug_info_t get_debug_info( GtkWidget *widget ) {
1.301 +debug_window_t get_debug_info( GtkWidget *widget ) {
1.302
1.303 GtkWidget *win = gtk_widget_get_toplevel(widget);
1.304 - debug_info_t data = (debug_info_t)gtk_object_get_data( GTK_OBJECT(win), "debug_data" );
1.305 + debug_window_t data = (debug_window_t)gtk_object_get_data( GTK_OBJECT(win), "debug_data" );
1.306 return data;
1.307 }
1.308
1.309 -void debug_win_enable_widget( debug_info_t data, const char *name,
1.310 +void debug_win_enable_widget( debug_window_t data, const char *name,
1.311 gboolean enabled )
1.312 {
1.313 GtkWidget *widget = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(data->win), name));
1.314 gtk_widget_set_sensitive( widget, enabled );
1.315 }
1.316
1.317 -void debug_win_set_running( debug_info_t data, gboolean isRunning )
1.318 +void debug_window_set_running( debug_window_t data, gboolean isRunning )
1.319 {
1.320 if( data != NULL ) {
1.321 debug_win_enable_widget( data, "stop_btn", isRunning );
.