- added instructions how to update the online documentation
[bochs-mirror.git] / gui / wenhdbg_h.h
blob66a5c5c774d41e41b6792f4133160e6004356951
1 // include file for the Win32 Enhanced GUI debugger frontend
2 // User Customizable initial settings:
4 bx_bool SeeReg[8] = {
5 TRUE, // in 64bit mode, show 32bit versions of registers also (EAX, ...)
6 FALSE, // show segment registers (CS, ...)
7 FALSE, // show GDTR, IDTR, LDTR, Task Reg
8 FALSE, // show control register (CR0, ...)
9 FALSE, // show FPU (STi) / MMX registers
10 FALSE, // show XMM registers
11 FALSE, // show the Debug Registers (DR0, ...)
12 FALSE // Test Registers not yet supported in bochs (2.3.7)
15 bx_bool ShowIOWindows = TRUE; // Display the top-row Step/Continue pushbuttons
16 bx_bool ShowButtons = TRUE; // Display the top-row Step/Continue pushbuttons
17 bx_bool SeeRegColors = TRUE; // Display registers with background color "groups"
18 bx_bool ignoreNxtT = TRUE; // Do not show "Next at t=" output lines
19 bx_bool ignSSDisasm = TRUE; // Do not show extra disassembly line at each break
20 int UprCase = 1; // 1 = convert all Asm, Register names, Register values to uppercase
21 int DumpInAsciiMode = 3; // bit 1 = show ASCII in dumps, bit 2 = show hex, value=0 is illegal
23 bx_bool isLittleEndian = TRUE;
24 int DefaultAsmLines = 250; // default # of asm lines disassembled and "cached"
25 int bottommargin = 6; // ASM autoscroller tries to leave this many lines below
26 int topmargin = 3; // autoscroller tries to leave this many lines above
27 // Note: topmargin must be less than bottommargin
29 // How to use DockOrder: the Register list is window 1, ASM is window 2, MemDump is window 3
30 // Create the hex value with the digits in the order you want the windows to be.
31 // 0x312 would have MemDump on the left, Register in the middle, ASM on the right
32 short DockOrder = 0x123; // set the default List "docking" (Reg, ASM, Dump)
34 COLORREF ColorList[16] = { // background "register type" colors indexed by RegColor value
35 RGB(255,255,255), // white
36 RGB(200,255,255), // blue (aqua)
37 RGB(230,230,230), // gray
38 RGB(248,255,200), // yellow
39 RGB(216,216,255), // purple
40 RGB(200,255,200), // green
41 RGB(255,230,200), // orange
42 RGB(255,255,255), // user definable
43 RGB(255,255,255),
44 RGB(255,255,255),
45 RGB(255,255,255),
46 RGB(255,255,255),
47 RGB(255,255,255),
48 RGB(255,255,255),
49 RGB(255,255,255),
50 RGB(255,255,255)
53 #define STATUS_WIN_OVERLAP 4 // # of "extra" pixels at the top of a Status window
54 #define STACK_ENTRIES 50 // # of words/dwords/qwords to display in stack window
55 // Note: STACK_ENTRIES must be <= 512
57 // END of User Customizable settings
59 #include <math.h>
60 #include "iodev/iodev.h"
61 #include "wenhdbg_res.h" // MenuIDs
64 #ifndef LVS_EX_DOUBLEBUFFER
65 #define IS_WIN98
66 // these two defines may not exist in some compilers
67 #define LVS_EX_DOUBLEBUFFER 0
68 #define LVIF_GROUPID 0
69 #endif
71 #define MAX_ASM 2048 // max entries in ASM window
73 // The wordsize popup is the 13th entry in the Opt menu -- COUNTING SEPARATORS
74 // Index = (entry number - 1) -- if the Opt menu is modified, then update this value
75 // -- or else the checkmarks won't work
76 #define WS_POPUP_IDX 12
79 // Handles to Windows and global stuff
80 HWND hY; // complete parent window
81 HWND hL[3]; // 0=registers, 1=Asm, 2=MemDump
82 HWND hE_I; // command input window
83 HWND hS_S; // "status" window at bottom
84 HWND hE_O; // debugger text output
85 HWND hT; // param_tree window
86 HWND hBTN[5]; // button row
87 HWND hCPUt[BX_MAX_SMP_THREADS_SUPPORTED]; // "tabs" for the individual CPUs
88 HFONT CustomFont = NULL;
89 HMENU hOptMenu; // "Options" popup menu (needed to set check marks)
90 HMENU hViewMenu; // "View" popup menu (needed to gray entries)
91 HMENU hCmdMenu; // "Command" popup menu (needed to gray entries)
92 // one "defualtProc" for each edit window (Input and Output)
93 WNDPROC wEdit[2];
94 WNDPROC wBtn; // all the buttons have the same Proc
95 WNDPROC wTreeView;
96 WNDPROC wListView; // all the lists use the same Proc
98 //HANDLE hTCevent[BX_MAX_SMP_THREADS_SUPPORTED]; // Start/Sleep Control for cpu_loop threads
100 // get a "class" to access the disassebler
101 // Note; any instance has access to all the member functions -- that is enough!
102 // -- i.e. No further initialization necessary.
103 static disassembler bx_disassemble;
104 // for refreshing the bochs VGA window:
105 BOCHSAPI extern bx_devices_c bx_devices;
107 // Note: all these BSS global variables are initialized to 0 automatically
108 Bit64u SelectedDataAddress = 0;
109 Bit64u CurrentAsmLA = 0; // = EIP/RIP -- for highlighting in ASM window
110 Bit64u BottomAsmLA; // beginning and end addrs on ASM window
111 Bit64u TopAsmLA;
113 Bit32u PrevStepNSize = 50; // cpu_loop control variables
114 //Bit32u RequestedLoops; // number of cpu_loops the user is asking for
115 //bx_bool DoBreak; // stop a local subthreaded cpu_loop
116 Bit64u PrevPtime = 9; // any number other than 0
117 Bit64u NewPtime; // used to test whether sim has "updated"
118 unsigned int TotCPUs; // # of CPUs in a multi-CPU simulation
119 unsigned int CurrentCPU; // cpu that is being displayed
122 // window resizing/docking stuff
123 HCURSOR hCursResize;
124 HCURSOR hCursDock;
125 HCURSOR hCursArrow;
126 LVHITTESTINFO lvht; // calculate and remember which list item was clicked
127 int OneCharWide; // average width of a char in current font
128 int Sizing = 0; // current "resizing/docking mode"
129 int Resize_HiX; // horizontal limits of the current resize operation
130 int Resize_LoX;
131 unsigned short BarScrx[2]; // position of central listview's left and right borders in SCREEN coordinates
132 unsigned short BarClix[2]; // in client coordinates
133 unsigned int ListWidthPix[3] = {5,7,8}; // set initial proportions of Reg, Asm, Dump windows
134 unsigned int LstTop = 0;
135 int CurCenterList;
136 int SizeList; // pre-docking list #
137 bx_bool DumpHasFocus = FALSE;
138 Bit32s xClick = -1; // halfway through a mouseclick flag + location
139 Bit32s yClick; // values are in Listview coordinates
140 Bit32u CurTimeStamp; // last mousedown time
141 short nDock[36] = { // lookup table for alternate DockOrders
142 0x231, 0x312, 0x231, 0x213, 0x132, 0x132,
143 0x213, 0x321, 0x123, 0x123, 0x321, 0x312,
144 0x213, 0x213, 0x123, 0x312, 0x321, 0x312,
145 0x132, 0x123, 0x132, 0x321, 0x231, 0x231,
146 0x312, 0x312, 0x231, 0x213, 0x132, 0x213,
147 0x132, 0x123, 0x321, 0x321, 0x123, 0x231
150 // base window "styles" for the 3 listviews.
151 long LVStyle[3] = {
152 LVS_REPORT | WS_CHILD,
153 LVS_SHOWSELALWAYS | LVS_REPORT | WS_CHILD,
154 LVS_SHOWSELALWAYS | LVS_REPORT | WS_CHILD | WS_VISIBLE
157 bx_bool AtBreak = FALSE; // Status indicators
158 bx_bool PrevAtBreak = FALSE;
159 bx_bool CpuModeChange = TRUE;
160 bx_bool StatusChange = TRUE;
162 bx_bool In64Mode = FALSE; // CPU modes
163 bx_bool In32Mode = FALSE;
164 unsigned CpuMode = 0;
165 Bit32u InPaging = 0; // Storage for the top bit of CR0, unmodified
167 bx_bool doOneTimeInit = TRUE; // Internal flags
168 bx_bool ResizeColmns; // address/value column autosize flag
169 bx_bool dbgOn = FALSE; // the bochs internal debugger needs some time to get started
170 bx_bool FWflag = FALSE; // friendly warning has been shown to user once already
171 int StackSized; // autosize flag for stack window
173 char *PrevStack; // buffer for testing changes in stack values
174 Bit64u PStackLA = 0; // to calculate alignment between prev and current stack
175 bx_bool StackEntChg[STACK_ENTRIES]; // flag for "change detected" on each stack line
176 bx_bool StkInvOnce = FALSE; // sometimes need to specially invalidate the stack window
178 // DViewModes
179 #define VIEW_MEMDUMP 0
180 #define VIEW_GDT 1
181 #define VIEW_IDT 2
182 #define VIEW_PAGING 3
183 #define VIEW_STACK 4
184 #define VIEW_PTREE 5
186 bx_bool DumpInitted = FALSE; // has the MemDump window ever been filled with data?
187 int DumpAlign = 1;
188 int PrevDAD; // saves "previous DumpAlign value" (forces column autosize)
189 char *DataDump;
190 Bit64u DumpStart = 0; // current emulated address (lin or phys) of DataDump
191 bx_bool doDumpRefresh;
192 int DViewMode = VIEW_MEMDUMP;
193 bx_bool DumpMode = 1; // 0 physical, 1 linear
194 char* DC0txt[2] = {"P.Address","L.Address"}; // DumpMode definitions in text
196 // make some global 512b temp char buffers -- they are needed to test against overflows anyway
197 char *tmpcb, *tmpcd; // space is allocated in bigbuf
198 char *tmpce, *tmpcf; // exclusively for use in subthreads
199 char *AsciiHex; // Unsigned char to printable hex xlat table
201 #define outbufSIZE 30720
202 char bigbuf[outbufSIZE]; // 30K preallocated storage for all char buffers (see DoAllInit)
203 char *DbgAppendPtr = bigbuf;
204 char *OutWindow; // buffer for the Output window
205 #define OutWinSIZE 10240
206 int OutWinCnt = OutWinSIZE; // available size of OutWindow buffer
207 int PO_Tdelay = 0; // delay before displaying partial output lines
209 int AsmLineCount = 1; // # of disassembled asm lines loaded
210 int AsmPgSize = 0;
211 int ListLineRatio; // number of vertical pixels in a ListView Item
212 int ListVerticalPix; // number of vertical pixels in each List
213 Bit64u AsmLA[MAX_ASM]; // linear address of each disassembled ASM line
215 // Command stuff
216 int CommandHistoryIdx = 0;
217 char *CmdHistory[64]; // 64 command History storage (fixed 80b each)
218 int CmdHInsert = 0; // index of next history entry to store
220 // register storage -- names and values
221 #define RAX_Rnum 0
222 #define RBX_Rnum 1
223 #define RCX_Rnum 2
224 #define RDX_Rnum 3
225 #define RSI_Rnum 4
226 #define RDI_Rnum 5
227 #define RBP_Rnum 6
228 #define RSP_Rnum 7
229 #define RIP_Rnum 8
230 #define R8_Rnum 9
231 #define R9_Rnum 10
232 #define R10_Rnum 11
233 #define R11_Rnum 12
234 #define R12_Rnum 13
235 #define R13_Rnum 14
236 #define R14_Rnum 15
237 #define R15_Rnum 16
238 #define EFL_Rnum 17 // it makes the most sense if EFLAGS is between RXX and EXX
239 #define EAX_Rnum 18 // because it "belongs with" both sets of GP registers
240 #define EBX_Rnum 19
241 #define ECX_Rnum 20
242 #define EDX_Rnum 21
243 #define ESI_Rnum 22
244 #define EDI_Rnum 23
245 #define EBP_Rnum 24
246 #define ESP_Rnum 25
247 #define EIP_Rnum 26
248 #define CS_Rnum 27
249 #define DS_Rnum 28
250 #define ES_Rnum 29
251 #define SS_Rnum 30
252 #define FS_Rnum 31
253 #define GS_Rnum 32
254 #define GDTRnum 33
255 #define IDTRnum 34
256 #define LDTRnum 35
257 #define TRRnum 36
258 #define CR0_Rnum 37
259 #define CR3_Rnum 38
260 #define CR4_Rnum 39
261 #define EFER_Rnum 40 // currently used to mark the last entry in rV[]
262 #define ST0_Rnum 41
263 #define ST1_Rnum 42
264 #define ST2_Rnum 43
265 #define ST3_Rnum 44
266 #define ST4_Rnum 45
267 #define ST5_Rnum 46
268 #define ST6_Rnum 47
269 #define ST7_Rnum 48
270 #define XMM0_Rnum 49
271 #define XMM1_Rnum 50
272 #define XMM2_Rnum 51
273 #define XMM3_Rnum 52
274 #define XMM4_Rnum 53
275 #define XMM5_Rnum 54
276 #define XMM6_Rnum 55
277 #define XMM7_Rnum 56
278 #define XMM8_Rnum 57
279 #define XMM9_Rnum 58
280 #define XMMA_Rnum 59
281 #define XMMB_Rnum 60
282 #define XMMC_Rnum 61
283 #define XMMD_Rnum 62
284 #define XMME_Rnum 63
285 #define XMMF_Rnum 64
286 #define DR0_Rnum 65
287 #define DR1_Rnum 66
288 #define DR2_Rnum 67
289 #define DR3_Rnum 68
290 #define DR6_Rnum 69
291 #define DR7_Rnum 70
292 // #define TR0_Rnum 71 -- put Test Registers in here when they are supported
293 #define TOT_REG_NUM 72
294 // extra "register numbers" for registers that have more than one part
295 #define GDTR_Lim 72
296 #define IDTR_Lim 73
297 #define ST0_exp 74
298 #define ST1_exp 75
299 #define ST2_exp 76
300 #define ST3_exp 77
301 #define ST4_exp 78
302 #define ST5_exp 79
303 #define ST6_exp 80
304 #define ST7_exp 81
305 #define XMM0_hi 82
306 #define XMM1_hi 82
307 #define XMM2_hi 83
308 #define XMM3_hi 84
309 #define XMM4_hi 85
310 #define XMM5_hi 86
311 #define XMM6_hi 87
312 #define XMM7_hi 88
313 #define XMM8_hi 89
314 #define XMM9_hi 90
315 #define XMMA_hi 91
316 #define XMMB_hi 92
317 #define XMMC_hi 93
318 #define XMMD_hi 94
319 #define XMME_hi 95
320 #define XMMF_hi 96
321 #define EXTRA_REGS 28
323 char * EflBName[16] = {
324 "cf", "pf", "af", "zf", "sf", "tf", "if", "df", "of", "nt", "rf", "vm", "ac", "vif", "vip", "id"
326 int EflBNameLen[16] = {
327 2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,2
329 int EflBitVal[16] = {
330 1, 4, 0x10, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x4000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000
333 // only pay special attention to registers up to EFER
334 char* RegLCName[EFER_Rnum + 1] = {
335 "rax","rbx","rcx","rdx","rsi","rdi","rbp","rsp","rip",
336 "r8","r9","r10","r11","r12","r13","r14","r15",
337 "eflags","eax","ebx","ecx","edx","esi","edi","ebp","esp","eip",
338 "cs","ds","es","ss","fs","gs",
339 "gdtr","idtr","ldtr","tr","cr0","cr3","cr4","efer"
341 char* RDispName[EFER_Rnum + 1];
342 bx_param_num_c *RegObject[BX_MAX_SMP_THREADS_SUPPORTED][TOT_REG_NUM + EXTRA_REGS];
343 Bit64u rV[EFER_Rnum + 1]; // current values of registers
344 Bit64u PV[EFER_Rnum + 1]; // previous values of registers
345 Bit32s GDT_Len; // "limits" (= bytesize-1) for GDT and IDT
346 Bit32s IDT_Len;
347 Bit8u RegColor[TOT_REG_NUM]; // specifies foreground and background color of registers
348 // Text color is red if the upper bit is set. Background is set according to ColorList.
349 int RitemToRnum[TOT_REG_NUM]; // mapping from Reg List Item# to register number
351 // lviG is a generic ListViewItem with GroupID -- reused many times
352 LV_ITEM lviG = {LVIF_TEXT | LVIF_GROUPID,0,0,0,0,(LPSTR)0,0,0,0};
354 TVINSERTSTRUCT tvis; // tree-view generic item
356 Bit64u ladrmin = 0; // bochs linear addressing access variables
357 Bit64u ladrmax = 0;
358 Bit64u l_p_offset;
360 #define BTN_BASE 1024
361 #define MULTICPU_BTN_BASE 1030
362 int BtnLkup[6] = {
363 CMD_CONT, CMD_STEP1, CMD_STEPN, CMD_BREAK, CMD_RFRSH, CMD_BRKALL
365 char* BTxt[6] = {"Continue [c]","Step [s]","Step N [s ###]","Break [^C]","Refresh","Break All"};
366 char* GDTt2[8] = {"16-bit code","64-bit code","32-bit code","16-bit data","64-bit data","32-bit data","Illegal","Unused"};
367 char* GDTsT[] = { "","Available 16bit TSS","LDT","Busy 16bit TSS","16bit Call Gate",
368 "Task Gate","16bit Interrupt Gate","16bit Trap Gate","Reserved",
369 "Available 32bit TSS","Reserved","Busy 32bit TSS","32bit Call Gate",
370 "Reserved","32bit Interrupt Gate","32bit Trap Gate"
372 // Register hex display formats -- index by UprCase
373 char* Fmt64b[2] = { "%016I64x", "%016I64X" };
374 char* Fmt32b[2] = { "%08x", "%08X" };
375 char* Fmt16b[2] = { "%04x", "%04X" };
376 char* xDT64Fmt[2] = { "%016I64x (%4x)", "%016I64X (%4X)" };
377 char* xDT32Fmt[2] = { "%08x (%4x)", "%08X (%4X)" };
379 // do the linear breakpoint list as 2 arrays, rather than a structure -- much easier to search!
380 bx_address BrkLAddr[BX_DBG_MAX_LIN_BPOINTS];
381 unsigned int BrkIdx[BX_DBG_MAX_LIN_BPOINTS];
382 int BreakCount = 0;
384 // AskTest stuff
385 struct ASKTEXT {
386 const TCHAR* ti;
387 const TCHAR* as;
388 TCHAR* re;
389 int DefT;