1 // bfe2 - globals 2 // Copyright (c) 1999-2003 Brand Huntsman and Lee Salzman 3 // 4 5 6 #include <stdio.h> 7 #include <stdlib.h> 8 #include <string.h> 9 #include <unistd.h> 10 #include <signal.h> 11 #include <ctype.h> 12 #include <sys/types.h> 13 #include <sys/time.h> 14 #include <sys/stat.h> 15 #include <gtk/gtk.h> 16 17 18 #define RC_PATH ".bferc" 19 #define HISTORY_PATH "__bfe.log__" 20 21 #define MAX_BREAKPOINTS 30 22 #define MAX_WATCHPOINTS 30 23 24 // default preferences 25 #define DEF_HISLEN 50 26 #define DEF_STACKABOVE 8 27 #define DEF_STACKBELOW 4 28 #define DEF_STEPLOCK 2 29 #define DEF_NEXTLOCK 2 30 #define DEF_RELOAD_BP 1 31 #define DEF_RELOAD_WP 1 32 #define DEF_PAGE_TAB 0 33 34 // text entry and button height 35 #define WIDGET_HEIGHT 20 36 37 // cpu state widgets 38 #define WLEN_REGISTER 85 39 #define WLEN_SEGMENT 110 40 #define WLEN_DTABLE 140 41 #define STACK_LIST_W 150 42 #define STACK_LIST_H 140 43 #define FLAGS_LIST_W 160 44 #define FLAGS_LIST_H 210 45 46 // string lengths 47 #define LEN_RCPATH 200 48 #define LEN_BUFFER 200 49 #define LEN_NUMBER 16 50 #define LEN_ADDRESS 18 51 #define LEN_INSTRUCTION 128 52 #define LEN_STRUCT_NAME 128 53 #define LEN_FIELD_NAME 128 54 55 56 #ifndef uint32 57 typedef unsigned int uint32; 58 #endif 59 #ifndef int32 60 typedef int int32; 61 #endif 62 #ifndef uint64 63 typedef unsigned long long uint64; 64 #endif 65 #ifndef int64 66 typedef long long int64; 67 #endif 68 69 70 // 71 // main.c 72 // 73 74 extern GtkWidget *bochs_button, *refreshall_button, *notebook; 75 extern uint show_state; 76 77 78 // 79 // misc.c 80 // 81 82 83 // 84 // gtk.c 85 // 86 87 typedef enum { HORIZONTAL, VERTICAL } e_orientation; 88 struct s_bgroup_button { 89 GtkWidget *widget; 90 guint id; 91 }; 92 typedef struct s_bgroup { 93 void (*callback)( struct s_bgroup *group ); 94 uint current; 95 uint nr_buttons; 96 struct s_bgroup_button button[1]; 97 } s_bgroup; 98 99 100 // 101 // bochs.c 102 // 103 104 extern FILE *writepipe, *readpipe; 105 extern uint bochs_running, bochs_offline, p_step; 106 extern int bochs_pid; 107 108 109 // 110 // ctrl.c 111 // 112 113 extern GtkWidget *physical_text, *virtual_text, *instruction_text; 114 extern uint32 i_virtual_segment, i_virtual_offset, i_physical_address; 115 extern char i_bytes[LEN_INSTRUCTION], i_description[LEN_INSTRUCTION]; 116 117 118 // 119 // state.c 120 // 121 122 typedef struct s_segment { 123 uint32 segment; 124 uint32 descriptor[2]; 125 uint valid; 126 } s_segment; 127 typedef struct s_table { 128 uint32 base; 129 uint32 limit; 130 } s_table; 131 typedef struct s_cpu { 132 uint32 eax; 133 uint32 ebx; 134 uint32 ecx; 135 uint32 edx; 136 uint32 ebp; 137 uint32 esi; 138 uint32 edi; 139 uint32 esp; 140 uint32 eflags; 141 uint32 eip; 142 struct s_segment cs; 143 struct s_segment ss; 144 struct s_segment ds; 145 struct s_segment es; 146 struct s_segment fs; 147 struct s_segment gs; 148 struct s_segment ldtr; 149 struct s_segment tr; 150 struct s_table gdtr; 151 struct s_table idtr; 152 uint32 dr0; 153 uint32 dr1; 154 uint32 dr2; 155 uint32 dr3; 156 uint32 dr4; 157 uint32 dr5; 158 uint32 dr6; 159 uint32 dr7; 160 uint32 tr3; 161 uint32 tr4; 162 uint32 tr5; 163 uint32 tr6; 164 uint32 tr7; 165 uint32 cr0; 166 uint32 cr1; 167 uint32 cr2; 168 uint32 cr3; 169 uint32 cr4; 170 uint inhibit; 171 } s_cpu; 172 173 extern struct s_cpu cpu; 174 175 176 // 177 // breakpoints.c 178 // 179 180 enum { BP_PHYSICAL, BP_LINEAR, BP_VIRTUAL }; // toggle group 181 typedef enum { BP_UPDATE, BP_REDRAW } e_bp_mode; 182 typedef struct s_breakpoint { 183 uint number; 184 uint type; 185 uint enabled; 186 uint32 segment; 187 uint32 offset; 188 } s_breakpoint; 189 190 extern struct s_breakpoint breakpoints[MAX_BREAKPOINTS]; 191 192 193 // 194 // watchpoints.c 195 // 196 197 enum { WP_READ, WP_WRITE }; // toggle group 198 typedef enum { WP_UPDATE, WP_REDRAW } e_wp_mode; 199 typedef struct s_watchpoint { 200 uint type; 201 uint enabled; 202 uint32 offset; 203 uint32 value; 204 uint value_size; 205 } s_watchpoint; 206 207 extern struct s_watchpoint watchpoints[MAX_WATCHPOINTS]; 208 209 210 // 211 // memory.c 212 // 213 214 enum { MT_PHYSICAL, MT_LINEAR }; // toggle group 215 enum { MS_BYTE, MS_WORD, MS_DWORD, MS_QWORD }; // toggle group 216 enum { MF_HEX, MF_DEC, MF_UDEC, MF_BIN, MF_OCT }; // toggle group 217 typedef struct s_memwin { 218 GtkWidget *window, *close_button, *refresh_button; 219 GtkCList *list; 220 guint id; 221 222 uint32 base; 223 uint nr_units; 224 uint unit_type; 225 uint unit_size; 226 uint unit_format; 227 228 struct s_memwin *prev; 229 struct s_memwin *next; 230 } s_memwin; 231 232 extern struct s_memwin *memwin_head, *memwin_tail; 233 234 235 // 236 // structures.c 237 // 238 239 typedef struct s_field { 240 char name[LEN_FIELD_NAME]; 241 uint size; 242 243 struct s_field *prev; 244 struct s_field *next; 245 } s_field; 246 typedef struct s_structwin { 247 GtkWidget *window, *close_button, *refresh_button; 248 GtkWidget *start_text, *total_text; 249 GtkCList *list; 250 251 char name[LEN_STRUCT_NAME]; 252 uint32 base; 253 uint nr_elts; 254 uint nr_fields; 255 struct s_field *fields_head; 256 struct s_field *fields_tail; 257 258 struct s_structwin *prev; 259 struct s_structwin *next; 260 } s_structwin; 261 262 extern struct s_structwin *structwin_head, *structwin_tail; 263 264 265 // 266 // prefs.c 267 // 268 269 extern uint h_maxlen, stack_above, stack_below, tracing, steplock_time, nextlock_time; 270 extern uint reload_breakpoints, reload_watchpoints; 271 272 273 // 274 // history.c 275 // 276