- add another choice when you have action=ask: abort! Calling abort

will dump core, and the core can sometimes be loaded into the debugger
  to give some hints as to what is going on.  This could be especially
  useful when the bochs debugger is off.
- try to do something reasonable when abort() doesn't exist on the system.
This commit is contained in:
Bryce Denney 2001-10-07 00:35:35 +00:00
parent 8a21b1a9d6
commit 49d50d0010
2 changed files with 24 additions and 7 deletions

View File

@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////
// $Id: control.cc,v 1.34 2001-10-06 22:31:31 bdenney Exp $
// $Id: control.cc,v 1.35 2001-10-07 00:35:35 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
/*
* gui/control.cc
* $Id: control.cc,v 1.34 2001-10-06 22:31:31 bdenney Exp $
* $Id: control.cc,v 1.35 2001-10-07 00:35:35 bdenney Exp $
*
* This is code for a text-mode control panel. Note that this file
* does NOT include bochs.h. Instead, it does all of its contact with
@ -584,8 +584,8 @@ int bx_write_rc (char *rc)
}
}
char *log_action_ask_choices[] = { "cont", "alwayscont", "die", "debug" };
int log_action_n_choices = 3 + (BX_DEBUGGER?1:0);
char *log_action_ask_choices[] = { "cont", "alwayscont", "die", "abort", "debug" };
int log_action_n_choices = 4 + (BX_DEBUGGER?1:0);
int control_panel_notify_callback (int code)
{
@ -605,14 +605,18 @@ int control_panel_notify_callback (int code)
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), 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");
#endif
int choice;
if (ask_menu ("Choose cont, alwayscont, or die. [%s] ",
ask:
if (ask_menu ("Choose one of the actions above: [%s] ",
log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
return SIM->notify_return(-1);
// return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
if (!BX_HAVE_ABORT && choice==3) goto ask;
SIM->notify_return(choice);
}
break;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: logio.cc,v 1.10 2001-10-06 22:23:10 bdenney Exp $
// $Id: logio.cc,v 1.11 2001-10-07 00:35:35 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -356,8 +356,21 @@ logfunctions::ask (int level, char *prefix, char *fmt, va_list ap)
break;
case 2: // user chose die
fatal (prefix, fmt, ap);
case 3: // user chose abort
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 3:
case 4:
// 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