From d0108926486154ebb3e493e8dfedd1bbceb80e35 Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Tue, 28 Feb 2023 14:24:55 +0800 Subject: [PATCH] Convert `dcs` to the rzshell (#3403) --- librz/core/cmd/cmd_debug.c | 31 ++++++++--------------------- librz/core/cmd_descs/cmd_debug.yaml | 5 ++++- librz/core/cmd_descs/cmd_descs.c | 14 ++++++++++++- librz/core/cmd_descs/cmd_descs.h | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/librz/core/cmd/cmd_debug.c b/librz/core/cmd/cmd_debug.c index e49d76c2e9..26d46417c5 100644 --- a/librz/core/cmd/cmd_debug.c +++ b/librz/core/cmd/cmd_debug.c @@ -24,14 +24,6 @@ } \ } while (0) -static const char *help_msg_dcs[] = { - "Usage:", "dcs", " Continue until syscall", - "dcs", "", "Continue until next syscall", - "dcs [str]", "", "Continue until next call to the 'str' syscall", - "dcs", "*", "Trace all syscalls, a la strace", - NULL -}; - static const char *help_msg_dcu[] = { "Usage:", "dcu", " Continue until address", "dcu.", "", "Alias for dcu $$ (continue until current address", @@ -2520,24 +2512,17 @@ RZ_IPI RzCmdStatus rz_cmd_debug_continue_traptrace_handler(RzCore *core, int arg } // dcs -RZ_IPI int rz_cmd_debug_continue_syscall(void *data, const char *input) { - RzCore *core = (RzCore *)data; +RZ_IPI RzCmdStatus rz_cmd_debug_continue_syscall_handler(RzCore *core, int argc, const char **argv) { CMD_CHECK_DEBUG_DEAD(core); rz_cons_break_push(rz_core_static_debug_stop, core->dbg); - switch (input[0]) { - case '*': - cmd_debug_cont_syscall(core, "-1"); - break; - case ' ': - cmd_debug_cont_syscall(core, input + 2); - break; - case '\0': + if (argc > 1) { + if (!strcmp(argv[1], "*")) { + cmd_debug_cont_syscall(core, "-1"); + } else { + cmd_debug_cont_syscall(core, argv[1]); + } + } else { cmd_debug_cont_syscall(core, NULL); - break; - default: - case '?': - rz_core_cmd_help(core, help_msg_dcs); - break; } rz_cons_break_pop(); rz_core_dbg_follow_seek_register(core); diff --git a/librz/core/cmd_descs/cmd_debug.yaml b/librz/core/cmd_descs/cmd_debug.yaml index 1f8127e99e..57e2a1812c 100644 --- a/librz/core/cmd_descs/cmd_debug.yaml +++ b/librz/core/cmd_descs/cmd_debug.yaml @@ -300,7 +300,10 @@ commands: - name: dcs summary: Continue until syscall cname: cmd_debug_continue_syscall - type: RZ_CMD_DESC_TYPE_OLDINPUT + args: + - name: syscall + type: RZ_CMD_ARG_TYPE_STRING + optional: true - name: dct summary: Traptrace from curseek to len, no argument to list cname: cmd_debug_continue_traptrace diff --git a/librz/core/cmd_descs/cmd_descs.c b/librz/core/cmd_descs/cmd_descs.c index db48c07ee1..78d4f46d1c 100644 --- a/librz/core/cmd_descs/cmd_descs.c +++ b/librz/core/cmd_descs/cmd_descs.c @@ -313,6 +313,7 @@ static const RzCmdDescArg cmd_debug_add_watchpoint_args[2]; static const RzCmdDescArg cmd_debug_set_cond_bp_win_args[3]; static const RzCmdDescArg cmd_debug_continue_execution_args[2]; static const RzCmdDescArg cmd_debug_continue_send_signal_args[3]; +static const RzCmdDescArg cmd_debug_continue_syscall_args[2]; static const RzCmdDescArg cmd_debug_continue_traptrace_args[2]; static const RzCmdDescArg cmd_debug_descriptor_open_args[2]; static const RzCmdDescArg cmd_debug_descriptor_close_args[2]; @@ -6994,8 +6995,19 @@ static const RzCmdDescHelp cmd_debug_continue_ret_help = { .args = cmd_debug_continue_ret_args, }; +static const RzCmdDescArg cmd_debug_continue_syscall_args[] = { + { + .name = "syscall", + .type = RZ_CMD_ARG_TYPE_STRING, + .flags = RZ_CMD_ARG_FLAG_LAST, + .optional = true, + + }, + { 0 }, +}; static const RzCmdDescHelp cmd_debug_continue_syscall_help = { .summary = "Continue until syscall", + .args = cmd_debug_continue_syscall_args, }; static const RzCmdDescArg cmd_debug_continue_traptrace_args[] = { @@ -18654,7 +18666,7 @@ RZ_IPI void rzshell_cmddescs_init(RzCore *core) { RzCmdDesc *cmd_debug_continue_ret_cd = rz_cmd_desc_argv_new(core->rcmd, dc_cd, "dcr", rz_cmd_debug_continue_ret_handler, &cmd_debug_continue_ret_help); rz_warn_if_fail(cmd_debug_continue_ret_cd); - RzCmdDesc *cmd_debug_continue_syscall_cd = rz_cmd_desc_oldinput_new(core->rcmd, dc_cd, "dcs", rz_cmd_debug_continue_syscall, &cmd_debug_continue_syscall_help); + RzCmdDesc *cmd_debug_continue_syscall_cd = rz_cmd_desc_argv_new(core->rcmd, dc_cd, "dcs", rz_cmd_debug_continue_syscall_handler, &cmd_debug_continue_syscall_help); rz_warn_if_fail(cmd_debug_continue_syscall_cd); RzCmdDesc *cmd_debug_continue_traptrace_cd = rz_cmd_desc_argv_new(core->rcmd, dc_cd, "dct", rz_cmd_debug_continue_traptrace_handler, &cmd_debug_continue_traptrace_help); diff --git a/librz/core/cmd_descs/cmd_descs.h b/librz/core/cmd_descs/cmd_descs.h index 3ac9cdbe74..27b81307e6 100644 --- a/librz/core/cmd_descs/cmd_descs.h +++ b/librz/core/cmd_descs/cmd_descs.h @@ -925,7 +925,7 @@ RZ_IPI RzCmdStatus rz_cmd_debug_continue_mapped_io_handler(RzCore *core, int arg // "dcr" RZ_IPI RzCmdStatus rz_cmd_debug_continue_ret_handler(RzCore *core, int argc, const char **argv); // "dcs" -RZ_IPI int rz_cmd_debug_continue_syscall(void *data, const char *input); +RZ_IPI RzCmdStatus rz_cmd_debug_continue_syscall_handler(RzCore *core, int argc, const char **argv); // "dct" RZ_IPI RzCmdStatus rz_cmd_debug_continue_traptrace_handler(RzCore *core, int argc, const char **argv); // "dcu"