diff --git a/librz/core/cmd/cmd_analysis.c b/librz/core/cmd/cmd_analysis.c index 005db6de7b2..f981d11030e 100644 --- a/librz/core/cmd/cmd_analysis.c +++ b/librz/core/cmd/cmd_analysis.c @@ -4676,15 +4676,39 @@ RZ_IPI RzCmdStatus rz_il_vm_step_until_addr_handler(RzCore *core, int argc, cons } RZ_IPI RzCmdStatus rz_il_vm_status_handler(RzCore *core, int argc, const char **argv, RzOutputMode mode) { - if (argc == 3) { - ut64 value = rz_num_math(core->num, argv[2]); - if (rz_core_analysis_il_vm_set(core, argv[1], value)) { - rz_cons_printf("%s = 0x%" PFMT64x "\n", argv[1], value); + if (argc > 1) { + RzList *l = rz_str_split_duplist_n(argv[1], "=", 1, true); + if (!l) { + return RZ_CMD_STATUS_ERROR; } - } else { - // print variable or all variables - rz_core_analysis_il_vm_status(core, argc == 2 ? argv[1] : NULL, mode); + size_t llen = rz_list_length(l); + if (!llen) { + rz_list_free(l); + return RZ_CMD_STATUS_ERROR; + } + const char *varname = rz_list_get_n(l, 0); + if (RZ_STR_ISEMPTY(varname)) { + RZ_LOG_ERROR("core: No string specified before `=`. Make sure to use the format =.\n"); + rz_list_free(l); + return RZ_CMD_STATUS_ERROR; + } + + if (llen == 2) { + // assign variable + const char *valstr = rz_list_get_n(l, 1); + ut64 value = rz_num_math(core->num, valstr); + if (rz_core_analysis_il_vm_set(core, varname, value)) { + rz_cons_printf("%s = 0x%" PFMT64x "\n", varname, value); + } + } else { + // print variable + rz_core_analysis_il_vm_status(core, varname, mode); + } + rz_list_free(l); + return RZ_CMD_STATUS_OK; } + // print all variables + rz_core_analysis_il_vm_status(core, NULL, mode); return RZ_CMD_STATUS_OK; } diff --git a/librz/core/cmd_descs/cmd_analysis.yaml b/librz/core/cmd_descs/cmd_analysis.yaml index 6c8b903f11d..a213518ccd0 100644 --- a/librz/core/cmd_descs/cmd_analysis.yaml +++ b/librz/core/cmd_descs/cmd_analysis.yaml @@ -992,6 +992,7 @@ commands: type: RZ_CMD_ARG_TYPE_RZNUM - name: aezv summary: Print or modify the current status of the RzIL Virtual Machine + args_str: " [ [= ]]" cname: il_vm_status type: RZ_CMD_DESC_TYPE_ARGV_MODES modes: @@ -1000,11 +1001,9 @@ commands: - RZ_OUTPUT_MODE_JSON - RZ_OUTPUT_MODE_QUIET args: - - name: var_name - type: RZ_CMD_ARG_TYPE_STRING - optional: true - - name: number - type: RZ_CMD_ARG_TYPE_RZNUM + - name: var_name=value + type: RZ_CMD_ARG_TYPE_EVAL_FULL + flags: RZ_CMD_ARG_FLAG_LAST optional: true - name: ag summary: Analysis graph commands diff --git a/librz/core/cmd_descs/cmd_descs.c b/librz/core/cmd_descs/cmd_descs.c index 6cfbcf9603a..039bbc9dbc8 100644 --- a/librz/core/cmd_descs/cmd_descs.c +++ b/librz/core/cmd_descs/cmd_descs.c @@ -213,7 +213,7 @@ static const RzCmdDescArg il_step_until_opt_args[2]; static const RzCmdDescArg il_vm_step_args[2]; static const RzCmdDescArg il_vm_step_with_events_args[2]; static const RzCmdDescArg il_vm_step_until_addr_args[2]; -static const RzCmdDescArg il_vm_status_args[3]; +static const RzCmdDescArg il_vm_status_args[2]; static const RzCmdDescArg analysis_graph_dataref_args[2]; static const RzCmdDescArg analysis_graph_dataref_global_args[2]; static const RzCmdDescArg analysis_graph_callgraph_function_args[2]; @@ -4048,14 +4048,8 @@ static const RzCmdDescHelp il_vm_step_until_addr_help = { static const RzCmdDescArg il_vm_status_args[] = { { - .name = "var_name", + .name = "var_name=value", .type = RZ_CMD_ARG_TYPE_STRING, - .optional = true, - - }, - { - .name = "number", - .type = RZ_CMD_ARG_TYPE_RZNUM, .flags = RZ_CMD_ARG_FLAG_LAST, .optional = true, @@ -4064,6 +4058,7 @@ static const RzCmdDescArg il_vm_status_args[] = { }; static const RzCmdDescHelp il_vm_status_help = { .summary = "Print or modify the current status of the RzIL Virtual Machine", + .args_str = " [ [= ]]", .args = il_vm_status_args, }; diff --git a/test/db/cmd/cmd_aez b/test/db/cmd/cmd_aez index 9627ada5fac..68c93fc4413 100644 --- a/test/db/cmd/cmd_aez +++ b/test/db/cmd/cmd_aez @@ -93,10 +93,10 @@ s 0 aezi aezv echo -- -aezv PC 0x42 +aezv PC=0x42 aezv echo -- -aezv ptr 0xc0ffee +aezv ptr=0xc0ffee aezv EOF EXPECT=<