- simple "show cpu" feature for the win32 debugger dialog

This commit is contained in:
Volker Ruppert 2007-01-05 16:53:45 +00:00
parent 5c21f7821f
commit d4b9bb45c7
3 changed files with 121 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.cc,v 1.54 2006-12-17 18:14:59 vruppert Exp $
// $Id: win32dialog.cc,v 1.55 2007-01-05 16:53:45 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#include "config.h"
@ -27,6 +27,8 @@ static void *old_callback_arg = NULL;
static HWND hDebugDialog = NULL;
static char *debug_cmd = NULL;
static BOOL debug_cmd_ready = FALSE;
static BOOL showCPU = FALSE;
static bx_param_num_c *cpu_param[16];
#endif
int AskFilename(HWND hwnd, bx_param_filename_c *param, const char *ext);
@ -903,12 +905,49 @@ int RuntimeOptionsDialog()
}
#if BX_DEBUGGER
void RefreshDebugDialog()
{
#if BX_SUPPORT_SAVE_RESTORE
unsigned i;
char buffer[20];
if (showCPU) {
for (i = 0; i < 15; i++) {
sprintf(buffer, "%08X", cpu_param[i]->get());
SetDlgItemText(hDebugDialog, IDCPUVAL1+i, buffer);
}
}
#endif
}
static BOOL CALLBACK DebuggerDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
unsigned i;
int idx, lines;
static RECT R;
switch (msg) {
case WM_INITDIALOG:
GetWindowRect(hDlg, &R);
#if BX_SUPPORT_SAVE_RESTORE
cpu_param[0] = SIM->get_param_num("cpu.0.EAX", SIM->get_sr_root());
cpu_param[1] = SIM->get_param_num("cpu.0.EBX", SIM->get_sr_root());
cpu_param[2] = SIM->get_param_num("cpu.0.ECX", SIM->get_sr_root());
cpu_param[3] = SIM->get_param_num("cpu.0.EDX", SIM->get_sr_root());
cpu_param[4] = SIM->get_param_num("cpu.0.ESP", SIM->get_sr_root());
cpu_param[5] = SIM->get_param_num("cpu.0.EBP", SIM->get_sr_root());
cpu_param[6] = SIM->get_param_num("cpu.0.ESI", SIM->get_sr_root());
cpu_param[7] = SIM->get_param_num("cpu.0.EDI", SIM->get_sr_root());
cpu_param[8] = SIM->get_param_num("cpu.0.EIP", SIM->get_sr_root());
cpu_param[9] = SIM->get_param_num("cpu.0.CS.selector", SIM->get_sr_root());
cpu_param[10] = SIM->get_param_num("cpu.0.DS.selector", SIM->get_sr_root());
cpu_param[11] = SIM->get_param_num("cpu.0.ES.selector", SIM->get_sr_root());
cpu_param[12] = SIM->get_param_num("cpu.0.FS.selector", SIM->get_sr_root());
cpu_param[13] = SIM->get_param_num("cpu.0.GS.selector", SIM->get_sr_root());
cpu_param[14] = SIM->get_param_num("cpu.0.EFLAGS", SIM->get_sr_root());
#else
EnableWindow(GetDlgItem(hdlg, IDSHOWCPU), FALSE);
#endif
return TRUE;
break;
case WM_CLOSE:
@ -930,6 +969,21 @@ static BOOL CALLBACK DebuggerDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
case IDSTOP:
SIM->debug_break();
break;
case IDSHOWCPU:
showCPU = !showCPU;
if (showCPU) {
SetDlgItemText(hDlg, IDSHOWCPU, "Hide CPU <<");
MoveWindow(hDlg, R.left, R.top, R.right - R.left + 300, R.bottom - R.top, TRUE);
RefreshDebugDialog();
} else {
SetDlgItemText(hDlg, IDSHOWCPU, "Show CPU >>");
MoveWindow(hDlg, R.left, R.top, R.right - R.left, R.bottom - R.top, TRUE);
}
for (i = 0; i < 15; i++) {
ShowWindow(GetDlgItem(hDlg, IDCPULBL1+i), showCPU ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hDlg, IDCPUVAL1+i), showCPU ? SW_SHOW : SW_HIDE);
}
break;
}
case WM_USER:
if (wParam == 0x1234) {
@ -961,12 +1015,6 @@ void InitDebugDialog(HWND mainwnd)
(DLGPROC)DebuggerDlgProc);
ShowWindow(hDebugDialog, SW_SHOW);
}
void RefreshDebugDialog()
{
// TODO: implement modeless dialog box with cpu registers and add some code
// here to update the controls
}
#endif
BxEvent* win32_notify_callback(void *unused, BxEvent *event)

View File

@ -81,3 +81,36 @@
#define DEBUG_CMD 3020
#define IDEXEC 3030
#define IDSTOP 3040
#define IDSHOWCPU 3050
#define IDCPULBL1 3061
#define IDCPULBL2 3062
#define IDCPULBL3 3063
#define IDCPULBL4 3064
#define IDCPULBL5 3065
#define IDCPULBL6 3066
#define IDCPULBL7 3067
#define IDCPULBL8 3068
#define IDCPULBL9 3069
#define IDCPULBL10 3070
#define IDCPULBL11 3071
#define IDCPULBL12 3072
#define IDCPULBL13 3073
#define IDCPULBL14 3074
#define IDCPULBL15 3075
#define IDCPULBL16 3076
#define IDCPUVAL1 3081
#define IDCPUVAL2 3082
#define IDCPUVAL3 3083
#define IDCPUVAL4 3084
#define IDCPUVAL5 3085
#define IDCPUVAL6 3086
#define IDCPUVAL7 3087
#define IDCPUVAL8 3088
#define IDCPUVAL9 3089
#define IDCPUVAL10 3090
#define IDCPUVAL11 3091
#define IDCPUVAL12 3092
#define IDCPUVAL13 3093
#define IDCPUVAL14 3094
#define IDCPUVAL15 3095
#define IDCPUVAL16 3096

View File

@ -152,7 +152,38 @@ FONT 8, "Helv"
BEGIN
EDITTEXT DEBUG_MSG, 15, 15, 220, 120, ES_MULTILINE | ES_READONLY | WS_HSCROLL | WS_VSCROLL | NOT WS_TABSTOP
EDITTEXT DEBUG_CMD, 15, 145, 220, 14
PUSHBUTTON "Execute", IDEXEC, 70, 170, 50, 14
PUSHBUTTON "Stop", IDSTOP, 130, 170, 50, 14
PUSHBUTTON "Execute", IDEXEC, 40, 170, 50, 14
PUSHBUTTON "Stop", IDSTOP, 100, 170, 50, 14
PUSHBUTTON "Show CPU >>", IDSHOWCPU, 160, 170, 50, 14
LTEXT "EAX", IDCPULBL1, 260, 17, 30, 14
EDITTEXT IDCPUVAL1, 290, 15, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "EBX", IDCPULBL2, 260, 32, 30, 14
EDITTEXT IDCPUVAL2, 290, 30, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "ECX", IDCPULBL3, 260, 47, 30, 14
EDITTEXT IDCPUVAL3, 290, 45, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "EDX", IDCPULBL4, 260, 62, 30, 14
EDITTEXT IDCPUVAL4, 290, 60, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "ESP", IDCPULBL5, 260, 77, 30, 14
EDITTEXT IDCPUVAL5, 290, 75, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "EBP", IDCPULBL6, 260, 92, 30, 14
EDITTEXT IDCPUVAL6, 290, 90, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "ESI", IDCPULBL7, 260, 107, 30, 14
EDITTEXT IDCPUVAL7, 290, 105, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "EDI", IDCPULBL8, 260, 122, 30, 14
EDITTEXT IDCPUVAL8, 290, 120, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "EIP", IDCPULBL9, 260, 172, 30, 14
EDITTEXT IDCPUVAL9, 290, 170, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "CS", IDCPULBL10, 350, 17, 30, 14
EDITTEXT IDCPUVAL10, 380, 15, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "DS", IDCPULBL11, 350, 32, 30, 14
EDITTEXT IDCPUVAL11, 380, 30, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "ES", IDCPULBL12, 350, 47, 30, 14
EDITTEXT IDCPUVAL12, 380, 45, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "FS", IDCPULBL13, 350, 62, 30, 14
EDITTEXT IDCPUVAL13, 380, 60, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "GS", IDCPULBL14, 350, 77, 30, 14
EDITTEXT IDCPUVAL14, 380, 75, 50, 14, ES_READONLY | ES_RIGHT
LTEXT "EFLAGS", IDCPULBL15, 350, 172, 30, 14
EDITTEXT IDCPUVAL15, 380, 170, 50, 14, ES_READONLY | ES_RIGHT
END