From 721a61545786f77286c4174f6c0a35e71e2997f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sat, 16 Jun 2018 10:51:02 +0200 Subject: [PATCH] Task cmd Adjustments --- libr/core/cmd.c | 43 ++++++++++++------------------------------- libr/core/cmd_print.c | 22 +++++++++------------- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/libr/core/cmd.c b/libr/core/cmd.c index 7802f2090d..2c0d7702fd 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -1268,16 +1268,7 @@ static int cmd_thread(void *data, const char *input) { case 'j': r_core_task_list (core, *input); break; -#if 0 - case 't': - r_cons_break_push (NULL, NULL); - while (!r_cons_is_breaked ()) { - r_sys_sleep(1); - } - r_cons_break_pop (); - break; -#endif - case 't': { + case 't': { // "&t" int usecs = 0; if (input[1] == ' ') { usecs = (int) r_num_math (core->num, input + 1); @@ -1285,28 +1276,25 @@ static int cmd_thread(void *data, const char *input) { task_test (core, usecs); break; } - case '&': + case '&': { // "&&" if (r_sandbox_enable (0)) { eprintf ("This command is disabled in sandbox mode\n"); return 0; } - if (input[1] == '&') { - // wait until ^C - } else { - int tid = r_num_math (core->num, input + 1); - if (tid) { - RCoreTask *task = r_core_task_get (core, tid); - if (task) { - r_core_task_join (core, task); - } else { - eprintf ("Cannot find task\n"); - } + int tid = r_num_math (core->num, input + 1); + if (tid) { + RCoreTask *task = r_core_task_get (core, tid); + if (task) { + r_core_task_join (core, task); } else { - //r_core_task_run (core, NULL); + eprintf ("Cannot find task\n"); } + } else { + //r_core_task_run (core, NULL); } break; - case '=': { + } + case '=': { // "&=" // r_core_task_list (core, '='); int tid = r_num_math (core->num, input + 1); if (tid) { @@ -1324,13 +1312,6 @@ static int cmd_thread(void *data, const char *input) { r_core_task_list (core, 1); }} break; - case '+': - if (r_sandbox_enable (0)) { - eprintf ("This command is disabled in sandbox mode\n"); - return 0; - } - //r_core_task_add (core, r_core_task_new (core, input + 1, (RCoreTaskCallback)task_finished, core)); - break; case '-': if (r_sandbox_enable (0)) { eprintf ("This command is disabled in sandbox mode\n"); diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index cbf736857f..5d9c0db914 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -12,21 +12,17 @@ #define PF_USAGE_STR "pf[.k[.f[=v]]|[v]]|[n]|[0|cnt][fmt] [a0 a1 ...]" static const char *help_msg_amper[] = { - "Usage:", "&[-|]", "Manage tasks ( XXX broken because of mutex in r_core_cmd )", - "&", "", "list all running threads", - "&=", "", "show output of all tasks", + "Usage:", "&[-|]", "Manage tasks (WARNING: Experimental. Use with caution!)", + "&", " ", "run in a new background task", + "&", "", "list all tasks", + "&j", "", "list all tasks (in JSON)", "&=", " 3", "show output of task 3", - "&j", "", "list all running threads (in JSON)", - "&?", "", "show this help", - "&+", " aa", "push to the task list", + "&=", "", "show output of all tasks", "&-", " 1", "delete task #1", - "&", "-*", "delete all threads", - "&", " aa", "run analysis in background", - "&", " &&", "run all tasks in background", - "&&", "", "run all pendings tasks (and join threads)", - "&&&", "", "run all pendings tasks until ^C", - "", "", "TODO: last command should honor asm.bits", - "", "", "WARN: this feature is very experimental. Use it with caution", + "&", "-*", "delete all done tasks", + "&?", "", "show this help", + "&&", " 3", "wait until task 3 is finished", + "&&", "", "wait until all tasks are finished", NULL };