full support for saving log options per device (from bochsrc and config interface)

simplified setting up log options per device after parsing bochsrc / command line
This commit is contained in:
Volker Ruppert 2013-02-04 18:51:07 +00:00
parent 48b345d06f
commit 7d32178e72
6 changed files with 22 additions and 20 deletions

View File

@ -1640,6 +1640,7 @@ int bx_read_configuration(const char *rcfile)
int action = SIM->get_default_log_action(level);
io->set_log_action(level, action);
}
bx_set_log_actions_by_device(0);
return 0;
}
@ -1657,6 +1658,7 @@ int bx_parse_cmdline(int arg, int argc, char *argv[])
int action = SIM->get_default_log_action(level);
io->set_log_action(level, action);
}
bx_set_log_actions_by_device(0);
return 0;
}
@ -3145,29 +3147,36 @@ int bx_write_clock_cmos_options(FILE *fp)
int bx_write_log_options(FILE *fp, bx_list_c *base)
{
char pname[20];
bx_list_c *logfn, *level;
bx_list_c *logfn, *loglev;
bx_param_num_c *mparam;
int i, j;
int action, def_action, level, mod;
fprintf(fp, "log: %s\n", SIM->get_param_string("filename", base)->getptr());
fprintf(fp, "logprefix: %s\n", SIM->get_param_string("prefix", base)->getptr());
strcpy(pname, "general.logfn");
logfn = (bx_list_c*) SIM->get_param(pname);
for (i = 0; i < logfn->get_size(); i++) {
level = (bx_list_c*) logfn->get(i);
fprintf(fp, "%s: action=%s", level->get_name(),
io->getaction(logfunctions::get_default_action(i)));
if (level->get_size() > 0) {
for (j = 0; j < level->get_size(); j++) {
mparam = (bx_param_num_c*)level->get(j);
fprintf(fp, ", %s=%s\n", mparam->get_name(), SIM->get_action_name(mparam->get()));
for (level = 0; level < N_LOGLEV; level++) {
loglev = (bx_list_c*) logfn->get(level);
def_action = SIM->get_default_log_action(level);
fprintf(fp, "%s: action=%s", loglev->get_name(), SIM->get_action_name(def_action));
// stage #1: save log actions of existing modules
for (mod = 0; mod < SIM->get_n_log_modules(); mod++) {
action = SIM->get_log_action(mod, level);
if (action != def_action) {
fprintf(fp, ", %s=%s", SIM->get_logfn_name(mod), SIM->get_action_name(action));
}
} else {
fprintf(fp, "\n");
}
// stage #2: save log actions of not yet existing modules (from bochsrc)
for (mod = 0; mod < loglev->get_size(); mod++) {
mparam = (bx_param_num_c*)loglev->get(mod);
action = mparam->get();
if ((action >= 0) && (action != def_action)) {
fprintf(fp, ", %s=%s", mparam->get_name(), SIM->get_action_name(action));
}
}
fprintf(fp, "\n");
}
return 0;
}

View File

@ -102,9 +102,6 @@ public:
virtual void set_default_log_action(int level, int action) {
logfunctions::set_default_action(level, action);
}
virtual void apply_log_actions_by_device() {
bx_set_log_actions_by_device(0);
}
virtual const char *get_log_level_name(int level);
virtual int get_max_log_level() { return N_LOGLEV; }
virtual void quit_sim(int code);

View File

@ -642,7 +642,6 @@ public:
virtual void set_log_action(int mod, int level, int action) {}
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual void apply_log_actions_by_device() {}
virtual const char *get_action_name(int action) {return 0;}
virtual const char *get_log_level_name(int level) {return 0;}
virtual int get_max_log_level() {return -1;}

View File

@ -589,7 +589,6 @@ static int log_level_n_choices_normal = 4;
void bx_log_options(int individual)
{
SIM->apply_log_actions_by_device(); // settings from bochsrc
if (individual) {
int done = 0;
while (!done) {

View File

@ -421,7 +421,6 @@ static BOOL CALLBACK LogOptDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
switch (msg) {
case WM_INITDIALOG:
advanced = (BOOL)lParam;
SIM->apply_log_actions_by_device(); // settings from bochsrc
InitLogOptionsDialog(hDlg, advanced);
changed = FALSE;
EnableWindow(GetDlgItem(hDlg, IDAPPLY), FALSE);

View File

@ -307,7 +307,6 @@ void AdvancedLogOptionsDialog::Init()
void AdvancedLogOptionsDialog::CopyParamToGui()
{
SIM->apply_log_actions_by_device(); // settings from bochsrc
bx_param_string_c *logfile = SIM->get_param_string(BXPN_LOG_FILENAME);
SetLogfile(wxString(logfile->getptr(), wxConvUTF8));
// copy log action settings from siminterface to gui