moved debugger notify callback functions to enh_dbg.cc

This commit is contained in:
Volker Ruppert 2013-02-14 21:06:20 +00:00
parent e43ac349a6
commit 5416e462e9
7 changed files with 52 additions and 175 deletions

View File

@ -235,6 +235,13 @@ unsigned short RWPSnapCount;
bx_phy_address WWP_Snapshot[16];
bx_phy_address RWP_Snapshot[16];
char *debug_cmd;
bx_bool debug_cmd_ready;
bx_bool vgaw_refresh;
static bxevent_handler old_callback = NULL;
static void *old_callback_arg = NULL;
short nDock[36] = { // lookup table for alternate DockOrders
0x231, 0x312, 0x231, 0x213, 0x132, 0x132,
0x213, 0x321, 0x123, 0x123, 0x321, 0x312,
@ -3378,14 +3385,58 @@ void ActivateMenuItem (int cmd)
}
}
BxEvent *enh_dbg_notify_callback(void *unused, BxEvent *event)
{
switch (event->type)
{
case BX_SYNC_EVT_GET_DBG_COMMAND:
{
debug_cmd = new char[512];
debug_cmd_ready = 0;
HitBreak();
while (debug_cmd_ready == 0 && bx_user_quit == 0)
{
if (vgaw_refresh != 0) // is the GUI frontend requesting a VGAW refresh?
SIM->refresh_vga();
vgaw_refresh = 0;
#ifdef WIN32
Sleep(10);
#elif BX_HAVE_USLEEP
usleep(10000);
#else
sleep(1);
#endif
}
if (bx_user_quit != 0) {
bx_dbg_exit(0);
}
event->u.debugcmd.command = debug_cmd;
event->retcode = 1;
return event;
}
case BX_ASYNC_EVT_DBG_MSG:
{
ParseIDText(event->u.logmsg.msg);
return event;
}
default:
return (*old_callback)(old_callback_arg, event);
}
}
void InitDebugDialog()
{
// redirect notify callback to the debugger specific code
SIM->get_notify_callback(&old_callback, &old_callback_arg);
assert (old_callback != NULL);
SIM->set_notify_callback(enh_dbg_notify_callback, NULL);
DoAllInit(); // non-os-specific init stuff
OSInit();
}
void CloseDebugDialog()
{
SIM->set_notify_callback(old_callback, old_callback_arg);
CloseDialog();
}

View File

@ -71,8 +71,6 @@ void CloseDialog();
void HitBreak();
void ParseIDText(const char *x);
extern char *debug_cmd;
extern bx_bool debug_cmd_ready;
extern bx_bool vgaw_refresh;
#ifdef WIN32

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2012 The Bochs Project
// Copyright (C) 2002-2013 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -140,12 +140,6 @@ static char sdl_ips_text[20];
static void headerbar_click(int x);
#if !defined(WIN32) && BX_DEBUGGER && BX_DEBUGGER_GUI
BxEvent *sdl_notify_callback (void *unused, BxEvent *event);
static bxevent_handler old_callback = NULL;
static void *old_callback_arg = NULL;
#endif
void switch_to_windowed(void)
{
@ -355,10 +349,6 @@ void bx_sdl_gui_c::specific_init(int argc, char **argv, unsigned header_bar_y)
BX_PANIC(("Config interface 'win32config' is required for gui debugger"));
}
#else
// redirect notify callback to sdl specific code
SIM->get_notify_callback (&old_callback, &old_callback_arg);
assert (old_callback != NULL);
SIM->set_notify_callback (sdl_notify_callback, NULL);
init_debug_dialog();
#endif
#endif
@ -1628,46 +1618,4 @@ void bx_sdl_gui_c::show_ips(Bit32u ips_count)
}
#endif
#if !defined(WIN32) && BX_DEBUGGER && BX_DEBUGGER_GUI
#include "enh_dbg.h"
BxEvent *sdl_notify_callback(void *unused, BxEvent *event)
{
switch (event->type)
{
case BX_SYNC_EVT_GET_DBG_COMMAND:
{
debug_cmd = new char[512];
debug_cmd_ready = 0;
HitBreak();
while (debug_cmd_ready == 0 && bx_user_quit == 0)
{
if (vgaw_refresh != 0) // is the GUI frontend requesting a VGAW refresh?
SIM->refresh_vga();
vgaw_refresh = 0;
#if BX_HAVE_USLEEP
usleep(10000);
#else
sleep(1);
#endif
}
if (bx_user_quit != 0) {
bx_dbg_exit(0);
}
event->u.debugcmd.command = debug_cmd;
event->retcode = 1;
return event;
}
case BX_ASYNC_EVT_DBG_MSG:
{
ParseIDText(event->u.logmsg.msg);
return event;
}
default:
return (*old_callback)(old_callback_arg, event);
}
}
#endif /* if BX_DEBUGGER && BX_DEBUGGER_GUI */
#endif /* if BX_WITH_SDL */

View File

@ -208,13 +208,6 @@ private:
bx_bool save_sr_param(FILE *fp, bx_param_c *node, const char *sr_path, int level);
};
#if BX_DEBUGGER && BX_DEBUGGER_GUI
// FIXME: these probably belong inside the bx_simulator_interface_c structure
char *debug_cmd = NULL;
bx_bool debug_cmd_ready = 0;
bx_bool vgaw_refresh = 0;
#endif
// recursive function to find parameters from the path
static bx_param_c *find_param(const char *full_pname, const char *rest_of_pname, bx_param_c *base)
{

View File

@ -28,11 +28,6 @@
#include "win32paramdlg.h"
const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
#if BX_DEBUGGER
extern char *debug_cmd;
extern bx_bool debug_cmd_ready;
extern bx_bool vgaw_refresh;
#endif
char *backslashes(char *s)
{
@ -765,31 +760,6 @@ BxEvent* win32_notify_callback(void *unused, BxEvent *event)
case BX_SYNC_EVT_LOG_ASK:
LogAskDialog(event);
return event;
#if BX_DEBUGGER && BX_DEBUGGER_GUI
case BX_SYNC_EVT_GET_DBG_COMMAND:
{
// sim is at a "break" -- internal debugger is ready for a command
debug_cmd = new char[512];
debug_cmd_ready = FALSE;
HitBreak();
while (debug_cmd_ready == FALSE && bx_user_quit == 0)
{
if (vgaw_refresh != FALSE) // is the GUI frontend requesting a VGAW refresh?
SIM->refresh_vga();
vgaw_refresh = FALSE;
Sleep(10);
}
if (bx_user_quit != 0) {
bx_dbg_exit(0);
}
event->u.debugcmd.command = debug_cmd;
event->retcode = 1;
return event;
}
case BX_ASYNC_EVT_DBG_MSG:
ParseIDText (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) {

View File

@ -121,11 +121,6 @@ static bx_bool wx_hide_ips = 0;
#if defined (wxHAS_RAW_KEY_CODES) && defined(__WXGTK__)
static Bit32u convertStringToGDKKey (const char *string);
#endif
#if BX_DEBUGGER && BX_DEBUGGER_GUI
BxEvent *wx_notify_callback (void *unused, BxEvent *event);
static bxevent_handler old_callback = NULL;
static void *old_callback_arg = NULL;
#endif
//////////////////////////////////////////////////////////////
@ -1009,10 +1004,6 @@ void bx_wx_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
}
#if BX_DEBUGGER && BX_DEBUGGER_GUI
// redirect notify callback to wx specific code
SIM->get_notify_callback(&old_callback, &old_callback_arg);
assert(old_callback != NULL);
SIM->set_notify_callback(wx_notify_callback, NULL);
#ifdef WIN32
// on Windows the debugger gui must run in a separate thread
DWORD threadID;
@ -1676,7 +1667,6 @@ void bx_wx_gui_c::exit(void)
{
clear_screen();
#if BX_DEBUGGER && BX_DEBUGGER_GUI
SIM->set_notify_callback(old_callback, old_callback_arg);
close_debug_dialog();
#endif
}
@ -1767,47 +1757,4 @@ static Bit32u convertStringToGDKKey (const char *string)
}
#endif
#if BX_DEBUGGER && BX_DEBUGGER_GUI
#include "enh_dbg.h"
BxEvent *wx_notify_callback(void *unused, BxEvent *event)
{
switch (event->type)
{
case BX_SYNC_EVT_GET_DBG_COMMAND:
{
debug_cmd = new char[512];
debug_cmd_ready = 0;
HitBreak();
while (debug_cmd_ready == 0 && bx_user_quit == 0)
{
if (vgaw_refresh != 0) // is the GUI frontend requesting a VGAW refresh?
SIM->refresh_vga();
vgaw_refresh = 0;
#ifdef WIN32
Sleep(10);
#elif BX_HAVE_USLEEP
usleep(10000);
#else
sleep(1);
#endif
}
if (bx_user_quit != 0) {
bx_dbg_exit(0);
}
event->u.debugcmd.command = debug_cmd;
event->retcode = 1;
return event;
}
case BX_ASYNC_EVT_DBG_MSG:
{
ParseIDText(event->u.logmsg.msg);
return event;
}
default:
return (*old_callback)(old_callback_arg, event);
}
}
#endif /* if BX_DEBUGGER && BX_DEBUGGER_GUI */
#endif /* if BX_WITH_WX */

View File

@ -2644,36 +2644,6 @@ BxEvent *x11_notify_callback (void *unused, BxEvent *event)
event->retcode = x11_yesno_dialog((bx_param_bool_c *)param);
return event;
}
#if BX_DEBUGGER && BX_DEBUGGER_GUI
case BX_SYNC_EVT_GET_DBG_COMMAND:
{
debug_cmd = new char[512];
debug_cmd_ready = 0;
HitBreak();
while (debug_cmd_ready == 0 && bx_user_quit == 0)
{
if (vgaw_refresh != 0) // is the GUI frontend requesting a VGAW refresh?
SIM->refresh_vga();
vgaw_refresh = 0;
#if BX_HAVE_USLEEP
usleep(10000);
#else
sleep(1);
#endif
}
if (bx_user_quit != 0) {
bx_dbg_exit(0);
}
event->u.debugcmd.command = debug_cmd;
event->retcode = 1;
return event;
}
case BX_ASYNC_EVT_DBG_MSG:
{
ParseIDText (event->u.logmsg.msg);
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