diff --git a/libr/core/agraph.c b/libr/core/agraph.c index 1e42f8d0f4..7e57ddb2b6 100644 --- a/libr/core/agraph.c +++ b/libr/core/agraph.c @@ -3488,6 +3488,15 @@ static int agraph_print(RAGraph *g, int is_interactive, RCore *core, RAnalFuncti return true; } +static void check_function_modified(RCore *core, RAnalFunction *fcn) { + if (r_anal_function_was_modified (fcn)) { + if (r_config_get_i (core->config, "anal.detectwrites") + || r_cons_yesno ('y', "Function was modified. Reanalyze? (Y/n)")) { + r_anal_function_update_analysis (fcn); + } + } +} + static int agraph_refresh(struct agraph_refresh_data *grd) { if (!grd) { return 0; @@ -3534,6 +3543,7 @@ static int agraph_refresh(struct agraph_refresh_data *grd) { } if (f && fcn && f != *fcn) { *fcn = f; + check_function_modified (core, *fcn); g->need_reload_nodes = true; g->force_update_seek = true; } @@ -3557,6 +3567,10 @@ static void agraph_refresh_oneshot(struct agraph_refresh_data *grd) { r_core_task_enqueue_oneshot (&grd->core->tasks, (RCoreTaskOneShot) agraph_refresh, grd); } +static void agraph_set_need_reload_nodes(struct agraph_refresh_data *grd) { + grd->g->need_reload_nodes = true; +} + static void agraph_toggle_speed(RAGraph *g, RCore *core) { const int alt = r_config_get_i (core->config, "graph.scroll"); g->movspeed = g->movspeed == DEFAULT_SPEED? alt: DEFAULT_SPEED; @@ -4155,6 +4169,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int r_cons_canvas_free (can); return false; } + check_function_modified (core, fcn); g = r_agraph_new (can); if (!g) { r_cons_canvas_free (can); @@ -4784,7 +4799,9 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int showcursor (core, false); break; case ':': + core->cons->event_resize = (RConsEvent)agraph_set_need_reload_nodes; r_core_visual_prompt_input (core); + core->cons->event_resize = (RConsEvent)agraph_refresh_oneshot; if (!g) { g->need_reload_nodes = true; // maybe too slow and unnecessary sometimes? better be safe and reload get_bbupdate (g, core, fcn); diff --git a/libr/core/core.c b/libr/core/core.c index 85ff25f6a3..e69f83f918 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -2536,6 +2536,10 @@ static void ev_iowrite_cb(REvent *ev, int type, void *user, void *data) { REventIOWrite *iow = data; if (r_config_get_i (core->config, "anal.detectwrites")) { r_anal_update_analysis_range (core->anal, iow->addr, iow->len); + if (core->cons->event_resize && core->cons->event_data) { + // Force a reload of the graph + core->cons->event_resize (core->cons->event_data); + } } }