Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_core.h>
Go to the source code of this file.
Classes | |
struct | oneshot_t |
struct | core_task_ctx_t |
struct | cmd_task_ctx_t |
struct | function_task_ctx_t |
Macros | |
#define | TASK_SIGSET_T void * |
Typedefs | |
typedef struct oneshot_t | OneShot |
typedef struct core_task_ctx_t | CoreTaskCtx |
typedef struct cmd_task_ctx_t | CmdTaskCtx |
typedef struct function_task_ctx_t | FunctionTaskCtx |
typedef struct cmd_task_ctx_t CmdTaskCtx |
Context for (user-visible) command tasks
typedef struct core_task_ctx_t CoreTaskCtx |
Common base for all contexts of tasks in core. Must be the first member of every task context!
typedef struct function_task_ctx_t FunctionTaskCtx |
Context for (user-invisible) function tasks
|
static |
Delete all done, transient, non-current jobs that have not been deleted yet.
Definition at line 217 of file task.c.
References rz_list_delete(), and rz_core_tasks_t::tasks.
Referenced by rz_core_task_schedule().
|
static |
Definition at line 575 of file task.c.
References cmd, core_task_ctx_init(), free(), NULL, RZ_NEW, rz_return_val_if_fail, and strdup().
Referenced by rz_core_cmd_task_new().
|
static |
Definition at line 615 of file task.c.
References core_task_ctx_fini(), and free().
Referenced by rz_core_cmd_task_new().
|
static |
Definition at line 593 of file task.c.
References eprintf, rz_core_tasks_t::main_task, NULL, rz_cons_default_context_is_interactive(), rz_core_cmd(), rz_core_cmd_str(), and rz_core_task_self().
Referenced by rz_core_cmd_task_get_result(), rz_core_cmd_task_new(), rz_core_task_del_all_done(), rz_core_task_is_cmd(), and rz_core_task_print().
|
static |
Definition at line 556 of file task.c.
References rz_cons_context_break_pop(), and rz_cons_context_free().
Referenced by cmd_task_free(), and function_task_free().
|
static |
Definition at line 545 of file task.c.
References rz_core_t::max_cmd_depth, NULL, rz_cons_context_break_push(), rz_cons_context_new(), and rz_cons_singleton().
Referenced by cmd_task_ctx_new(), and function_task_ctx_new().
|
static |
Definition at line 665 of file task.c.
References core_task_ctx_init(), free(), NULL, and RZ_NEW.
Referenced by rz_core_function_task_new().
|
static |
Definition at line 688 of file task.c.
References core_task_ctx_fini(), and free().
Referenced by rz_core_function_task_new().
|
static |
Definition at line 680 of file task.c.
References rz_cons_pop(), and rz_cons_push().
Referenced by rz_core_function_task_get_result(), and rz_core_function_task_new().
RZ_API const char* rz_core_cmd_task_get_result | ( | RzCoreTask * | task | ) |
Get the result of the command that was run in a task created with rz_core_cmd_task_new. If the task is not a command task, returns NULL.
Definition at line 646 of file task.c.
References cmd_task_runner(), and NULL.
Referenced by task_output().
RZ_API RzCoreTask* rz_core_cmd_task_new | ( | RzCore * | core, |
const char * | cmd, | ||
RzCoreCmdTaskFinished | finished_cb, | ||
void * | finished_cb_user | ||
) |
Create a new task that runs a command and saves its result. These tasks are user-visible under the & command family.
Definition at line 629 of file task.c.
References cmd, cmd_task_ctx_new(), cmd_task_free(), cmd_task_runner(), NULL, rz_core_task_new(), and rz_core_t::tasks.
Referenced by task_enqueue().
RZ_API void* rz_core_function_task_get_result | ( | RzCoreTask * | task | ) |
Get the return value of the function that was run in a task created with rz_core_function_task_new. If the task is not a function task, returns NULL.
Definition at line 718 of file task.c.
References function_task_runner(), and NULL.
RZ_API RzCoreTask* rz_core_function_task_new | ( | RzCore * | core, |
RzCoreTaskFunction | fcn, | ||
void * | fcn_user | ||
) |
Create a new task that runs a custom function and saves its result. These tasks are not user-visible.
Definition at line 700 of file task.c.
References function_task_ctx_new(), function_task_free(), function_task_runner(), NULL, rz_core_task_new(), and rz_core_t::tasks.
RZ_API void rz_core_task_break | ( | RzCoreTaskScheduler * | scheduler, |
int | id | ||
) |
Definition at line 483 of file task.c.
References task_break(), task_get(), TASK_SIGSET_T, tasks_lock_enter(), and tasks_lock_leave().
Referenced by task_break().
RZ_API void rz_core_task_break_all | ( | RzCoreTaskScheduler * | scheduler | ) |
Definition at line 495 of file task.c.
References task_break(), TASK_SIGSET_T, rz_core_tasks_t::tasks, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_core_fini(), and rz_main_rizin().
RZ_IPI void rz_core_task_break_cb | ( | RzCoreTask * | task, |
void * | user | ||
) |
Definition at line 738 of file task.c.
References NULL, and rz_cons_context_break().
Referenced by rz_core_init().
RZ_IPI void rz_core_task_ctx_switch | ( | RzCoreTask * | next, |
void * | user | ||
) |
Definition at line 727 of file task.c.
References rz_cons_context_load(), and rz_cons_context_reset().
Referenced by rz_core_init().
RZ_API void rz_core_task_decref | ( | RzCoreTask * | task | ) |
Definition at line 200 of file task.c.
References task_free(), TASK_SIGSET_T, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_core_task_is_cmd(), rz_core_task_join(), rz_core_task_scheduler_init(), and task_output().
RZ_API int rz_core_task_del | ( | RzCoreTaskScheduler * | scheduler, |
int | id | ||
) |
Definition at line 508 of file task.c.
References rz_core_tasks_t::main_task, rz_list_delete(), TASK_SIGSET_T, rz_core_tasks_t::tasks, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_tasks_delete_handler().
Definition at line 844 of file task.c.
References cmd_task_runner(), rz_core_tasks_t::main_task, rz_list_delete(), TASK_SIGSET_T, rz_core_tasks_t::tasks, rz_core_t::tasks, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_tasks_delete_all_handler().
RZ_API void rz_core_task_enqueue | ( | RzCoreTaskScheduler * | scheduler, |
RzCoreTask * | task | ||
) |
Definition at line 374 of file task.c.
References rz_list_append(), rz_th_new(), rz_th_sem_new(), rz_th_sem_wait(), task_run_thread(), TASK_SIGSET_T, rz_core_tasks_t::tasks, tasks_lock_enter(), and tasks_lock_leave().
Referenced by task_enqueue().
RZ_API void rz_core_task_enqueue_oneshot | ( | RzCoreTaskScheduler * | scheduler, |
RzCoreTaskOneShot | func, | ||
void * | user | ||
) |
Definition at line 391 of file task.c.
References oneshot(), rz_core_tasks_t::oneshot_queue, rz_core_tasks_t::oneshot_running, rz_core_tasks_t::oneshots_enqueued, rz_list_append(), RZ_NEW, TASK_SIGSET_T, tasks_lock_enter(), tasks_lock_leave(), and rz_core_tasks_t::tasks_running.
Referenced by __do_panels_refreshOneShot(), agraph_refresh_oneshot(), rz_core_bind_cons(), rz_core_visual_analysis_refresh_oneshot(), and visual_refresh_oneshot().
RZ_API RzCoreTask* rz_core_task_get_incref | ( | RzCoreTaskScheduler * | scheduler, |
int | id | ||
) |
Definition at line 461 of file task.c.
References rz_core_task_incref(), task_get(), TASK_SIGSET_T, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_core_task_is_cmd(), rz_core_task_join(), and task_output().
RZ_API void rz_core_task_incref | ( | RzCoreTask * | task | ) |
Definition at line 190 of file task.c.
References TASK_SIGSET_T, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_core_task_get_incref(), and rz_core_task_join().
Definition at line 834 of file task.c.
References cmd_task_runner(), r, rz_core_task_decref(), rz_core_task_get_incref(), and rz_core_t::tasks.
Referenced by rz_tasks_delete_handler(), rz_tasks_wait_handler(), and task_break().
RZ_API void rz_core_task_join | ( | RzCoreTaskScheduler * | scheduler, |
RzCoreTask * | current, | ||
int | id | ||
) |
Definition at line 96 of file task.c.
References rz_core_task_decref(), rz_core_task_get_incref(), rz_core_task_incref(), rz_core_task_sleep_begin(), rz_core_task_sleep_end(), rz_list_clone(), rz_list_free(), task_join(), TASK_SIGSET_T, rz_core_tasks_t::tasks, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_core_fini(), rz_main_rizin(), and rz_tasks_wait_handler().
Definition at line 811 of file task.c.
References NULL, pj_a(), pj_end(), pj_free(), pj_new(), pj_string(), rz_cons_printf(), rz_cons_println(), rz_core_task_print(), TASK_SIGSET_T, rz_core_tasks_t::tasks, rz_core_t::tasks, tasks_lock_enter(), tasks_lock_leave(), and rz_core_tasks_t::tasks_running.
Referenced by rz_tasks_handler().
RZ_API RzCoreTask* rz_core_task_new | ( | RzCoreTaskScheduler * | sched, |
RzCoreTaskRunner | runner, | ||
RzCoreTaskRunnerFree | runner_free, | ||
void * | runner_user | ||
) |
Definition at line 161 of file task.c.
References fail, NULL, RZ_NEW0, rz_th_cond_new(), rz_th_lock_new(), task_free(), and rz_core_tasks_t::task_id_next.
Referenced by rz_core_cmd_task_new(), rz_core_function_task_new(), and rz_core_task_scheduler_init().
RZ_API void rz_core_task_print | ( | RzCore * | core, |
RzCoreTask * | task, | ||
int | mode, | ||
PJ * | j | ||
) |
Definition at line 758 of file task.c.
References cmd, cmd_task_runner(), rz_core_tasks_t::main_task, NULL, pj_end(), pj_kb(), pj_ki(), pj_ks(), pj_o(), rz_cons_printf(), rz_core_task_status(), rz_return_if_fail, and rz_core_t::tasks.
Referenced by rz_core_task_list().
RZ_API int rz_core_task_run_sync | ( | RzCoreTaskScheduler * | scheduler, |
RzCoreTask * | task | ||
) |
Definition at line 415 of file task.c.
References NULL, and task_run_thread().
RZ_API int rz_core_task_running_tasks_count | ( | RzCoreTaskScheduler * | scheduler | ) |
Definition at line 71 of file task.c.
References count, rz_core_tasks_t::main_task, TASK_SIGSET_T, rz_core_tasks_t::tasks, tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_main_rizin().
RZ_API void rz_core_task_schedule | ( | RzCoreTask * | current, |
RzTaskState | next_state | ||
) |
Definition at line 231 of file task.c.
References cleanup_transient(), rz_core_tasks_t::ctx_switch, rz_core_tasks_t::ctx_switch_user, rz_core_tasks_t::current_task, free(), NULL, oneshot(), rz_core_tasks_t::oneshot_queue, rz_core_tasks_t::oneshot_running, rz_core_tasks_t::oneshots_enqueued, rz_list_append(), rz_list_pop_head(), rz_th_cond_signal(), rz_th_cond_wait(), rz_th_lock_enter(), rz_th_lock_leave(), TASK_SIGSET_T, tasks_lock_enter(), tasks_lock_leave(), rz_core_tasks_t::tasks_queue, and rz_core_tasks_t::tasks_running.
Referenced by rz_core_task_sleep_begin(), rz_core_task_yield(), and task_end().
RZ_API void rz_core_task_scheduler_fini | ( | RzCoreTaskScheduler * | tasks | ) |
Definition at line 27 of file task.c.
References rz_core_tasks_t::lock, rz_core_tasks_t::oneshot_queue, rz_list_free(), rz_th_lock_free(), rz_core_tasks_t::tasks, and rz_core_tasks_t::tasks_queue.
Referenced by rz_core_fini().
RZ_API void rz_core_task_scheduler_init | ( | RzCoreTaskScheduler * | sched, |
RzCoreTaskContextSwitch | ctx_switch, | ||
void * | ctx_switch_user, | ||
RzCoreTaskBreak | break_cb, | ||
void * | break_cb_user | ||
) |
Definition at line 7 of file task.c.
References rz_core_tasks_t::break_cb, rz_core_tasks_t::break_cb_user, rz_core_tasks_t::ctx_switch, rz_core_tasks_t::ctx_switch_user, rz_core_tasks_t::current_task, free(), rz_core_tasks_t::lock, rz_core_tasks_t::main_task, NULL, rz_core_tasks_t::oneshot_queue, rz_core_tasks_t::oneshot_running, rz_core_tasks_t::oneshots_enqueued, rz_core_task_decref(), rz_core_task_new(), rz_list_append(), rz_list_new(), rz_list_newf(), rz_th_lock_new(), rz_core_tasks_t::task_id_next, rz_core_tasks_t::tasks, rz_core_tasks_t::tasks_queue, and rz_core_tasks_t::tasks_running.
Referenced by rz_core_init().
RZ_API RzCoreTask* rz_core_task_self | ( | RzCoreTaskScheduler * | scheduler | ) |
Definition at line 446 of file task.c.
References rz_core_tasks_t::current_task, and rz_core_tasks_t::main_task.
Referenced by cmd_task_runner(), rz_core_sleep_begin(), and rz_core_task_yield().
RZ_API void rz_core_task_sleep_begin | ( | RzCoreTask * | task | ) |
Definition at line 438 of file task.c.
References rz_core_task_schedule().
Referenced by rz_core_sleep_begin(), and rz_core_task_join().
RZ_API void rz_core_task_sleep_end | ( | RzCoreTask * | task | ) |
Definition at line 442 of file task.c.
References task_wakeup().
Referenced by rz_core_sleep_end(), and rz_core_task_join().
RZ_API const char* rz_core_task_status | ( | RzCoreTask * | task | ) |
RZ_API void rz_core_task_sync_begin | ( | RzCoreTaskScheduler * | scheduler | ) |
Definition at line 421 of file task.c.
References rz_core_tasks_t::main_task, NULL, TASK_SIGSET_T, task_wakeup(), tasks_lock_enter(), and tasks_lock_leave().
Referenced by open_core_file(), and rz_main_rizin().
RZ_API void rz_core_task_sync_end | ( | RzCoreTaskScheduler * | scheduler | ) |
Definition at line 432 of file task.c.
References rz_core_tasks_t::main_task, and task_end().
Referenced by open_core_file(), and rz_main_rizin().
RZ_API void rz_core_task_yield | ( | RzCoreTaskScheduler * | scheduler | ) |
Definition at line 336 of file task.c.
References rz_core_task_schedule(), and rz_core_task_self().
Referenced by core_perform_auto_analysis(), DEFINE_HANDLE_TS_FCN(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), rz_core_analysis_all(), rz_core_analysis_everything(), and rz_core_cmd_foreach().
|
static |
break without locking, don't call directly and use public api instead!
Definition at line 475 of file task.c.
References rz_core_tasks_t::break_cb, and rz_core_tasks_t::break_cb_user.
Referenced by rz_core_task_break(), and rz_core_task_break_all().
|
static |
Definition at line 344 of file task.c.
References rz_core_task_schedule().
Referenced by rz_core_task_sync_end(), and task_run_thread().
|
static |
Definition at line 144 of file task.c.
References free(), rz_th_cond_free(), rz_th_free(), rz_th_lock_free(), rz_th_sem_free(), and rz_th_wait().
Referenced by rz_core_task_decref(), and rz_core_task_new().
|
static |
Definition at line 450 of file task.c.
References NULL, and rz_core_tasks_t::tasks.
Referenced by rz_core_task_break(), and rz_core_task_get_incref().
|
static |
Definition at line 86 of file task.c.
References rz_th_sem_post(), and rz_th_sem_wait().
Referenced by rz_core_task_join().
|
static |
Definition at line 348 of file task.c.
References NULL, rz_th_sem_post(), task_end(), TASK_SIGSET_T, task_wakeup(), tasks_lock_enter(), and tasks_lock_leave().
Referenced by rz_core_task_enqueue(), and rz_core_task_run_sync().
|
static |
Definition at line 298 of file task.c.
References rz_core_tasks_t::ctx_switch, rz_core_tasks_t::ctx_switch_user, rz_core_tasks_t::current_task, rz_list_append(), rz_th_cond_wait(), rz_th_lock_enter(), rz_th_lock_leave(), TASK_SIGSET_T, tasks_lock_enter(), tasks_lock_leave(), rz_core_tasks_t::tasks_queue, and rz_core_tasks_t::tasks_running.
Referenced by rz_core_task_sleep_end(), rz_core_task_sync_begin(), and task_run_thread().
|
static |
Definition at line 48 of file task.c.
Referenced by tasks_lock_enter().
|
static |
Definition at line 51 of file task.c.
Referenced by tasks_lock_leave().
|
static |
Definition at line 56 of file task.c.
References rz_core_tasks_t::lock, rz_th_lock_enter(), and tasks_lock_block_signals().
Referenced by rz_core_task_break(), rz_core_task_break_all(), rz_core_task_decref(), rz_core_task_del(), rz_core_task_del_all_done(), rz_core_task_enqueue(), rz_core_task_enqueue_oneshot(), rz_core_task_get_incref(), rz_core_task_incref(), rz_core_task_join(), rz_core_task_list(), rz_core_task_running_tasks_count(), rz_core_task_schedule(), rz_core_task_sync_begin(), task_run_thread(), and task_wakeup().
|
static |
Definition at line 61 of file task.c.
References rz_core_tasks_t::lock, rz_th_lock_leave(), and tasks_lock_block_signals_reset().
Referenced by rz_core_task_break(), rz_core_task_break_all(), rz_core_task_decref(), rz_core_task_del(), rz_core_task_del_all_done(), rz_core_task_enqueue(), rz_core_task_enqueue_oneshot(), rz_core_task_get_incref(), rz_core_task_incref(), rz_core_task_join(), rz_core_task_list(), rz_core_task_running_tasks_count(), rz_core_task_schedule(), rz_core_task_sync_begin(), task_run_thread(), and task_wakeup().