2003-05-22 00:33:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2003-05-22 00:33:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-02-08 12:05:52 +03:00
|
|
|
//
|
2021-01-21 21:10:40 +03:00
|
|
|
// Copyright (C) 2003-2021 The Bochs Project
|
2009-02-08 12:05:52 +03:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-05-22 00:33:24 +04:00
|
|
|
|
2021-03-26 22:12:09 +03:00
|
|
|
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
|
|
|
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
|
|
|
// is used to know when we are exporting symbols and when we are importing.
|
|
|
|
#define BX_PLUGGABLE
|
|
|
|
|
2008-10-21 17:45:03 +04:00
|
|
|
#include "win32dialog.h"
|
|
|
|
#include "bochs.h"
|
2021-01-31 18:22:58 +03:00
|
|
|
#include "bx_debug/debug.h"
|
2010-02-26 17:18:19 +03:00
|
|
|
#include "param_names.h"
|
2021-01-30 21:47:25 +03:00
|
|
|
#include "gui.h"
|
2003-05-22 00:33:24 +04:00
|
|
|
#include "win32res.h"
|
2009-03-10 22:33:03 +03:00
|
|
|
#include "win32paramdlg.h"
|
2021-03-26 22:12:09 +03:00
|
|
|
#include "plugin.h"
|
2003-05-22 00:33:24 +04:00
|
|
|
|
2020-08-21 18:18:44 +03:00
|
|
|
#if BX_USE_WIN32CONFIG
|
|
|
|
|
2021-03-26 22:12:09 +03:00
|
|
|
static int win32_ci_callback(void *userdata, ci_command_t command);
|
|
|
|
static BxEvent* win32_notify_callback(void *unused, BxEvent *event);
|
|
|
|
|
|
|
|
PLUGIN_ENTRY_FOR_MODULE(win32config)
|
|
|
|
{
|
|
|
|
if (mode == PLUGIN_INIT) {
|
|
|
|
SIM->register_configuration_interface("win32config", win32_ci_callback, NULL);
|
|
|
|
SIM->set_notify_callback(win32_notify_callback, NULL);
|
|
|
|
} else if (mode == PLUGIN_PROBE) {
|
2021-03-27 20:23:31 +03:00
|
|
|
return (int)PLUGTYPE_CI;
|
2021-03-26 22:12:09 +03:00
|
|
|
}
|
|
|
|
return 0; // Success
|
|
|
|
}
|
|
|
|
|
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h
--- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200
+++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100
@@ -2,7 +2,7 @@
// $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2015 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -276,8 +276,9 @@
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
- void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
- void ask (int level, const char *prefix, const char *fmt, va_list ap);
+ void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status);
+ void warn(int level, const char *prefix, const char *fmt, va_list ap);
+ void ask(int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
@@ -334,7 +335,8 @@
void set_log_action(int loglevel, int action);
const char *getlevel(int i) const;
const char *getaction(int i) const;
-
+ int isaction(const char *val) const;
+
protected:
int n_logfn;
#define MAX_LOGFNS 512
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES
--- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100
+++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100
@@ -1,5 +1,8 @@
Changes after 2.6.8 release:
+- General
+ - Added new log action "warn", designed to show a message box on error events.
+
- Configure and compile
- Added Android host platform support.
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc
--- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200
+++ ./config.cc 2016-12-27 19:53:10.461420368 +0100
@@ -2062,15 +2062,8 @@
actstr = strtok(NULL, "");
if (actstr != NULL) {
def_action = !strcmp(module, "action");
- if (!strcmp(actstr, "fatal"))
- action = ACT_FATAL;
- else if (!strcmp (actstr, "report"))
- action = ACT_REPORT;
- else if (!strcmp (actstr, "ignore"))
- action = ACT_IGNORE;
- else if (!strcmp (actstr, "ask"))
- action = ACT_ASK;
- else {
+ action = SIM->is_action_name(actstr);
+ if (action < ACT_IGNORE) {
PARSE_ERR(("%s: %s directive malformed.", context, params[0]));
free(param);
return -1;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc
--- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200
+++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100
@@ -2,7 +2,7 @@
// $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2014-2015 The Bochs Project
+// Copyright (C) 2014-2016 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
@@ -1478,20 +1478,16 @@
SDL_MessageBoxData msgboxdata;
SDL_MessageBoxButtonData buttondata[4];
int level, retcode;
-#if BX_DEBUGGER || BX_GDBSTUB
- int defbtn = 3;
-#else
- int defbtn = 2;
-#endif
char message[512];
level = event->u.logmsg.level;
- sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg);
+ sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
msgboxdata.flags = SDL_MESSAGEBOX_ERROR;
msgboxdata.window = window;
msgboxdata.title = SIM->get_log_level_name(level);
msgboxdata.message = message;
- msgboxdata.numbuttons = defbtn + 1;
+ msgboxdata.numbuttons = 2;
msgboxdata.buttons = buttondata;
msgboxdata.colorScheme = NULL;
buttondata[0].flags = 0;
@@ -1500,14 +1496,18 @@
buttondata[1].flags = 0;
buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS;
buttondata[1].text = "Alwayscont";
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ msgboxdata.numbuttons = 3;
+ buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE;
+ buttondata[2].text = "Quit";
#if BX_DEBUGGER || BX_GDBSTUB
- buttondata[2].flags = 0;
- buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
- buttondata[2].text = "Debugger";
-#endif
- buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
- buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE;
- buttondata[defbtn].text = "Quit";
+ msgboxdata.numbuttons = 4;
+ buttondata[3].flags = 0;
+ buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
+ buttondata[3].text = "Debugger";
+#endif
+ }
if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) {
return -1;
} else {
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc
--- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100
+++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100
@@ -2,7 +2,7 @@
// $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2015 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -100,6 +100,7 @@
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
virtual const char *get_action_name(int action);
+ virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
@@ -123,6 +124,7 @@
virtual void set_notify_callback(bxevent_handler func, void *arg);
virtual void get_notify_callback(bxevent_handler *func, void **arg);
virtual BxEvent* sim_to_ci_event(BxEvent *event);
+ virtual int log_warn(const char *prefix, int level, const char *msg);
virtual int log_ask(const char *prefix, int level, const char *msg);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
@@ -420,6 +422,11 @@
return io->getaction(action);
}
+int bx_real_sim_c::is_action_name(const char *val)
+{
+ return io->isaction(val);
+}
+
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
@@ -575,6 +582,21 @@
}
}
+int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg)
+{
+ BxEvent be;
+ be.type = BX_SYNC_EVT_LOG_ASK;
+ be.u.logmsg.prefix = prefix;
+ be.u.logmsg.level = level;
+ be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN;
+ // default return value in case something goes wrong.
+ be.retcode = BX_LOG_NOTIFY_FAILED;
+ // calling notify
+ sim_to_ci_event(&be);
+ return be.retcode;
+}
+
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg)
{
@@ -583,6 +605,7 @@
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_ASKDLG;
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
@@ -1157,16 +1180,10 @@
} else if (!strncmp(string, "PANIC=", 6)) {
type = LOGLEV_PANIC;
}
- if (!strcmp(string+j, "ignore")) {
- action = ACT_IGNORE;
- } else if (!strcmp(string+j, "report")) {
- action = ACT_REPORT;
- } else if (!strcmp(string+j, "ask")) {
- action = ACT_ASK;
- } else if (!strcmp(string+j, "fatal")) {
- action = ACT_FATAL;
+ action = is_action_name(string+j);
+ if (action >= ACT_IGNORE) {
+ set_log_action(dev, type, action);
}
- set_log_action(dev, type, action);
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h
--- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200
+++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100
@@ -168,6 +168,7 @@
typedef enum {
ACT_IGNORE = 0,
ACT_REPORT,
+ ACT_WARN,
ACT_ASK,
ACT_FATAL,
N_ACT
@@ -178,11 +179,11 @@
// normally all action choices are available for all event types. The exclude
// expression allows some choices to be eliminated if they don't make any
// sense. For example, it would be stupid to ignore a panic.
-#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
- /* can't die or ask, on debug or info events */ \
- (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \
- /* can't ignore panics */ \
- || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
+#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
+ /* can't die, ask or warn, on debug or info events */ \
+ (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \
+ /* can't ignore panics */ \
+ || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
)
// floppy / cdrom media status
@@ -392,6 +393,7 @@
// synchronizing threads, etc. for each.
typedef struct {
Bit8u level;
+ Bit8u flag;
const char *prefix;
const char *msg;
} BxLogMsgEvent;
@@ -419,6 +421,12 @@
BX_LOG_NOTIFY_FAILED
};
+enum {
+ BX_LOG_ASK_ASKDLG,
+ BX_LOG_ASK_MSGBOX_WARN,
+ BX_LOG_ASK_MSGBOX_QUIT
+};
+
// Event type: BX_SYNC_EVT_GET_DBG_COMMAND
//
// This is a synchronous event sent from the simulator to the debugger
@@ -675,6 +683,7 @@
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual const char *get_action_name(int action) {return NULL;}
+ virtual int is_action_name(const char *val) {return -1;}
virtual const char *get_log_level_name(int level) {return NULL;}
virtual int get_max_log_level() {return -1;}
@@ -715,6 +724,9 @@
// send an event from the simulator to the CI.
virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;}
+ // called from simulator when it hits errors, to warn the user
+ // before continuing simulation
+ virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;}
// called from simulator when it hits serious errors, to ask if the user
// wants to continue or not
virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc
--- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100
+++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100
@@ -2,7 +2,7 @@
// $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2013 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -552,8 +552,8 @@
}
static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] ";
-static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" };
-static int log_level_n_choices_normal = 4;
+static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" };
+static int log_level_n_choices_normal = N_ACT;
void bx_log_options(int individual)
{
@@ -589,7 +589,7 @@
bx_print_log_action_table();
for (int level=0; level<SIM->get_max_log_level(); level++) {
char prompt[1024];
- int action, default_action = 4; // default to no change
+ int action, default_action = N_ACT; // default to no change
sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level));
// do show the no change choice (choices=4)
if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0)
@@ -718,47 +718,50 @@
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
- {
- int level = event->u.logmsg.level;
- fprintf(stderr, "========================================================================\n");
- fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
- fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
- fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
- fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
- fprintf(stderr, " cont - continue execution\n");
- fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
- fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
- fprintf(stderr, " die - stop execution now\n");
- fprintf(stderr, " abort - dump core %s\n",
- BX_HAVE_ABORT ? "" : "(Disabled)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ int level = event->u.logmsg.level;
+ fprintf(stderr, "========================================================================\n");
+ fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
+ fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
+ fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
+ fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
+ fprintf(stderr, " cont - continue execution\n");
+ fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
+ fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
+ fprintf(stderr, " die - stop execution now\n");
+ fprintf(stderr, " abort - dump core %s\n",
+ BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
- fprintf(stderr, " debug - continue and return to bochs debugger\n");
+ fprintf(stderr, " debug - continue and return to bochs debugger\n");
#endif
#if BX_GDBSTUB
- fprintf(stderr, " debug - hand control to gdb\n");
+ fprintf(stderr, " debug - hand control to gdb\n");
#endif
- int choice;
+ int choice;
ask:
- if (ask_menu("Choose one of the actions above: [%s] ", "",
- log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
- event->retcode = -1;
- // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
- if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
- fflush(stdout);
- fflush(stderr);
- event->retcode = choice;
- }
- return event;
- case BX_ASYNC_EVT_REFRESH:
- case BX_ASYNC_EVT_DBG_MSG:
- case BX_ASYNC_EVT_LOG_MSG:
- // The text mode interface does not use these events, so just ignore
- // them.
- return event;
- default:
- fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
- return event;
+ if (ask_menu("Choose one of the actions above: [%s] ", "",
+ log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
+ event->retcode = -1;
+ // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
+ if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
+ fflush(stdout);
+ fflush(stderr);
+ event->retcode = choice;
+ } else {
+ // warning prompt not implemented
+ event->retcode = 0;
+ }
+ return event;
+ case BX_ASYNC_EVT_REFRESH:
+ case BX_ASYNC_EVT_DBG_MSG:
+ case BX_ASYNC_EVT_LOG_MSG:
+ // The text mode interface does not use these events, so just ignore
+ // them.
+ return event;
+ default:
+ fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
+ return event;
}
assert(0); // switch statement should return
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc
--- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200
+++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100
@@ -2,7 +2,7 @@
// $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2003-2014 The Bochs Project
+// Copyright (C) 2003-2016 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
@@ -27,7 +27,7 @@
#include "win32res.h"
#include "win32paramdlg.h"
-const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
+const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
HWND GetBochsWindow()
{
@@ -97,12 +97,16 @@
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
#endif
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ } else {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
+ }
SetFocus(GetDlgItem(hDlg, IDASKLIST));
return FALSE;
case WM_CLOSE:
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc
--- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100
+++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -208,7 +208,6 @@
: wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
- //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3};
static wxString names[] = ADVLOG_OPTS_TYPE_NAMES;
SetTitle(ADVLOG_OPTS_TITLE);
vertSizer = new wxBoxSizer(wxVERTICAL);
@@ -1563,7 +1562,7 @@
bool includeNoChange)
{
static wxString choices[] = LOG_OPTS_CHOICES;
- static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4};
+ static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5};
wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize);
int lastChoice = 0; // remember index of last choice
int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h
--- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100
+++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $
////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -354,10 +354,10 @@
#define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?")
#define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") }
#define LOG_OPTS_N_TYPES 4
-#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
-#define LOG_OPTS_N_CHOICES_NORMAL 4
-#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change"
-#define LOG_OPTS_NO_CHANGE 4 // index of "no change"
+#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
+#define LOG_OPTS_N_CHOICES_NORMAL 5
+#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change"
+#define LOG_OPTS_NO_CHANGE 5 // index of "no change"
#define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".")
wxFlexGridSizer *gridSizer;
wxChoice *action[LOG_OPTS_N_TYPES];
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc
--- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100
+++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100
@@ -2,7 +2,7 @@
// $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -1158,6 +1158,10 @@
#if !BX_DEBUGGER && !BX_GDBSTUB
dlg.EnableButton(dlg.DEBUG, FALSE);
#endif
+ if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) {
+ dlg.EnableButton(dlg.DIE, FALSE);
+ dlg.EnableButton(dlg.DUMP, FALSE);
+ }
dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8));
dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8));
int n = dlg.ShowModal();
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc
--- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100
+++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100
@@ -2687,11 +2687,7 @@
} else {
size_x = 30 + maxlen * 6;
}
- if (lines < 3) {
- size_y = 90;
- } else {
- size_y = 60 + lines * 15;
- }
+ size_y = 70 + lines * 15;
x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y,
(mode == XDLG_SIMPLE) ? 1 : 2);
ypos = 34;
@@ -2729,11 +2725,21 @@
bx_param_string_c *sparam;
bx_param_enum_c *eparam;
bx_list_c *list;
+ char message[256];
switch (event->type)
{
case BX_SYNC_EVT_LOG_ASK:
- event->retcode = x11_ask_dialog(event);
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ event->retcode = x11_ask_dialog(event);
+ } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) {
+ const char *title = SIM->get_log_level_name(event->u.logmsg.level);
+ sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
+ bx_param_bool_c bparam(NULL, "warn", title, message, 1);
+ x11_message_box(&bparam, XDLG_SIMPLE);
+ event->retcode = 0;
+ }
return event;
case BX_SYNC_EVT_ASK_PARAM:
param = event->u.param.param;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc
--- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200
+++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100
@@ -2,7 +2,7 @@
// $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -50,11 +50,25 @@
else return "?";
}
+static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" };
+
const char* iofunctions::getaction(int i) const
{
- static const char *name[] = { "ignore", "report", "ask", "fatal" };
assert (i>=ACT_IGNORE && i<N_ACT);
- return name[i];
+ return act_name[i];
+}
+
+int iofunctions::isaction(const char *val) const
+{
+ int action = -1;
+
+ for (int i = 0; i < N_ACT; i++) {
+ if (!strcmp(val, act_name[i])) {
+ action = ACT_IGNORE + i;
+ break;
+ }
+ }
+ return action;
}
void iofunctions::flush(void)
@@ -414,6 +428,11 @@
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_ERROR] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_ERROR, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_ERROR] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_ERROR, prefix, fmt, ap);
@@ -438,6 +457,11 @@
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_PANIC] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_PANIC, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_PANIC] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_PANIC, prefix, fmt, ap);
@@ -465,6 +489,36 @@
// the actions ask() and fatal() are not supported here
}
+void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap)
+{
+ // Guard against reentry on warn() function. The danger is that some
+ // function that's called within warn() could trigger another
+ // BX_ERROR that could call warn() again, leading to infinite
+ // recursion and infinite asks.
+ static char in_warn_already = 0;
+ char buf1[1024];
+ if (in_warn_already) {
+ fprintf(stderr, "logfunctions::warn() should not reenter!!\n");
+ return;
+ }
+ in_warn_already = 1;
+ vsnprintf(buf1, sizeof(buf1), fmt, ap);
+ // FIXME: facility set to 0 because it's unknown.
+
+ // update vga screen. This is useful because sometimes useful messages
+ // are printed on the screen just before a panic. It's also potentially
+ // dangerous if this function calls ask again... That's why I added
+ // the reentry check above.
+ SIM->refresh_vga();
+
+ // ensure the text screen is showing
+ SIM->set_display_mode(DISP_MODE_CONFIG);
+ SIM->log_warn(prefix, level, buf1);
+ // return to simulation mode
+ SIM->set_display_mode(DISP_MODE_SIM);
+ in_warn_already = 0;
+}
+
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
{
// Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
|
|
|
const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
|
2005-10-22 15:00:00 +04:00
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
HWND GetBochsWindow()
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
|
2006-11-12 13:07:18 +03:00
|
|
|
hwnd = FindWindow("Bochs for Windows", NULL);
|
2003-05-22 00:33:24 +04:00
|
|
|
if (hwnd == NULL) {
|
|
|
|
hwnd = GetForegroundWindow();
|
|
|
|
}
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
2006-05-29 22:52:46 +04:00
|
|
|
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
if (uMsg == BFFM_INITIALIZED) {
|
|
|
|
GetCurrentDirectory(MAX_PATH, path);
|
|
|
|
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)path);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-06 18:05:08 +03:00
|
|
|
#ifndef BIF_NEWDIALOGSTYLE
|
|
|
|
#define BIF_NEWDIALOGSTYLE 0
|
|
|
|
#endif
|
|
|
|
|
2006-04-09 17:55:55 +04:00
|
|
|
int BrowseDir(const char *Title, char *result)
|
|
|
|
{
|
|
|
|
BROWSEINFO browseInfo;
|
|
|
|
LPITEMIDLIST ItemIDList;
|
2006-08-30 00:10:27 +04:00
|
|
|
int r = -1;
|
2006-04-09 17:55:55 +04:00
|
|
|
|
|
|
|
memset(&browseInfo,0,sizeof(BROWSEINFO));
|
2009-03-24 19:28:03 +03:00
|
|
|
browseInfo.hwndOwner = GetBochsWindow();
|
2006-04-09 17:55:55 +04:00
|
|
|
browseInfo.pszDisplayName = result;
|
|
|
|
browseInfo.lpszTitle = (LPCSTR)Title;
|
|
|
|
browseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
|
2006-05-29 22:52:46 +04:00
|
|
|
browseInfo.lpfn = BrowseCallbackProc;
|
2006-04-09 17:55:55 +04:00
|
|
|
ItemIDList = SHBrowseForFolder(&browseInfo);
|
|
|
|
if (ItemIDList != NULL) {
|
|
|
|
*result = 0;
|
|
|
|
if (SHGetPathFromIDList(ItemIDList, result)) {
|
2006-08-30 00:10:27 +04:00
|
|
|
if (result[0]) r = 0;
|
2006-04-09 17:55:55 +04:00
|
|
|
}
|
|
|
|
// free memory used
|
|
|
|
IMalloc * imalloc = 0;
|
|
|
|
if (SUCCEEDED(SHGetMalloc(&imalloc))) {
|
|
|
|
imalloc->Free(ItemIDList);
|
|
|
|
imalloc->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
static BOOL CALLBACK LogAskProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
BxEvent *event;
|
|
|
|
int level;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
event = (BxEvent*)lParam;
|
|
|
|
level = event->u.logmsg.level;
|
|
|
|
SetWindowText(hDlg, SIM->get_log_level_name(level));
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDASKDEV), event->u.logmsg.prefix);
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
|
2016-12-29 12:47:07 +03:00
|
|
|
if (event->u.logmsg.mode == BX_LOG_DLG_ASK) {
|
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h
--- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200
+++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100
@@ -2,7 +2,7 @@
// $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2015 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -276,8 +276,9 @@
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
- void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
- void ask (int level, const char *prefix, const char *fmt, va_list ap);
+ void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status);
+ void warn(int level, const char *prefix, const char *fmt, va_list ap);
+ void ask(int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
@@ -334,7 +335,8 @@
void set_log_action(int loglevel, int action);
const char *getlevel(int i) const;
const char *getaction(int i) const;
-
+ int isaction(const char *val) const;
+
protected:
int n_logfn;
#define MAX_LOGFNS 512
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES
--- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100
+++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100
@@ -1,5 +1,8 @@
Changes after 2.6.8 release:
+- General
+ - Added new log action "warn", designed to show a message box on error events.
+
- Configure and compile
- Added Android host platform support.
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc
--- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200
+++ ./config.cc 2016-12-27 19:53:10.461420368 +0100
@@ -2062,15 +2062,8 @@
actstr = strtok(NULL, "");
if (actstr != NULL) {
def_action = !strcmp(module, "action");
- if (!strcmp(actstr, "fatal"))
- action = ACT_FATAL;
- else if (!strcmp (actstr, "report"))
- action = ACT_REPORT;
- else if (!strcmp (actstr, "ignore"))
- action = ACT_IGNORE;
- else if (!strcmp (actstr, "ask"))
- action = ACT_ASK;
- else {
+ action = SIM->is_action_name(actstr);
+ if (action < ACT_IGNORE) {
PARSE_ERR(("%s: %s directive malformed.", context, params[0]));
free(param);
return -1;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc
--- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200
+++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100
@@ -2,7 +2,7 @@
// $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2014-2015 The Bochs Project
+// Copyright (C) 2014-2016 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
@@ -1478,20 +1478,16 @@
SDL_MessageBoxData msgboxdata;
SDL_MessageBoxButtonData buttondata[4];
int level, retcode;
-#if BX_DEBUGGER || BX_GDBSTUB
- int defbtn = 3;
-#else
- int defbtn = 2;
-#endif
char message[512];
level = event->u.logmsg.level;
- sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg);
+ sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
msgboxdata.flags = SDL_MESSAGEBOX_ERROR;
msgboxdata.window = window;
msgboxdata.title = SIM->get_log_level_name(level);
msgboxdata.message = message;
- msgboxdata.numbuttons = defbtn + 1;
+ msgboxdata.numbuttons = 2;
msgboxdata.buttons = buttondata;
msgboxdata.colorScheme = NULL;
buttondata[0].flags = 0;
@@ -1500,14 +1496,18 @@
buttondata[1].flags = 0;
buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS;
buttondata[1].text = "Alwayscont";
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ msgboxdata.numbuttons = 3;
+ buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE;
+ buttondata[2].text = "Quit";
#if BX_DEBUGGER || BX_GDBSTUB
- buttondata[2].flags = 0;
- buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
- buttondata[2].text = "Debugger";
-#endif
- buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
- buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE;
- buttondata[defbtn].text = "Quit";
+ msgboxdata.numbuttons = 4;
+ buttondata[3].flags = 0;
+ buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
+ buttondata[3].text = "Debugger";
+#endif
+ }
if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) {
return -1;
} else {
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc
--- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100
+++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100
@@ -2,7 +2,7 @@
// $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2015 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -100,6 +100,7 @@
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
virtual const char *get_action_name(int action);
+ virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
@@ -123,6 +124,7 @@
virtual void set_notify_callback(bxevent_handler func, void *arg);
virtual void get_notify_callback(bxevent_handler *func, void **arg);
virtual BxEvent* sim_to_ci_event(BxEvent *event);
+ virtual int log_warn(const char *prefix, int level, const char *msg);
virtual int log_ask(const char *prefix, int level, const char *msg);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
@@ -420,6 +422,11 @@
return io->getaction(action);
}
+int bx_real_sim_c::is_action_name(const char *val)
+{
+ return io->isaction(val);
+}
+
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
@@ -575,6 +582,21 @@
}
}
+int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg)
+{
+ BxEvent be;
+ be.type = BX_SYNC_EVT_LOG_ASK;
+ be.u.logmsg.prefix = prefix;
+ be.u.logmsg.level = level;
+ be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN;
+ // default return value in case something goes wrong.
+ be.retcode = BX_LOG_NOTIFY_FAILED;
+ // calling notify
+ sim_to_ci_event(&be);
+ return be.retcode;
+}
+
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg)
{
@@ -583,6 +605,7 @@
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_ASKDLG;
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
@@ -1157,16 +1180,10 @@
} else if (!strncmp(string, "PANIC=", 6)) {
type = LOGLEV_PANIC;
}
- if (!strcmp(string+j, "ignore")) {
- action = ACT_IGNORE;
- } else if (!strcmp(string+j, "report")) {
- action = ACT_REPORT;
- } else if (!strcmp(string+j, "ask")) {
- action = ACT_ASK;
- } else if (!strcmp(string+j, "fatal")) {
- action = ACT_FATAL;
+ action = is_action_name(string+j);
+ if (action >= ACT_IGNORE) {
+ set_log_action(dev, type, action);
}
- set_log_action(dev, type, action);
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h
--- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200
+++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100
@@ -168,6 +168,7 @@
typedef enum {
ACT_IGNORE = 0,
ACT_REPORT,
+ ACT_WARN,
ACT_ASK,
ACT_FATAL,
N_ACT
@@ -178,11 +179,11 @@
// normally all action choices are available for all event types. The exclude
// expression allows some choices to be eliminated if they don't make any
// sense. For example, it would be stupid to ignore a panic.
-#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
- /* can't die or ask, on debug or info events */ \
- (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \
- /* can't ignore panics */ \
- || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
+#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
+ /* can't die, ask or warn, on debug or info events */ \
+ (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \
+ /* can't ignore panics */ \
+ || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
)
// floppy / cdrom media status
@@ -392,6 +393,7 @@
// synchronizing threads, etc. for each.
typedef struct {
Bit8u level;
+ Bit8u flag;
const char *prefix;
const char *msg;
} BxLogMsgEvent;
@@ -419,6 +421,12 @@
BX_LOG_NOTIFY_FAILED
};
+enum {
+ BX_LOG_ASK_ASKDLG,
+ BX_LOG_ASK_MSGBOX_WARN,
+ BX_LOG_ASK_MSGBOX_QUIT
+};
+
// Event type: BX_SYNC_EVT_GET_DBG_COMMAND
//
// This is a synchronous event sent from the simulator to the debugger
@@ -675,6 +683,7 @@
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual const char *get_action_name(int action) {return NULL;}
+ virtual int is_action_name(const char *val) {return -1;}
virtual const char *get_log_level_name(int level) {return NULL;}
virtual int get_max_log_level() {return -1;}
@@ -715,6 +724,9 @@
// send an event from the simulator to the CI.
virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;}
+ // called from simulator when it hits errors, to warn the user
+ // before continuing simulation
+ virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;}
// called from simulator when it hits serious errors, to ask if the user
// wants to continue or not
virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc
--- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100
+++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100
@@ -2,7 +2,7 @@
// $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2013 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -552,8 +552,8 @@
}
static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] ";
-static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" };
-static int log_level_n_choices_normal = 4;
+static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" };
+static int log_level_n_choices_normal = N_ACT;
void bx_log_options(int individual)
{
@@ -589,7 +589,7 @@
bx_print_log_action_table();
for (int level=0; level<SIM->get_max_log_level(); level++) {
char prompt[1024];
- int action, default_action = 4; // default to no change
+ int action, default_action = N_ACT; // default to no change
sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level));
// do show the no change choice (choices=4)
if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0)
@@ -718,47 +718,50 @@
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
- {
- int level = event->u.logmsg.level;
- fprintf(stderr, "========================================================================\n");
- fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
- fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
- fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
- fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
- fprintf(stderr, " cont - continue execution\n");
- fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
- fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
- fprintf(stderr, " die - stop execution now\n");
- fprintf(stderr, " abort - dump core %s\n",
- BX_HAVE_ABORT ? "" : "(Disabled)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ int level = event->u.logmsg.level;
+ fprintf(stderr, "========================================================================\n");
+ fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
+ fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
+ fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
+ fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
+ fprintf(stderr, " cont - continue execution\n");
+ fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
+ fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
+ fprintf(stderr, " die - stop execution now\n");
+ fprintf(stderr, " abort - dump core %s\n",
+ BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
- fprintf(stderr, " debug - continue and return to bochs debugger\n");
+ fprintf(stderr, " debug - continue and return to bochs debugger\n");
#endif
#if BX_GDBSTUB
- fprintf(stderr, " debug - hand control to gdb\n");
+ fprintf(stderr, " debug - hand control to gdb\n");
#endif
- int choice;
+ int choice;
ask:
- if (ask_menu("Choose one of the actions above: [%s] ", "",
- log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
- event->retcode = -1;
- // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
- if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
- fflush(stdout);
- fflush(stderr);
- event->retcode = choice;
- }
- return event;
- case BX_ASYNC_EVT_REFRESH:
- case BX_ASYNC_EVT_DBG_MSG:
- case BX_ASYNC_EVT_LOG_MSG:
- // The text mode interface does not use these events, so just ignore
- // them.
- return event;
- default:
- fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
- return event;
+ if (ask_menu("Choose one of the actions above: [%s] ", "",
+ log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
+ event->retcode = -1;
+ // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
+ if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
+ fflush(stdout);
+ fflush(stderr);
+ event->retcode = choice;
+ } else {
+ // warning prompt not implemented
+ event->retcode = 0;
+ }
+ return event;
+ case BX_ASYNC_EVT_REFRESH:
+ case BX_ASYNC_EVT_DBG_MSG:
+ case BX_ASYNC_EVT_LOG_MSG:
+ // The text mode interface does not use these events, so just ignore
+ // them.
+ return event;
+ default:
+ fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
+ return event;
}
assert(0); // switch statement should return
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc
--- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200
+++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100
@@ -2,7 +2,7 @@
// $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2003-2014 The Bochs Project
+// Copyright (C) 2003-2016 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
@@ -27,7 +27,7 @@
#include "win32res.h"
#include "win32paramdlg.h"
-const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
+const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
HWND GetBochsWindow()
{
@@ -97,12 +97,16 @@
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
#endif
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ } else {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
+ }
SetFocus(GetDlgItem(hDlg, IDASKLIST));
return FALSE;
case WM_CLOSE:
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc
--- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100
+++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -208,7 +208,6 @@
: wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
- //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3};
static wxString names[] = ADVLOG_OPTS_TYPE_NAMES;
SetTitle(ADVLOG_OPTS_TITLE);
vertSizer = new wxBoxSizer(wxVERTICAL);
@@ -1563,7 +1562,7 @@
bool includeNoChange)
{
static wxString choices[] = LOG_OPTS_CHOICES;
- static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4};
+ static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5};
wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize);
int lastChoice = 0; // remember index of last choice
int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h
--- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100
+++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $
////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -354,10 +354,10 @@
#define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?")
#define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") }
#define LOG_OPTS_N_TYPES 4
-#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
-#define LOG_OPTS_N_CHOICES_NORMAL 4
-#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change"
-#define LOG_OPTS_NO_CHANGE 4 // index of "no change"
+#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
+#define LOG_OPTS_N_CHOICES_NORMAL 5
+#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change"
+#define LOG_OPTS_NO_CHANGE 5 // index of "no change"
#define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".")
wxFlexGridSizer *gridSizer;
wxChoice *action[LOG_OPTS_N_TYPES];
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc
--- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100
+++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100
@@ -2,7 +2,7 @@
// $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -1158,6 +1158,10 @@
#if !BX_DEBUGGER && !BX_GDBSTUB
dlg.EnableButton(dlg.DEBUG, FALSE);
#endif
+ if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) {
+ dlg.EnableButton(dlg.DIE, FALSE);
+ dlg.EnableButton(dlg.DUMP, FALSE);
+ }
dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8));
dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8));
int n = dlg.ShowModal();
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc
--- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100
+++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100
@@ -2687,11 +2687,7 @@
} else {
size_x = 30 + maxlen * 6;
}
- if (lines < 3) {
- size_y = 90;
- } else {
- size_y = 60 + lines * 15;
- }
+ size_y = 70 + lines * 15;
x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y,
(mode == XDLG_SIMPLE) ? 1 : 2);
ypos = 34;
@@ -2729,11 +2725,21 @@
bx_param_string_c *sparam;
bx_param_enum_c *eparam;
bx_list_c *list;
+ char message[256];
switch (event->type)
{
case BX_SYNC_EVT_LOG_ASK:
- event->retcode = x11_ask_dialog(event);
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ event->retcode = x11_ask_dialog(event);
+ } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) {
+ const char *title = SIM->get_log_level_name(event->u.logmsg.level);
+ sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
+ bx_param_bool_c bparam(NULL, "warn", title, message, 1);
+ x11_message_box(&bparam, XDLG_SIMPLE);
+ event->retcode = 0;
+ }
return event;
case BX_SYNC_EVT_ASK_PARAM:
param = event->u.param.param;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc
--- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200
+++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100
@@ -2,7 +2,7 @@
// $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -50,11 +50,25 @@
else return "?";
}
+static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" };
+
const char* iofunctions::getaction(int i) const
{
- static const char *name[] = { "ignore", "report", "ask", "fatal" };
assert (i>=ACT_IGNORE && i<N_ACT);
- return name[i];
+ return act_name[i];
+}
+
+int iofunctions::isaction(const char *val) const
+{
+ int action = -1;
+
+ for (int i = 0; i < N_ACT; i++) {
+ if (!strcmp(val, act_name[i])) {
+ action = ACT_IGNORE + i;
+ break;
+ }
+ }
+ return action;
}
void iofunctions::flush(void)
@@ -414,6 +428,11 @@
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_ERROR] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_ERROR, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_ERROR] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_ERROR, prefix, fmt, ap);
@@ -438,6 +457,11 @@
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_PANIC] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_PANIC, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_PANIC] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_PANIC, prefix, fmt, ap);
@@ -465,6 +489,36 @@
// the actions ask() and fatal() are not supported here
}
+void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap)
+{
+ // Guard against reentry on warn() function. The danger is that some
+ // function that's called within warn() could trigger another
+ // BX_ERROR that could call warn() again, leading to infinite
+ // recursion and infinite asks.
+ static char in_warn_already = 0;
+ char buf1[1024];
+ if (in_warn_already) {
+ fprintf(stderr, "logfunctions::warn() should not reenter!!\n");
+ return;
+ }
+ in_warn_already = 1;
+ vsnprintf(buf1, sizeof(buf1), fmt, ap);
+ // FIXME: facility set to 0 because it's unknown.
+
+ // update vga screen. This is useful because sometimes useful messages
+ // are printed on the screen just before a panic. It's also potentially
+ // dangerous if this function calls ask again... That's why I added
+ // the reentry check above.
+ SIM->refresh_vga();
+
+ // ensure the text screen is showing
+ SIM->set_display_mode(DISP_MODE_CONFIG);
+ SIM->log_warn(prefix, level, buf1);
+ // return to simulation mode
+ SIM->set_display_mode(DISP_MODE_SIM);
+ in_warn_already = 0;
+}
+
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
{
// Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
|
2003-05-22 00:33:24 +04:00
|
|
|
#if BX_DEBUGGER
|
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h
--- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200
+++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100
@@ -2,7 +2,7 @@
// $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2015 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -276,8 +276,9 @@
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
- void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
- void ask (int level, const char *prefix, const char *fmt, va_list ap);
+ void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status);
+ void warn(int level, const char *prefix, const char *fmt, va_list ap);
+ void ask(int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
@@ -334,7 +335,8 @@
void set_log_action(int loglevel, int action);
const char *getlevel(int i) const;
const char *getaction(int i) const;
-
+ int isaction(const char *val) const;
+
protected:
int n_logfn;
#define MAX_LOGFNS 512
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES
--- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100
+++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100
@@ -1,5 +1,8 @@
Changes after 2.6.8 release:
+- General
+ - Added new log action "warn", designed to show a message box on error events.
+
- Configure and compile
- Added Android host platform support.
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc
--- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200
+++ ./config.cc 2016-12-27 19:53:10.461420368 +0100
@@ -2062,15 +2062,8 @@
actstr = strtok(NULL, "");
if (actstr != NULL) {
def_action = !strcmp(module, "action");
- if (!strcmp(actstr, "fatal"))
- action = ACT_FATAL;
- else if (!strcmp (actstr, "report"))
- action = ACT_REPORT;
- else if (!strcmp (actstr, "ignore"))
- action = ACT_IGNORE;
- else if (!strcmp (actstr, "ask"))
- action = ACT_ASK;
- else {
+ action = SIM->is_action_name(actstr);
+ if (action < ACT_IGNORE) {
PARSE_ERR(("%s: %s directive malformed.", context, params[0]));
free(param);
return -1;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc
--- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200
+++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100
@@ -2,7 +2,7 @@
// $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2014-2015 The Bochs Project
+// Copyright (C) 2014-2016 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
@@ -1478,20 +1478,16 @@
SDL_MessageBoxData msgboxdata;
SDL_MessageBoxButtonData buttondata[4];
int level, retcode;
-#if BX_DEBUGGER || BX_GDBSTUB
- int defbtn = 3;
-#else
- int defbtn = 2;
-#endif
char message[512];
level = event->u.logmsg.level;
- sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg);
+ sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
msgboxdata.flags = SDL_MESSAGEBOX_ERROR;
msgboxdata.window = window;
msgboxdata.title = SIM->get_log_level_name(level);
msgboxdata.message = message;
- msgboxdata.numbuttons = defbtn + 1;
+ msgboxdata.numbuttons = 2;
msgboxdata.buttons = buttondata;
msgboxdata.colorScheme = NULL;
buttondata[0].flags = 0;
@@ -1500,14 +1496,18 @@
buttondata[1].flags = 0;
buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS;
buttondata[1].text = "Alwayscont";
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ msgboxdata.numbuttons = 3;
+ buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE;
+ buttondata[2].text = "Quit";
#if BX_DEBUGGER || BX_GDBSTUB
- buttondata[2].flags = 0;
- buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
- buttondata[2].text = "Debugger";
-#endif
- buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
- buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE;
- buttondata[defbtn].text = "Quit";
+ msgboxdata.numbuttons = 4;
+ buttondata[3].flags = 0;
+ buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
+ buttondata[3].text = "Debugger";
+#endif
+ }
if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) {
return -1;
} else {
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc
--- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100
+++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100
@@ -2,7 +2,7 @@
// $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2015 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -100,6 +100,7 @@
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
virtual const char *get_action_name(int action);
+ virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
@@ -123,6 +124,7 @@
virtual void set_notify_callback(bxevent_handler func, void *arg);
virtual void get_notify_callback(bxevent_handler *func, void **arg);
virtual BxEvent* sim_to_ci_event(BxEvent *event);
+ virtual int log_warn(const char *prefix, int level, const char *msg);
virtual int log_ask(const char *prefix, int level, const char *msg);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
@@ -420,6 +422,11 @@
return io->getaction(action);
}
+int bx_real_sim_c::is_action_name(const char *val)
+{
+ return io->isaction(val);
+}
+
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
@@ -575,6 +582,21 @@
}
}
+int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg)
+{
+ BxEvent be;
+ be.type = BX_SYNC_EVT_LOG_ASK;
+ be.u.logmsg.prefix = prefix;
+ be.u.logmsg.level = level;
+ be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN;
+ // default return value in case something goes wrong.
+ be.retcode = BX_LOG_NOTIFY_FAILED;
+ // calling notify
+ sim_to_ci_event(&be);
+ return be.retcode;
+}
+
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg)
{
@@ -583,6 +605,7 @@
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_ASKDLG;
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
@@ -1157,16 +1180,10 @@
} else if (!strncmp(string, "PANIC=", 6)) {
type = LOGLEV_PANIC;
}
- if (!strcmp(string+j, "ignore")) {
- action = ACT_IGNORE;
- } else if (!strcmp(string+j, "report")) {
- action = ACT_REPORT;
- } else if (!strcmp(string+j, "ask")) {
- action = ACT_ASK;
- } else if (!strcmp(string+j, "fatal")) {
- action = ACT_FATAL;
+ action = is_action_name(string+j);
+ if (action >= ACT_IGNORE) {
+ set_log_action(dev, type, action);
}
- set_log_action(dev, type, action);
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h
--- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200
+++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100
@@ -168,6 +168,7 @@
typedef enum {
ACT_IGNORE = 0,
ACT_REPORT,
+ ACT_WARN,
ACT_ASK,
ACT_FATAL,
N_ACT
@@ -178,11 +179,11 @@
// normally all action choices are available for all event types. The exclude
// expression allows some choices to be eliminated if they don't make any
// sense. For example, it would be stupid to ignore a panic.
-#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
- /* can't die or ask, on debug or info events */ \
- (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \
- /* can't ignore panics */ \
- || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
+#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
+ /* can't die, ask or warn, on debug or info events */ \
+ (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \
+ /* can't ignore panics */ \
+ || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
)
// floppy / cdrom media status
@@ -392,6 +393,7 @@
// synchronizing threads, etc. for each.
typedef struct {
Bit8u level;
+ Bit8u flag;
const char *prefix;
const char *msg;
} BxLogMsgEvent;
@@ -419,6 +421,12 @@
BX_LOG_NOTIFY_FAILED
};
+enum {
+ BX_LOG_ASK_ASKDLG,
+ BX_LOG_ASK_MSGBOX_WARN,
+ BX_LOG_ASK_MSGBOX_QUIT
+};
+
// Event type: BX_SYNC_EVT_GET_DBG_COMMAND
//
// This is a synchronous event sent from the simulator to the debugger
@@ -675,6 +683,7 @@
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual const char *get_action_name(int action) {return NULL;}
+ virtual int is_action_name(const char *val) {return -1;}
virtual const char *get_log_level_name(int level) {return NULL;}
virtual int get_max_log_level() {return -1;}
@@ -715,6 +724,9 @@
// send an event from the simulator to the CI.
virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;}
+ // called from simulator when it hits errors, to warn the user
+ // before continuing simulation
+ virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;}
// called from simulator when it hits serious errors, to ask if the user
// wants to continue or not
virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc
--- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100
+++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100
@@ -2,7 +2,7 @@
// $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2013 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -552,8 +552,8 @@
}
static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] ";
-static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" };
-static int log_level_n_choices_normal = 4;
+static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" };
+static int log_level_n_choices_normal = N_ACT;
void bx_log_options(int individual)
{
@@ -589,7 +589,7 @@
bx_print_log_action_table();
for (int level=0; level<SIM->get_max_log_level(); level++) {
char prompt[1024];
- int action, default_action = 4; // default to no change
+ int action, default_action = N_ACT; // default to no change
sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level));
// do show the no change choice (choices=4)
if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0)
@@ -718,47 +718,50 @@
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
- {
- int level = event->u.logmsg.level;
- fprintf(stderr, "========================================================================\n");
- fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
- fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
- fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
- fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
- fprintf(stderr, " cont - continue execution\n");
- fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
- fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
- fprintf(stderr, " die - stop execution now\n");
- fprintf(stderr, " abort - dump core %s\n",
- BX_HAVE_ABORT ? "" : "(Disabled)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ int level = event->u.logmsg.level;
+ fprintf(stderr, "========================================================================\n");
+ fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
+ fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
+ fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
+ fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
+ fprintf(stderr, " cont - continue execution\n");
+ fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
+ fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
+ fprintf(stderr, " die - stop execution now\n");
+ fprintf(stderr, " abort - dump core %s\n",
+ BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
- fprintf(stderr, " debug - continue and return to bochs debugger\n");
+ fprintf(stderr, " debug - continue and return to bochs debugger\n");
#endif
#if BX_GDBSTUB
- fprintf(stderr, " debug - hand control to gdb\n");
+ fprintf(stderr, " debug - hand control to gdb\n");
#endif
- int choice;
+ int choice;
ask:
- if (ask_menu("Choose one of the actions above: [%s] ", "",
- log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
- event->retcode = -1;
- // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
- if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
- fflush(stdout);
- fflush(stderr);
- event->retcode = choice;
- }
- return event;
- case BX_ASYNC_EVT_REFRESH:
- case BX_ASYNC_EVT_DBG_MSG:
- case BX_ASYNC_EVT_LOG_MSG:
- // The text mode interface does not use these events, so just ignore
- // them.
- return event;
- default:
- fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
- return event;
+ if (ask_menu("Choose one of the actions above: [%s] ", "",
+ log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
+ event->retcode = -1;
+ // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
+ if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
+ fflush(stdout);
+ fflush(stderr);
+ event->retcode = choice;
+ } else {
+ // warning prompt not implemented
+ event->retcode = 0;
+ }
+ return event;
+ case BX_ASYNC_EVT_REFRESH:
+ case BX_ASYNC_EVT_DBG_MSG:
+ case BX_ASYNC_EVT_LOG_MSG:
+ // The text mode interface does not use these events, so just ignore
+ // them.
+ return event;
+ default:
+ fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
+ return event;
}
assert(0); // switch statement should return
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc
--- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200
+++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100
@@ -2,7 +2,7 @@
// $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2003-2014 The Bochs Project
+// Copyright (C) 2003-2016 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
@@ -27,7 +27,7 @@
#include "win32res.h"
#include "win32paramdlg.h"
-const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
+const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
HWND GetBochsWindow()
{
@@ -97,12 +97,16 @@
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
#endif
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ } else {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
+ }
SetFocus(GetDlgItem(hDlg, IDASKLIST));
return FALSE;
case WM_CLOSE:
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc
--- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100
+++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -208,7 +208,6 @@
: wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
- //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3};
static wxString names[] = ADVLOG_OPTS_TYPE_NAMES;
SetTitle(ADVLOG_OPTS_TITLE);
vertSizer = new wxBoxSizer(wxVERTICAL);
@@ -1563,7 +1562,7 @@
bool includeNoChange)
{
static wxString choices[] = LOG_OPTS_CHOICES;
- static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4};
+ static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5};
wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize);
int lastChoice = 0; // remember index of last choice
int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h
--- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100
+++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $
////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -354,10 +354,10 @@
#define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?")
#define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") }
#define LOG_OPTS_N_TYPES 4
-#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
-#define LOG_OPTS_N_CHOICES_NORMAL 4
-#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change"
-#define LOG_OPTS_NO_CHANGE 4 // index of "no change"
+#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
+#define LOG_OPTS_N_CHOICES_NORMAL 5
+#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change"
+#define LOG_OPTS_NO_CHANGE 5 // index of "no change"
#define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".")
wxFlexGridSizer *gridSizer;
wxChoice *action[LOG_OPTS_N_TYPES];
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc
--- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100
+++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100
@@ -2,7 +2,7 @@
// $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -1158,6 +1158,10 @@
#if !BX_DEBUGGER && !BX_GDBSTUB
dlg.EnableButton(dlg.DEBUG, FALSE);
#endif
+ if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) {
+ dlg.EnableButton(dlg.DIE, FALSE);
+ dlg.EnableButton(dlg.DUMP, FALSE);
+ }
dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8));
dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8));
int n = dlg.ShowModal();
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc
--- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100
+++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100
@@ -2687,11 +2687,7 @@
} else {
size_x = 30 + maxlen * 6;
}
- if (lines < 3) {
- size_y = 90;
- } else {
- size_y = 60 + lines * 15;
- }
+ size_y = 70 + lines * 15;
x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y,
(mode == XDLG_SIMPLE) ? 1 : 2);
ypos = 34;
@@ -2729,11 +2725,21 @@
bx_param_string_c *sparam;
bx_param_enum_c *eparam;
bx_list_c *list;
+ char message[256];
switch (event->type)
{
case BX_SYNC_EVT_LOG_ASK:
- event->retcode = x11_ask_dialog(event);
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ event->retcode = x11_ask_dialog(event);
+ } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) {
+ const char *title = SIM->get_log_level_name(event->u.logmsg.level);
+ sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
+ bx_param_bool_c bparam(NULL, "warn", title, message, 1);
+ x11_message_box(&bparam, XDLG_SIMPLE);
+ event->retcode = 0;
+ }
return event;
case BX_SYNC_EVT_ASK_PARAM:
param = event->u.param.param;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc
--- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200
+++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100
@@ -2,7 +2,7 @@
// $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -50,11 +50,25 @@
else return "?";
}
+static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" };
+
const char* iofunctions::getaction(int i) const
{
- static const char *name[] = { "ignore", "report", "ask", "fatal" };
assert (i>=ACT_IGNORE && i<N_ACT);
- return name[i];
+ return act_name[i];
+}
+
+int iofunctions::isaction(const char *val) const
+{
+ int action = -1;
+
+ for (int i = 0; i < N_ACT; i++) {
+ if (!strcmp(val, act_name[i])) {
+ action = ACT_IGNORE + i;
+ break;
+ }
+ }
+ return action;
}
void iofunctions::flush(void)
@@ -414,6 +428,11 @@
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_ERROR] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_ERROR, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_ERROR] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_ERROR, prefix, fmt, ap);
@@ -438,6 +457,11 @@
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_PANIC] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_PANIC, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_PANIC] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_PANIC, prefix, fmt, ap);
@@ -465,6 +489,36 @@
// the actions ask() and fatal() are not supported here
}
+void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap)
+{
+ // Guard against reentry on warn() function. The danger is that some
+ // function that's called within warn() could trigger another
+ // BX_ERROR that could call warn() again, leading to infinite
+ // recursion and infinite asks.
+ static char in_warn_already = 0;
+ char buf1[1024];
+ if (in_warn_already) {
+ fprintf(stderr, "logfunctions::warn() should not reenter!!\n");
+ return;
+ }
+ in_warn_already = 1;
+ vsnprintf(buf1, sizeof(buf1), fmt, ap);
+ // FIXME: facility set to 0 because it's unknown.
+
+ // update vga screen. This is useful because sometimes useful messages
+ // are printed on the screen just before a panic. It's also potentially
+ // dangerous if this function calls ask again... That's why I added
+ // the reentry check above.
+ SIM->refresh_vga();
+
+ // ensure the text screen is showing
+ SIM->set_display_mode(DISP_MODE_CONFIG);
+ SIM->log_warn(prefix, level, buf1);
+ // return to simulation mode
+ SIM->set_display_mode(DISP_MODE_SIM);
+ in_warn_already = 0;
+}
+
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
{
// Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
|
2003-05-22 00:33:24 +04:00
|
|
|
#endif
|
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h
--- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200
+++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100
@@ -2,7 +2,7 @@
// $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2015 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -276,8 +276,9 @@
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
- void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
- void ask (int level, const char *prefix, const char *fmt, va_list ap);
+ void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status);
+ void warn(int level, const char *prefix, const char *fmt, va_list ap);
+ void ask(int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
@@ -334,7 +335,8 @@
void set_log_action(int loglevel, int action);
const char *getlevel(int i) const;
const char *getaction(int i) const;
-
+ int isaction(const char *val) const;
+
protected:
int n_logfn;
#define MAX_LOGFNS 512
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES
--- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100
+++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100
@@ -1,5 +1,8 @@
Changes after 2.6.8 release:
+- General
+ - Added new log action "warn", designed to show a message box on error events.
+
- Configure and compile
- Added Android host platform support.
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc
--- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200
+++ ./config.cc 2016-12-27 19:53:10.461420368 +0100
@@ -2062,15 +2062,8 @@
actstr = strtok(NULL, "");
if (actstr != NULL) {
def_action = !strcmp(module, "action");
- if (!strcmp(actstr, "fatal"))
- action = ACT_FATAL;
- else if (!strcmp (actstr, "report"))
- action = ACT_REPORT;
- else if (!strcmp (actstr, "ignore"))
- action = ACT_IGNORE;
- else if (!strcmp (actstr, "ask"))
- action = ACT_ASK;
- else {
+ action = SIM->is_action_name(actstr);
+ if (action < ACT_IGNORE) {
PARSE_ERR(("%s: %s directive malformed.", context, params[0]));
free(param);
return -1;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc
--- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200
+++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100
@@ -2,7 +2,7 @@
// $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2014-2015 The Bochs Project
+// Copyright (C) 2014-2016 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
@@ -1478,20 +1478,16 @@
SDL_MessageBoxData msgboxdata;
SDL_MessageBoxButtonData buttondata[4];
int level, retcode;
-#if BX_DEBUGGER || BX_GDBSTUB
- int defbtn = 3;
-#else
- int defbtn = 2;
-#endif
char message[512];
level = event->u.logmsg.level;
- sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg);
+ sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
msgboxdata.flags = SDL_MESSAGEBOX_ERROR;
msgboxdata.window = window;
msgboxdata.title = SIM->get_log_level_name(level);
msgboxdata.message = message;
- msgboxdata.numbuttons = defbtn + 1;
+ msgboxdata.numbuttons = 2;
msgboxdata.buttons = buttondata;
msgboxdata.colorScheme = NULL;
buttondata[0].flags = 0;
@@ -1500,14 +1496,18 @@
buttondata[1].flags = 0;
buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS;
buttondata[1].text = "Alwayscont";
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ msgboxdata.numbuttons = 3;
+ buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE;
+ buttondata[2].text = "Quit";
#if BX_DEBUGGER || BX_GDBSTUB
- buttondata[2].flags = 0;
- buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
- buttondata[2].text = "Debugger";
-#endif
- buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
- buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE;
- buttondata[defbtn].text = "Quit";
+ msgboxdata.numbuttons = 4;
+ buttondata[3].flags = 0;
+ buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
+ buttondata[3].text = "Debugger";
+#endif
+ }
if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) {
return -1;
} else {
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc
--- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100
+++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100
@@ -2,7 +2,7 @@
// $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2015 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -100,6 +100,7 @@
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
virtual const char *get_action_name(int action);
+ virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
@@ -123,6 +124,7 @@
virtual void set_notify_callback(bxevent_handler func, void *arg);
virtual void get_notify_callback(bxevent_handler *func, void **arg);
virtual BxEvent* sim_to_ci_event(BxEvent *event);
+ virtual int log_warn(const char *prefix, int level, const char *msg);
virtual int log_ask(const char *prefix, int level, const char *msg);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
@@ -420,6 +422,11 @@
return io->getaction(action);
}
+int bx_real_sim_c::is_action_name(const char *val)
+{
+ return io->isaction(val);
+}
+
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
@@ -575,6 +582,21 @@
}
}
+int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg)
+{
+ BxEvent be;
+ be.type = BX_SYNC_EVT_LOG_ASK;
+ be.u.logmsg.prefix = prefix;
+ be.u.logmsg.level = level;
+ be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN;
+ // default return value in case something goes wrong.
+ be.retcode = BX_LOG_NOTIFY_FAILED;
+ // calling notify
+ sim_to_ci_event(&be);
+ return be.retcode;
+}
+
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg)
{
@@ -583,6 +605,7 @@
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_ASKDLG;
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
@@ -1157,16 +1180,10 @@
} else if (!strncmp(string, "PANIC=", 6)) {
type = LOGLEV_PANIC;
}
- if (!strcmp(string+j, "ignore")) {
- action = ACT_IGNORE;
- } else if (!strcmp(string+j, "report")) {
- action = ACT_REPORT;
- } else if (!strcmp(string+j, "ask")) {
- action = ACT_ASK;
- } else if (!strcmp(string+j, "fatal")) {
- action = ACT_FATAL;
+ action = is_action_name(string+j);
+ if (action >= ACT_IGNORE) {
+ set_log_action(dev, type, action);
}
- set_log_action(dev, type, action);
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h
--- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200
+++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100
@@ -168,6 +168,7 @@
typedef enum {
ACT_IGNORE = 0,
ACT_REPORT,
+ ACT_WARN,
ACT_ASK,
ACT_FATAL,
N_ACT
@@ -178,11 +179,11 @@
// normally all action choices are available for all event types. The exclude
// expression allows some choices to be eliminated if they don't make any
// sense. For example, it would be stupid to ignore a panic.
-#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
- /* can't die or ask, on debug or info events */ \
- (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \
- /* can't ignore panics */ \
- || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
+#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
+ /* can't die, ask or warn, on debug or info events */ \
+ (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \
+ /* can't ignore panics */ \
+ || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
)
// floppy / cdrom media status
@@ -392,6 +393,7 @@
// synchronizing threads, etc. for each.
typedef struct {
Bit8u level;
+ Bit8u flag;
const char *prefix;
const char *msg;
} BxLogMsgEvent;
@@ -419,6 +421,12 @@
BX_LOG_NOTIFY_FAILED
};
+enum {
+ BX_LOG_ASK_ASKDLG,
+ BX_LOG_ASK_MSGBOX_WARN,
+ BX_LOG_ASK_MSGBOX_QUIT
+};
+
// Event type: BX_SYNC_EVT_GET_DBG_COMMAND
//
// This is a synchronous event sent from the simulator to the debugger
@@ -675,6 +683,7 @@
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual const char *get_action_name(int action) {return NULL;}
+ virtual int is_action_name(const char *val) {return -1;}
virtual const char *get_log_level_name(int level) {return NULL;}
virtual int get_max_log_level() {return -1;}
@@ -715,6 +724,9 @@
// send an event from the simulator to the CI.
virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;}
+ // called from simulator when it hits errors, to warn the user
+ // before continuing simulation
+ virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;}
// called from simulator when it hits serious errors, to ask if the user
// wants to continue or not
virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc
--- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100
+++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100
@@ -2,7 +2,7 @@
// $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2013 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -552,8 +552,8 @@
}
static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] ";
-static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" };
-static int log_level_n_choices_normal = 4;
+static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" };
+static int log_level_n_choices_normal = N_ACT;
void bx_log_options(int individual)
{
@@ -589,7 +589,7 @@
bx_print_log_action_table();
for (int level=0; level<SIM->get_max_log_level(); level++) {
char prompt[1024];
- int action, default_action = 4; // default to no change
+ int action, default_action = N_ACT; // default to no change
sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level));
// do show the no change choice (choices=4)
if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0)
@@ -718,47 +718,50 @@
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
- {
- int level = event->u.logmsg.level;
- fprintf(stderr, "========================================================================\n");
- fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
- fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
- fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
- fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
- fprintf(stderr, " cont - continue execution\n");
- fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
- fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
- fprintf(stderr, " die - stop execution now\n");
- fprintf(stderr, " abort - dump core %s\n",
- BX_HAVE_ABORT ? "" : "(Disabled)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ int level = event->u.logmsg.level;
+ fprintf(stderr, "========================================================================\n");
+ fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
+ fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
+ fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
+ fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
+ fprintf(stderr, " cont - continue execution\n");
+ fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
+ fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
+ fprintf(stderr, " die - stop execution now\n");
+ fprintf(stderr, " abort - dump core %s\n",
+ BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
- fprintf(stderr, " debug - continue and return to bochs debugger\n");
+ fprintf(stderr, " debug - continue and return to bochs debugger\n");
#endif
#if BX_GDBSTUB
- fprintf(stderr, " debug - hand control to gdb\n");
+ fprintf(stderr, " debug - hand control to gdb\n");
#endif
- int choice;
+ int choice;
ask:
- if (ask_menu("Choose one of the actions above: [%s] ", "",
- log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
- event->retcode = -1;
- // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
- if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
- fflush(stdout);
- fflush(stderr);
- event->retcode = choice;
- }
- return event;
- case BX_ASYNC_EVT_REFRESH:
- case BX_ASYNC_EVT_DBG_MSG:
- case BX_ASYNC_EVT_LOG_MSG:
- // The text mode interface does not use these events, so just ignore
- // them.
- return event;
- default:
- fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
- return event;
+ if (ask_menu("Choose one of the actions above: [%s] ", "",
+ log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
+ event->retcode = -1;
+ // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
+ if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
+ fflush(stdout);
+ fflush(stderr);
+ event->retcode = choice;
+ } else {
+ // warning prompt not implemented
+ event->retcode = 0;
+ }
+ return event;
+ case BX_ASYNC_EVT_REFRESH:
+ case BX_ASYNC_EVT_DBG_MSG:
+ case BX_ASYNC_EVT_LOG_MSG:
+ // The text mode interface does not use these events, so just ignore
+ // them.
+ return event;
+ default:
+ fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
+ return event;
}
assert(0); // switch statement should return
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc
--- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200
+++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100
@@ -2,7 +2,7 @@
// $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2003-2014 The Bochs Project
+// Copyright (C) 2003-2016 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
@@ -27,7 +27,7 @@
#include "win32res.h"
#include "win32paramdlg.h"
-const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
+const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
HWND GetBochsWindow()
{
@@ -97,12 +97,16 @@
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
#endif
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ } else {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
+ }
SetFocus(GetDlgItem(hDlg, IDASKLIST));
return FALSE;
case WM_CLOSE:
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc
--- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100
+++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -208,7 +208,6 @@
: wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
- //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3};
static wxString names[] = ADVLOG_OPTS_TYPE_NAMES;
SetTitle(ADVLOG_OPTS_TITLE);
vertSizer = new wxBoxSizer(wxVERTICAL);
@@ -1563,7 +1562,7 @@
bool includeNoChange)
{
static wxString choices[] = LOG_OPTS_CHOICES;
- static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4};
+ static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5};
wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize);
int lastChoice = 0; // remember index of last choice
int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h
--- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100
+++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $
////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -354,10 +354,10 @@
#define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?")
#define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") }
#define LOG_OPTS_N_TYPES 4
-#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
-#define LOG_OPTS_N_CHOICES_NORMAL 4
-#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change"
-#define LOG_OPTS_NO_CHANGE 4 // index of "no change"
+#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
+#define LOG_OPTS_N_CHOICES_NORMAL 5
+#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change"
+#define LOG_OPTS_NO_CHANGE 5 // index of "no change"
#define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".")
wxFlexGridSizer *gridSizer;
wxChoice *action[LOG_OPTS_N_TYPES];
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc
--- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100
+++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100
@@ -2,7 +2,7 @@
// $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 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
@@ -1158,6 +1158,10 @@
#if !BX_DEBUGGER && !BX_GDBSTUB
dlg.EnableButton(dlg.DEBUG, FALSE);
#endif
+ if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) {
+ dlg.EnableButton(dlg.DIE, FALSE);
+ dlg.EnableButton(dlg.DUMP, FALSE);
+ }
dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8));
dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8));
int n = dlg.ShowModal();
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc
--- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100
+++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100
@@ -2687,11 +2687,7 @@
} else {
size_x = 30 + maxlen * 6;
}
- if (lines < 3) {
- size_y = 90;
- } else {
- size_y = 60 + lines * 15;
- }
+ size_y = 70 + lines * 15;
x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y,
(mode == XDLG_SIMPLE) ? 1 : 2);
ypos = 34;
@@ -2729,11 +2725,21 @@
bx_param_string_c *sparam;
bx_param_enum_c *eparam;
bx_list_c *list;
+ char message[256];
switch (event->type)
{
case BX_SYNC_EVT_LOG_ASK:
- event->retcode = x11_ask_dialog(event);
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ event->retcode = x11_ask_dialog(event);
+ } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) {
+ const char *title = SIM->get_log_level_name(event->u.logmsg.level);
+ sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
+ bx_param_bool_c bparam(NULL, "warn", title, message, 1);
+ x11_message_box(&bparam, XDLG_SIMPLE);
+ event->retcode = 0;
+ }
return event;
case BX_SYNC_EVT_ASK_PARAM:
param = event->u.param.param;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc
--- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200
+++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100
@@ -2,7 +2,7 @@
// $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2016 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
@@ -50,11 +50,25 @@
else return "?";
}
+static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" };
+
const char* iofunctions::getaction(int i) const
{
- static const char *name[] = { "ignore", "report", "ask", "fatal" };
assert (i>=ACT_IGNORE && i<N_ACT);
- return name[i];
+ return act_name[i];
+}
+
+int iofunctions::isaction(const char *val) const
+{
+ int action = -1;
+
+ for (int i = 0; i < N_ACT; i++) {
+ if (!strcmp(val, act_name[i])) {
+ action = ACT_IGNORE + i;
+ break;
+ }
+ }
+ return action;
}
void iofunctions::flush(void)
@@ -414,6 +428,11 @@
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_ERROR] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_ERROR, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_ERROR] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_ERROR, prefix, fmt, ap);
@@ -438,6 +457,11 @@
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_PANIC] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_PANIC, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_PANIC] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_PANIC, prefix, fmt, ap);
@@ -465,6 +489,36 @@
// the actions ask() and fatal() are not supported here
}
+void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap)
+{
+ // Guard against reentry on warn() function. The danger is that some
+ // function that's called within warn() could trigger another
+ // BX_ERROR that could call warn() again, leading to infinite
+ // recursion and infinite asks.
+ static char in_warn_already = 0;
+ char buf1[1024];
+ if (in_warn_already) {
+ fprintf(stderr, "logfunctions::warn() should not reenter!!\n");
+ return;
+ }
+ in_warn_already = 1;
+ vsnprintf(buf1, sizeof(buf1), fmt, ap);
+ // FIXME: facility set to 0 because it's unknown.
+
+ // update vga screen. This is useful because sometimes useful messages
+ // are printed on the screen just before a panic. It's also potentially
+ // dangerous if this function calls ask again... That's why I added
+ // the reentry check above.
+ SIM->refresh_vga();
+
+ // ensure the text screen is showing
+ SIM->set_display_mode(DISP_MODE_CONFIG);
+ SIM->log_warn(prefix, level, buf1);
+ // return to simulation mode
+ SIM->set_display_mode(DISP_MODE_SIM);
+ in_warn_already = 0;
+}
+
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
{
// Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
|
|
|
|
} else {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
|
|
|
|
}
|
2003-05-22 00:33:24 +04:00
|
|
|
SetFocus(GetDlgItem(hDlg, IDASKLIST));
|
|
|
|
return FALSE;
|
|
|
|
case WM_CLOSE:
|
2003-10-24 19:39:57 +04:00
|
|
|
EndDialog(hDlg, BX_LOG_ASK_CHOICE_DIE);
|
2003-05-22 00:33:24 +04:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hDlg, SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_GETCURSEL, 0, 0));
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2003-10-24 19:39:57 +04:00
|
|
|
EndDialog(hDlg, BX_LOG_ASK_CHOICE_DIE);
|
2003-05-22 00:33:24 +04:00
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
2003-05-22 00:33:24 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-25 22:34:03 +04:00
|
|
|
static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static bx_param_string_c *param;
|
2006-05-30 02:33:38 +04:00
|
|
|
char buffer[512];
|
|
|
|
const char *title;
|
2003-05-25 22:34:03 +04:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
param = (bx_param_string_c *)lParam;
|
2006-02-28 18:48:59 +03:00
|
|
|
title = param->get_label();
|
2017-04-20 21:31:52 +03:00
|
|
|
if ((title == NULL) || (strlen(title) == 0)) {
|
2006-02-28 18:48:59 +03:00
|
|
|
title = param->get_name();
|
|
|
|
}
|
|
|
|
SetWindowText(hDlg, title);
|
2003-05-25 22:34:03 +04:00
|
|
|
SetWindowText(GetDlgItem(hDlg, IDSTRING), param->getptr());
|
2005-10-22 15:00:00 +04:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTRING), EM_SETLIMITTEXT, param->get_maxsize(), 0);
|
|
|
|
return TRUE;
|
2003-05-25 22:34:03 +04:00
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
2005-10-22 15:00:00 +04:00
|
|
|
GetDlgItemText(hDlg, IDSTRING, buffer, param->get_maxsize() + 1);
|
2003-05-25 22:34:03 +04:00
|
|
|
param->set(buffer);
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
2003-05-25 22:34:03 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-03-22 12:40:18 +03:00
|
|
|
void SetStandardLogOptions(HWND hDlg)
|
2004-02-01 22:22:41 +03:00
|
|
|
{
|
2004-02-05 23:02:53 +03:00
|
|
|
int level, idx;
|
2004-02-01 22:22:41 +03:00
|
|
|
int defchoice[5];
|
|
|
|
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2004-02-05 23:02:53 +03:00
|
|
|
int mod = 0;
|
2017-04-20 21:31:52 +03:00
|
|
|
int first = SIM->get_log_action (mod, level);
|
2004-02-01 22:22:41 +03:00
|
|
|
BOOL consensus = true;
|
|
|
|
// now compare all others to first. If all match, then use "first" as
|
|
|
|
// the initial value.
|
2004-02-05 23:02:53 +03:00
|
|
|
for (mod=1; mod<SIM->get_n_log_modules(); mod++) {
|
2004-02-01 22:22:41 +03:00
|
|
|
if (first != SIM->get_log_action (mod, level)) {
|
|
|
|
consensus = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (consensus)
|
|
|
|
defchoice[level] = first;
|
|
|
|
else
|
|
|
|
defchoice[level] = 4;
|
|
|
|
}
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2004-02-01 22:22:41 +03:00
|
|
|
idx = 0;
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_RESETCONTENT, 0, 0);
|
2004-02-01 22:22:41 +03:00
|
|
|
for (int action=0; action<5; action++) {
|
2012-10-06 01:36:49 +04:00
|
|
|
// the exclude expression allows some choices not being available if they
|
|
|
|
// don't make any sense. For example, it would be stupid to ignore a panic.
|
|
|
|
if (!BX_LOG_OPTS_EXCLUDE(level, action)) {
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_ADDSTRING, 0, (LPARAM)log_choices[action]);
|
2004-02-01 22:22:41 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETITEMDATA, idx, action);
|
|
|
|
if (action == defchoice[level]) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETCURSEL, idx, 0);
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-02-05 23:02:53 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), FALSE);
|
|
|
|
}
|
|
|
|
|
2009-03-22 12:40:18 +03:00
|
|
|
void SetAdvancedLogOptions(HWND hDlg)
|
2004-02-05 23:02:53 +03:00
|
|
|
{
|
|
|
|
int idx, level, mod;
|
|
|
|
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETCURSEL, 0, 0);
|
|
|
|
mod = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETITEMDATA, idx, 0);
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2004-02-05 23:02:53 +03:00
|
|
|
idx = 0;
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_RESETCONTENT, 0, 0);
|
|
|
|
for (int action=0; action<4; action++) {
|
2012-10-06 01:36:49 +04:00
|
|
|
// exclude some action / level combinations (see above)
|
|
|
|
if (!BX_LOG_OPTS_EXCLUDE(level, action)) {
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_ADDSTRING, 0, (LPARAM)log_choices[action]);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETITEMDATA, idx, action);
|
|
|
|
if (action == SIM->get_log_action (mod, level)) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETCURSEL, idx, 0);
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
2004-02-04 01:40:33 +03:00
|
|
|
}
|
|
|
|
}
|
2004-02-01 22:22:41 +03:00
|
|
|
}
|
|
|
|
|
2012-04-03 01:30:37 +04:00
|
|
|
void InitLogOptionsDialog(HWND hDlg, BOOL advanced)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
|
|
|
int idx, mod;
|
2012-02-21 23:50:56 +04:00
|
|
|
char name[32];
|
2009-03-22 12:40:18 +03:00
|
|
|
|
|
|
|
for (mod=0; mod<SIM->get_n_log_modules(); mod++) {
|
2012-02-21 23:50:56 +04:00
|
|
|
if (lstrcmp(SIM->get_logfn_name(mod), "?")) {
|
|
|
|
lstrcpyn(name, SIM->get_logfn_name(mod), 32);
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_ADDSTRING, 0, (LPARAM)name);
|
2009-03-22 12:40:18 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETITEMDATA, idx, mod);
|
|
|
|
}
|
|
|
|
}
|
2012-04-03 01:30:37 +04:00
|
|
|
if (advanced) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDADVLOGOPT), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, 0, 0);
|
|
|
|
SetAdvancedLogOptions(hDlg);
|
|
|
|
} else {
|
|
|
|
SetStandardLogOptions(hDlg);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplyLogOptions(HWND hDlg, BOOL advanced)
|
|
|
|
{
|
|
|
|
int idx, level, mod, value;
|
|
|
|
|
|
|
|
if (advanced) {
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETCURSEL, 0, 0);
|
|
|
|
mod = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETITEMDATA, idx, 0);
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2009-03-22 12:40:18 +03:00
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETCURSEL, 0, 0);
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETITEMDATA, idx, 0);
|
2012-04-06 17:15:27 +04:00
|
|
|
SIM->set_log_action(mod, level, value);
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), TRUE);
|
|
|
|
} else {
|
2011-10-01 11:24:18 +04:00
|
|
|
for (level=0; level<N_LOGLEV; level++) {
|
2009-03-22 12:40:18 +03:00
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETCURSEL, 0, 0);
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETITEMDATA, idx, 0);
|
|
|
|
if (value < 4) {
|
|
|
|
// set new default
|
2011-10-01 11:24:18 +04:00
|
|
|
SIM->set_default_log_action(level, value);
|
2009-03-22 12:40:18 +03:00
|
|
|
// apply that action to all modules (devices)
|
2011-10-01 11:24:18 +04:00
|
|
|
SIM->set_log_action(-1, level, value);
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDADVLOGOPT), TRUE);
|
|
|
|
}
|
|
|
|
|
2009-03-30 00:48:17 +04:00
|
|
|
static BOOL CALLBACK LogOptDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
|
|
|
static BOOL advanced;
|
|
|
|
static BOOL changed;
|
|
|
|
long noticode;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2012-04-03 01:30:37 +04:00
|
|
|
advanced = (BOOL)lParam;
|
|
|
|
InitLogOptionsDialog(hDlg, advanced);
|
2009-03-22 12:40:18 +03:00
|
|
|
changed = FALSE;
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDAPPLY), FALSE);
|
|
|
|
return TRUE;
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
noticode = HIWORD(wParam);
|
|
|
|
switch(noticode) {
|
|
|
|
case CBN_SELCHANGE: /* LBN_SELCHANGE is the same value */
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDDEVLIST:
|
|
|
|
SetAdvancedLogOptions(hDlg);
|
|
|
|
break;
|
|
|
|
case IDLOGEVT1:
|
|
|
|
case IDLOGEVT2:
|
|
|
|
case IDLOGEVT3:
|
|
|
|
case IDLOGEVT4:
|
|
|
|
case IDLOGEVT5:
|
|
|
|
if (!changed) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDADVLOGOPT), FALSE);
|
|
|
|
if (advanced) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), FALSE);
|
|
|
|
}
|
|
|
|
changed = TRUE;
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDAPPLY), TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDADVLOGOPT:
|
|
|
|
if (SendMessage(GetDlgItem(hDlg, IDADVLOGOPT), BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), TRUE);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, 0, 0);
|
|
|
|
SetAdvancedLogOptions(hDlg);
|
|
|
|
advanced = TRUE;
|
|
|
|
} else {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, (WPARAM)-1, 0);
|
|
|
|
SetStandardLogOptions(hDlg);
|
|
|
|
advanced = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDAPPLY:
|
|
|
|
ApplyLogOptions(hDlg, advanced);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDAPPLY), FALSE);
|
2009-04-08 00:18:14 +04:00
|
|
|
changed = FALSE;
|
2009-03-22 12:40:18 +03:00
|
|
|
break;
|
|
|
|
case IDOK:
|
2009-04-08 00:18:14 +04:00
|
|
|
if (changed) {
|
|
|
|
ApplyLogOptions(hDlg, advanced);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-01-30 21:32:52 +03:00
|
|
|
void LogOptionsDialog(HWND hwnd, bool runtime)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
2012-04-03 01:30:37 +04:00
|
|
|
DialogBoxParam(NULL, MAKEINTRESOURCE(LOGOPT_DLG), hwnd, (DLGPROC)LogOptDlgProc, (LPARAM)runtime);
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
|
2012-02-17 21:23:57 +04:00
|
|
|
static BOOL CALLBACK PluginCtrlDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int count, i;
|
|
|
|
long code;
|
|
|
|
bx_list_c *plugin_ctrl;
|
2021-01-21 21:10:40 +03:00
|
|
|
bx_param_bool_c *plugin;
|
2012-02-17 21:23:57 +04:00
|
|
|
char plugname[20], message[80];
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
plugin_ctrl = (bx_list_c*) SIM->get_param(BXPN_PLUGIN_CTRL);
|
|
|
|
count = plugin_ctrl->get_size();
|
|
|
|
for (i = 0; i < count; i++) {
|
2021-01-21 21:10:40 +03:00
|
|
|
plugin = (bx_param_bool_c*)plugin_ctrl->get(i);
|
|
|
|
if (plugin->get()) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST2), LB_ADDSTRING, 0, (LPARAM)plugin->get_name());
|
|
|
|
} else {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST1), LB_ADDSTRING, 0, (LPARAM)plugin->get_name());
|
|
|
|
}
|
2012-02-17 21:23:57 +04:00
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDLOAD), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), FALSE);
|
|
|
|
return TRUE;
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
code = HIWORD(wParam);
|
|
|
|
switch (LOWORD(wParam)) {
|
2021-01-21 21:10:40 +03:00
|
|
|
case IDPLUGLIST1:
|
2012-02-17 21:23:57 +04:00
|
|
|
if (code == LBN_SELCHANGE) {
|
2021-01-21 21:10:40 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST2), LB_SETCURSEL, -1, 0);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDLOAD), TRUE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), FALSE);
|
2012-02-17 21:23:57 +04:00
|
|
|
}
|
|
|
|
break;
|
2021-01-21 21:10:40 +03:00
|
|
|
case IDPLUGLIST2:
|
|
|
|
if (code == LBN_SELCHANGE) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST1), LB_SETCURSEL, -1, 0);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDLOAD), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), TRUE);
|
2012-02-17 21:23:57 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDLOAD:
|
2021-01-21 21:10:40 +03:00
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDPLUGLIST1), LB_GETCURSEL, 0, 0);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST1), LB_GETTEXT, i, (LPARAM)plugname);
|
2012-02-17 21:23:57 +04:00
|
|
|
if (SIM->opt_plugin_ctrl(plugname, 1)) {
|
|
|
|
wsprintf(message, "Plugin '%s' loaded", plugname);
|
|
|
|
MessageBox(hDlg, message, "Plugin Control", MB_ICONINFORMATION);
|
2021-01-21 21:10:40 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST1), LB_DELETESTRING, i, 0);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST2), LB_ADDSTRING, 0, (LPARAM)plugname);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDLOAD), FALSE);
|
2012-02-17 21:23:57 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDUNLOAD:
|
2021-01-21 21:10:40 +03:00
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDPLUGLIST2), LB_GETCURSEL, 0, 0);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST2), LB_GETTEXT, i, (LPARAM)plugname);
|
2012-02-17 21:23:57 +04:00
|
|
|
if (SIM->opt_plugin_ctrl(plugname, 0)) {
|
|
|
|
wsprintf(message, "Plugin '%s' unloaded", plugname);
|
|
|
|
MessageBox(hDlg, message, "Plugin Control", MB_ICONINFORMATION);
|
2021-01-21 21:10:40 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST1), LB_ADDSTRING, 0, (LPARAM)plugname);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDPLUGLIST2), LB_DELETESTRING, i, 0);
|
2012-02-17 21:23:57 +04:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUNLOAD), FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginCtrlDialog(HWND hwnd)
|
|
|
|
{
|
|
|
|
DialogBox(NULL, MAKEINTRESOURCE(PLUGIN_CTRL_DLG), hwnd, (DLGPROC)PluginCtrlDlgProc);
|
|
|
|
}
|
|
|
|
|
2009-03-22 12:40:18 +03:00
|
|
|
typedef struct {
|
|
|
|
const char *label;
|
|
|
|
const char *param;
|
|
|
|
} edit_opts_t;
|
|
|
|
|
2009-03-30 00:48:17 +04:00
|
|
|
edit_opts_t start_options[] = {
|
2012-02-17 21:23:57 +04:00
|
|
|
{"Plugin Control", "#plugins"},
|
2009-03-22 12:40:18 +03:00
|
|
|
{"Logfile", "log"},
|
2012-02-17 21:23:57 +04:00
|
|
|
{"Log Options", "#logopts"},
|
2009-03-22 12:40:18 +03:00
|
|
|
{"CPU", "cpu"},
|
2011-02-25 19:27:01 +03:00
|
|
|
#if BX_CPU_LEVEL >= 4
|
2010-02-26 01:04:31 +03:00
|
|
|
{"CPUID", "cpuid"},
|
2011-02-25 19:27:01 +03:00
|
|
|
#endif
|
2009-03-22 12:40:18 +03:00
|
|
|
{"Memory", "memory"},
|
|
|
|
{"Clock & CMOS", "clock_cmos"},
|
|
|
|
{"PCI", "pci"},
|
|
|
|
{"Display & Interface", "display"},
|
|
|
|
{"Keyboard & Mouse", "keyboard_mouse"},
|
|
|
|
{"Disk & Boot", BXPN_MENU_DISK_WIN32},
|
|
|
|
{"Serial / Parallel / USB", "ports"},
|
|
|
|
{"Network card", "network"},
|
2011-03-12 20:37:26 +03:00
|
|
|
{"Sound card", "sound"},
|
2009-03-22 12:40:18 +03:00
|
|
|
{"Other", "misc"},
|
|
|
|
#if BX_PLUGINS
|
|
|
|
{"User-defined Options", "user"},
|
|
|
|
#endif
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2009-03-30 00:48:17 +04:00
|
|
|
edit_opts_t runtime_options[] = {
|
|
|
|
{"CD-ROM", BXPN_MENU_RUNTIME_CDROM},
|
|
|
|
{"USB", BXPN_MENU_RUNTIME_USB},
|
|
|
|
{"Misc", BXPN_MENU_RUNTIME_MISC},
|
2012-02-17 21:23:57 +04:00
|
|
|
{"Log Options", "#logopts"},
|
2009-03-30 00:48:17 +04:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
static BOOL CALLBACK MainMenuDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-03-22 12:40:18 +03:00
|
|
|
{
|
2021-01-30 21:32:52 +03:00
|
|
|
static bool runtime;
|
2009-03-30 23:34:22 +04:00
|
|
|
int choice, code, i;
|
2009-03-22 12:40:18 +03:00
|
|
|
bx_param_filename_c *rcfile;
|
|
|
|
char path[BX_PATHNAME_LEN];
|
2009-03-30 00:48:17 +04:00
|
|
|
const char *pname;
|
2009-03-22 12:40:18 +03:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2021-01-30 21:32:52 +03:00
|
|
|
runtime = (bool)lParam;
|
2009-03-22 12:40:18 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDEDITCFG), FALSE);
|
2009-03-30 00:48:17 +04:00
|
|
|
if (runtime) {
|
|
|
|
SetWindowText(hDlg, "Bochs Runtime Menu");
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDREADRC), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDRESETCFG), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDRESTORE), FALSE);
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDOK), "&Continue");
|
|
|
|
i = 0;
|
|
|
|
while (runtime_options[i].label != NULL) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDEDITBOX), LB_ADDSTRING, 0, (LPARAM)runtime_options[i].label);
|
|
|
|
i++;
|
|
|
|
}
|
2009-03-30 23:34:22 +04:00
|
|
|
choice = IDOK;
|
2009-03-30 00:48:17 +04:00
|
|
|
} else {
|
|
|
|
i = 0;
|
|
|
|
while (start_options[i].label != NULL) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDEDITBOX), LB_ADDSTRING, 0, (LPARAM)start_options[i].label);
|
|
|
|
i++;
|
|
|
|
}
|
2009-03-30 23:34:22 +04:00
|
|
|
if (SIM->get_param_enum(BXPN_BOCHS_START)->get() == BX_LOAD_START) {
|
|
|
|
choice = IDREADRC;
|
|
|
|
} else {
|
|
|
|
choice = IDOK;
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
2009-03-30 23:34:22 +04:00
|
|
|
SetFocus(GetDlgItem(hDlg, choice));
|
2009-03-30 00:48:17 +04:00
|
|
|
return FALSE;
|
2009-03-22 12:40:18 +03:00
|
|
|
case WM_CLOSE:
|
2012-03-29 21:05:44 +04:00
|
|
|
if (runtime) {
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
} else {
|
|
|
|
bx_user_quit = 1;
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
code = HIWORD(wParam);
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDREADRC:
|
|
|
|
rcfile = new bx_param_filename_c(NULL, "rcfile", "Load Bochs Config File",
|
|
|
|
"", "bochsrc.bxrc", BX_PATHNAME_LEN);
|
|
|
|
rcfile->set_extension("bxrc");
|
2009-03-29 04:21:10 +04:00
|
|
|
if (AskFilename(hDlg, rcfile, NULL) > 0) {
|
2009-03-22 12:40:18 +03:00
|
|
|
SIM->reset_all_param();
|
|
|
|
SIM->read_rc(rcfile->getptr());
|
|
|
|
}
|
|
|
|
delete rcfile;
|
|
|
|
break;
|
|
|
|
case IDWRITERC:
|
|
|
|
rcfile = new bx_param_filename_c(NULL, "rcfile", "Save Bochs Config File",
|
|
|
|
"", "bochsrc.bxrc", BX_PATHNAME_LEN);
|
|
|
|
rcfile->set_extension("bxrc");
|
|
|
|
rcfile->set_options(rcfile->SAVE_FILE_DIALOG);
|
2009-03-29 04:21:10 +04:00
|
|
|
if (AskFilename(hDlg, rcfile, NULL) > 0) {
|
2009-03-22 12:40:18 +03:00
|
|
|
SIM->write_rc(rcfile->getptr(), 1);
|
|
|
|
}
|
|
|
|
delete rcfile;
|
|
|
|
break;
|
|
|
|
case IDEDITBOX:
|
|
|
|
if ((code == LBN_SELCHANGE) ||
|
|
|
|
(code == LBN_DBLCLK)) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDEDITCFG), TRUE);
|
|
|
|
}
|
|
|
|
if (code != LBN_DBLCLK) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDEDITCFG:
|
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDEDITBOX), LB_GETCURSEL, 0, 0);
|
2009-03-30 00:48:17 +04:00
|
|
|
if (runtime) {
|
|
|
|
pname = runtime_options[i].param;
|
2009-03-22 12:40:18 +03:00
|
|
|
} else {
|
2009-03-30 00:48:17 +04:00
|
|
|
pname = start_options[i].param;
|
|
|
|
}
|
2012-02-17 21:23:57 +04:00
|
|
|
if (pname[0] != '#') {
|
2021-03-05 19:52:26 +03:00
|
|
|
bx_list_c *list = (bx_list_c*)SIM->get_param(pname);
|
|
|
|
if (list != NULL) {
|
|
|
|
if (list->get_size() > 0) {
|
|
|
|
win32ParamDialog(hDlg, pname);
|
|
|
|
} else {
|
|
|
|
MessageBox(hDlg, "Nothing to configure in this section", "Warning", MB_ICONEXCLAMATION);
|
|
|
|
}
|
2009-03-30 23:34:22 +04:00
|
|
|
} else {
|
|
|
|
MessageBox(hDlg, "Nothing to configure in this section", "Warning", MB_ICONEXCLAMATION);
|
|
|
|
}
|
2009-03-30 00:48:17 +04:00
|
|
|
} else {
|
2012-02-17 21:23:57 +04:00
|
|
|
if (!lstrcmp(pname, "#logopts")) {
|
2012-04-03 01:30:37 +04:00
|
|
|
LogOptionsDialog(hDlg, runtime);
|
2012-02-17 21:23:57 +04:00
|
|
|
} else if (!lstrcmp(pname, "#plugins")) {
|
|
|
|
PluginCtrlDialog(hDlg);
|
|
|
|
} else {
|
|
|
|
MessageBox(hDlg, "Unknown keyword", "Warning", MB_ICONEXCLAMATION);
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDRESETCFG:
|
|
|
|
if (MessageBox(hDlg, "Reset all options back to their factory defaults ?",
|
|
|
|
"Reset Configuration", MB_ICONEXCLAMATION | MB_YESNO) == IDYES) {
|
|
|
|
SIM->reset_all_param();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDRESTORE:
|
|
|
|
path[0] = 0;
|
|
|
|
if (BrowseDir("Restore Bochs state from...", path) >= 0) {
|
|
|
|
SIM->get_param_bool(BXPN_RESTORE_FLAG)->set(1);
|
|
|
|
SIM->get_param_string(BXPN_RESTORE_PATH)->set(path);
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDOK:
|
2011-06-11 23:38:52 +04:00
|
|
|
if (runtime) {
|
|
|
|
SIM->update_runtime_options();
|
|
|
|
}
|
2009-03-22 12:40:18 +03:00
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2012-03-29 21:05:44 +04:00
|
|
|
if (runtime) {
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDQUIT:
|
2009-03-24 19:28:03 +03:00
|
|
|
bx_user_quit = 1;
|
2009-03-22 12:40:18 +03:00
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
void LogAskDialog(BxEvent *event)
|
|
|
|
{
|
2013-11-10 21:36:13 +04:00
|
|
|
event->retcode = (Bit32s) DialogBoxParam(NULL, MAKEINTRESOURCE(ASK_DLG), GetBochsWindow(),
|
2003-05-22 00:33:24 +04:00
|
|
|
(DLGPROC)LogAskProc, (LPARAM)event);
|
|
|
|
}
|
|
|
|
|
2003-05-25 22:34:03 +04:00
|
|
|
int AskString(bx_param_string_c *param)
|
|
|
|
{
|
2013-11-10 21:36:13 +04:00
|
|
|
return (int) DialogBoxParam(NULL, MAKEINTRESOURCE(STRING_DLG), GetBochsWindow(),
|
2003-05-25 22:34:03 +04:00
|
|
|
(DLGPROC)StringParamProc, (LPARAM)param);
|
|
|
|
}
|
|
|
|
|
2021-01-30 21:32:52 +03:00
|
|
|
int MainMenuDialog(HWND hwnd, bool runtime)
|
2004-02-01 04:40:14 +03:00
|
|
|
{
|
2013-11-10 21:36:13 +04:00
|
|
|
return (int) DialogBoxParam(NULL, MAKEINTRESOURCE(MAINMENU_DLG), hwnd,
|
2009-03-30 00:48:17 +04:00
|
|
|
(DLGPROC)MainMenuDlgProc, (LPARAM)runtime);
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
|
2005-10-22 15:00:00 +04:00
|
|
|
BxEvent* win32_notify_callback(void *unused, BxEvent *event)
|
|
|
|
{
|
2006-12-17 21:14:59 +03:00
|
|
|
int opts;
|
2005-10-22 15:00:00 +04:00
|
|
|
bx_param_c *param;
|
|
|
|
bx_param_string_c *sparam;
|
2009-03-22 23:18:17 +03:00
|
|
|
char pname[BX_PATHNAME_LEN];
|
2005-10-22 15:00:00 +04:00
|
|
|
|
|
|
|
event->retcode = -1;
|
|
|
|
switch (event->type)
|
|
|
|
{
|
2016-12-29 12:47:07 +03:00
|
|
|
case BX_SYNC_EVT_LOG_DLG:
|
2005-10-22 15:00:00 +04:00
|
|
|
LogAskDialog(event);
|
|
|
|
return event;
|
2020-10-18 22:57:05 +03:00
|
|
|
case BX_SYNC_EVT_MSG_BOX:
|
|
|
|
MessageBox(GetBochsWindow(), event->u.logmsg.msg, event->u.logmsg.prefix, MB_ICONERROR);
|
|
|
|
return event;
|
2005-10-22 15:00:00 +04:00
|
|
|
case BX_SYNC_EVT_ASK_PARAM:
|
|
|
|
param = event->u.param.param;
|
2018-01-19 23:27:04 +03:00
|
|
|
if (param->get_type() == BXT_PARAM_STRING || param->get_type() == BXT_PARAM_BYTESTRING) {
|
2005-10-22 15:00:00 +04:00
|
|
|
sparam = (bx_param_string_c *)param;
|
2009-03-16 00:16:17 +03:00
|
|
|
opts = sparam->get_options();
|
2005-10-22 15:00:00 +04:00
|
|
|
if (opts & sparam->IS_FILENAME) {
|
2006-08-30 00:10:27 +04:00
|
|
|
if (opts & sparam->SELECT_FOLDER_DLG) {
|
|
|
|
event->retcode = BrowseDir(sparam->get_label(), sparam->getptr());
|
2005-10-22 15:00:00 +04:00
|
|
|
} else {
|
2013-12-08 02:58:41 +04:00
|
|
|
event->retcode = AskFilename(GetBochsWindow(), (bx_param_filename_c *)sparam, NULL);
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
|
|
|
return event;
|
|
|
|
} else {
|
|
|
|
event->retcode = AskString(sparam);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
} else if (param->get_type() == BXT_LIST) {
|
2013-12-08 02:58:41 +04:00
|
|
|
param->get_param_path(pname, BX_PATHNAME_LEN);
|
|
|
|
if (!strncmp(pname, "floppy", 6)) {
|
2013-12-09 01:22:50 +04:00
|
|
|
event->retcode = (Bit32s) win32FloppyParamDialog(GetBochsWindow(), pname);
|
2013-12-08 02:58:41 +04:00
|
|
|
} else {
|
|
|
|
event->retcode = (Bit32s) win32ParamDialog(GetBochsWindow(), pname);
|
|
|
|
}
|
2005-10-22 15:00:00 +04:00
|
|
|
return event;
|
2006-06-01 00:12:43 +04:00
|
|
|
} else if (param->get_type() == BXT_PARAM_BOOL) {
|
|
|
|
UINT flag = MB_YESNO | MB_SETFOREGROUND;
|
|
|
|
if (((bx_param_bool_c *)param)->get() == 0) {
|
|
|
|
flag |= MB_DEFBUTTON2;
|
|
|
|
}
|
|
|
|
((bx_param_bool_c *)param)->set(MessageBox(GetActiveWindow(), param->get_description(), param->get_label(), flag) == IDYES);
|
|
|
|
event->retcode = 0;
|
|
|
|
return event;
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
|
|
|
case BX_SYNC_EVT_TICK: // called periodically by siminterface.
|
2009-03-24 19:28:03 +03:00
|
|
|
event->retcode = 0;
|
2005-10-22 15:00:00 +04:00
|
|
|
// fall into default case
|
|
|
|
default:
|
2009-03-24 19:28:03 +03:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int win32_ci_callback(void *userdata, ci_command_t command)
|
|
|
|
{
|
|
|
|
switch (command)
|
|
|
|
{
|
|
|
|
case CI_START:
|
|
|
|
if (SIM->get_param_enum(BXPN_BOCHS_START)->get() == BX_QUICK_START) {
|
|
|
|
SIM->begin_simulation(bx_startup_flags.argc, bx_startup_flags.argv);
|
|
|
|
// we don't expect it to return, but if it does, quit
|
|
|
|
SIM->quit_sim(1);
|
|
|
|
} else {
|
2009-03-30 00:48:17 +04:00
|
|
|
if (MainMenuDialog(GetActiveWindow(), 0) == 1) {
|
|
|
|
SIM->begin_simulation(bx_startup_flags.argc, bx_startup_flags.argv);
|
|
|
|
}
|
|
|
|
SIM->quit_sim(1);
|
2009-03-24 19:28:03 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CI_RUNTIME_CONFIG:
|
2017-01-11 00:40:05 +03:00
|
|
|
if (!bx_gui->has_gui_console()) {
|
|
|
|
if (MainMenuDialog(GetBochsWindow(), 1) < 0) {
|
|
|
|
bx_user_quit = 1;
|
2009-03-24 19:28:03 +03:00
|
|
|
#if !BX_DEBUGGER
|
2017-01-11 00:40:05 +03:00
|
|
|
bx_atexit();
|
|
|
|
SIM->quit_sim(1);
|
2009-03-24 19:28:03 +03:00
|
|
|
#else
|
2017-01-11 00:40:05 +03:00
|
|
|
bx_dbg_exit(1);
|
2009-03-24 19:28:03 +03:00
|
|
|
#endif
|
2017-01-11 00:40:05 +03:00
|
|
|
return -1;
|
|
|
|
}
|
2009-03-24 19:28:03 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CI_SHUTDOWN:
|
|
|
|
break;
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
2009-03-24 19:28:03 +03:00
|
|
|
return 0;
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
|
|
|
|
2014-06-20 13:31:56 +04:00
|
|
|
#endif // BX_USE_WIN32CONFIG
|