diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-07-07 20:46:57 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-07-07 20:46:57 +0000 |
commit | 64c981385b63006523ebafeb24bdf895ee290475 (patch) | |
tree | 826374a0f8640693018c0c92c0c43862df2ec5f7 | |
parent | 3c7403c706d7ee3214409d17b555b1427a17e20e (diff) | |
download | mdk-64c981385b63006523ebafeb24bdf895ee290475.tar.gz mdk-64c981385b63006523ebafeb24bdf895ee290475.tar.bz2 |
timing command
-rw-r--r-- | mixlib/mix_vm_command.c | 45 | ||||
-rw-r--r-- | mixlib/mix_vm_command.h | 7 |
2 files changed, 47 insertions, 5 deletions
diff --git a/mixlib/mix_vm_command.c b/mixlib/mix_vm_command.c index 4f0295f..6eab3a2 100644 --- a/mixlib/mix_vm_command.c +++ b/mixlib/mix_vm_command.c @@ -96,6 +96,7 @@ DEC_FUN (cabp_); DEC_FUN (weval_); DEC_FUN (w2d_); DEC_FUN (tracing_); +DEC_FUN (timing_); DEC_FUN (edit_); DEC_FUN (compile_); DEC_FUN (pedit_); @@ -156,12 +157,15 @@ command_ commands_[] = { { "w2d", cmd_w2d_, N_("Convert a MIX word to its decimal value"), "w2d WORD"}, { "tracing", cmd_tracing_, N_("Turn on/off instruction tracing"), - "tracing on|off"}, + "tracing [on|off]"}, + { "timing", cmd_timing_, N_("Turn on/off timing statistics"), + "timing [on|off]"}, { NULL, NULL, NULL, NULL}, }; /* configuration keys */ static const gchar *TRACING_KEY_ = "Tracing"; +static const gchar *TIMING_KEY_ = "Timing"; static const gchar *EDITOR_KEY_ = "Editor"; static const gchar *ASM_KEY_ = "Assembler"; @@ -251,6 +255,8 @@ mix_vm_cmd_dispatcher_new_with_config (FILE *out, FILE *err, if (val) mix_vm_cmd_dispatcher_set_editor (result, val); val = mix_config_get (result->config, ASM_KEY_); if (val) mix_vm_cmd_dispatcher_set_assembler (result, val); + val = mix_config_get (result->config, TIMING_KEY_); + if (val) cmd_timing_ (result, val); } return result; } @@ -1326,17 +1332,48 @@ cmd_tracing_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) dis->trace = FALSE; if (dis->config) mix_config_update (dis->config, TRACING_KEY_, OFF); } - else + else if (arg && !strlen (arg)) + { + fprintf (dis->out, "Instruction tracing is currently set %s\n", + dis->trace ? "ON" : "OFF"); + } + else cmd_help_ (dis, "tracing"); return TRUE; } static gboolean +cmd_timing_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) +{ + static const gchar *ON = "on"; + static const gchar *OFF = "off"; + if (arg && !strcmp (arg, ON)) + { + dis->printtime = TRUE; + if (dis->config) mix_config_update (dis->config, TIMING_KEY_, ON); + } + else if (arg && !strcmp (arg, OFF)) + { + dis->printtime = FALSE; + if (dis->config) mix_config_update (dis->config, TIMING_KEY_, OFF); + } + else if (arg && !strlen (arg)) + { + fprintf (dis->out, "Instruction timing is currently set %s\n", + dis->printtime ? "ON" : "OFF"); + } + else + cmd_help_ (dis, "timing"); + return TRUE; +} + + +static gboolean cmd_pedit_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { const gchar *ed = mix_vm_cmd_dispatcher_get_editor (dis); if (dis) - fprintf (dis->out, "Edit command:%s\n", ed); + fprintf (dis->out, "Edit command: %s\n", ed); else fprintf (dis->out, "Edit command not set (use sedit)\n"); return TRUE; @@ -1355,7 +1392,7 @@ cmd_pasm_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { const gchar *ed = mix_vm_cmd_dispatcher_get_assembler (dis); if (dis) - fprintf (dis->out, "Compile command:%s\n", ed); + fprintf (dis->out, "Compile command: %s\n", ed); else fprintf (dis->out, "Compile command not set (use sasm)\n"); return TRUE; diff --git a/mixlib/mix_vm_command.h b/mixlib/mix_vm_command.h index b1c6839..40bb7e8 100644 --- a/mixlib/mix_vm_command.h +++ b/mixlib/mix_vm_command.h @@ -41,7 +41,11 @@ typedef enum { MIX_CMD_HELP = 0, /* echo help message */ MIX_CMD_LOAD, /* load a mix program */ MIX_CMD_EDIT, /* edit mixal source */ + MIX_CMD_PEDIT, /* print editor command */ + MIX_CMD_SEDIT, /* set editor command*/ MIX_CMD_COMPILE, /* compile mixal source */ + MIX_CMD_PASM, /* print compiler command */ + MIX_CMD_SASM, /* set assembler command */ MIX_CMD_RUN, /* run a loaded program */ MIX_CMD_NEXT, /* run next instruction */ MIX_CMD_LOC, /* print location pointer */ @@ -62,7 +66,8 @@ typedef enum { MIX_CMD_CABP, /* clear all breakpoints */ MIX_CMD_WEVAL, /* evaluate a w-expression */ MIX_CMD_W2D, /* print word in decimal notation */ - MIX_CMD_TRACE, /* enable/disable instruction traces */ + MIX_CMD_TRACING, /* enable/disable instruction traces */ + MIX_CMD_TIMING, /* enable/disable timing statistics */ MIX_CMD_INVALID, /* invalid command identifier */ } mix_vm_command_t; |