- fixed broken debugger "rc file" command line option. Now it is possible to

execute debugger commands from the specified file. This is the command line
  counterpart to the undocumented debugger command "source".
This commit is contained in:
Volker Ruppert 2006-10-24 17:53:47 +00:00
parent 4ceec75181
commit f348c6cf50
3 changed files with 47 additions and 58 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: dbg_main.cc,v 1.84 2006-10-21 22:18:39 sshwarts Exp $
// $Id: dbg_main.cc,v 1.85 2006-10-24 17:53:47 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -54,7 +54,6 @@ extern const char* cpu_mode_string(unsigned cpu_mode);
static bx_param_bool_c *sim_running = NULL;
static char bx_debug_rc_fname[BX_MAX_PATH];
static char tmp_buf[512];
static char tmp_buf_prev[512];
static char *tmp_buf_ptr;
@ -131,11 +130,24 @@ void dbg_printf(const char *fmt, ...)
SIM->debug_puts(buf); // send to debugger, which will free buf when done.
}
int bx_dbg_main(int argc, char *argv[])
void bx_dbg_init_infile(void)
{
int i, bochs_argc=0;
char **bochs_argv = NULL;
argc = 1;
bx_infile_stack_index = 0;
bx_infile_stack[0].fp = stdin;
bx_infile_stack[0].lineno = 0;
}
int bx_dbg_set_rcfile(const char *rcfile)
{
strncpy(bx_infile_stack[0].fname, rcfile, BX_MAX_PATH);
bx_infile_stack[0].fname[BX_MAX_PATH-1] = 0;
BX_INFO(("debugger using rc file '%s'.", rcfile));
return bx_nest_infile((char*)rcfile);
}
int bx_dbg_main(void)
{
int i;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
@ -155,41 +167,6 @@ int bx_dbg_main(int argc, char *argv[])
bx_debugger.default_addr = 0;
bx_debugger.next_bpoint_id = 1;
argv0 = strdup(argv[0]);
bx_debug_rc_fname[0] = '\0';
bochs_argv = (char **) &argv[0];
bochs_argc = 1;
// process "-rc pathname" option, if it exists
i = 1;
if ((argc >= 2) && !strcmp(argv[1], "-rc")) {
if(argc == 2) {
BX_ERROR(("%s: -rc option used, but no path specified.", argv[0]));
dbg_printf("usage: %s [-rc path]\n", argv0);
BX_EXIT(1);
}
strncpy(bx_debug_rc_fname, argv[2], BX_MAX_PATH-1);
i += 2; // skip past "-rc" and filename
bochs_argv = (char **) &argv[2];
}
bx_infile_stack_index = 0;
bx_infile_stack[0].fp = stdin;
strncpy(bx_infile_stack[0].fname, argv[0], BX_MAX_PATH);
bx_infile_stack[0].fname[BX_MAX_PATH-1] = 0;
bx_infile_stack[0].lineno = 0;
if (bx_debug_rc_fname[0] == '\0') {
BX_INFO(("Warning: no rc file specified."));
}
else {
BX_INFO(("%s: using rc file '%s'.", argv[0], bx_debug_rc_fname));
// if there's an error, the user will know about it before proceeding
(void) bx_nest_infile(bx_debug_rc_fname);
}
// Open debugger log file if needed
if ((strlen(SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->getptr()) > 0)
&& (strcmp(SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->getptr(), "-") != 0)) {
@ -206,9 +183,6 @@ int bx_dbg_main(int argc, char *argv[])
memset(bx_disasm_ibuf, 0, sizeof(bx_disasm_ibuf));
// parse any remaining args in the usual way
bx_parse_cmdline(1, bochs_argc, bochs_argv);
// create a boolean parameter that will tell if the simulation is
// running (continue command) or waiting for user response. This affects
// some parts of the GUI.

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: debug.h,v 1.29 2006-10-21 21:28:20 sshwarts Exp $
// $Id: debug.h,v 1.30 2006-10-24 17:53:47 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -457,7 +457,9 @@ typedef struct bx_guard_found_t {
extern bx_guard_t bx_guard;
int bx_dbg_main(int argc, char *argv[]);
void bx_dbg_init_infile(void);
int bx_dbg_set_rcfile(const char *rcfile);
int bx_dbg_main(void);
void bx_dbg_user_input_loop(void);
void bx_dbg_interpret_line(char *cmd);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.346 2006-10-15 10:45:15 vruppert Exp $
// $Id: main.cc,v 1.347 2006-10-24 17:53:47 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -75,7 +75,7 @@ void bx_unmapped_io_write_handler(Bit32u address, Bit32u value,
unsigned io_len);
#endif
void bx_init_bx_dbg (void);
void bx_init_bx_dbg(void);
static char *divider = "========================================================================";
static logfunctions thePluginLog;
logfunctions *pluginlog = &thePluginLog;
@ -482,6 +482,9 @@ void print_usage()
" -q quick start (skip configuration interface)\n"
#if BX_SUPPORT_SAVE_RESTORE
" -r path restore the Bochs state from path\n"
#endif
#if BX_DEBUGGER
" -rc filename execute debugger commands stored in file\n"
#endif
" --help display this help and exit\n\n"
"For information on Bochs configuration file arguments, see the\n"
@ -518,31 +521,31 @@ int bx_init_main (int argc, char *argv[])
int arg = 1, load_rcfile=1;
while (arg < argc) {
// parse next arg
if (!strcmp ("--help", argv[arg]) || !strncmp ("-h", argv[arg], 2)
if (!strcmp("--help", argv[arg]) || !strncmp("-h", argv[arg], 2)
#if defined(WIN32)
|| !strncmp ("/?", argv[arg], 2)
|| !strncmp("/?", argv[arg], 2)
#endif
) {
print_usage();
SIM->quit_sim (0);
SIM->quit_sim(0);
}
else if (!strcmp ("-n", argv[arg])) {
else if (!strcmp("-n", argv[arg])) {
load_rcfile = 0;
}
else if (!strcmp ("-q", argv[arg])) {
else if (!strcmp("-q", argv[arg])) {
SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_QUICK_START);
}
else if (!strcmp ("-f", argv[arg])) {
else if (!strcmp("-f", argv[arg])) {
if (++arg >= argc) BX_PANIC(("-f must be followed by a filename"));
else bochsrc_filename = argv[arg];
}
else if (!strcmp ("-qf", argv[arg])) {
else if (!strcmp("-qf", argv[arg])) {
SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_QUICK_START);
if (++arg >= argc) BX_PANIC(("-qf must be followed by a filename"));
else bochsrc_filename = argv[arg];
}
#if BX_SUPPORT_SAVE_RESTORE
else if (!strcmp ("-r", argv[arg])) {
else if (!strcmp("-r", argv[arg])) {
if (++arg >= argc) BX_PANIC(("-r must be followed by a path"));
else {
SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_QUICK_START);
@ -552,7 +555,7 @@ int bx_init_main (int argc, char *argv[])
}
#endif
#if BX_WITH_CARBON
else if (!strncmp ("-psn", argv[arg], 4)) {
else if (!strncmp("-psn", argv[arg], 4)) {
// "-psn" is passed if we are launched by double-clicking
// 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
@ -570,6 +573,13 @@ int bx_init_main (int argc, char *argv[])
BX_INFO (("argument %d is %s", a, argv[a]));
}
}
#endif
#if BX_DEBUGGER
else if (!strcmp("-rc", argv[arg])) {
// process "-rc filename" option, if it exists
if (++arg >= argc) BX_PANIC(("-rc must be followed by a filename"));
else bx_dbg_set_rcfile(argv[arg]);
}
#endif
else if (argv[arg][0] == '-') {
print_usage();
@ -869,7 +879,7 @@ int bx_begin_simulation (int argc, char *argv[])
#if BX_DEBUGGER
// If using the debugger, it will take control and call
// bx_init_hardware() and cpu_loop()
bx_dbg_main(argc, argv);
bx_dbg_main();
#else
#if BX_GDBSTUB
// If using gdbstub, it will take control and call
@ -1101,6 +1111,9 @@ int bx_init_hardware()
void bx_init_bx_dbg(void)
{
#if BX_DEBUGGER
bx_dbg_init_infile();
#endif
bx_dbg.floppy = 0;
bx_dbg.keyboard = 0;
bx_dbg.video = 0;