Search
lxdream.org :: lxdream/src/gtkui/debug_win.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gtkui/debug_win.c
changeset 736:a02d1475ccfd
prev669:ab344e42bca9
next755:ab873907b00e
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (13 years ago)
permissions -rw-r--r--
last change Re-indent everything consistently
Fix include guards for consistency as well
file annotate diff log raw
1.1 --- a/src/gtkui/debug_win.c Mon May 12 10:00:13 2008 +0000
1.2 +++ b/src/gtkui/debug_win.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -29,7 +29,7 @@
1.4 #include "aica/armdasm.h"
1.5
1.6 GdkColor *msg_colors[] = { &gui_colour_error, &gui_colour_error, &gui_colour_warn,
1.7 - &gui_colour_normal,&gui_colour_debug, &gui_colour_trace };
1.8 + &gui_colour_normal,&gui_colour_debug, &gui_colour_trace };
1.9
1.10 const cpu_desc_t cpu_list[4] = { &sh4_cpu_desc, &arm_cpu_desc, &armt_cpu_desc, NULL };
1.11
1.12 @@ -45,9 +45,9 @@
1.13 gpointer user_data);
1.14 void on_jump_pc_btn_clicked( GtkButton *button, gpointer user_data);
1.15 void on_disasm_list_select_row (GtkCList *clist, gint row, gint column,
1.16 - GdkEvent *event, gpointer user_data);
1.17 + GdkEvent *event, gpointer user_data);
1.18 void on_disasm_list_unselect_row (GtkCList *clist, gint row, gint column,
1.19 - GdkEvent *event, gpointer user_data);
1.20 + GdkEvent *event, gpointer user_data);
1.21 gboolean on_debug_delete_event(GtkWidget *widget, GdkEvent event, gpointer user_data);
1.22
1.23 struct debug_window_info {
1.24 @@ -65,10 +65,10 @@
1.25 };
1.26
1.27 debug_window_t debug_window_new( const gchar *title, GtkWidget *menubar,
1.28 - GtkWidget *toolbar, GtkAccelGroup *accel_group )
1.29 + GtkWidget *toolbar, GtkAccelGroup *accel_group )
1.30 {
1.31 debug_window_t data = g_malloc0( sizeof(struct debug_window_info) + cpu_list[0]->regs_size );
1.32 - GtkWidget *vbox;
1.33 + GtkWidget *vbox;
1.34
1.35 data->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1.36 gtk_window_set_default_size (GTK_WINDOW (data->window), 700, 480);
1.37 @@ -88,15 +88,15 @@
1.38 GtkWidget *hbox1 = gtk_hbox_new (FALSE, 0);
1.39 gtk_box_pack_start (GTK_BOX (disasm_box), hbox1, FALSE, FALSE, 3);
1.40 gtk_box_pack_start (GTK_BOX (hbox1), gtk_label_new (_("Page")), FALSE, FALSE, 4);
1.41 -
1.42 +
1.43 data->page_field = GTK_ENTRY(gtk_entry_new ());
1.44 gtk_box_pack_start (GTK_BOX (hbox1), GTK_WIDGET(data->page_field), FALSE, TRUE, 0);
1.45 -
1.46 +
1.47 GtkWidget *jump_pc_btn = gtk_button_new_with_mnemonic (_(" Jump to PC "));
1.48 gtk_box_pack_start (GTK_BOX (hbox1), jump_pc_btn, FALSE, FALSE, 4);
1.49 -
1.50 +
1.51 gtk_box_pack_start (GTK_BOX (hbox1), gtk_label_new(_("Mode")), FALSE, FALSE, 5);
1.52 -
1.53 +
1.54 GtkWidget *mode_box = gtk_combo_new ();
1.55 gtk_box_pack_start (GTK_BOX (hbox1), mode_box, FALSE, FALSE, 0);
1.56 GList *mode_box_items = NULL;
1.57 @@ -119,19 +119,19 @@
1.58 gtk_clist_set_column_width( data->disasm_list, 1, 16 );
1.59 gtk_clist_column_titles_hide (GTK_CLIST (data->disasm_list));
1.60 gtk_container_add (GTK_CONTAINER (disasm_scroll), GTK_WIDGET(data->disasm_list));
1.61 -
1.62 +
1.63 GtkWidget *reg_scroll = gtk_scrolled_window_new (NULL, NULL);
1.64 gtk_paned_pack2 (GTK_PANED (hpaned), reg_scroll, FALSE, TRUE);
1.65 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (reg_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1.66 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (reg_scroll), GTK_SHADOW_IN);
1.67 -
1.68 +
1.69 data->regs_list = GTK_CLIST(gtk_clist_new (2));
1.70 gtk_container_add (GTK_CONTAINER (reg_scroll), GTK_WIDGET(data->regs_list));
1.71 gtk_clist_set_column_width (GTK_CLIST (data->regs_list), 0, 80);
1.72 gtk_clist_set_column_width (GTK_CLIST (data->regs_list), 1, 80);
1.73 gtk_clist_column_titles_hide (GTK_CLIST (data->regs_list));
1.74 gtk_widget_modify_font( GTK_WIDGET(data->regs_list), gui_fixed_font );
1.75 -
1.76 +
1.77 vbox = gtk_vbox_new(FALSE, 0);
1.78 gtk_container_add( GTK_CONTAINER(data->window), vbox );
1.79 gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, FALSE, 0 );
1.80 @@ -140,30 +140,30 @@
1.81 gtk_box_pack_start( GTK_BOX(vbox), data->statusbar, FALSE, FALSE, 0 );
1.82
1.83 g_signal_connect ((gpointer) data->page_field, "key_press_event",
1.84 - G_CALLBACK (on_page_field_key_press_event),
1.85 - data);
1.86 + G_CALLBACK (on_page_field_key_press_event),
1.87 + data);
1.88 g_signal_connect ((gpointer) jump_pc_btn, "clicked",
1.89 - G_CALLBACK (on_jump_pc_btn_clicked),
1.90 - data);
1.91 + G_CALLBACK (on_jump_pc_btn_clicked),
1.92 + data);
1.93 g_signal_connect ((gpointer) mode_field, "changed",
1.94 - G_CALLBACK (on_mode_field_changed),
1.95 - data);
1.96 + G_CALLBACK (on_mode_field_changed),
1.97 + data);
1.98 g_signal_connect ((gpointer) data->disasm_list, "select_row",
1.99 - G_CALLBACK (on_disasm_list_select_row),
1.100 - data);
1.101 + G_CALLBACK (on_disasm_list_select_row),
1.102 + data);
1.103 g_signal_connect ((gpointer) data->disasm_list, "unselect_row",
1.104 - G_CALLBACK (on_disasm_list_unselect_row),
1.105 - data);
1.106 + G_CALLBACK (on_disasm_list_unselect_row),
1.107 + data);
1.108 g_signal_connect ((gpointer) data->window, "delete_event",
1.109 - G_CALLBACK (on_debug_delete_event),
1.110 - data);
1.111 -
1.112 + G_CALLBACK (on_debug_delete_event),
1.113 + data);
1.114 +
1.115 data->disasm_from = -1;
1.116 data->disasm_to = -1;
1.117 data->disasm_pc = -1;
1.118 data->cpu = cpu_list[0];
1.119 data->cpu_list = cpu_list;
1.120 -
1.121 +
1.122 init_register_list( data );
1.123 gtk_object_set_data( GTK_OBJECT(data->window), "debug_data", data );
1.124 set_disassembly_pc( data, *data->cpu->pc, FALSE );
1.125 @@ -176,18 +176,18 @@
1.126 void debug_window_show( debug_window_t data, gboolean show )
1.127 {
1.128 if( show ) {
1.129 - gtk_widget_show( data->window );
1.130 + gtk_widget_show( data->window );
1.131 } else {
1.132 - gtk_widget_hide( data->window );
1.133 + gtk_widget_hide( data->window );
1.134 }
1.135 }
1.136
1.137 int debug_window_get_selected_row( debug_window_t data )
1.138 {
1.139 if( data->disasm_list->selection == NULL ) {
1.140 - return -1;
1.141 + return -1;
1.142 } else {
1.143 - return GPOINTER_TO_INT(data->disasm_list->selection->data);
1.144 + return GPOINTER_TO_INT(data->disasm_list->selection->data);
1.145 }
1.146 }
1.147
1.148 @@ -253,7 +253,7 @@
1.149 char *arr[4] = { addr, " ", opcode, buf };
1.150 unsigned int from = page & 0xFFFFF000;
1.151 unsigned int to = from + 4096;
1.152 -
1.153 +
1.154 gtk_clist_clear(data->disasm_list);
1.155
1.156 sprintf( addr, "%08X", from );
1.157 @@ -265,26 +265,26 @@
1.158 gtk_clist_set_foreground( data->disasm_list, 0, &gui_colour_error );
1.159 } else {
1.160 for( i=from; i<to; i = next ) {
1.161 - next = data->cpu->disasm_func( i, buf, sizeof(buf), opcode );
1.162 + next = data->cpu->disasm_func( i, buf, sizeof(buf), opcode );
1.163 sprintf( addr, "%08X", i );
1.164 posn = gtk_clist_append( data->disasm_list, arr );
1.165 if( buf[0] == '?' )
1.166 gtk_clist_set_foreground( data->disasm_list, posn, &gui_colour_warn );
1.167 - if( data->cpu->get_breakpoint != NULL ) {
1.168 - int type = data->cpu->get_breakpoint( i );
1.169 - switch(type) {
1.170 - case BREAK_ONESHOT:
1.171 - gtk_clist_set_background( data->disasm_list, posn, &gui_colour_temp_break );
1.172 - break;
1.173 - case BREAK_KEEP:
1.174 - gtk_clist_set_background( data->disasm_list, posn, &gui_colour_break );
1.175 - break;
1.176 - }
1.177 - }
1.178 + if( data->cpu->get_breakpoint != NULL ) {
1.179 + int type = data->cpu->get_breakpoint( i );
1.180 + switch(type) {
1.181 + case BREAK_ONESHOT:
1.182 + gtk_clist_set_background( data->disasm_list, posn, &gui_colour_temp_break );
1.183 + break;
1.184 + case BREAK_KEEP:
1.185 + gtk_clist_set_background( data->disasm_list, posn, &gui_colour_break );
1.186 + break;
1.187 + }
1.188 + }
1.189 }
1.190 if( data->disasm_pc != -1 && data->disasm_pc >= from && data->disasm_pc < to )
1.191 gtk_clist_set_foreground( data->disasm_list, address_to_row(data, data->disasm_pc),
1.192 - &gui_colour_pc );
1.193 + &gui_colour_pc );
1.194 }
1.195
1.196 if( page != from ) { /* not a page boundary */
1.197 @@ -297,7 +297,7 @@
1.198 void jump_to_disassembly( debug_window_t data, unsigned int addr, gboolean select )
1.199 {
1.200 int row;
1.201 -
1.202 +
1.203 if( addr < data->disasm_from || addr >= data->disasm_to )
1.204 set_disassembly_region(data,addr);
1.205
1.206 @@ -318,13 +318,13 @@
1.207 void set_disassembly_pc( debug_window_t data, unsigned int pc, gboolean select )
1.208 {
1.209 int row;
1.210 -
1.211 +
1.212 jump_to_disassembly( data, pc, select );
1.213 if( data->disasm_pc != -1 && data->disasm_pc >= data->disasm_from &&
1.214 - data->disasm_pc < data->disasm_to )
1.215 + data->disasm_pc < data->disasm_to )
1.216 gtk_clist_set_foreground( data->disasm_list,
1.217 - (data->disasm_pc - data->disasm_from) / data->cpu->instr_size,
1.218 - &gui_colour_normal );
1.219 + (data->disasm_pc - data->disasm_from) / data->cpu->instr_size,
1.220 + &gui_colour_normal );
1.221 row = address_to_row( data, pc );
1.222 gtk_clist_set_foreground( data->disasm_list, row, &gui_colour_pc );
1.223 data->disasm_pc = pc;
1.224 @@ -334,15 +334,15 @@
1.225 {
1.226 int i;
1.227 for( i=0; data->cpu_list[i] != NULL; i++ ) {
1.228 - if( strcmp( data->cpu_list[i]->name, cpu ) == 0 ) {
1.229 - if( data->cpu != data->cpu_list[i] ) {
1.230 - data->cpu = data->cpu_list[i];
1.231 - data->disasm_from = data->disasm_to = -1; /* Force reload */
1.232 - set_disassembly_pc( data, *data->cpu->pc, FALSE );
1.233 - init_register_list( data );
1.234 - }
1.235 - return;
1.236 - }
1.237 + if( strcmp( data->cpu_list[i]->name, cpu ) == 0 ) {
1.238 + if( data->cpu != data->cpu_list[i] ) {
1.239 + data->cpu = data->cpu_list[i];
1.240 + data->disasm_from = data->disasm_to = -1; /* Force reload */
1.241 + set_disassembly_pc( data, *data->cpu->pc, FALSE );
1.242 + init_register_list( data );
1.243 + }
1.244 + return;
1.245 + }
1.246 }
1.247 }
1.248
1.249 @@ -351,11 +351,11 @@
1.250 uint32_t pc = row_to_address( data, row );
1.251 int oldType = data->cpu->get_breakpoint( pc );
1.252 if( oldType != BREAK_NONE ) {
1.253 - data->cpu->clear_breakpoint( pc, oldType );
1.254 - gtk_clist_set_background( data->disasm_list, row, &gui_colour_white );
1.255 + data->cpu->clear_breakpoint( pc, oldType );
1.256 + gtk_clist_set_background( data->disasm_list, row, &gui_colour_white );
1.257 } else {
1.258 - data->cpu->set_breakpoint( pc, BREAK_KEEP );
1.259 - gtk_clist_set_background( data->disasm_list, row, &gui_colour_break );
1.260 + data->cpu->set_breakpoint( pc, BREAK_KEEP );
1.261 + gtk_clist_set_background( data->disasm_list, row, &gui_colour_break );
1.262 }
1.263 }
1.264
1.265 @@ -382,12 +382,12 @@
1.266
1.267 int address_to_row( debug_window_t data, uint32_t address ) {
1.268 if( data->disasm_from > address || data->disasm_to <= address )
1.269 - return -1;
1.270 + return -1;
1.271 return (address - data->disasm_from) / data->cpu->instr_size;
1.272 }
1.273
1.274 debug_window_t get_debug_info( GtkWidget *widget ) {
1.275 -
1.276 +
1.277 GtkWidget *win = gtk_widget_get_toplevel(widget);
1.278 debug_window_t data = (debug_window_t)gtk_object_get_data( GTK_OBJECT(win), "debug_data" );
1.279 return data;
1.280 @@ -396,8 +396,8 @@
1.281 void debug_window_set_running( debug_window_t data, gboolean isRunning )
1.282 {
1.283 if( data != NULL ) {
1.284 - gtk_gui_enable_action( "SingleStep", !isRunning );
1.285 - gtk_gui_enable_action( "RunTo", !isRunning && dreamcast_can_run() );
1.286 + gtk_gui_enable_action( "SingleStep", !isRunning );
1.287 + gtk_gui_enable_action( "RunTo", !isRunning && dreamcast_can_run() );
1.288 }
1.289 }
1.290
1.291 @@ -412,7 +412,7 @@
1.292 gpointer user_data)
1.293 {
1.294 if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
1.295 - debug_window_t data = get_debug_info(widget);
1.296 + debug_window_t data = get_debug_info(widget);
1.297 const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
1.298 gchar *endptr;
1.299 unsigned int val = strtoul( text, &endptr, 16 );
1.300 @@ -435,14 +435,14 @@
1.301 }
1.302
1.303 void on_disasm_list_select_row (GtkCList *clist, gint row, gint column,
1.304 - GdkEvent *event, gpointer user_data)
1.305 + GdkEvent *event, gpointer user_data)
1.306 {
1.307 gtk_gui_enable_action( "SetBreakpoint", TRUE );
1.308 gtk_gui_enable_action( "RunTo", dreamcast_can_run() );
1.309 }
1.310
1.311 void on_disasm_list_unselect_row (GtkCList *clist, gint row, gint column,
1.312 - GdkEvent *event, gpointer user_data)
1.313 + GdkEvent *event, gpointer user_data)
1.314 {
1.315 gtk_gui_enable_action( "SetBreakpoint", FALSE );
1.316 gtk_gui_enable_action( "RunTo", FALSE );
.