From 742ea7c38cb50c257cc8d674dddfd0d32cd21c22 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 11 Jan 2003 22:43:13 +0000 Subject: Bug #1704 fixed. --- mixlib/xmix_vm_handlers.c | 100 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/mixlib/xmix_vm_handlers.c b/mixlib/xmix_vm_handlers.c index 7a6c3d1..4d0285f 100644 --- a/mixlib/xmix_vm_handlers.c +++ b/mixlib/xmix_vm_handlers.c @@ -1,24 +1,24 @@ /* -*-c-*- -------------- xmix_vm_handlers.c : * Implementation of the functions declared in xmix_vm_handlers.h * ------------------------------------------------------------------ - * $Id: xmix_vm_handlers.c,v 1.6 2002/04/09 23:54:32 jao Exp $ + * $Id: xmix_vm_handlers.c,v 1.7 2003/01/11 22:43:13 jao Exp $ * ------------------------------------------------------------------ - * Copyright (C) 2001, 2002 Free Software Foundation, Inc. - * + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * */ @@ -37,25 +37,25 @@ mix_vm_command_info_t commands_[] = { { "pasm", cmd_pasm_, N_("Print the compile command"), "pasm"}, { "sasm", cmd_sasm_, N_("Set the compile command"), "sasm COMMAND (e.g. mixasm -g -l %s)"}, - { "run", cmd_run_, N_("Run loaded or given MIX code file"), + { "run", cmd_run_, N_("Run loaded or given MIX code file"), "run [FILENAME]"}, - { "next", cmd_next_, N_("Execute next instruction(s)"), + { "next", cmd_next_, N_("Execute next instruction(s)"), "next [NO_OF_INS]"}, { "pstat", cmd_pstat_, N_("Print current vm status"), "pstat"}, { "pc", cmd_pc_, N_("Print program counter value"), "pc" }, { "psym", cmd_psym_, N_("Print symbol value"), "psym [SYMBOLNAME]"}, - { "preg", cmd_preg_, N_("Print register value"), + { "preg", cmd_preg_, N_("Print register value"), "preg [A | X | J | I[1-6]]"}, - { "pflags", cmd_pflags_, N_("Print comparison and overflow flags"), + { "pflags", cmd_pflags_, N_("Print comparison and overflow flags"), "pflags"}, { "pall", cmd_pall_, N_("Print all registers and flags"), "pall"}, - { "pmem", cmd_pmem_, N_("Print memory contents in address range"), + { "pmem", cmd_pmem_, N_("Print memory contents in address range"), "pmem FROM[-TO]"}, - { "sreg", cmd_sreg_, N_("Set register value"), - "preg A | X | J | I[1-6] VALUE"}, + { "sreg", cmd_sreg_, N_("Set register value"), + "sreg A | X | J | I[1-6] VALUE"}, { "scmp", cmd_scmp_, N_("Set comparison flag value"), "scmp L | E | G"}, { "sover", cmd_sover_, N_("Set overflow flag value"), "sover T | F" }, - { "smem", cmd_smem_, N_("Set memory contents in given address"), + { "smem", cmd_smem_, N_("Set memory contents in given address"), "smem ADDRESS VALUE"}, { "ssym", cmd_ssym_, N_("Set a symbol\'s value"), "ssym SYMBOL WEXPR"}, { "sbp", cmd_sbp_, N_("Set break point at given line"), "sbp LINENO"}, @@ -107,7 +107,7 @@ trace_ (mix_vm_cmd_dispatcher_t *dis) { enum {BUFFER_LEN = 128}; static gchar STRINS[BUFFER_LEN]; - + if (wants_logs_ (dis)) { const mix_src_file_t *file = mix_vm_get_src_file (dis->vm); @@ -117,13 +117,13 @@ trace_ (mix_vm_cmd_dispatcher_t *dis) mix_ins_t fins; mix_word_to_ins_uncheck (ins, fins); mix_ins_to_string_in_buffer (&fins, STRINS, BUFFER_LEN); - + if (file != NULL) { gulong b = mix_vm_get_break_lineno (dis->vm); if (b > 0) line = mix_src_file_get_line (file, b); } - + log_message_ (dis, "%d: [%-15s]\t%s", (gint)loc, STRINS, line); } } @@ -230,7 +230,7 @@ cmd_load_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) if (wants_logs_ (dis)) log_message_ (dis, _("Program loaded. Start address: %d"), mix_vm_get_prog_count (dis->vm)); - + dis->laptime = dis->progtime = 0; return TRUE; } @@ -288,11 +288,11 @@ cmd_compile_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) gboolean cmd_run_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { - if (arg != NULL && *arg != '\0' && cmd_load_ (dis, arg) != TRUE) + if (arg != NULL && *arg != '\0' && cmd_load_ (dis, arg) != TRUE) return FALSE; - + if (mix_vm_is_halted (dis->vm)) cmd_load_ (dis, dis->program); - + if (wants_logs_ (dis)) log_message_ (dis, _("Running ...")); switch (run_and_trace_ (dis)) @@ -306,7 +306,7 @@ cmd_run_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) gulong line = mix_vm_get_break_lineno (dis->vm); if (line != 0) log_message_ - (dis, _("... stopped: breakpoint at line %ld (address %d)"), + (dis, _("... stopped: breakpoint at line %ld (address %d)"), line, mix_vm_get_prog_count (dis->vm)); else log_message_ (dis, _("... stopped: breakpoint at address %d"), @@ -359,7 +359,7 @@ cmd_next_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) } if (mix_vm_is_halted (dis->vm)) cmd_load_ (dis, dis->program); - + while ( ins_no-- > 0 ) { if (dis->trace) trace_ (dis); @@ -414,7 +414,7 @@ cmd_psym_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) mix_symbol_table_print (table, MIX_SYM_ROWS, dis->out, TRUE); result = TRUE; } - + return result; } @@ -443,7 +443,7 @@ cmd_preg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { static gint32 opt[] = { MIX_DUMP_rI1, MIX_DUMP_rI2, MIX_DUMP_rI3, MIX_DUMP_rI4, - MIX_DUMP_rI5, MIX_DUMP_rI6 + MIX_DUMP_rI5, MIX_DUMP_rI6 }; int i = arg[1] - '1'; if ( i < 0 || i > 5 ) @@ -486,7 +486,7 @@ cmd_pmem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg) int i = 0; gboolean error = FALSE; gchar *arg = NULL; - + if ( strlen (carg) == 0 ) { log_error_ (dis, _("Missing memory address")); @@ -510,14 +510,14 @@ cmd_pmem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg) i++; while (isspace (narg[i])) i++; - if (narg[i] != '\0') + if (narg[i] != '\0') error = TRUE; - else + else end = atol (narg); } else error = TRUE; - + if (error) { log_error_ (dis, _("Invalid argument: %s"), arg); @@ -545,7 +545,7 @@ cmd_sreg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) char reg = arg[0]; gboolean ok = TRUE; long value; - + i = (reg == 'I') ? 2 : 1; ok = strlen (arg) > 2 && isspace (arg[i]); if (ok) @@ -576,7 +576,7 @@ cmd_sreg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) case 'I': { guint k = arg[1] - '0'; - if ( k < 7 ) + if ( k < 7 ) mix_vm_set_rI (dis->vm, k, mix_short_new (value)); else ok = FALSE; @@ -591,7 +591,7 @@ cmd_sreg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { log_error_ (dis, _("Invalid argument: %s"), arg); } - + return ok; } @@ -617,7 +617,7 @@ cmd_scmp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { log_error_ (dis, _("Invalid argument: %s"), arg); } - + return ok; } @@ -640,7 +640,7 @@ cmd_sover_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { log_error_ (dis, _("Invalid argument: %s"), arg); } - + return ok; } @@ -652,7 +652,7 @@ cmd_smem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg) glong value = 0; int k = 0; gchar *arg = NULL; - + if (ok) { arg = g_strdup (carg); @@ -682,7 +682,7 @@ cmd_smem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg) log_error_ (dis, _("Invalid argument: %s"), arg); } if (arg) g_free (arg); - + return ok; } @@ -859,7 +859,7 @@ cmd_weval_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) log_error_ (dis, _("Missing expression")); return FALSE; } - + if (mix_eval_expression_with_loc (dis->eval, arg, mix_vm_get_prog_count (dis->vm)) == MIX_EVAL_OK) @@ -891,7 +891,7 @@ cmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) log_error_ (dis, _("Missing expression")); return FALSE; } - else + else { gchar *cp = g_strdup (arg), *a = cp; mix_byte_t bytes[5] = {0, 0, 0, 0, 0}; @@ -914,7 +914,7 @@ cmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) b = strtok (NULL, " \t"); } } - if (success) + if (success) { if (strtok (NULL, "\t") != NULL) { @@ -930,7 +930,7 @@ cmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) } } g_free (cp); - + return success; } } @@ -954,7 +954,7 @@ cmd_strace_ (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 log_error_ (dis, _("Wrong argument: "), arg); return TRUE; } @@ -978,11 +978,11 @@ cmd_stime_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) dis->printtime = FALSE; if (dis->config) mix_config_update (dis->config, TIMING_KEY_, OFF); } - else + else log_error_ (dis, _("Wrong argument: "), arg); return TRUE; } - + gboolean cmd_ptime_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) { @@ -1058,7 +1058,7 @@ static mix_predicate_type_t get_reg_pred_ (const gchar *arg) { mix_predicate_type_t pred = INVALID_REG_; - + switch (*arg) { case 'A': @@ -1302,7 +1302,7 @@ cmd_slog_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) dis->log_msg = FALSE; if (dis->config) mix_config_update (dis->config, LOGGING_KEY_, OFF); } - else + else log_error_ (dis, _("Wrong argument: "), arg); return TRUE; } @@ -1338,19 +1338,19 @@ cmd_pline_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg) log_error_ (dis, _("Invalid argument")); return FALSE; } - + if (line == 0) line = mix_vm_cmd_dispatcher_get_src_file_lineno (dis); - + if (line == 0) txt = "No such line (debug info not available)\n"; else txt = mix_vm_cmd_dispatcher_get_src_file_line (dis, line, FALSE); - + if (txt == NULL || strlen (txt) == 0) txt = "No such line\n"; - + fprintf (dis->out, "Line %ld: %s\n", line, txt); - + return TRUE; } -- cgit v1.2.3