mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-09 01:21:05 +00:00
Make cmd_depth task-local (#14888)
This commit is contained in:
parent
56c10e0368
commit
f5c5d0afa3
@ -99,6 +99,7 @@ static void cons_stack_load(RConsStack *data, bool free_current) {
|
||||
|
||||
static void cons_context_init(RConsContext *context, R_NULLABLE RConsContext *parent) {
|
||||
context->breaked = false;
|
||||
context->cmd_depth = R_CONS_CMD_DEPTH + 1;
|
||||
context->buffer = NULL;
|
||||
context->buffer_sz = 0;
|
||||
context->lastEnabled = true;
|
||||
|
@ -1772,7 +1772,7 @@ static bool cb_cmddepth(void *user, void *data) {
|
||||
RCore *core = (RCore *)user;
|
||||
int c = R_MAX (((RConfigNode*)data)->i_value, 0);
|
||||
core->max_cmd_depth = c;
|
||||
core->cmd_depth = c;
|
||||
core->cons->context->cmd_depth = c;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2341,7 +2341,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
|
||||
ut64 orig_offset = core->offset;
|
||||
icmd = strdup (cmd);
|
||||
|
||||
if (core->max_cmd_depth - core->cmd_depth == 1) {
|
||||
if (core->max_cmd_depth - core->cons->context->cmd_depth == 1) {
|
||||
core->prompt_offset = core->offset;
|
||||
}
|
||||
cmd = r_str_trim_head_tail (icmd);
|
||||
@ -4358,14 +4358,14 @@ R_API int r_core_cmd(RCore *core, const char *cstr, int log) {
|
||||
r_line_hist_add (cstr);
|
||||
}
|
||||
|
||||
if (core->cmd_depth < 1) {
|
||||
if (core->cons->context->cmd_depth < 1) {
|
||||
eprintf ("r_core_cmd: That was too deep (%s)...\n", cmd);
|
||||
free (ocmd);
|
||||
R_FREE (core->oobi);
|
||||
core->oobi_len = 0;
|
||||
goto beach;
|
||||
}
|
||||
core->cmd_depth--;
|
||||
core->cons->context->cmd_depth--;
|
||||
for (rcmd = cmd;;) {
|
||||
ptr = strchr (rcmd, '\n');
|
||||
if (ptr) {
|
||||
@ -4383,7 +4383,7 @@ R_API int r_core_cmd(RCore *core, const char *cstr, int log) {
|
||||
}
|
||||
/* run pending analysis commands */
|
||||
run_pending_anal (core);
|
||||
core->cmd_depth++;
|
||||
core->cons->context->cmd_depth++;
|
||||
free (ocmd);
|
||||
R_FREE (core->oobi);
|
||||
core->oobi_len = 0;
|
||||
@ -4635,7 +4635,7 @@ R_API char *r_core_cmd_str(RCore *core, const char *cmd) {
|
||||
|
||||
R_API void r_core_cmd_repeat(RCore *core, int next) {
|
||||
// Fix for backtickbug px`~`
|
||||
if (!core->lastcmd || core->cmd_depth < 1) {
|
||||
if (!core->lastcmd || core->cons->context->cmd_depth < 1) {
|
||||
return;
|
||||
}
|
||||
switch (*core->lastcmd) {
|
||||
|
@ -2626,8 +2626,7 @@ R_API bool r_core_init(RCore *core) {
|
||||
core->ev = r_event_new (core);
|
||||
r_event_hook (core->ev, R_EVENT_ALL, cb_event_handler, NULL);
|
||||
core->lock = r_th_lock_new (true);
|
||||
core->max_cmd_depth = R_CORE_CMD_DEPTH + 1;
|
||||
core->cmd_depth = core->max_cmd_depth;
|
||||
core->max_cmd_depth = R_CONS_CMD_DEPTH + 1;
|
||||
core->sdb = sdb_new (NULL, "r2kv.sdb", 0); // XXX: path must be in home?
|
||||
core->lastsearch = NULL;
|
||||
core->cmdfilter = NULL;
|
||||
|
@ -208,6 +208,7 @@ R_API RCoreTask *r_core_task_new(RCore *core, bool create_cons, const char *cmd,
|
||||
if (!task->cons_context) {
|
||||
goto hell;
|
||||
}
|
||||
task->cons_context->cmd_depth = core->max_cmd_depth;
|
||||
}
|
||||
|
||||
task->id = core->task_id_next++;
|
||||
|
@ -58,6 +58,8 @@ extern "C" {
|
||||
|
||||
R_LIB_VERSION_HEADER(r_cons);
|
||||
|
||||
#define R_CONS_CMD_DEPTH 100
|
||||
|
||||
typedef int (*RConsGetSize)(int *rows);
|
||||
typedef int (*RConsGetCursor)(int *rows);
|
||||
typedef bool (*RConsIsBreaked)(void);
|
||||
@ -429,6 +431,7 @@ typedef struct r_cons_context_t {
|
||||
RStack *break_stack;
|
||||
RConsEvent event_interrupt;
|
||||
void *event_interrupt_data;
|
||||
int cmd_depth;
|
||||
|
||||
// Used for per-task logging redirection
|
||||
RLogCallback log_callback; // TODO: RList of callbacks
|
||||
|
@ -85,8 +85,6 @@ R_LIB_VERSION_HEADER(r_core);
|
||||
|
||||
#define RTR_MAX_HOSTS 255
|
||||
|
||||
#define R_CORE_CMD_DEPTH 100
|
||||
|
||||
/* visual mode */
|
||||
#define R_CORE_VISUAL_MODE_PX 0
|
||||
#define R_CORE_VISUAL_MODE_PD 1
|
||||
@ -310,7 +308,6 @@ typedef struct r_core_t {
|
||||
RThreadLock *tasks_lock;
|
||||
int tasks_running;
|
||||
bool oneshot_running;
|
||||
int cmd_depth;
|
||||
int max_cmd_depth;
|
||||
ut8 switch_file_view;
|
||||
Sdb *sdb;
|
||||
|
Loading…
x
Reference in New Issue
Block a user