- first attempt to implement a debugger gui dialog for win32
- new display library option "windebug" enables the new feature - simple dialog box with a command line and a multiline text viever - TODO: implement modeless dialog with cpu registers and it should be possible to interrupt "continue" and "step N" commands - win32dialog: fixed function GetBochsWindow() - textconfig: removed unused save/restore prompt
This commit is contained in:
parent
f19595136b
commit
3063397fd4
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: dbg_main.cc,v 1.86 2006-11-07 08:24:22 sshwarts Exp $
|
||||
// $Id: dbg_main.cc,v 1.87 2006-11-12 10:07:17 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -195,7 +195,7 @@ int bx_dbg_main(void)
|
||||
sim_running->set(0);
|
||||
}
|
||||
// setup Ctrl-C handler
|
||||
if (!SIM->is_wx_selected()) {
|
||||
if (!SIM->has_debug_gui()) {
|
||||
signal(SIGINT, bx_debug_ctrlc_handler);
|
||||
BX_INFO(("set SIGINT handler to bx_debug_ctrlc_handler"));
|
||||
}
|
||||
@ -297,7 +297,7 @@ void bx_get_command(void)
|
||||
if (bx_infile_stack_index == 0) {
|
||||
sprintf(prompt, "<bochs:%d> ", bx_infile_stack[bx_infile_stack_index].lineno);
|
||||
}
|
||||
if (SIM->is_wx_selected() && bx_infile_stack_index == 0) {
|
||||
if (SIM->has_debug_gui() && bx_infile_stack_index == 0) {
|
||||
// wait for wxWidgets to send another debugger command
|
||||
charptr_ret = SIM->debug_get_next_command();
|
||||
if (charptr_ret) {
|
||||
@ -440,7 +440,7 @@ void bxerror(char *s)
|
||||
void bx_debug_ctrlc_handler(int signum)
|
||||
{
|
||||
UNUSED(signum);
|
||||
if (SIM->is_wx_selected()) {
|
||||
if (SIM->has_debug_gui()) {
|
||||
// in a multithreaded environment, a signal such as SIGINT can be sent to all
|
||||
// threads. This function is only intended to handle signals in the
|
||||
// simulator thread. It will simply return if called from any other thread.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.cc,v 1.171 2006-09-26 19:16:10 sshwarts Exp $
|
||||
// $Id: siminterface.cc,v 1.172 2006-11-12 10:07:17 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// See siminterface.h for description of the siminterface concept.
|
||||
@ -128,8 +128,9 @@ public:
|
||||
virtual int begin_simulation (int argc, char *argv[]);
|
||||
virtual void set_sim_thread_func(is_sim_thread_func_t func) {}
|
||||
virtual bx_bool is_sim_thread();
|
||||
bx_bool wxsel;
|
||||
virtual bx_bool is_wx_selected() { return wxsel; }
|
||||
bx_bool debug_gui;
|
||||
virtual void set_debug_gui(bx_bool val) { debug_gui = val; }
|
||||
virtual bx_bool has_debug_gui() { return debug_gui; }
|
||||
// provide interface to bx_gui->set_display_mode() method for config
|
||||
// interfaces to use.
|
||||
virtual void set_display_mode(disp_mode_t newmode) {
|
||||
@ -285,7 +286,7 @@ bx_real_sim_c::bx_real_sim_c()
|
||||
ci_callback = NULL;
|
||||
ci_callback_data = NULL;
|
||||
is_sim_thread_func = NULL;
|
||||
wxsel = 0;
|
||||
debug_gui = 0;
|
||||
|
||||
enabled = 1;
|
||||
init_done = 0;
|
||||
@ -658,11 +659,11 @@ int bx_real_sim_c::create_disk_image(
|
||||
}
|
||||
|
||||
void bx_real_sim_c::refresh_ci() {
|
||||
if (SIM->is_wx_selected()) {
|
||||
if (SIM->has_debug_gui()) {
|
||||
// presently, only wxWidgets interface uses these events
|
||||
// It's an async event, so allocate a pointer and send it.
|
||||
// The event will be freed by the recipient.
|
||||
BxEvent *event = new BxEvent ();
|
||||
BxEvent *event = new BxEvent();
|
||||
event->type = BX_ASYNC_EVT_REFRESH;
|
||||
sim_to_ci_event(event);
|
||||
}
|
||||
@ -721,12 +722,12 @@ char *bx_real_sim_c::debug_get_next_command()
|
||||
|
||||
void bx_real_sim_c::debug_puts(const char *text)
|
||||
{
|
||||
if (SIM->is_wx_selected()) {
|
||||
if (SIM->has_debug_gui()) {
|
||||
// send message to the wxWidgets debugger
|
||||
BxEvent *event = new BxEvent();
|
||||
event->type = BX_ASYNC_EVT_DBG_MSG;
|
||||
event->u.logmsg.msg = text;
|
||||
sim_to_ci_event (event);
|
||||
sim_to_ci_event(event);
|
||||
// the event will be freed by the recipient
|
||||
} else {
|
||||
// text mode debugger: just write to console
|
||||
@ -759,9 +760,9 @@ int bx_real_sim_c::configuration_interface(const char *ignore, ci_command_t comm
|
||||
return -1;
|
||||
}
|
||||
if (!strcmp(name, "wx"))
|
||||
wxsel = 1;
|
||||
debug_gui = 1;
|
||||
else
|
||||
wxsel = 0;
|
||||
debug_gui = 0;
|
||||
// enter configuration mode, just while running the configuration interface
|
||||
set_display_mode(DISP_MODE_CONFIG);
|
||||
int retval = (*ci_callback)(ci_callback_data, command);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.h,v 1.202 2006-10-08 10:18:51 vruppert Exp $
|
||||
// $Id: siminterface.h,v 1.203 2006-11-12 10:07:17 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Intro to siminterface by Bryce Denney:
|
||||
@ -1220,7 +1220,8 @@ public:
|
||||
is_sim_thread_func = func;
|
||||
}
|
||||
virtual bx_bool is_sim_thread() {return 1;}
|
||||
virtual bx_bool is_wx_selected() {return 0;}
|
||||
virtual void set_debug_gui(bx_bool val) {}
|
||||
virtual bx_bool has_debug_gui() {return 0;}
|
||||
// provide interface to bx_gui->set_display_mode() method for config
|
||||
// interfaces to use.
|
||||
virtual void set_display_mode(disp_mode_t newmode) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: textconfig.cc,v 1.64 2006-10-02 17:07:36 vruppert Exp $
|
||||
// $Id: textconfig.cc,v 1.65 2006-11-12 10:07:18 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is code for a text-mode configuration interface. Note that this file
|
||||
@ -316,15 +316,6 @@ static char *runtime_menu_prompt =
|
||||
"13. Quit now\n"
|
||||
"\n"
|
||||
"Please choose one: [12] ";
|
||||
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
static char *save_state_prompt =
|
||||
"----------------\n"
|
||||
"Save Bochs State\n"
|
||||
"----------------\n\n"
|
||||
"What is the path to save the Bochs state to?\n"
|
||||
"To cancel, type 'none'. [%s] ";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define NOT_IMPLEMENTED(choice) \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: win32.cc,v 1.109 2006-10-15 16:23:42 vruppert Exp $
|
||||
// $Id: win32.cc,v 1.110 2006-11-12 10:07:18 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -632,6 +632,10 @@ void bx_win32_gui_c::specific_init(int argc, char **argv, unsigned
|
||||
BX_INFO(("option %d: %s", i, argv[i]));
|
||||
if (!strcmp(argv[i], "legacyF12")) {
|
||||
legacyF12 = TRUE;
|
||||
#if BX_DEBUGGER
|
||||
} else if (!strcmp(argv[i], "windebug")) {
|
||||
SIM->set_debug_gui(1);
|
||||
#endif
|
||||
} else {
|
||||
BX_PANIC(("Unknown win32 option '%s'", argv[i]));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: win32dialog.cc,v 1.49 2006-08-29 20:10:26 vruppert Exp $
|
||||
// $Id: win32dialog.cc,v 1.50 2006-11-12 10:07:18 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config.h"
|
||||
@ -23,6 +23,9 @@ const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation",
|
||||
static int retcode = 0;
|
||||
static bxevent_handler old_callback = NULL;
|
||||
static void *old_callback_arg = NULL;
|
||||
#if BX_DEBUGGER
|
||||
static char debug_msg[1024];
|
||||
#endif
|
||||
|
||||
int AskFilename(HWND hwnd, bx_param_filename_c *param, const char *ext);
|
||||
|
||||
@ -30,7 +33,7 @@ HWND GetBochsWindow()
|
||||
{
|
||||
HWND hwnd;
|
||||
|
||||
hwnd = FindWindow("Bochs for Windows - Display", NULL);
|
||||
hwnd = FindWindow("Bochs for Windows", NULL);
|
||||
if (hwnd == NULL) {
|
||||
hwnd = GetForegroundWindow();
|
||||
}
|
||||
@ -891,6 +894,60 @@ int RuntimeOptionsDialog()
|
||||
return retcode;
|
||||
}
|
||||
|
||||
#if BX_DEBUGGER
|
||||
static BOOL CALLBACK DebuggerDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static char *buffer;
|
||||
int i, j;
|
||||
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
buffer = (char *)lParam;
|
||||
for (i = 0; i < lstrlen(debug_msg); i++) {
|
||||
if (debug_msg[i] == 10) {
|
||||
for (j = lstrlen(debug_msg); j >= i; j--) debug_msg[j+1] = debug_msg[j];
|
||||
debug_msg[i] = 13;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
SendMessage(GetDlgItem(hDlg, DEBUG_MSG), WM_SETTEXT, 0, (LPARAM)debug_msg);
|
||||
debug_msg[0] = 0;
|
||||
SetFocus(GetDlgItem(hDlg, DEBUG_CMD));
|
||||
return FALSE;
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
lstrcpy(buffer, "q");
|
||||
EndDialog(hDlg, 0);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
GetDlgItemText(hDlg, DEBUG_CMD, buffer, 512);
|
||||
if (lstrlen(buffer) > 0) {
|
||||
EndDialog(hDlg, 1);
|
||||
} else {
|
||||
SetFocus(GetDlgItem(hDlg, DEBUG_CMD));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
int DebugControlDialog(char *buffer)
|
||||
{
|
||||
return DialogBoxParam(NULL, MAKEINTRESOURCE(DEBUGGER_DLG), GetBochsWindow(),
|
||||
(DLGPROC)DebuggerDlgProc, (LPARAM)buffer);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int opts;
|
||||
@ -903,6 +960,25 @@ BxEvent* win32_notify_callback(void *unused, BxEvent *event)
|
||||
case BX_SYNC_EVT_LOG_ASK:
|
||||
LogAskDialog(event);
|
||||
return event;
|
||||
#if BX_DEBUGGER
|
||||
case BX_SYNC_EVT_GET_DBG_COMMAND:
|
||||
{
|
||||
char *cmd = new char[512];
|
||||
DebugControlDialog(cmd);
|
||||
event->u.debugcmd.command = cmd;
|
||||
event->retcode = 1;
|
||||
return event;
|
||||
}
|
||||
case BX_ASYNC_EVT_DBG_MSG:
|
||||
if (lstrlen(debug_msg) + lstrlen((char*)event->u.logmsg.msg) < 1023) {
|
||||
lstrcat(debug_msg, (char*)event->u.logmsg.msg);
|
||||
} else {
|
||||
lstrcpy(debug_msg, (char*)event->u.logmsg.msg);
|
||||
}
|
||||
// free the char* which was allocated in dbg_printf
|
||||
delete [] ((char*)event->u.logmsg.msg);
|
||||
return event;
|
||||
#endif
|
||||
case BX_SYNC_EVT_ASK_PARAM:
|
||||
param = event->u.param.param;
|
||||
if (param->get_type() == BXT_PARAM_STRING) {
|
||||
@ -933,8 +1009,12 @@ BxEvent* win32_notify_callback(void *unused, BxEvent *event)
|
||||
event->retcode = 0;
|
||||
return event;
|
||||
}
|
||||
case BX_ASYNC_EVT_REFRESH:
|
||||
#if BX_DEBUGGER
|
||||
RefreshDebugDialog();
|
||||
return event;
|
||||
#endif
|
||||
case BX_SYNC_EVT_TICK: // called periodically by siminterface.
|
||||
case BX_ASYNC_EVT_REFRESH: // called when some bx_param_c parameters have changed.
|
||||
// fall into default case
|
||||
default:
|
||||
return (*old_callback)(old_callback_arg, event);
|
||||
@ -943,6 +1023,9 @@ BxEvent* win32_notify_callback(void *unused, BxEvent *event)
|
||||
|
||||
void win32_init_notify_callback()
|
||||
{
|
||||
#if BX_DEBUGGER
|
||||
debug_msg[0] = 0;
|
||||
#endif
|
||||
SIM->get_notify_callback(&old_callback, &old_callback_arg);
|
||||
assert (old_callback != NULL);
|
||||
SIM->set_notify_callback(win32_notify_callback, NULL);
|
||||
|
@ -76,3 +76,6 @@
|
||||
#define IDUSBOPT1 2630
|
||||
#define IDUSBDEV2 2640
|
||||
#define IDUSBOPT2 2650
|
||||
#define DEBUGGER_DLG 3000
|
||||
#define DEBUG_MSG 3010
|
||||
#define DEBUG_CMD 3020
|
||||
|
@ -145,3 +145,13 @@ BEGIN
|
||||
EDITTEXT IDSBLOGLEV, 85, 125, 70, 14, ES_NUMBER
|
||||
END
|
||||
|
||||
DEBUGGER_DLG DIALOG 30, 30, 250, 195
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Debug Control"
|
||||
FONT 8, "Helv"
|
||||
BEGIN
|
||||
EDITTEXT DEBUG_MSG, 15, 15, 220, 120, ES_MULTILINE | ES_READONLY | WS_HSCROLL | WS_VSCROLL
|
||||
EDITTEXT DEBUG_CMD, 15, 145, 220, 14
|
||||
DEFPUSHBUTTON "Execute", IDOK, 100, 170, 50, 14
|
||||
END
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user