Bochs/bochs/logio.cc

606 lines
15 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////
2009-12-04 23:02:12 +03:00
// $Id: logio.cc,v 1.75 2009-12-04 20:02:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
2009-12-04 23:02:12 +03:00
// Copyright (C) 2001-2009 The Bochs Project
2001-06-19 20:25:41 +04: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
2009-08-22 23:30:23 +04:00
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
/////////////////////////////////////////////////////////////////////////
2001-06-19 20:25:41 +04:00
#include "bochs.h"
#include "cpu/cpu.h"
#include "iodev/iodev.h"
2001-06-19 20:25:41 +04:00
#include <assert.h>
#if BX_WITH_CARBON
2004-02-14 09:33:29 +03:00
#define Float32 KLUDGE_Float32
#define Float64 KLUDGE_Float64
#include <Carbon/Carbon.h>
2004-02-14 09:33:29 +03:00
#undef Float32
#undef Float64
#endif
2001-06-19 20:25:41 +04:00
// Just for the iofunctions
static int Allocio=0;
2001-06-19 20:25:41 +04:00
void iofunctions::flush(void)
{
if(logfd && magic == MAGIC_LOGNUM) {
fflush(logfd);
}
2001-06-19 20:25:41 +04:00
}
void iofunctions::init(void)
{
// iofunctions methods must not be called before this magic
// number is set.
magic=MAGIC_LOGNUM;
// sets the default logprefix
strcpy(logprefix,"%t%e%d");
n_logfn = 0;
init_log(stderr);
log = new logfunc_t(this);
log->put("IO");
log->ldebug("Init(log file: '%s').",logfn);
2001-06-19 20:25:41 +04:00
}
void iofunctions::add_logfn(logfunc_t *fn)
2001-06-19 20:25:41 +04:00
{
assert(n_logfn < MAX_LOGFNS);
2001-06-19 20:25:41 +04:00
logfn_list[n_logfn++] = fn;
}
void iofunctions::remove_logfn(logfunc_t *fn)
{
assert(n_logfn > 0);
int i = 0;
while ((fn != logfn_list[i]) && (i < n_logfn)) {
i++;
};
if (i < n_logfn) {
for (int j=i; j<n_logfn-1; j++) {
logfn_list[j] = logfn_list[j+1];
}
n_logfn--;
}
}
void iofunctions::set_log_action(int loglevel, int action)
2001-06-19 20:25:41 +04:00
{
for(int i=0; i<n_logfn; i++)
2001-06-19 20:25:41 +04:00
logfn_list[i]->setonoff(loglevel, action);
}
void iofunctions::init_log(const char *fn)
2001-06-19 20:25:41 +04:00
{
assert(magic==MAGIC_LOGNUM);
// use newfd/newfn so that we can log the message to the OLD log
// file descriptor.
FILE *newfd = stderr;
2007-10-25 03:29:40 +04:00
const char *newfn = "/dev/stderr";
if(strcmp(fn, "-") != 0) {
newfd = fopen(fn, "w");
if(newfd != NULL) {
newfn = strdup(fn);
log->ldebug("Opened log file '%s'.", fn);
} else {
// in constructor, genlog might not exist yet, so do it the safe way.
log->error("Couldn't open log file: %s, using stderr instead", fn);
newfd = stderr;
}
}
logfd = newfd;
logfn = newfn;
2001-06-19 20:25:41 +04:00
}
void iofunctions::init_log(FILE *fs)
2001-06-19 20:25:41 +04:00
{
assert(magic==MAGIC_LOGNUM);
logfd = fs;
if(fs == stderr) {
logfn = "/dev/stderr";
} else if(fs == stdout) {
logfn = "/dev/stdout";
} else {
logfn = "(unknown)";
}
2001-06-19 20:25:41 +04:00
}
void iofunctions::init_log(int fd)
2001-06-19 20:25:41 +04:00
{
assert(magic==MAGIC_LOGNUM);
FILE *tmpfd;
if((tmpfd = fdopen(fd,"w")) == NULL) {
log->panic("Couldn't open fd %d as a stream for writing", fd);
return;
}
init_log(tmpfd);
2001-06-19 20:25:41 +04:00
};
void iofunctions::exit_log()
{
flush();
if (logfd != stderr) {
fclose(logfd);
logfd = stderr;
2007-10-25 03:29:40 +04:00
free((char *)logfn);
logfn = "/dev/stderr";
}
}
// all other functions may use genlog safely.
#define LOG_THIS genlog->
2002-06-28 18:03:47 +04:00
// This converts the option string to a printf style string with the following args:
// 1. timer, 2. event, 3. cpu0 eip, 4. device
void iofunctions::set_log_prefix(const char* prefix)
{
strcpy(logprefix, prefix);
2002-06-28 18:03:47 +04:00
}
// iofunctions::out(level, prefix, fmt, ap)
2001-06-19 20:25:41 +04:00
// DO NOT nest out() from ::info() and the like.
// fmt and ap retained for direct printinf from iofunctions only!
void iofunctions::out(int level, const char *prefix, const char *fmt, va_list ap)
2001-06-19 20:25:41 +04:00
{
char c=' ', *s;
assert(magic==MAGIC_LOGNUM);
assert(this != NULL);
assert(logfd != NULL);
switch (level) {
case LOGLEV_INFO: c='i'; break;
case LOGLEV_PANIC: c='p'; break;
case LOGLEV_PASS: c='s'; break;
case LOGLEV_ERROR: c='e'; break;
case LOGLEV_DEBUG: c='d'; break;
default: break;
}
s=logprefix;
while(*s) {
switch(*s) {
case '%':
if(*(s+1)) s++;
else break;
switch(*s) {
case 'd':
fprintf(logfd, "%s", prefix==NULL?"":prefix);
break;
case 't':
fprintf(logfd, FMT_TICK, bx_pc_system.time_ticks());
break;
case 'i':
#if BX_SUPPORT_SMP == 0
fprintf(logfd, "%08x", BX_CPU(0)->get_eip());
#endif
break;
case 'e':
fprintf(logfd, "%c", c);
break;
case '%':
fprintf(logfd,"%%");
break;
default:
fprintf(logfd,"%%%c",*s);
}
break;
default :
fprintf(logfd,"%c",*s);
}
s++;
}
fprintf(logfd," ");
2001-06-19 20:25:41 +04:00
if(level==LOGLEV_PANIC)
fprintf(logfd, ">>PANIC<< ");
if(level==LOGLEV_PASS)
fprintf(logfd, ">>PASS<< ");
2001-06-19 20:25:41 +04:00
vfprintf(logfd, fmt, ap);
fprintf(logfd, "\n");
fflush(logfd);
2001-06-19 20:25:41 +04:00
}
iofunctions::iofunctions(FILE *fs)
{
init();
init_log(fs);
2001-06-19 20:25:41 +04:00
}
iofunctions::iofunctions(const char *fn)
2001-06-19 20:25:41 +04:00
{
init();
init_log(fn);
2001-06-19 20:25:41 +04:00
}
iofunctions::iofunctions(int fd)
{
init();
init_log(fd);
2001-06-19 20:25:41 +04:00
}
iofunctions::iofunctions()
2001-06-19 20:25:41 +04:00
{
init();
2001-06-19 20:25:41 +04:00
}
iofunctions::~iofunctions(void)
{
// flush before erasing magic number, or flush does nothing.
flush();
magic=0;
2001-06-19 20:25:41 +04:00
}
#define LOG_THIS genlog->
int logfunctions::default_onoff[N_LOGLEV] =
{
ACT_IGNORE, // ignore debug
ACT_REPORT, // report info
ACT_REPORT, // report error
#if BX_WITH_WX || BX_WITH_WIN32 || BX_WITH_X11
ACT_ASK, // on panic, ask user what to do
#else
ACT_FATAL, // on panic, quit
#endif
ACT_FATAL
};
2001-06-19 20:25:41 +04:00
logfunctions::logfunctions(void)
{
prefix = NULL;
put(" ");
if (io == NULL && Allocio == 0) {
Allocio = 1;
io = new iofunc_t(stderr);
}
setio(io);
// BUG: unfortunately this can be called before the bochsrc is read,
// which means that the bochsrc has no effect on the actions.
for (int i=0; i<N_LOGLEV; i++)
onoff[i] = get_default_action(i);
2001-06-19 20:25:41 +04:00
}
logfunctions::logfunctions(iofunc_t *iofunc)
{
prefix = NULL;
put(" ");
setio(iofunc);
// BUG: unfortunately this can be called before the bochsrc is read,
// which means that the bochsrc has no effect on the actions.
for (int i=0; i<N_LOGLEV; i++)
onoff[i] = get_default_action(i);
2001-06-19 20:25:41 +04:00
}
logfunctions::~logfunctions()
2001-06-19 20:25:41 +04:00
{
2009-02-20 20:05:03 +03:00
logio->remove_logfn(this);
if (prefix) free(prefix);
2001-06-19 20:25:41 +04:00
}
void logfunctions::setio(iofunc_t *i)
2001-06-19 20:25:41 +04:00
{
// add pointer to iofunction object to use
2009-02-20 20:05:03 +03:00
logio = i;
// give iofunction a pointer to me
i->add_logfn(this);
2001-06-19 20:25:41 +04:00
}
2007-10-25 03:29:40 +04:00
void logfunctions::put(const char *p)
2001-06-19 20:25:41 +04:00
{
2009-02-20 20:05:03 +03:00
char *tmpbuf=strdup("[ ]"); // if we ever have more than 32 chars,
// we need to rethink this
if (tmpbuf == NULL)
2009-02-20 20:05:03 +03:00
return; // allocation not successful
2009-02-20 20:05:03 +03:00
if (prefix != NULL)
{
2009-02-20 20:05:03 +03:00
free(prefix); // free previously allocated memory
prefix = NULL;
}
2007-12-30 21:02:22 +03:00
size_t len=strlen(p);
if (len > (strlen(tmpbuf) - 2)) {
len = strlen(tmpbuf) - 2;
}
2009-02-20 20:05:03 +03:00
for(size_t i=1;i <= len;i++) {
tmpbuf[i]=p[i-1];
}
2009-02-20 20:05:03 +03:00
prefix = tmpbuf;
2001-06-19 20:25:41 +04:00
}
void logfunctions::info(const char *fmt, ...)
2001-06-19 20:25:41 +04:00
{
va_list ap;
2001-06-19 20:25:41 +04:00
2009-02-20 20:05:03 +03:00
assert(logio != NULL);
2001-06-19 20:25:41 +04:00
if(!onoff[LOGLEV_INFO]) return;
2001-06-19 20:25:41 +04:00
va_start(ap, fmt);
2009-02-20 20:05:03 +03:00
logio->out(LOGLEV_INFO, prefix, fmt, ap);
if (onoff[LOGLEV_INFO] == ACT_ASK)
2009-02-20 20:05:03 +03:00
ask(LOGLEV_INFO, prefix, fmt, ap);
if (onoff[LOGLEV_INFO] == ACT_FATAL)
2009-02-20 20:05:03 +03:00
fatal(prefix, fmt, ap, 1);
va_end(ap);
2001-06-19 20:25:41 +04:00
}
void logfunctions::error(const char *fmt, ...)
2001-06-19 20:25:41 +04:00
{
va_list ap;
2001-06-19 20:25:41 +04:00
2009-02-20 20:05:03 +03:00
assert(logio != NULL);
2001-06-19 20:25:41 +04:00
if(!onoff[LOGLEV_ERROR]) return;
2001-06-19 20:25:41 +04:00
va_start(ap, fmt);
2009-02-20 20:05:03 +03:00
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
if (onoff[LOGLEV_ERROR] == ACT_ASK)
2009-02-20 20:05:03 +03:00
ask(LOGLEV_ERROR, prefix, fmt, ap);
if (onoff[LOGLEV_ERROR] == ACT_FATAL)
2009-02-20 20:05:03 +03:00
fatal(prefix, fmt, ap, 1);
va_end(ap);
2001-06-19 20:25:41 +04:00
}
void logfunctions::panic(const char *fmt, ...)
2001-06-19 20:25:41 +04:00
{
va_list ap;
2001-06-19 20:25:41 +04:00
2009-02-20 20:05:03 +03:00
assert(logio != NULL);
2001-06-19 20:25:41 +04:00
// Special case for panics since they are so important. Always print
// the panic to the log, no matter what the log action says.
//if(!onoff[LOGLEV_PANIC]) return;
2001-06-19 20:25:41 +04:00
va_start(ap, fmt);
2009-02-20 20:05:03 +03:00
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
// This fixes a funny bug on linuxppc where va_list is no pointer but a struct
va_end(ap);
va_start(ap, fmt);
if (onoff[LOGLEV_PANIC] == ACT_ASK)
2009-02-20 20:05:03 +03:00
ask(LOGLEV_PANIC, prefix, fmt, ap);
if (onoff[LOGLEV_PANIC] == ACT_FATAL)
2009-02-20 20:05:03 +03:00
fatal(prefix, fmt, ap, 1);
va_end(ap);
}
void logfunctions::pass(const char *fmt, ...)
{
va_list ap;
2009-02-20 20:05:03 +03:00
assert(logio != NULL);
// Special case for panics since they are so important. Always print
// the panic to the log, no matter what the log action says.
//if(!onoff[LOGLEV_PASS]) return;
va_start(ap, fmt);
2009-02-20 20:05:03 +03:00
logio->out(LOGLEV_PASS, prefix, fmt, ap);
// This fixes a funny bug on linuxppc where va_list is no pointer but a struct
va_end(ap);
va_start(ap, fmt);
if (onoff[LOGLEV_PASS] == ACT_ASK)
2009-02-20 20:05:03 +03:00
ask(LOGLEV_PASS, prefix, fmt, ap);
if (onoff[LOGLEV_PASS] == ACT_FATAL)
2009-02-20 20:05:03 +03:00
fatal(prefix, fmt, ap, 101);
va_end(ap);
2001-06-19 20:25:41 +04:00
}
void logfunctions::ldebug(const char *fmt, ...)
2001-06-19 20:25:41 +04:00
{
va_list ap;
2001-06-19 20:25:41 +04:00
2009-02-20 20:05:03 +03:00
assert(logio != NULL);
2001-06-19 20:25:41 +04:00
if(!onoff[LOGLEV_DEBUG]) return;
2001-06-19 20:25:41 +04:00
va_start(ap, fmt);
2009-02-20 20:05:03 +03:00
logio->out(LOGLEV_DEBUG, prefix, fmt, ap);
if (onoff[LOGLEV_DEBUG] == ACT_ASK)
2009-02-20 20:05:03 +03:00
ask(LOGLEV_DEBUG, prefix, fmt, ap);
if (onoff[LOGLEV_DEBUG] == ACT_FATAL)
2009-02-20 20:05:03 +03:00
fatal(prefix, fmt, ap, 1);
va_end(ap);
2001-06-19 20:25:41 +04:00
}
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
2001-06-19 20:25:41 +04:00
{
// Guard against reentry on ask() function. The danger is that some
// function that's called within ask() could trigger another
// BX_PANIC that could call ask() again, leading to infinite
// recursion and infinite asks.
static char in_ask_already = 0;
char buf1[1024];
if (in_ask_already) {
fprintf(stderr, "logfunctions::ask() should not reenter!!\n");
return;
}
in_ask_already = 1;
vsnprintf(buf1, sizeof(buf1), fmt, ap);
2001-06-19 20:25:41 +04:00
// 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.
Add plugin support to Bochs by merging all the changes from the BRANCH_PLUGINS branch! Authors: Bryce Denney Christophe Bothamy Kevin Lawton (we grabbed a lot of plugin code from plex86) Testing help from: Volker Ruppert Don Becker (Psyon) Jeremy Parsons (Br'fin) The change log is too long to paste in here. To read the change log, do cvs log patches/patch.final-from-BRANCH_PLUGINS.gz All the changes and a detailed description are contained in a patch called patch.final-from-BRANCH_PLUGINS.gz. To look at the complete patch, do cvs upd -r1.1 patches/patch.final-from-BRANCH_PLUGINS.gz Then you will have a local copy of the patch, which you can gunzip and play with however you want. Modified Files: .bochsrc Makefile.in aclocal.m4 bochs.h config.h.in configure configure.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h state_file.h bios/Makefile.in bios/rombios.c cpu/Makefile.in cpu/access.cc cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer32.cc cpu/exception.cc cpu/fetchdecode.cc cpu/fetchdecode64.cc cpu/flag_ctrl.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io.cc cpu/logical16.cc cpu/logical32.cc cpu/logical8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/protect_ctrl.cc cpu/segment_ctrl_pro.cc cpu/shift16.cc cpu/shift32.cc cpu/stack64.cc cpu/string.cc cpu/tasking.cc debug/Makefile.in debug/dbg_main.cc disasm/Makefile.in doc/docbook/user/user.dbk dynamic/Makefile.in fpu/Makefile.in gui/Makefile.in gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/control.cc gui/control.h gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/sdlkeys.h gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc gui/wxmain.h gui/x.cc gui/keymaps/sdl-pc-de.map gui/keymaps/sdl-pc-us.map gui/keymaps/x11-pc-de.map instrument/example0/instrument.h instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/Makefile.in iodev/biosdev.cc iodev/biosdev.h iodev/cdrom.cc iodev/cmos.cc iodev/cmos.h iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_fbsd.cc iodev/eth_linux.cc iodev/eth_null.cc iodev/eth_tap.cc iodev/floppy.cc iodev/floppy.h iodev/guest2host.cc iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/iodebug.cc iodev/iodebug.h iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.cc iodev/ne2k.h iodev/parallel.cc iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pci2isa.cc iodev/pci2isa.h iodev/pic.cc iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/scancodes.cc iodev/scancodes.h iodev/serial.cc iodev/serial.h iodev/slowdown_timer.cc iodev/slowdown_timer.h iodev/unmapped.cc iodev/unmapped.h iodev/vga.cc iodev/vga.h memory/Makefile.in memory/memory.cc memory/memory.h memory/misc_mem.cc misc/bximage.c misc/niclist.c Added Files: README-plugins extplugin.h ltdl.c ltdl.h ltdlconf.h.in ltmain.sh plugin.cc plugin.h
2002-10-25 01:07:56 +04:00
if (SIM->get_init_done()) DEV_vga_refresh();
// ensure the text screen is showing
SIM->set_display_mode(DISP_MODE_CONFIG);
int val = SIM->log_msg(prefix, level, buf1);
switch(val)
2001-06-19 20:25:41 +04:00
{
case BX_LOG_ASK_CHOICE_CONTINUE:
2001-06-19 20:25:41 +04:00
break;
case BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS:
// user said continue, and don't "ask" for this facility again.
setonoff(level, ACT_REPORT);
2001-06-19 20:25:41 +04:00
break;
case BX_LOG_ASK_CHOICE_DIE:
case BX_LOG_NOTIFY_FAILED:
bx_user_quit = (val==BX_LOG_ASK_CHOICE_DIE)?1:0;
in_ask_already = 0; // because fatal will longjmp out
2006-11-19 19:18:41 +03:00
fatal(prefix, buf1, ap, 1);
// should never get here
BX_PANIC(("in ask(), fatal() should never return!"));
break;
case BX_LOG_ASK_CHOICE_DUMP_CORE:
fprintf(stderr, "User chose to dump core...\n");
#if BX_HAVE_ABORT
abort();
#else
// do something highly illegal that should kill the process.
// Hey, this is fun!
{
char *crashptr = (char *)0; char c = *crashptr;
}
fprintf(stderr, "Sorry, I couldn't find your abort() function. Exiting.");
exit(0);
#endif
#if BX_DEBUGGER
case BX_LOG_ASK_CHOICE_ENTER_DEBUG:
// user chose debugger. To "drop into the debugger" we just set the
// interrupt_requested bit and continue execution. Before the next
// instruction, it should notice the user interrupt and return to
// the debugger.
bx_debug_break();
break;
#elif BX_GDBSTUB
case BX_LOG_ASK_CHOICE_ENTER_DEBUG:
bx_gdbstub_break();
break;
#endif
default:
// this happens if panics happen before the callback is initialized
// in gui/control.cc.
fprintf(stderr, "WARNING: log_msg returned unexpected value %d\n", val);
2001-06-19 20:25:41 +04:00
}
// return to simulation mode
SIM->set_display_mode(DISP_MODE_SIM);
in_ask_already = 0;
2001-06-19 20:25:41 +04:00
}
#if BX_WITH_CARBON
/* Panic button to display fatal errors.
Completely self contained, can't rely on carbon.cc being available */
static void carbonFatalDialog(const char *error, const char *exposition)
{
DialogRef alertDialog;
CFStringRef cfError;
CFStringRef cfExposition;
DialogItemIndex index;
AlertStdCFStringAlertParamRec alertParam = {0};
// Init libraries
InitCursor();
// Assemble dialog
cfError = CFStringCreateWithCString(NULL, error, kCFStringEncodingASCII);
if(exposition != NULL)
{
cfExposition = CFStringCreateWithCString(NULL, exposition, kCFStringEncodingASCII);
}
else {
cfExposition = NULL;
}
alertParam.version = kStdCFStringAlertVersionOne;
alertParam.defaultText = CFSTR("Quit");
alertParam.position = kWindowDefaultPosition;
alertParam.defaultButton = kAlertStdAlertOKButton;
// Display Dialog
CreateStandardAlert(
kAlertStopAlert,
cfError,
cfExposition, /* can be NULL */
&alertParam, /* can be NULL */
&alertDialog);
RunStandardAlert(alertDialog, NULL, &index);
// Cleanup
CFRelease(cfError);
if(cfExposition != NULL) { CFRelease(cfExposition); }
}
#endif
void logfunctions::fatal(const char *prefix, const char *fmt, va_list ap, int exit_status)
2001-06-19 20:25:41 +04:00
{
#if !BX_WITH_WX
// store prefix and message in 'exit_msg' before unloading device plugins
char tmpbuf[1024];
char exit_msg[1024];
vsprintf(tmpbuf, fmt, ap);
sprintf(exit_msg, "%s %s", prefix, tmpbuf);
#endif
#if !BX_DEBUGGER
2001-06-19 20:25:41 +04:00
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,
"For more information, try running Bochs within Terminal by clicking on \"bochs.scpt\".");
}
#endif
#if !BX_WITH_WX
2007-10-25 03:29:40 +04:00
static const char *divider = "========================================================================";
fprintf(stderr, "%s\n", divider);
fprintf(stderr, "Bochs is exiting with the following message:\n");
fprintf(stderr, "%s", exit_msg);
fprintf(stderr, "\n%s\n", divider);
#endif
2001-06-19 20:25:41 +04:00
#if !BX_DEBUGGER
BX_EXIT(exit_status);
2001-06-19 20:25:41 +04:00
#else
- Apply patch.replace-Boolean rev 1.3. Every "Boolean" is now changed to a "bx_bool" which is always defined as Bit32u on all platforms. In Carbon specific code, Boolean is still used because the Carbon header files define it to unsigned char. - this fixes bug [ 623152 ] MacOSX: Triple Exception Booting win95. The bug was that some code in Bochs depends on Boolean to be a 32 bit value. (This should be fixed, but I don't know all the places where it needs to be fixed yet.) Because Carbon defined Boolean as an unsigned char, Bochs just followed along and used the unsigned char definition to avoid compile problems. This exposed the dependency on 32 bit Boolean on MacOS X only and led to major simulation problems, that could only be reproduced and debugged on that platform. - On the mailing list we debated whether to make all Booleans into "bool" or our own type. I chose bx_bool for several reasons. 1. Unlike C++'s bool, we can guarantee that bx_bool is the same size on all platforms, which makes it much less likely to have more platform-specific simulation differences in the future. (I spent hours on a borrowed MacOSX machine chasing bug 618388 before discovering that different sized Booleans were the problem, and I don't want to repeat that.) 2. We still have at least one dependency on 32 bit Booleans which must be fixed some time, but I don't want to risk introducing new bugs into the simulation just before the 2.0 release. Modified Files: bochs.h config.h.in gdbstub.cc logio.cc main.cc pc_system.cc pc_system.h plugin.cc plugin.h bios/rombios.c cpu/apic.cc cpu/arith16.cc cpu/arith32.cc cpu/arith64.cc cpu/arith8.cc cpu/cpu.cc cpu/cpu.h cpu/ctrl_xfer16.cc cpu/ctrl_xfer32.cc cpu/ctrl_xfer64.cc cpu/data_xfer16.cc cpu/data_xfer32.cc cpu/data_xfer64.cc cpu/debugstuff.cc cpu/exception.cc cpu/fetchdecode.cc cpu/flag_ctrl_pro.cc cpu/init.cc cpu/io_pro.cc cpu/lazy_flags.cc cpu/lazy_flags.h cpu/mult16.cc cpu/mult32.cc cpu/mult64.cc cpu/mult8.cc cpu/paging.cc cpu/proc_ctrl.cc cpu/segment_ctrl_pro.cc cpu/stack_pro.cc cpu/tasking.cc debug/dbg_main.cc debug/debug.h debug/sim2.cc disasm/dis_decode.cc disasm/disasm.h doc/docbook/Makefile docs-html/cosimulation.html fpu/wmFPUemu_glue.cc gui/amigaos.cc gui/beos.cc gui/carbon.cc gui/gui.cc gui/gui.h gui/keymap.cc gui/keymap.h gui/macintosh.cc gui/nogui.cc gui/rfb.cc gui/sdl.cc gui/siminterface.cc gui/siminterface.h gui/term.cc gui/win32.cc gui/wx.cc gui/wxmain.cc gui/wxmain.h gui/x.cc instrument/example0/instrument.cc instrument/example0/instrument.h instrument/example1/instrument.cc instrument/example1/instrument.h instrument/stubs/instrument.cc instrument/stubs/instrument.h iodev/cdrom.cc iodev/cdrom.h iodev/cdrom_osx.cc iodev/cmos.cc iodev/devices.cc iodev/dma.cc iodev/dma.h iodev/eth_arpback.cc iodev/eth_packetmaker.cc iodev/eth_packetmaker.h iodev/floppy.cc iodev/floppy.h iodev/guest2host.h iodev/harddrv.cc iodev/harddrv.h iodev/ioapic.cc iodev/ioapic.h iodev/iodebug.cc iodev/iodev.h iodev/keyboard.cc iodev/keyboard.h iodev/ne2k.h iodev/parallel.h iodev/pci.cc iodev/pci.h iodev/pic.h iodev/pit.cc iodev/pit.h iodev/pit_wrap.cc iodev/pit_wrap.h iodev/sb16.cc iodev/sb16.h iodev/serial.cc iodev/serial.h iodev/vga.cc iodev/vga.h memory/memory.h memory/misc_mem.cc
2002-10-25 15:44:41 +04:00
static bx_bool dbg_exit_called = 0;
2001-06-19 20:25:41 +04:00
if (dbg_exit_called == 0) {
dbg_exit_called = 1;
bx_dbg_exit(exit_status);
}
2001-06-19 20:25:41 +04:00
#endif
// not safe to use BX_* log functions in here.
fprintf(stderr, "fatal() should never return, but it just did\n");
2001-06-19 20:25:41 +04:00
}
iofunc_t *io = NULL;
logfunc_t *genlog = NULL;
void bx_center_print(FILE *file, const char *line, unsigned maxwidth)
2001-06-19 20:25:41 +04:00
{
2007-12-30 21:02:22 +03:00
size_t len = strlen(line);
if (len > maxwidth)
BX_PANIC(("bx_center_print: line is too long: '%s'", line));
2007-12-30 21:02:22 +03:00
size_t imax = (maxwidth - len) >> 1;
for (size_t i=0; i<imax; i++) fputc(' ', file);
fputs(line, file);
2001-06-19 20:25:41 +04:00
}