---------------------------------------------------------------------- Patch name: patch.logfilefmteip Author: Carl Sopchak Date: May, 26th 2002 Detailed description: I reworked and included Carl's patch to have a new bochsrc directive to describe the format of the log prefix. This option can be any string with special tokens being replaced at run time : # %t : 11 decimal digits timer tick # %i : 8 hexadecimal digits of cpu0 current eip # %e : 1 character event type ('i'nfo, 'd'ebug, 'p'anic, 'e'rror) # %d : 5 characters string of the device, between brackets the default is "%t%i%d", so the logprefix is the same as before. New tokens can be easily added or changed if needed. Original Detailed description: While working with Bela Lubkin of Caldera, trying to get bochs to install SCO OSR5, Bela asked me to add the EIP to the log file. The attached patch changes the timestamp portion of a log file entry to tttttttttt-x-@eeeeeee[sssss] where tttttttttt is the ticks, x is the type of entry (error, panic, info, debug), eeeeeeee is the EIP (in hex), and sssss remains the subsystem (e.g., HD, FDD, BIOS, etc) Please make this part of the standard bochs package. Thanks, Carl Patch was created with: cvs diff -u Apply patch to what version: cvs checked out on May, 26th 2002 Instructions: To patch, go to main bochs directory. Type "patch -p0 < THIS_PATCH_FILE". ---------------------------------------------------------------------- Index: .bochsrc =================================================================== RCS file: /cvsroot/bochs/bochs/.bochsrc,v retrieving revision 1.41 diff -u -r1.41 .bochsrc --- .bochsrc 4 May 2002 16:00:40 -0000 1.41 +++ .bochsrc 26 Jun 2002 14:39:43 -0000 @@ -152,6 +152,22 @@ log: bochsout.txt #======================================================================= +# LOGPREFIX: +# This handles the format of the string prepended to each log line : +# You may use those special tokens : +# %t : 11 decimal digits timer tick +# %i : 8 hexadecimal digits of cpu0 current eip +# %e : 1 character event type ('i'nfo, 'd'ebug, 'p'anic, 'e'rror) +# %d : 5 characters string of the device, between brackets +# +# Default : %t%e%d +# Examples: +# logprefix: %t-%e-@%i-%d +# logprefix: %i%e%d +#======================================================================= +#logprefix: %t%e%d + +#======================================================================= # LOG CONTROLS # # Bochs now has four severity levels for event logging. Index: bochs.h =================================================================== RCS file: /cvsroot/bochs/bochs/bochs.h,v retrieving revision 1.65 diff -u -r1.65 bochs.h --- bochs.h 16 Jun 2002 15:02:27 -0000 1.65 +++ bochs.h 26 Jun 2002 14:39:44 -0000 @@ -277,12 +277,16 @@ } } logfunc_t; +#define BX_LOGPREFIX_SIZE 51 + class iofunctions { - int showtick,magic; + int magic; + char logprefix[BX_LOGPREFIX_SIZE]; FILE *logfd; class logfunctions *log; void init(void); void flush(void); + void setlogprefix(void); // Log Class defines #define IOLOG 0 #define FDLOG 1 @@ -589,6 +593,7 @@ typedef struct { bx_param_string_c *Ofilename; + bx_param_string_c *Oprefix; // one array item for each log level, indexed by LOGLEV_*. // values: ACT_IGNORE, ACT_REPORT, ACT_ASK, ACT_FATAL unsigned char actions[N_LOGLEV]; Index: logio.cc =================================================================== RCS file: /cvsroot/bochs/bochs/logio.cc,v retrieving revision 1.18 diff -u -r1.18 logio.cc --- logio.cc 1 Jun 2002 07:39:19 -0000 1.18 +++ logio.cc 26 Jun 2002 14:39:44 -0000 @@ -45,12 +45,48 @@ } } +// 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::setlogprefix(void) { + int i=0; + char *s; + char *f; + + s=bx_options.log.Oprefix->getptr (); + strcpy(logprefix,""); + while (*s!=0) { + if (*s!='%') { + if (strlen(logprefix)eip, prefix==NULL?"":prefix); + fprintf(logfd," "); if(l==LOGLEV_PANIC) fprintf(logfd, ">>PANIC<< "); Index: main.cc =================================================================== RCS file: /cvsroot/bochs/bochs/main.cc,v retrieving revision 1.101 diff -u -r1.101 main.cc --- main.cc 25 May 2002 13:16:55 -0000 1.101 +++ main.cc 26 Jun 2002 14:39:44 -0000 @@ -103,7 +103,7 @@ NULL, // newHardDriveSupport { 0, NULL, NULL, NULL }, // load32bitOSImage hack stuff // log options: ignore debug, report info and error, crash on panic. - { NULL, { ACT_IGNORE, ACT_REPORT, ACT_REPORT, ACT_ASK } }, + { NULL, NULL, { ACT_IGNORE, ACT_REPORT, ACT_REPORT, ACT_ASK } }, { NULL, NULL }, // KeyboardMapping }; @@ -832,6 +832,12 @@ "-", BX_PATHNAME_LEN); bx_options.log.Ofilename->set_ask_format ("Enter log filename: [%s] "); + bx_options.log.Oprefix = new bx_param_string_c (BXP_LOG_PREFIX, + "logprefix:prefix", + "Prefix prepended to log output", + "%t%e%d", BX_PATHNAME_LEN); + bx_options.log.Oprefix->set_ask_format ("Enter log prefix: [%s] "); + // loader bx_options.load32bitOSImage.OwhichOS = new bx_param_enum_c (BXP_LOAD32BITOS_WHICH, "Which operating system?", @@ -1693,6 +1699,12 @@ } bx_options.log.Ofilename->set (params[1]); } + else if (!strcmp(params[0], "logprefix")) { + if (num_params != 2) { + BX_PANIC(("%s: logprefix directive has wrong # args.", context)); + } + bx_options.log.Oprefix->set (params[1]); + } else if (!strcmp(params[0], "panic")) { if (num_params != 2) { BX_PANIC(("%s: panic directive malformed.", context)); @@ -2277,6 +2289,7 @@ bx_write_log_options (FILE *fp, bx_log_options *opt) { fprintf (fp, "log: %s\n", opt->Ofilename->getptr ()); + fprintf (fp, "logprefix: %s\n", opt->Oprefix->getptr ()); // no syntax to describe all the possible action settings for every // device. Instead, take a vote and record the most popular action // for each level of event. Index: gui/control.cc =================================================================== RCS file: /cvsroot/bochs/bochs/gui/control.cc,v retrieving revision 1.50 diff -u -r1.50 control.cc --- gui/control.cc 23 Jun 2002 18:02:55 -0000 1.50 +++ gui/control.cc 26 Jun 2002 14:39:44 -0000 @@ -102,6 +102,30 @@ return s; } +void +double_percent (char *s, int max_len) +{ + char d[CPANEL_PATH_LEN]; + int i=0,j=0; + + if (max_len>CPANEL_PATH_LEN) + max_len=CPANEL_PATH_LEN; + + max_len--; + + while((s[i]!=0)&&(jget_log_file (oldpath, CPANEL_PATH_LEN); - assert (retval >= 0); - sprintf (prompt, startup_options_prompt, oldpath); - if (ask_uint (prompt, 0, 10, 0, &choice, 10) < 0) return -1; + char oldpath[CPANEL_PATH_LEN]; + char oldprefix[CPANEL_PATH_LEN]; + int retval; + + retval = SIM->get_log_file (oldpath, CPANEL_PATH_LEN); + assert (retval >= 0); + double_percent(oldpath,CPANEL_PATH_LEN); + retval = SIM->get_log_prefix (oldprefix, CPANEL_PATH_LEN); + assert (retval >= 0); + double_percent(oldprefix,CPANEL_PATH_LEN); + + sprintf (prompt, startup_options_prompt, oldpath, oldprefix); + if (ask_uint (prompt, 0, 11, 0, &choice, 10) < 0) return -1; switch (choice) { case 0: return 0; case 1: askparam (BXP_LOG_FILENAME); break; - case 2: bx_log_options (0); break; - case 3: bx_log_options (1); break; - case 4: do_menu (BXP_MENU_MEMORY); break; - case 5: do_menu (BXP_MENU_INTERFACE); break; - case 6: do_menu (BXP_MENU_DISK); break; - case 7: do_menu (BXP_MENU_SERIAL_PARALLEL); break; - case 8: do_menu (BXP_SB16); break; - case 9: do_menu (BXP_NE2K); break; - case 10: do_menu (BXP_MENU_MISC); break; + case 2: askparam (BXP_LOG_PREFIX); break; + case 3: bx_log_options (0); break; + case 4: bx_log_options (1); break; + case 5: do_menu (BXP_MENU_MEMORY); break; + case 6: do_menu (BXP_MENU_INTERFACE); break; + case 7: do_menu (BXP_MENU_DISK); break; + case 8: do_menu (BXP_MENU_SERIAL_PARALLEL); break; + case 9: do_menu (BXP_SB16); break; + case 10: do_menu (BXP_NE2K); break; + case 11: do_menu (BXP_MENU_MISC); break; default: BAD_OPTION(menu, choice); } } Index: gui/siminterface.h =================================================================== RCS file: /cvsroot/bochs/bochs/gui/siminterface.h,v retrieving revision 1.37 diff -u -r1.37 siminterface.h --- gui/siminterface.h 2 May 2002 07:54:22 -0000 1.37 +++ gui/siminterface.h 26 Jun 2002 14:39:44 -0000 @@ -103,6 +103,7 @@ BXP_I440FX_SUPPORT, BXP_NEWHARDDRIVESUPPORT, BXP_LOG_FILENAME, + BXP_LOG_PREFIX, BXP_CMOS_PATH, BXP_CMOS_IMAGE, BXP_CMOS_TIME0, @@ -596,6 +597,8 @@ virtual int write_rc (char *rc, int overwrite) {return -1;} virtual int get_log_file (char *path, int len) {return -1;} virtual int set_log_file (char *path) {return -1;} + virtual int get_log_prefix (char *prefix, int len) {return -1;} + virtual int set_log_prefix (char *prefix) {return -1;} virtual int get_floppy_options (int drive, bx_floppy_options *out) {return -1;} virtual int get_cdrom_options (int drive, bx_cdrom_options *out) {return -1;} virtual char *get_floppy_type_name (int type) {return NULL;} Index: gui/siminterface.cc =================================================================== RCS file: /cvsroot/bochs/bochs/gui/siminterface.cc,v retrieving revision 1.41 diff -u -r1.41 siminterface.cc --- gui/siminterface.cc 23 Apr 2002 07:44:34 -0000 1.41 +++ gui/siminterface.cc 26 Jun 2002 14:39:44 -0000 @@ -69,6 +69,8 @@ virtual int write_rc (char *path, int overwrite); virtual int get_log_file (char *path, int len); virtual int set_log_file (char *path); + virtual int get_log_prefix (char *prefix, int len); + virtual int set_log_prefix (char *prefix); virtual int get_floppy_options (int drive, bx_floppy_options *out); virtual int get_cdrom_options (int drive, bx_cdrom_options *out); virtual char *get_floppy_type_name (int type); @@ -290,6 +292,20 @@ bx_real_sim_c::set_log_file (char *path) { bx_options.log.Ofilename->set (path); + return 0; +} + +int +bx_real_sim_c::get_log_prefix (char *prefix, int len) +{ + strncpy (prefix, bx_options.log.Oprefix->getptr (), len); + return 0; +} + +int +bx_real_sim_c::set_log_prefix (char *prefix) +{ + bx_options.log.Oprefix->set (prefix); return 0; }