static void ctree_refresh(GtkTreeStore *store) { GtkTreeModel *model = GTK_TREE_MODEL(store); int i; gchar *spath; GtkTreePath *path; GtkTreeIter iter; uint32_t data; gchar *sdata; int changed; GdkColor red, blue; gboolean success; GdkColor *color; gdk_color_parse("Blue", &blue); gdk_colormap_alloc_colors(gdk_colormap_get_system(), &blue, 1, FALSE, FALSE, &success); gdk_color_parse("Red", &red); gdk_colormap_alloc_colors(gdk_colormap_get_system(), &red, 1, FALSE, FALSE, &success); // refresh Ax nodes for(i = 0; i < 8; i++) { spath = g_strdup_printf("1:%i", i); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) continue; changed = ti68k_register_get_addr(i, &data); sdata = g_strdup_printf("%08x", data); color = changed ? &red : &blue; gtk_tree_store_set(store, &iter, COL_VALUE, sdata, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(sdata); g_free(spath); gtk_tree_path_free(path); } // refresh Dx nodes for(i = 0; i < 8; i++) { spath = g_strdup_printf("0:%i", i); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) continue; changed = ti68k_register_get_data(i, &data); sdata = g_strdup_printf("%08x", data); color = changed ? &red : &blue; gtk_tree_store_set(store, &iter, COL_VALUE, sdata, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(sdata); g_free(spath); gtk_tree_path_free(path); } // refresh Others node (PC) { spath = g_strdup_printf("2:%i", 0); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) return; changed = ti68k_register_get_pc(&data); sdata = g_strdup_printf("%06x", data); color = changed ? &red : &blue; gtk_tree_store_set(store, &iter, COL_VALUE, sdata, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(sdata); g_free(spath); gtk_tree_path_free(path); } // refresh Others node (USP) { spath = g_strdup_printf("2:%i", 1); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) return; changed = ti68k_register_get_usp(&data); sdata = g_strdup_printf("%06x", data); color = changed ? &red : &blue; gtk_tree_store_set(store, &iter, COL_VALUE, sdata, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(sdata); g_free(spath); gtk_tree_path_free(path); } // refresh Others node (SSP) { spath = g_strdup_printf("2:%i", 2); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) return; changed = ti68k_register_get_ssp(&data); sdata = g_strdup_printf("%06x", data); color = changed ? &red : &blue; gtk_tree_store_set(store, &iter, COL_VALUE, sdata, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(sdata); g_free(spath); gtk_tree_path_free(path); } // refresh Others node (SR) { spath = g_strdup_printf("2:%i", 3); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) return; changed = ti68k_register_get_sr(&data); sdata = g_strdup_printf("%04x", data); color = changed ? &red : &blue; gtk_tree_store_set(store, &iter, COL_VALUE, sdata, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(sdata); g_free(spath); gtk_tree_path_free(path); } // refresh Others node (S & U flags) { char s_flags[32], u_flags[32]; changed = ti68k_register_get_flags(s_flags, u_flags); color = changed ? &red : &blue; spath = g_strdup_printf("2:%i", 4); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) return; gtk_tree_store_set(store, &iter, COL_VALUE, s_flags, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(spath); gtk_tree_path_free(path); spath = g_strdup_printf("2:%i", 5); path = gtk_tree_path_new_from_string(spath); if(!gtk_tree_model_get_iter(model, &iter, path)) return; gtk_tree_store_set(store, &iter, COL_VALUE, u_flags, -1); gtk_tree_store_set(store, &iter, COL_COLOR, color, -1); g_free(spath); gtk_tree_path_free(path); } }
gint display_dbgcause_dbox2(GtkWidget *sb) { gint type, id, mode; guint sb_id; gchar *str = NULL; // get context ti68k_bkpt_get_cause(&type, &mode, &id); if(!type && !mode && !id) return 0; // user break if(!type && !mode) { uint32_t value; ti68k_register_get_pc(&value); str = g_strdup_printf("User break (pc=$0x%06x)", value); } // exception or code/mem ? else if(type == BK_TYPE_EXCEPTION) { // exception uint32_t sp; uint32_t pc; uint32_t sr; ti68k_register_get_sp(&sp); sr = mem_rd_long(sp); ti68k_register_get_sp(&sp); pc = mem_rd_long(sp+2); str = g_strdup_printf("type=<%s>, id=#%i, SR=%04x, PC=%06x\n", ti68k_exception_to_string(mode), id, str, pc); } else if(type == BK_TYPE_CODE) { // code uint32_t value; ti68k_register_get_pc(&value); str = g_strdup_printf("type=<%s>, id=#%i, PC=$0x%06x", ti68k_bkpt_type_to_string(type), id, value); } else if((type == BK_TYPE_ACCESS) || (type ==BK_TYPE_RANGE)) { // mem access or range uint32_t value, min, max; gchar *str1, *str2; ti68k_register_get_pc(&value); str1 = g_strdup_printf("type=<%s>, id=#%i, mode=<%s>, PC=$0x%06x", ti68k_bkpt_type_to_string(type), id, ti68k_bkpt_mode_to_string(type, mode), value); switch(type) { case BK_TYPE_ACCESS: ti68k_bkpt_get_access(id, &min, mode); str2 = g_strdup_printf("mem=$0x%06x", min); break; case BK_TYPE_RANGE: ti68k_bkpt_get_range(id, &min, &max, mode); str2 = g_strdup_printf("mem=$0x%06x-$0x%06x", min, max); break; default: str2 = g_strdup("n/a"); break; } str = g_strconcat(str1, ", ", str2, NULL); g_free(str1); g_free(str2); } else if(type == BK_TYPE_PROTECT) { uint32_t value; ti68k_register_get_pc(&value); switch(bkpts.id) { case 1: str = g_strdup_printf("hw protection violation: FLASH execution at $%06x.\nExecution allowed until $%06x.", value, 0x390000+tihw.archive_limit*0x10000); break; case 2: str = g_strdup_printf("hw protection violation: RAM execution at $%06x.\n", value); break; case 3: str = g_strdup_printf("hw protection violation: FLASH execution at $%06x.\nExecution allowed until $%06x.", value, tihw.rom_base + 0x10000 + tihw.io2[0x13]*0x10000); break; default: str = g_strdup("bug !\n"); break; } } else if(type == BK_TYPE_PGMENTRY) { uint16_t handle; uint32_t pc; ti68k_register_get_pc(&pc); ti68k_bkpt_get_pgmentry(id, &handle); str = g_strdup_printf("type=<%s>, id=#%i, handle=$%04x, PC=$0x%06x", ti68k_bkpt_type_to_string(type), id, handle, pc); } else { str = g_strdup("bug !\n"); } sb_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(sb), str); gtk_statusbar_push(GTK_STATUSBAR(sb), sb_id, str); g_free(str); return 0; }
gint dbgcause1_display_dbox() { GladeXML *xml; GtkWidget *dbox; GtkWidget *label; gint result; gchar *str; gint type, id, mode; uint32_t value, min, max; // get context ti68k_bkpt_get_cause(&type, &mode, &id); if(!type && !mode) return 0; // load GUI xml = glade_xml_new (tilp_paths_build_glade("dbg_cause-2.glade"), "dbgcause1_dbox", PACKAGE); if (!xml) g_error(_("%s: GUI loading failed !\n"), __FILE__); glade_xml_signal_autoconnect(xml); dbox = glade_xml_get_widget(xml, "dbgcause1_dbox"); // set PC label = glade_xml_get_widget(xml, "label21"); ti68k_register_get_pc(&value); str = g_strdup_printf("0x%06x", value); gtk_label_set_text(GTK_LABEL(label), str); g_free(str); // set type label = glade_xml_get_widget(xml, "label22"); str = g_strdup_printf("%s", ti68k_bkpt_type_to_string(type)); gtk_label_set_text(GTK_LABEL(label), str); g_free(str); // set mode label = glade_xml_get_widget(xml, "label23"); str = g_strdup_printf("%s", ti68k_bkpt_mode_to_string(type, mode)); gtk_label_set_text(GTK_LABEL(label), str); g_free(str); // set id label = glade_xml_get_widget(xml, "label24"); str = g_strdup_printf("%i", id); gtk_label_set_text(GTK_LABEL(label), str); g_free(str); // set target label = glade_xml_get_widget(xml, "label25"); switch(type) { case BK_TYPE_ACCESS: ti68k_bkpt_get_access(id, &min, mode); str = g_strdup_printf("0x%06x", min); break; case BK_TYPE_RANGE: ti68k_bkpt_get_range(id, &min, &max, mode); str = g_strdup_printf("0x%06x-0x%06x", min, max); break; default: str = g_strdup("n/a"); break; } gtk_label_set_text(GTK_LABEL(label), str); g_free(str); result = gtk_dialog_run(GTK_DIALOG(dbox)); switch (result) { case GTK_RESPONSE_OK: break; default: break; } gtk_widget_destroy(dbox); return 0; }
// show previously created window int gtk_debugger_enter(int context) { #ifndef NO_GDB gint type, id, mode; if (!dbg_on) gdbtk_show_insight(); #endif // debugger is open dbg_on = !0; // show breakpoint source (modal) switch(context) { case DBG_TRACE: break; case DBG_BREAK: break; } // display debugger windows (if not) gtk_debugger_display(); gtk_debugger_refresh(); // enable the debugger if GDB disabled it if (!options3.dbg_dock && !GTK_WIDGET_SENSITIVE(dbgw.regs)) gtk_debugger_enable(); // handle automatic debugging requests #ifndef NO_GDB if (symfile) { // get context ti68k_bkpt_get_cause(&type, &mode, &id); if(type == BK_TYPE_PGMENTRY) { uint16_t handle, offset; uint32_t pc; ti68k_bkpt_get_pgmentry_offset(id, &handle, &offset); ti68k_bkpt_del_pgmentry(handle); if(options3.dbg_dock || GTK_WIDGET_VISIBLE(dbgw.bkpts)) dbgbkpts_refresh_window(); delete_command(NULL, 0); symbol_file_clear(0); gdbtk_clear_file (); ti68k_register_get_pc(&pc); pc -= offset-2; gdb_add_symbol_file(symfile, pc); g_free (symfile); symfile = NULL; exec_build_section_table(); ti68k_unprotect_64KB_range(pc); gdb_hbreak("__main"); } } #endif return 0; }