Current cmd.depth depends on core, not on the global cons context now ##thread

* Fix a bunch of race conditions related to background analysis
This commit is contained in:
pancake 2023-11-14 10:05:13 +01:00
parent 5463d84733
commit db20331b87
7 changed files with 11 additions and 12 deletions

View File

@ -2203,8 +2203,7 @@ static int analop64_esil(RArchSession *as, RAnalOp *op, ut64 addr, const ut8 *bu
break;
}
case ARM64_INS_ADRP:
r_strbuf_setf (&op->esil, "%"PFMT64d",%s,=",
IMM64 (1), REG64 (0));
r_strbuf_setf (&op->esil, "%"PFMT64d",%s,=", IMM64 (1), REG64 (0));
break;
case ARM64_INS_EXTR:
// from VEX

View File

@ -131,7 +131,7 @@ static void cons_stack_load(RConsStack *data, bool free_current) {
static void cons_context_init(RConsContext *context, R_NULLABLE RConsContext *parent) {
context->marks = r_list_newf ((RListFree)r_cons_mark_free);
context->breaked = false;
context->cmd_depth = R_CONS_CMD_DEPTH + 1;
// context->cmd_depth = R_CONS_CMD_DEPTH + 1;
context->buffer_sz = 0;
context->lastEnabled = true;
context->buffer_len = 0;

View File

@ -2274,7 +2274,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->cons->context->cmd_depth = c;
core->cur_cmd_depth = c;
return true;
}

View File

@ -526,7 +526,7 @@ static void recursive_help(RCore *core, int detail, const char *cmd_prefix) {
static bool lastcmd_repeat(RCore *core, int next) {
int res = -1;
// Fix for backtickbug px`~`
if (!core->lastcmd || core->cons->context->cmd_depth < 1) {
if (!core->lastcmd || core->cur_cmd_depth < 1) {
return false;
}
switch (*core->lastcmd) {
@ -3760,7 +3760,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
goto beach;
}
if (core->max_cmd_depth - core->cons->context->cmd_depth == 1) {
if (core->max_cmd_depth - core->cur_cmd_depth == 1) {
core->prompt_offset = core->offset;
}
cmd = (char *)r_str_trim_head_ro (icmd);
@ -3825,7 +3825,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
const char *cmdrep = r_str_get (core->cmdtimes);
orep = rep;
bool is_root_cmd = core->cons->context->cmd_depth + 1 == core->max_cmd_depth;
bool is_root_cmd = core->cur_cmd_depth + 1 == core->max_cmd_depth;
if (is_root_cmd) {
r_cons_break_clear ();
}
@ -5960,8 +5960,7 @@ out_finish:
static int run_cmd_depth(RCore *core, char *cmd) {
char *rcmd;
int ret = false;
int *depth = R_UNWRAP4 (&core, cons, context, cmd_depth);
int *depth = &core->cur_cmd_depth;
if (depth) {
if (*depth < 1) {
R_LOG_ERROR ("That '%s' was too deep", cmd);

View File

@ -239,7 +239,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;
core->cur_cmd_depth = core->max_cmd_depth;
}
task->id = core->tasks.task_id_next++;

View File

@ -422,8 +422,8 @@ typedef struct r_cons_context_t {
RStack *break_stack;
RConsEvent event_interrupt;
void *event_interrupt_data;
int cmd_depth;
int cmd_str_depth;
// int cmd_depth;
int cmd_str_depth; // wtf ?
bool noflush;
// Used for per-task logging redirection

View File

@ -362,6 +362,7 @@ struct r_core_t {
RList *scriptstack;
RCoreTaskScheduler tasks;
int max_cmd_depth;
int cur_cmd_depth;
ut8 switch_file_view;
Sdb *sdb;
int incomment;