Fixes for bug [ #467530 ] cmd line overrides config interface
- rework the order of initialization with and without the control panel. The thing that was bothering me most was the command line options were being processed after the user had set everything in the control panel. This is clearly not what's expected--the command line options should affect the startup defaults of the control panel, but whatever the user chooses in the cpanel menus is the final choice. - if the control panel (config interface) is not wanted, the user can put "-nocp" or "-nocontrolpanel" as the FIRST argument on the command line. Also, the "-psn" option which is automatically passed in by MacOS X when you doubleclick the application causes the control panel to be disabled. In this case, the order of operations is: 1. read bochsrc 2. parse command line options. - if the control panel is enabled (default), the command line options are parsed to provide the startup defaults for the control panel, but the control panel settings are the final answer. So the order is: 1. parse command line options 2. run control panel (if user chooses, he can read bochsrc from menus) - I haven't tested command line options with the debugger yet.
This commit is contained in:
parent
1b45532520
commit
03c9a235b5
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: bochs.h,v 1.50 2001-10-03 13:10:37 bdenney Exp $
|
||||
// $Id: bochs.h,v 1.51 2001-10-06 22:31:31 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -517,7 +517,7 @@ extern bx_devices_c bx_devices;
|
||||
|
||||
|
||||
char *bx_find_bochsrc (void);
|
||||
int bx_parse_cmdline (int argc, char *argv[]);
|
||||
int bx_parse_cmdline (int arg, int argc, char *argv[]);
|
||||
int bx_read_configuration (char *rcfile);
|
||||
int bx_write_configuration (char *rcfile, int overwrite);
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: control.cc,v 1.33 2001-10-06 08:45:18 bdenney Exp $
|
||||
// $Id: control.cc,v 1.34 2001-10-06 22:31:31 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/*
|
||||
* gui/control.cc
|
||||
* $Id: control.cc,v 1.33 2001-10-06 08:45:18 bdenney Exp $
|
||||
* $Id: control.cc,v 1.34 2001-10-06 22:31:31 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
|
||||
@ -393,25 +393,15 @@ void askparam (bx_id id)
|
||||
param->text_ask (stdin, stderr);
|
||||
}
|
||||
|
||||
// return value of bx_control_panel:
|
||||
// -1: error while reading, like if stdin closed
|
||||
// 0: no error
|
||||
// BX_DISABLE_CONTROL_PANEL: returned from BX_CPANEL_START_MAIN if
|
||||
// user chooses to revert to the normal way of running without the
|
||||
// control panel.
|
||||
int bx_control_panel (int menu)
|
||||
{
|
||||
Bit32u choice;
|
||||
while (1) {
|
||||
switch (menu)
|
||||
{
|
||||
case BX_CPANEL_START_MAIN:
|
||||
case BX_CPANEL_INIT:
|
||||
bx_control_panel_init ();
|
||||
{
|
||||
if (ask_yn (ask_about_control_panel, 1, &choice) < 0) return -1;
|
||||
if (choice == 0) return BX_DISABLE_CONTROL_PANEL;
|
||||
else return bx_control_panel (BX_CPANEL_START_MENU);
|
||||
}
|
||||
return 0;
|
||||
case BX_CPANEL_START_MENU:
|
||||
{
|
||||
static int read_rc = 0;
|
||||
|
@ -1,9 +1,9 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: control.h,v 1.5 2001-10-03 13:10:37 bdenney Exp $
|
||||
// $Id: control.h,v 1.6 2001-10-06 22:31:31 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
enum {
|
||||
BX_CPANEL_START_MAIN,
|
||||
BX_CPANEL_INIT,
|
||||
BX_CPANEL_START_MENU,
|
||||
BX_CPANEL_START_OPTS,
|
||||
BX_CPANEL_START_OPTS_MEM,
|
||||
@ -15,7 +15,7 @@ enum {
|
||||
BX_CPANEL_N_MENUS
|
||||
};
|
||||
|
||||
/* special return value from bx_control_panl */
|
||||
/* special return value from bx_control_panel */
|
||||
#define BX_DISABLE_CONTROL_PANEL 10
|
||||
|
||||
int bx_control_panel (int menu);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: main.cc,v 1.70 2001-10-03 12:56:51 bdenney Exp $
|
||||
// $Id: main.cc,v 1.71 2001-10-06 22:31:31 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -29,7 +29,7 @@
|
||||
#include <assert.h>
|
||||
#include "state_file.h"
|
||||
|
||||
int force_no_control_panel = 0;
|
||||
int enable_control_panel = 1;
|
||||
|
||||
extern "C" {
|
||||
#include <signal.h>
|
||||
@ -775,6 +775,7 @@ static void setupWorkingDirectory (char *path)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int arg = 1;
|
||||
// To deal with initialization order problems inherent in C++, use the macros
|
||||
// SAFE_GET_IOFUNC and SAFE_GET_GENLOG to retrieve "io" and "genlog" in all
|
||||
// constructors or functions called by constructors. The macros test for
|
||||
@ -788,14 +789,18 @@ main(int argc, char *argv[])
|
||||
bx_init_bx_dbg ();
|
||||
|
||||
#if BX_WITH_CARBON
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
/* "-psn" is passed if we are launched by double-clicking */
|
||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||
// ugly hack. I don't know how to open a window to print messages in,
|
||||
// so put them in /tmp/early-bochs-out.txt. Sorry. -bbd
|
||||
io->init_log("/tmp/early-bochs-out.txt");
|
||||
BX_INFO (("I was launched by double clicking. Fixing home directory."));
|
||||
argc = 1;
|
||||
argc = 1; // ignore all other args.
|
||||
setupWorkingDirectory (argv[0]);
|
||||
force_no_control_panel = 1;
|
||||
// there is no stdin/stdout so disable the text-based config interface.
|
||||
enable_control_panel = 0;
|
||||
}
|
||||
// if it was started from command line, there could be some args still.
|
||||
for (int a=0; a<argc; a++) {
|
||||
BX_INFO (("argument %d is %s", a, argv[a]));
|
||||
}
|
||||
@ -805,38 +810,33 @@ main(int argc, char *argv[])
|
||||
BX_INFO (("Now my working directory is %s", cwd));
|
||||
#endif
|
||||
|
||||
int read_rc_already = 0;
|
||||
init_siminterface ();
|
||||
bx_control_panel (BX_CPANEL_INIT);
|
||||
bx_init_options ();
|
||||
|
||||
#if BX_USE_CONTROL_PANEL
|
||||
if (force_no_control_panel) {
|
||||
SIM->set_enabled (0);
|
||||
} if (argc > 1 && (!strcmp ("-nocontrolpanel", argv[1]))) {
|
||||
// detect -nocontrolpanel or -nocp argument before anything else
|
||||
if (argc > 1 &&
|
||||
((!strcmp ("-nocontrolpanel", argv[1]))
|
||||
|| (!strcmp ("-nocp", argv[1])))) {
|
||||
// skip the control panel
|
||||
argc++;
|
||||
arg++;
|
||||
SIM->set_enabled (0);
|
||||
} else {
|
||||
// Display the pre-simulation control panel.
|
||||
if ((bx_control_panel (BX_CPANEL_START_MAIN)) == BX_DISABLE_CONTROL_PANEL)
|
||||
SIM->set_enabled (0);
|
||||
else {
|
||||
SIM->set_enabled (1);
|
||||
read_rc_already = 1;
|
||||
}
|
||||
enable_control_panel = 0;
|
||||
}
|
||||
#if !BX_USE_CONTROL_PANEL
|
||||
enable_control_panel = 0;
|
||||
#endif
|
||||
|
||||
if (!read_rc_already) {
|
||||
/* parse configuration file and command line arguments */
|
||||
if (!enable_control_panel) {
|
||||
// if we don't intend to run the control panel, parse the .bochsrc now.
|
||||
char *bochsrc = bx_find_bochsrc ();
|
||||
if (bochsrc)
|
||||
bx_read_configuration (bochsrc);
|
||||
|
||||
if (bochsrc == NULL && argc == 1) {
|
||||
// no bochsrc used. This is legal since they may have
|
||||
// everything on the command line. However if they have no
|
||||
// arguments then give them some friendly advice.
|
||||
if (bochsrc == NULL && arg>=argc) {
|
||||
// no bochsrc used. This is legal since they may have everything on the
|
||||
// command line. However if they have no arguments then give them some
|
||||
// friendly advice.
|
||||
fprintf (stderr, "%s\n", divider);
|
||||
fprintf (stderr, "Before running Bochs, you should cd to a directory which contains\n");
|
||||
fprintf (stderr, "a .bochsrc file and a disk image. If you downloaded a binary package,\n");
|
||||
@ -854,18 +854,25 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// parse the rest of the command line.
|
||||
if (bx_parse_cmdline (arg, argc, argv)) {
|
||||
fprintf (stderr, "There were errors while parsing the command line.\n");
|
||||
fprintf (stderr, "Bochs is exiting.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (enable_control_panel) {
|
||||
// Display the pre-simulation control panel.
|
||||
bx_control_panel (BX_CPANEL_START_MENU);
|
||||
SIM->set_enabled (1);
|
||||
}
|
||||
|
||||
#if BX_DEBUGGER
|
||||
// If using the debugger, it will take control and call
|
||||
// bx_init_hardware() and cpu_loop()
|
||||
bx_dbg_main(argc, argv);
|
||||
#else
|
||||
|
||||
if (bx_parse_cmdline (argc, argv)) {
|
||||
fprintf (stderr, "There were errors while parsing the command line.\n");
|
||||
fprintf (stderr, "Bochs is exiting.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
bx_init_hardware();
|
||||
|
||||
if (bx_options.load32bitOSImage.OwhichOS->get ()) {
|
||||
@ -917,15 +924,14 @@ bx_read_configuration (char *rcfile)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bx_parse_cmdline (int argc, char *argv[])
|
||||
int bx_parse_cmdline (int arg, int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1)
|
||||
BX_INFO (("parsing command line arguments"));
|
||||
//if (arg < argc) BX_INFO (("parsing command line arguments"));
|
||||
|
||||
int n = 2;
|
||||
while (n <= argc) {
|
||||
parse_line_unformatted("cmdline args", argv[n-1]);
|
||||
n++;
|
||||
while (arg < argc) {
|
||||
BX_INFO (("parsing arg %d, %s", arg, argv[arg]));
|
||||
parse_line_unformatted("cmdline args", argv[arg]);
|
||||
arg++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user