diff --git a/bochs/CHANGES b/bochs/CHANGES index 064f46eee..bd37720a6 100644 --- a/bochs/CHANGES +++ b/bochs/CHANGES @@ -2,6 +2,7 @@ Changes after 2.6.8 release: - General - Added new log action "warn", designed to show a message box on error events. + - Show message box before exit if log action is set to "fatal". - Configure and compile - Added Android host platform support. diff --git a/bochs/bochs.h b/bochs/bochs.h index d52751311..ac5769fe1 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -276,7 +276,7 @@ public: 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 fatal(int level, 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); diff --git a/bochs/logio.cc b/bochs/logio.cc index 1179bee51..a051f60cc 100644 --- a/bochs/logio.cc +++ b/bochs/logio.cc @@ -399,21 +399,13 @@ void logfunctions::info(const char *fmt, ...) assert(logio != NULL); - if (!onoff[LOGLEV_INFO]) return; + if (onoff[LOGLEV_INFO] == ACT_IGNORE) return; va_start(ap, fmt); logio->out(LOGLEV_INFO, prefix, fmt, ap); va_end(ap); - if (onoff[LOGLEV_INFO] == ACT_ASK) { - va_start(ap, fmt); - ask(LOGLEV_INFO, prefix, fmt, ap); - va_end(ap); - } - if (onoff[LOGLEV_INFO] == ACT_FATAL) { - va_start(ap, fmt); - fatal(prefix, fmt, ap, 1); - } + // the actions warn(), ask() and fatal() are not supported here } void logfunctions::error(const char *fmt, ...) @@ -422,7 +414,7 @@ void logfunctions::error(const char *fmt, ...) assert(logio != NULL); - if(!onoff[LOGLEV_ERROR]) return; + if (onoff[LOGLEV_ERROR] == ACT_IGNORE) return; va_start(ap, fmt); logio->out(LOGLEV_ERROR, prefix, fmt, ap); @@ -432,15 +424,14 @@ void logfunctions::error(const char *fmt, ...) va_start(ap, fmt); warn(LOGLEV_ERROR, prefix, fmt, ap); va_end(ap); - } - if (onoff[LOGLEV_ERROR] == ACT_ASK) { + } else if (onoff[LOGLEV_ERROR] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_ERROR, prefix, fmt, ap); va_end(ap); } if (onoff[LOGLEV_ERROR] == ACT_FATAL) { va_start(ap, fmt); - fatal(prefix, fmt, ap, 1); + fatal(LOGLEV_ERROR, prefix, fmt, ap, 1); } } @@ -461,16 +452,14 @@ void logfunctions::panic(const char *fmt, ...) va_start(ap, fmt); warn(LOGLEV_PANIC, prefix, fmt, ap); va_end(ap); - } - if (onoff[LOGLEV_PANIC] == ACT_ASK) { + } else if (onoff[LOGLEV_PANIC] == ACT_ASK) { va_start(ap, fmt); ask(LOGLEV_PANIC, prefix, fmt, ap); va_end(ap); } if (onoff[LOGLEV_PANIC] == ACT_FATAL) { va_start(ap, fmt); - fatal(prefix, fmt, ap, 1); - va_end(ap); + fatal(LOGLEV_PANIC, prefix, fmt, ap, 1); } } @@ -480,13 +469,13 @@ void logfunctions::ldebug(const char *fmt, ...) assert(logio != NULL); - if(!onoff[LOGLEV_DEBUG]) return; + if (onoff[LOGLEV_DEBUG] == ACT_IGNORE) return; va_start(ap, fmt); logio->out(LOGLEV_DEBUG, prefix, fmt, ap); va_end(ap); - // the actions ask() and fatal() are not supported here + // the actions warn(), ask() and fatal() are not supported here } void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap) @@ -639,28 +628,27 @@ static void carbonFatalDialog(const char *error, const char *exposition) } #endif -void logfunctions::fatal(const char *prefix, const char *fmt, va_list ap, int exit_status) +void logfunctions::fatal(int level, const char *prefix, const char *fmt, va_list ap, int exit_status) { char tmpbuf[1024]; char exit_msg[1024]; + vsnprintf(tmpbuf, sizeof(tmpbuf), fmt, ap); + va_end(ap); + if (!bx_user_quit) { + SIM->log_dlg(prefix, level, tmpbuf, BX_LOG_DLG_QUIT); + } if (!SIM->is_wx_selected()) { // store prefix and message in 'exit_msg' before unloading device plugins - vsnprintf(tmpbuf, sizeof(tmpbuf), fmt, ap); - va_end(ap); sprintf(exit_msg, "%s %s", prefix, tmpbuf); } #if !BX_DEBUGGER bx_atexit(); #endif #if BX_WITH_CARBON - if(!isatty(STDIN_FILENO) && !SIM->get_init_done()) - { - char buf1[1024]; - char buf2[1024]; - vsnprintf(buf1, sizeof(buf1), fmt, ap); - snprintf(buf2, sizeof(buf2), "Bochs startup error\n%s", buf1); - carbonFatalDialog(buf2, + if (!isatty(STDIN_FILENO) && !SIM->get_init_done()) { + snprintf(exit_msg, sizeof(exit_msg), "Bochs startup error\n%s", tmpbuf); + carbonFatalDialog(exit_msg, "For more information, try running Bochs within Terminal by clicking on \"bochs.scpt\"."); } #endif