📄 xmix_vm_handlers.c
字号:
log_error_ (dis, _("Invalid argument: %s"), arg); return FALSE; } mix_vm_dump (dis->vm, dis->dump); return TRUE;}gbooleancmd_pflags_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ mix_dump_context_set_opt (dis->dump, MIX_DUMP_CMP | MIX_DUMP_OVER); mix_vm_dump (dis->vm, dis->dump); return TRUE;}gbooleancmd_pall_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ mix_dump_context_set_opt (dis->dump, MIX_DUMP_ALL_NOMEM); mix_vm_dump (dis->vm, dis->dump); return TRUE;}gbooleancmd_pmem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg){ glong begin = MIX_SHORT_ZERO, end = MIX_SHORT_ZERO; int i = 0; gboolean error = FALSE; gchar *arg = NULL; if ( strlen (carg) == 0 ) { log_error_ (dis, _("Missing memory address")); return FALSE; } arg = g_strdup (carg); while (isdigit (arg[i])) i++; while (isspace (arg[i])) i++; if (arg[i] == '\0') begin = end = atol (arg); else if (arg[i] == '-') { gchar *narg; arg[i++] = '\0'; begin = atol (arg); narg = arg + i; i = 0; while (isdigit (narg[i])) i++; while (isspace (narg[i])) i++; if (narg[i] != '\0') error = TRUE; else end = atol (narg); } else error = TRUE; if (error) { log_error_ (dis, _("Invalid argument: %s"), arg); } else if ( end < begin || end > MIX_VM_CELL_NO - 1 ) { log_error_ (dis, _("Invalid range: %ld-%ld"), begin, end); error = TRUE; } else { mix_dump_context_set_opt (dis->dump, MIX_DUMP_CELLS); mix_dump_context_range (dis->dump, mix_short_new (begin), mix_short_new (end + 1)); mix_vm_dump (dis->vm, dis->dump); } g_free (arg); return !error;}gbooleancmd_sreg_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ int i = 0; char reg = arg[0]; gboolean ok = TRUE; long value; i = (reg == 'I') ? 2 : 1; ok = strlen (arg) > 2 && isspace (arg[i]); if (ok) { while (isspace (arg[i])) i++; ok = isdigit (arg[i]) || arg[i] == '+' || arg[i] == '-'; if (ok) { value = atol (arg + i); if (arg[i] == '+' || arg[i] == '-') i++; while (isdigit (arg[i])) i++; ok = (arg[i] == '\0'); if (ok) switch (reg) { case 'A': mix_vm_set_rA (dis->vm, mix_word_new (value)); break; case 'X': mix_vm_set_rX (dis->vm, mix_word_new (value)); break; case 'J': if ( value >= 0 ) mix_vm_set_rJ (dis->vm, mix_short_new (value)); else ok = FALSE; break; case 'I': { guint k = arg[1] - '0'; if ( k < 7 ) mix_vm_set_rI (dis->vm, k, mix_short_new (value)); else ok = FALSE; } break; default: ok = FALSE; } } } if (!ok) { log_error_ (dis, _("Invalid argument: %s"), arg); } return ok;}gbooleancmd_scmp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ gboolean ok = (strlen (arg) == 1); if (ok) switch (arg[0]) { case 'L': mix_vm_set_cmpflag (dis->vm, mix_LESS); break; case 'E': mix_vm_set_cmpflag (dis->vm, mix_EQ); break; case 'G': mix_vm_set_cmpflag (dis->vm, mix_GREAT); break; default: ok = FALSE; } if (!ok) { log_error_ (dis, _("Invalid argument: %s"), arg); } return ok;}gbooleancmd_sover_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ gboolean ok = (strlen (arg) == 1); if (ok) switch (arg[0]) { case 'T': mix_vm_set_overflow (dis->vm, TRUE); break; case 'F': mix_vm_set_overflow (dis->vm, FALSE); break; default: ok = FALSE; } if (!ok) { log_error_ (dis, _("Invalid argument: %s"), arg); } return ok;}gbooleancmd_smem_ (mix_vm_cmd_dispatcher_t *dis, const gchar *carg){ gboolean ok = (strlen (carg) > 2 && isdigit (carg[0])); glong addr = -1; glong value = 0; int k = 0; gchar *arg = NULL; if (ok) { arg = g_strdup (carg); while (isdigit (arg[k])) k++; ok = isspace (arg[k]); if (ok) { arg[k++] = '\0'; addr = atol (arg); ok = addr < MIX_VM_CELL_NO; } if (ok) { while (isspace (arg[k])) k++; value = atol (arg + k); if ( arg[k] == '+' || arg[k] == '-' ) k++; while (isdigit (arg[k])) k++; ok = arg[k] == '\0'; } } if (ok) mix_vm_set_addr_contents (dis->vm, mix_short_new (addr), mix_word_new (value)); else { log_error_ (dis, _("Invalid argument: %s"), arg); } if (arg) g_free (arg); return ok;}gbooleancmd_ssym_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ gboolean result = FALSE; if (arg == NULL || strlen(arg) == 0) { log_error_ (dis, _("Missing arguments")); } else { gchar *a = g_strdup (arg); gchar *s = strtok (a, " \t"); gchar *w = strtok (NULL, " \t"); if (w != NULL && strtok (NULL, " \t") == NULL) { cmd_weval_ (dis, w); if (mix_eval_last_error (dis->eval) == MIX_EVAL_OK) { mix_eval_set_symbol (dis->eval, s, mix_eval_value (dis->eval)); result = TRUE; } } else { log_error_ (dis, _("Wrong argument number")); } g_free (a); } return result;}gbooleancmd_sbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ glong lineno; glong k = 0; while (isdigit (arg[k])) k++; if (arg[k] != '\0') { log_error_ (dis, _("Invalid argument: %s"), arg); return FALSE; } lineno = atol (arg); switch (k = mix_vm_set_breakpoint (dis->vm, lineno)) { case MIX_VM_BP_INV_LINE: log_error_ (dis, _("Line number %ld too high"), lineno); break; case MIX_VM_BP_ERROR: log_error_ (dis, _("Could not set breakpoint: internal error")); break; case MIX_VM_BP_NDEBUG: log_error_ (dis, _("Could not set breakpoint: no debug info available"), dis->err); break; default: if (wants_logs_ (dis)) log_message_ (dis, _("Breakpoint set at line %ld"), k); return TRUE; } return FALSE;}gbooleancmd_sbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ glong address; glong k = 0; while (isdigit (arg[k])) k++; if (arg[k] != '\0') { log_error_ (dis, _("Invalid argument: %s"), arg); return FALSE; } address = atol (arg); switch (mix_vm_set_breakpoint_address (dis->vm, address)) { case MIX_VM_BP_INV_ADDRESS: log_error_ (dis, _("Invalid address %ld"), address); break; case MIX_VM_BP_ERROR: log_error_ (dis, _("Could not set breakpoint: internal error")); break; default: if (wants_logs_ (dis)) log_message_ (dis, _("Breakpoint set at address %ld"), address); return TRUE; } return FALSE;}gbooleancmd_cbp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ glong lineno; int k = 0; while (isdigit (arg[k])) k++; if (arg[k] != '\0') { log_error_ (dis, _("Invalid argument: %s"), arg); return FALSE; } lineno = atol (arg); switch (mix_vm_clear_breakpoint (dis->vm, lineno)) { case MIX_VM_BP_INV_LINE: log_error_ (dis, _("No breakpoint set at line %ld"), lineno); break; case MIX_VM_BP_ERROR: log_error_ (dis, _("Could not set breakpoint: internal error")); break; case MIX_VM_BP_NDEBUG: log_error_ (dis, _("No debug info available")); break; case MIX_VM_BP_OK: if (wants_logs_ (dis)) log_message_ (dis, _("Breakpoint cleared at line %ld"), lineno); return TRUE; default: g_assert_not_reached (); break; } return FALSE;}gbooleancmd_cbpa_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ glong address; glong k = 0; while (isdigit (arg[k])) k++; if (arg[k] != '\0') { log_error_ (dis, _("Invalid argument: %s"), arg); return FALSE; } address = atol (arg); switch (mix_vm_clear_breakpoint_address (dis->vm, address)) { case MIX_VM_BP_INV_ADDRESS: log_error_ (dis, _("Invalid address %ld"), address); break; case MIX_VM_BP_ERROR: log_error_ (dis, _("Could not clear breakpoint: internal error")); break; default: if (wants_logs_ (dis)) log_message_ (dis, _("Breakpoint cleared at address %ld"), address); return TRUE; } return FALSE;}gbooleancmd_cabp_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if (strlen (arg) != 0) { log_error_ (dis, _("Unexpected argument: %s"), arg); return FALSE; } mix_vm_clear_all_breakpoints (dis->vm); return TRUE;}gbooleancmd_weval_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if ( strlen (arg) == 0 ) { 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) { mix_word_print_to_file (mix_eval_value (dis->eval), NULL, dis->out); putc ('\n', dis->out); return TRUE; } else { gint pos = mix_eval_last_error_pos (dis->eval); gint k, len = strlen (arg); g_assert(pos > -1 && pos <= len); for (k = 0; k<pos; ++k) fputc (arg[k], dis->err); fputc ('\n', dis->err); for (k = 0; k<pos; ++k) fputc (' ', dis->err); for (k = pos; k < len; ++k) fputc (arg[k], dis->err); fprintf (dis->err, _("\nEvaluation error: %s\n"), mix_eval_last_error_string (dis->eval)); return FALSE; }}gbooleancmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg){ if ( strlen (arg) == 0 ) { log_error_ (dis, _("Missing expression")); return FALSE; } else { gchar *cp = g_strdup (arg), *a = cp; mix_byte_t bytes[5] = {0, 0, 0, 0, 0}; gchar *b; guint k = 0; gboolean is_n = (a[0] == '-'), success = TRUE; if (a[0] == '+' || a[0] == '-') ++a; b = strtok (a, " \t"); while (b != NULL && k < 5) { if (strlen (b) != 2 || !isdigit(b[0]) || !isdigit(b[1])) { log_error_ (dis, _("Incorrect byte specification: %s"), b); success = FALSE; b = NULL; } else { bytes[k++] = mix_byte_new (atoi (b)); b = strtok (NULL, " \t"); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -