1 /* 2 * TilEm II 3 * 4 * Copyright (c) 2010-2011 Thibault Duponchelle 5 * Copyright (c) 2011 Benjamin Moody 6 * 7 * This program is free software: you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation, either version 3 of the 10 * License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 typedef struct _TilemDebugBreakpoint { 22 enum { 23 TILEM_DB_BREAK_LOGICAL, 24 TILEM_DB_BREAK_PHYSICAL, 25 TILEM_DB_BREAK_PORT, 26 TILEM_DB_BREAK_OPCODE 27 } type; 28 29 enum { 30 TILEM_DB_BREAK_READ = 4, 31 TILEM_DB_BREAK_WRITE = 2, 32 TILEM_DB_BREAK_EXEC = 1 33 } mode; 34 35 dword start; 36 dword end; 37 dword mask; 38 39 int disabled; 40 int id[3]; 41 } TilemDebugBreakpoint; 42 43 typedef struct _TilemDebugger { 44 struct _TilemCalcEmulator *emu; 45 struct _TilemDisasm *dasm; 46 47 /* Debugger widgets */ 48 GtkWidget *window; /* Main debugger window */ 49 50 GtkWidget *disasm_view; /* Disassembly view */ 51 GtkWidget *mem_view; /* Memory view */ 52 GtkWidget *stack_view; /* Stack view */ 53 54 GtkWidget *regbox; /* Box containing registers */ 55 GtkWidget *reg_entries[14]; /* Entries for registers */ 56 GtkWidget *iff_checkbox; /* Checkbox for IFF */ 57 GtkWidget *flag_buttons[8]; /* Buttons for flags */ 58 59 /* Action groups */ 60 GtkActionGroup *run_actions; 61 GtkActionGroup *paused_actions; 62 GtkActionGroup *misc_actions; 63 64 /* Memory settings */ 65 int mem_rowsize; 66 int mem_start; 67 gboolean mem_logical; 68 69 /* Stack navigation */ 70 GtkAction *prev_stack_action; 71 int stack_index; 72 73 /* Breakpoints */ 74 GSList *breakpoints; 75 int last_bp_type; 76 int last_bp_mode; 77 78 /* Temporary breakpoint info */ 79 int step_bp; /* Breakpoint ID */ 80 dword step_next_addr; /* Target address */ 81 82 dword lastwrite; 83 dword lastsp; 84 dword lastpc; 85 gboolean paused; 86 gboolean refreshing; 87 gboolean delayed_refresh; 88 89 /* Other windows */ 90 struct _TilemKeypadDialog *keypad_dialog; 91 } TilemDebugger; 92 93 /* Create a new TilemDebugger. */ 94 TilemDebugger *tilem_debugger_new(TilemCalcEmulator *emu); 95 96 /* Free a TilemDebugger. */ 97 void tilem_debugger_free(TilemDebugger *dbg); 98 99 /* Show debugger, and pause emulator if not already paused. */ 100 void tilem_debugger_show(TilemDebugger *dbg); 101 102 /* Hide debugger, and resume emulation if not already running. */ 103 void tilem_debugger_hide(TilemDebugger *dbg); 104 105 /* New calculator loaded. */ 106 void tilem_debugger_calc_changed(TilemDebugger *dbg); 107 108 /* Update display. */ 109 void tilem_debugger_refresh(TilemDebugger *dbg, gboolean updatemem); 110 111 /* Add a new breakpoint. */ 112 TilemDebugBreakpoint * tilem_debugger_add_breakpoint(TilemDebugger *dbg, 113 const TilemDebugBreakpoint *bp); 114 115 /* Remove an existing breakpoint. */ 116 void tilem_debugger_remove_breakpoint(TilemDebugger *dbg, 117 TilemDebugBreakpoint *bp); 118 119 /* Modify an existing breakpoint. */ 120 void tilem_debugger_change_breakpoint(TilemDebugger *dbg, 121 TilemDebugBreakpoint *bp, 122 const TilemDebugBreakpoint *newbp); 123 124 /* Show a dialog letting the user add, remove, and edit breakpoints. */ 125 void tilem_debugger_edit_breakpoints(TilemDebugger *dbg); 126 127 128 /* Memory view */ 129 130 /* Create the memory view */ 131 GtkWidget *tilem_debugger_mem_view_new(TilemDebugger *dbg); 132 133 /* Set memory view settings */ 134 void tilem_debugger_mem_view_configure(GtkWidget *mem_view, 135 TilemCalcEmulator *emu, 136 int rowsize, int start, 137 gboolean logical); 138 139 140 /* Keypad dialog */ 141 142 typedef struct _TilemKeypadDialog { 143 TilemDebugger *dbg; 144 145 gboolean refreshing; 146 147 GtkWidget *window; 148 GtkWidget *output[7]; 149 GtkWidget *keys[7][8]; 150 GtkWidget *input[8]; 151 } TilemKeypadDialog; 152 153 /* Create a new TilemKeypadDialog. */ 154 TilemKeypadDialog *tilem_keypad_dialog_new(TilemDebugger *dbg); 155 156 /* Free a TilemKeypadDialog. */ 157 void tilem_keypad_dialog_free(TilemKeypadDialog *kpdlg); 158 159 /* New calculator loaded. */ 160 void tilem_keypad_dialog_calc_changed(TilemKeypadDialog *kpdlg); 161 162 /* Refresh key states. */ 163 void tilem_keypad_dialog_refresh(TilemKeypadDialog *kpdlg); 164 165