📄 xmix_vm_handlers.c
字号:
if (success) { if (strtok (NULL, "\t") != NULL) { log_error_ (dis, _("The expression %s does not fit in a word"), arg); success = FALSE; } else { mix_word_t w = mix_bytes_to_word (bytes, k); fprintf (dis->out, "%s%ld\n", is_n? "-":"+", mix_word_magnitude (w)); } } g_free (cp); return success; }}gbooleancmd_strace_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ static const gchar *ON = "on"; static const gchar *OFF = "off"; if (!arg || !strlen (arg)) { log_error_ (dis, _("Missing argument")); } else if (!strcmp (arg, ON)) { dis->trace = TRUE; if (dis->config) mix_config_update (dis->config, TRACING_KEY_, ON); } else if (!strcmp (arg, OFF)) { dis->trace = FALSE; if (dis->config) mix_config_update (dis->config, TRACING_KEY_, OFF); } else log_error_ (dis, _("Wrong argument: "), arg); return TRUE;}gbooleancmd_stime_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ static const gchar *ON = "on"; static const gchar *OFF = "off"; if (!arg || !strlen (arg)) { log_error_ (dis, _("Missing argument")); } else if (!strcmp (arg, ON)) { dis->printtime = TRUE; if (dis->config) mix_config_update (dis->config, TIMING_KEY_, ON); } else if (!strcmp (arg, OFF)) { dis->printtime = FALSE; if (dis->config) mix_config_update (dis->config, TIMING_KEY_, OFF); } else log_error_ (dis, _("Wrong argument: "), arg); return TRUE;} gbooleancmd_ptime_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ print_time_ (dis); return TRUE;}gbooleancmd_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); else fprintf (dis->out, _("Edit command not set (use sedit)\n")); return TRUE;}gbooleancmd_sedit_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (!arg || !strlen (arg)) { log_error_ (dis, _("Missing argument")); return FALSE; } mix_vm_cmd_dispatcher_set_editor (dis, arg); return TRUE;}gbooleancmd_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); else fprintf (dis->out, _("Compile command not set (use sasm)\n")); return TRUE;}gbooleancmd_sasm_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (!arg || !strlen (arg)) { log_error_ (dis, _("Missing argument")); return FALSE; } mix_vm_cmd_dispatcher_set_assembler (dis, arg); return TRUE;}gbooleancmd_sddir_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (!arg || !strlen (arg)) log_error_ (dis, _("Missing argument")); else if (mix_device_set_dir (arg) && dis->config) mix_config_set_devices_dir (dis->config, arg); return TRUE;}gbooleancmd_pddir_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ fprintf (dis->out, _("Device directory: %s\n"), mix_device_get_dir ()); return TRUE;}static const gint INVALID_REG_ = -2;static mix_predicate_type_tget_reg_pred_ (const gchar *arg){ mix_predicate_type_t pred = INVALID_REG_; switch (*arg) { case 'A': pred = MIX_PRED_REG_A; break; case 'X': pred = MIX_PRED_REG_X; break; case 'J': pred = MIX_PRED_REG_J; break; case 'I': { if ( strlen (arg) == 2 ) { int i = arg[1] - '1'; if (i >= 0 && i < 6) pred = MIX_PRED_REG_I1 - 1 + i; } } break; default: break; } return pred;}gbooleancmd_sbpr_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ mix_predicate_type_t pred = get_reg_pred_ (arg); if (pred != INVALID_REG_) { mix_vm_set_conditional_breakpoint (dis->vm, dis->preds[pred]); if (wants_logs_ (dis)) log_message_ (dis, _("Conditional breakpoint on r%s change set"), arg); return TRUE; } else { log_error_ (dis, _("Invalid argument %s"), arg); return FALSE; }}gbooleancmd_cbpr_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ mix_predicate_type_t pred = get_reg_pred_ (arg); if (pred != INVALID_REG_) { if (mix_vm_clear_conditional_breakpoint (dis->vm, dis->preds[pred])) { if (wants_logs_(dis)) log_message_ (dis, _("Conditional breakpoint on r%s change removed"), arg); } else log_error_ (dis, _("No breakpoint set on r%s change"), arg); return TRUE; } else { log_error_ (dis, _("Invalid argument %s"), arg); return FALSE; }}gbooleancmd_sbpm_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ gint add = atoi (arg); gpointer key, value; if (add < 0 || add > MIX_VM_CELL_NO) { log_error_ (dis, _("Invalid memory address: %s"), arg); return FALSE; } if (!g_hash_table_lookup_extended (dis->mem_preds, GINT_TO_POINTER (add), &key, &value)) { mix_predicate_t *new_pred = mix_predicate_new (MIX_PRED_MEM); mix_predicate_set_mem_address (new_pred, add); g_hash_table_insert (dis->mem_preds, GINT_TO_POINTER (add), (gpointer)new_pred); mix_vm_set_conditional_breakpoint (dis->vm, new_pred); } if (wants_logs_ (dis)) log_message_ (dis, _("Conditional breakpoint on mem cell no. %d set"), add); return TRUE;}gbooleancmd_cbpm_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ gint add = atoi (arg); gpointer key, value; if (add < 0 || add > MIX_VM_CELL_NO) { log_error_ (dis, _("Invalid memory address: %s"), arg); return FALSE; } if (g_hash_table_lookup_extended (dis->mem_preds, GINT_TO_POINTER (add), &key, &value)) { g_hash_table_remove (dis->mem_preds, key); mix_vm_clear_conditional_breakpoint (dis->vm, (mix_predicate_t *)value); mix_predicate_delete ((mix_predicate_t *)value); if (wants_logs_ (dis)) log_message_ (dis, _("Conditional breakpoint on mem cell no. %d removed"), add); } else { log_error_ (dis, _("No conditional breakpoint set at address %d"), add); } return TRUE;}gbooleancmd_sbpo_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (arg && strlen (arg)) log_error_ (dis, _("Unexpected argument: %s"), arg); else { mix_vm_set_conditional_breakpoint (dis->vm, dis->preds[MIX_PRED_OVER]); if (wants_logs_ (dis)) log_message_ (dis, _("Conditional breakpoint on overflow toggled set")); } return TRUE;}gbooleancmd_cbpo_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (arg && strlen (arg)) log_error_ (dis, _("Unexpected argument: %s"), arg); else { if (mix_vm_clear_conditional_breakpoint (dis->vm, dis->preds[MIX_PRED_OVER])) { if (wants_logs_ (dis)) log_message_ (dis, _("Conditional breakpoint on overflow toggled removed.")); } else log_error_ (dis, _("No breakpoint set on overflow toggle")); } return TRUE;}gbooleancmd_sbpc_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (arg && strlen (arg)) log_error_ (dis, _("Unexpected argument: %s"), arg); else { mix_vm_set_conditional_breakpoint (dis->vm, dis->preds[MIX_PRED_CMP]); if (wants_logs_ (dis)) log_message_ (dis, _("Conditional breakpoint on comparison flag changed set")); } return TRUE;}gbooleancmd_cbpc_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (arg && strlen (arg)) log_error_ (dis, _("Unexpected argument: %s"), arg); else { if (mix_vm_clear_conditional_breakpoint (dis->vm, dis->preds[MIX_PRED_CMP])) { if (wants_logs_ (dis)) log_message_ (dis, _("Conditional breakpoint on comparison flag changed removed.")); } else log_error_ (dis, _("No breakpoint set on comparison flag change")); } return TRUE;}gbooleancmd_pbt_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ enum {SIZE = 256}; static gchar BUFFER[SIZE]; gint no = atoi (arg); gint k = 0, address; guint line; const mix_src_file_t *file = mix_vm_get_src_file (dis->vm); char *name = file ? g_basename (mix_src_file_get_path (file)) : NULL; const GSList *add = mix_vm_get_backtrace (dis->vm); while (add && (no == 0 || k < no)) { BUFFER[0] = '\0'; address = GPOINTER_TO_INT (add->data); line = mix_vm_get_address_lineno (dis->vm, address); if (line && file) { int j = 0; snprintf (BUFFER, SIZE, "%s", mix_src_file_get_line (file, line)); while (!isspace (BUFFER[j])) j++; BUFFER[j] = '\0'; } if (strlen (BUFFER) == 0) snprintf (BUFFER, SIZE, "%d", address); fprintf (dis->out, "#%d\t%s\tin %s%s:%d\n", k, BUFFER, name, MIX_SRC_DEFEXT, line); ++k; add = add->next; } return TRUE;}gbooleancmd_slog_ (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->log_msg = TRUE; if (dis->config) mix_config_update (dis->config, LOGGING_KEY_, ON); } else if (arg && !strcmp (arg, OFF)) { dis->log_msg = FALSE; if (dis->config) mix_config_update (dis->config, LOGGING_KEY_, OFF); } else log_error_ (dis, _("Wrong argument: "), arg); return TRUE;}gbooleancmd_pprog_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ const gchar *path = mix_vm_cmd_dispatcher_get_program_path (dis); fprintf (dis->out, path? path : _("No program currently loaded")); fprintf (dis->out, "\n"); return (path != NULL);}gbooleancmd_psrc_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ const gchar *path = mix_vm_cmd_dispatcher_get_src_file_path (dis); fprintf (dis->out, path? path : _("No program currently loaded\n")); fprintf (dis->out, "\n"); return (path != NULL);}gbooleancmd_pline_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ gulong line = 0; const gchar *txt; if (arg && strlen (arg)) line = atoi (arg); if (line < 0) { 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;}gbooleancmd_pstat_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ static const gchar *MSGS[MIX_VM_EMPTY + 1] = { N_("Error loading or executing file"), N_("Execution stopped: breakpoint encountered"), N_("Execution stopped: conditional breakpoint encountered"), N_("Program successfully terminated"), N_("Execution stopped"), N_("Program successfully loaded"), N_("No program loaded") }; mix_vm_status_t status = mix_vm_get_run_status (mix_vm_cmd_dispatcher_get_vm (dis)); fprintf (dis->out, "VM status: %s\n", MSGS[status]); return TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -